basic json setup
This commit is contained in:
parent
5273920bf2
commit
7fef29b935
17
src/Makefile
17
src/Makefile
|
@ -1,21 +1,24 @@
|
|||
CC=gcc
|
||||
override CFLAGS := -g -I. -Wall -Wpedantic $(CFLAGS)
|
||||
CFLAGS_STATIC=$(CCLAGS) --static
|
||||
DEPS=
|
||||
CC=cc
|
||||
CFLAGS := -g -I. -Wall -Wpedantic -I ../deps/build/usr/local/include/
|
||||
LDFLAGS = -L ../deps/build/usr/local/lib/
|
||||
LDLIBS = -ljson-c
|
||||
LDFLAGS += $(LDLIBS)
|
||||
CFLAGS_STATIC = $(CFLAGS) --static
|
||||
OBJ=main.o pfparser.o sysparser.o
|
||||
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
csyslog: $(OBJ)
|
||||
gcc -o $@ $^ $(CFLAGS)
|
||||
$(CC) -o $@ $^ $(LDFLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -vf *.o csyslog
|
||||
|
||||
static: $(OBJ)
|
||||
gcc -o csyslog $^ $(CFLAGS_STATIC)
|
||||
$(CC) -o csyslog $^ $(LDFLAGS) --static
|
||||
|
||||
.PHONY: docker
|
||||
docker: static
|
||||
docker build -t csyslog .
|
||||
sudo docker build -t csyslog .
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "helpers.h"
|
||||
#include "sysparser.h"
|
||||
|
||||
#include <json-c/json.h>
|
||||
|
||||
void panic(const char* s) {
|
||||
perror(s);
|
||||
|
@ -115,6 +116,13 @@ int main(int argc, char** argv) {
|
|||
printf("Failed to parse pfsense data: %s\n\n", msg);
|
||||
} else {
|
||||
pfdata_print(&fwdata);
|
||||
|
||||
json_object* jobj = json_object_new_object();
|
||||
json_object *jstring = json_object_new_string("bar");
|
||||
json_object_object_add(jobj,"foo", jstring);
|
||||
printf("The json object created: %s\n",json_object_to_json_string(jobj));
|
||||
json_object_put(jobj);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,7 +171,6 @@ int pfdata_parse(char* message, pf_data* result) {
|
|||
field++;
|
||||
}
|
||||
|
||||
printf("### remaining: %s\n", message);
|
||||
/*Parse optional <protocol-specific-data>
|
||||
one of <tcp-data> | <udp-data> | <icmp-data> | <carp-data>
|
||||
ICMP and CARP are ignored*/
|
||||
|
|
Loading…
Reference in New Issue