debug json before use it in socket, split socket src

This commit is contained in:
2025-09-16 20:10:37 +02:00
parent 8a4268945c
commit 12242987f3
14 changed files with 406 additions and 83 deletions
+5 -4
View File
@@ -7,10 +7,11 @@ CC=gcc
ROOT_DIR=$(PWD)
YTESTDIR=$(PWD)/../../ytest_t
LISTDIR=$(PWD)/../../list_t
YSOCKETDIR=$(PWD)/../../y_socket_t
INCLUDE_LIST=$(LISTDIR)/src
INCLUDE_DIR=$(PWD)/../src
CFLAGS=-I$(INCLUDE_DIR) -I$(INCLUDE_LIST) -I$(YTESTDIR)/include_ytest/include
CFLAGS=-I$(INCLUDE_DIR) -I$(INCLUDE_LIST) -I$(YTESTDIR)/include_ytest/include -I$(YSOCKETDIR)/include
LDFLAGS=-L$(YTESTDIR) -lytest
#SRC_DIR=$(ROOT_DIR)/src
@@ -27,11 +28,11 @@ LISTSRC_O=$(LISTDIR)/src/list_t/list_t.o
JSONDIR=$(PWD)/..
JSONSRC=$(JSONDIR)/src/json_t/json_t.c
JSONSRC_O=$(JSONDIR)/src/json_t/json_t.o
YSTRINGLIST_O=$(YSOCKETDIR)/src/y_socket_t/y_list_string.o
TOPTARGETS := all clean
DEPS=$(LISTDIR) $(YTESTDIR) $(JSONDIR)
DEPS=$(LISTDIR) $(YTESTDIR) $(JSONDIR) $(YSOCKETDIR)
$(TOPTARGETS): $(DEPS)
@@ -45,7 +46,7 @@ $(DEPS):
#TOOLSRC=$(TOOLDIR)/src/tools_t/tools_t.c
#TOOLSRC_O=$(TOOLSRC:.c=.o)
OBJ=$(SRC:.c=.o) $(JSONSRC_O)
OBJ=$(SRC:.c=.o) $(JSONSRC_O) $(YSTRINGLIST_O)
#$(LISTSRC_O)
+18
View File
@@ -480,7 +480,25 @@ TEST(general_val_string_with_extra_value){
}
TEST(sprint_js_value__){
char *val = "{ \"-1 header\" : [ \"message\" , \"Hello! it's a string\" , [{},{},[ [ ] ] ] , { \"age\" : 48 , \"speaker\" : \" the president \" } , 45 , true ] , \"second\" : 324.1 , \"person\" : { \"name\" : \"Fana\" , \"age\" : 37 , \"genre\" : \"male\" , \"married\" : false , \"note\" : [2.1,4.45,4,10, { \"math\" : 17.1, \"malagasy\" : 12, \"eps\" : [ 5, 6 , 4 ] }] } , \"nul\" : { }} here extra string ";
struct js_value *js = create_js_value(val, NULL);
printf("\n##############################################\n");
print_js_value(js);
printf("\n##############################################\n");
char *buf = NULL;
long int ret = sprint_one_line_js_value(&buf, js);
printf("\nret = %ld,\nbuf:\n%s\n",ret, buf);
printf("\n##############################################\n");
free(buf);
buf=NULL;
ret = sprint_js_value(&buf, js,'\n',8);
printf("\nret = %ld,\nbuf:\n%s\n",ret, buf);
free_js_value(js);
if(buf) free(buf);
}
int main(int argc, char **argv){