Removed DISABLE_JSMN define for c-json-stdout (built-in per default).

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2020-09-26 00:44:29 +02:00
parent d3bb1ccf33
commit adce2272dc
2 changed files with 18 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
CC = gcc
PROJECT_CFLAGS += -Wall -Wextra $(EXTRA_CFLAGS) -I.
JSMN_CFLAGS := -DJSMN_STATIC=1 -DJSMN_STRICT=1 -Icontrib/jsmn
LIBS += -pthread -lpcap -lm
GOCC = go
@@ -61,10 +62,6 @@ else
ENABLE_SANITIZER_THREAD = no
endif
ifneq ($(DISABLE_JSMN),yes)
DISABLE_JSMN = no
endif
GO_DASHBOARD_SRCS := examples/go-dashboard/main.go examples/go-dashboard/ui/ui.go
RM = rm -f
@@ -80,11 +77,7 @@ nDPIsrvd: nDPIsrvd.c utils.c
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $^ -o $@ $(LDFLAGS) $(LIBS)
examples/c-json-stdout/c-json-stdout: examples/c-json-stdout/c-json-stdout.c
ifneq ($(DISABLE_JSMN),yes)
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) -DJSMN_STATIC=1 -DJSMN_STRICT=1 -DUSE_JSON=1 $@.c -o $@ $(LDFLAGS) $(LIBS)
else
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $@.c -o $@ $(LDFLAGS) $(LIBS)
endif
$(CC) $(PROJECT_CFLAGS) $(CFLAGS) $(JSMN_CFLAGS) $@.c -o $@ $(LDFLAGS) $(LIBS)
examples/go-dashboard/go-dashboard: $(GO_DASHBOARD_SRCS)
ifneq ($(GOCC),)
@@ -114,7 +107,6 @@ help:
@echo 'ENABLE_DEBUG = $(ENABLE_DEBUG)'
@echo 'ENABLE_SANITIZER = $(ENABLE_SANITIZER)'
@echo 'ENABLE_SANITIZER_THREAD = $(ENABLE_SANITIZER_THREAD)'
@echo 'DISABLE_JSMN = $(DISABLE_JSMN)'
@echo '------------------------------------'
.PHONY: all clean help

View File

@@ -8,9 +8,7 @@
#include <unistd.h>
#include "config.h"
#ifdef USE_JSON
#include "jsmn/jsmn.h"
#endif
#include "jsmn.h"
static char serv_listen_addr[INET_ADDRSTRLEN] = DISTRIBUTOR_HOST;
static uint16_t serv_listen_port = DISTRIBUTOR_PORT;
@@ -24,10 +22,8 @@ int main(void)
size_t buf_used = 0;
size_t json_start = 0;
unsigned long long int json_bytes = 0;
#ifdef USE_JSON
jsmn_parser parser;
jsmntok_t tokens[128];
#endif
if (sockfd < 0)
{
@@ -100,7 +96,6 @@ int main(void)
exit(1);
}
#ifdef USE_JSON
int r;
jsmn_init(&parser);
r = jsmn_parse(&parser,
@@ -127,9 +122,6 @@ int main(void)
}
}
printf("EoF\n");
#else
printf("RECV[%llu,%zd]: '%.*s'\n\n", buf_wanted, bytes_read, (int)buf_wanted, buf);
#endif
memmove(buf, buf + json_bytes, buf_used - json_bytes);
buf_used -= json_bytes;