Skip to content

Commit b5921b7

Browse files
committed
Add breakwater-parser C bindings
1 parent 121986c commit b5921b7

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
[workspace]
2-
members = ["breakwater-parser", "breakwater", "breakwater-egui-overlay"]
2+
members = [
3+
"breakwater-parser",
4+
"breakwater",
5+
"breakwater-egui-overlay",
6+
"breakwater-parser-c-bindings"
7+
]
38
resolver = "2"
49

510
[workspace.package]

breakwater-f-stack/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ CFLAGS += -O3 -g -gdwarf-2 $(shell $(PKGCONF) --cflags libdpdk)
1616
LIBS+= $(shell $(PKGCONF) --static --libs libdpdk)
1717
LIBS+= -I${FF_PATH}/lib -L${FF_PATH}/lib -Wl,--whole-archive,-lfstack,--no-whole-archive
1818
LIBS+= -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -pthread -lnuma
19+
# WIP, start with "sudo LD_LIBRARY_PATH=../target/release build/breakwater-f-stack"
20+
LIBS += -l breakwater_parser_c_bindings -L ../target/release/
1921

2022
TARGET="breakwater-f-stack"
2123
all:

breakwater-f-stack/breakwater-f-stack.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include "framebuffer.h"
1919
#include "parser.h"
2020

21+
extern void breakwater_init_original_parser(int width, int height);
22+
extern size_t breakwater_original_parser_parse(const char* buffer, size_t buffer_len);
23+
2124
#define MAX_EVENTS 512
2225

2326
/* kevent set */
@@ -160,7 +163,9 @@ int loop(void *arg)
160163
ssize_t readlen = ff_read(clientfd, buf, sizeof(buf));
161164
client->bytes_parsed += readlen;
162165

163-
size_t bytes_parsed = parse(buf, readlen, framebuffer, clientfd);
166+
// size_t bytes_parsed = parse(buf, readlen, framebuffer, clientfd);
167+
long parsed = breakwater_original_parser_parse(buf, readlen);
168+
printf("Parse result: %ld\n", parsed);
164169
} else {
165170
printf("unknown event: %8.8X\n", event.flags);
166171
}
@@ -173,6 +178,8 @@ int main(int argc, char * argv[])
173178
{
174179
int err = 0;
175180

181+
breakwater_init_original_parser(WIDTH, HEIGHT);
182+
176183
struct framebuffer* framebuffer;
177184
if((err = create_fb(&framebuffer, WIDTH, HEIGHT, SHARED_MEMORY_NAME))) {
178185
fprintf(stderr, "Failed to allocate framebuffer: %s\n", strerror(err));

0 commit comments

Comments
 (0)