diff --git a/Makefile b/Makefile
index 1684914..04aa32b 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ all:
${MAKE} -C ikc3 all
${MAKE} -C kc3s all
${MAKE} -C ekc3 all
+ ${MAKE} -C json all
${MAKE} -C http all
${MAKE} -C httpd all
${MAKE} -C test all
@@ -30,6 +31,7 @@ asan:
${MAKE} -C ikc3 asan
${MAKE} -C kc3s asan
${MAKE} -C ekc3 asan
+ ${MAKE} -C json asan
${MAKE} -C http asan
${MAKE} -C httpd asan
${MAKE} -C test asan
@@ -43,6 +45,7 @@ build:
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
${MAKE} -C ekc3 build
+ ${MAKE} -C json build
${MAKE} -C http build
${MAKE} -C httpd build
${MAKE} -C test build
@@ -55,6 +58,7 @@ clean:
${MAKE} -C ikc3 clean
${MAKE} -C kc3s clean
${MAKE} -C ekc3 clean
+ ${MAKE} -C json clean
${MAKE} -C http clean
${MAKE} -C httpd clean
${MAKE} -C test clean
@@ -66,6 +70,7 @@ clean_cov:
${MAKE} -C ikc3 clean_cov
${MAKE} -C kc3s clean_cov
${MAKE} -C ekc3 clean_cov
+ ${MAKE} -C json clean_cov
${MAKE} -C http clean_cov
${MAKE} -C httpd clean_cov
${MAKE} -C test clean_cov
@@ -78,6 +83,7 @@ cov:
${MAKE} -C ikc3 cov
${MAKE} -C kc3s cov
${MAKE} -C ekc3 cov
+ ${MAKE} -C json cov
${MAKE} -C http cov
${MAKE} -C httpd cov
${MAKE} -C test cov
@@ -90,6 +96,7 @@ debug:
${MAKE} -C ikc3 debug
${MAKE} -C kc3s debug
${MAKE} -C ekc3 debug
+ ${MAKE} -C json debug
${MAKE} -C http debug
${MAKE} -C httpd debug
${MAKE} -C test debug
@@ -128,6 +135,7 @@ distclean:
${MAKE} -C ikc3 distclean
${MAKE} -C kc3s distclean
${MAKE} -C ekc3 distclean
+ ${MAKE} -C json distclean
${MAKE} -C http distclean
${MAKE} -C httpd distclean
${MAKE} -C test distclean
@@ -138,6 +146,7 @@ gcovr:
${MAKE} -C ikc3 gcovr
${MAKE} -C kc3s gcovr
${MAKE} -C ekc3 gcovr
+ ${MAKE} -C json gcovr
${MAKE} -C http gcovr
${MAKE} -C httpd gcovr
${MAKE} -C test gcovr
@@ -152,26 +161,6 @@ gdb_demo_gl:
${MAKE} debug
${MAKE} -C libkc3 gdb_demo_gl
-gdb_httpd:
- ${MAKE} -C libtommath debug
- ${MAKE} -C ucd2c
- ${MAKE} -C libkc3 debug
- ${MAKE} -C ikc3 debug
- ${MAKE} -C kc3s debug
- ${MAKE} -C http debug
- ${MAKE} -C httpd debug
- ${MAKE} -C test gdb_httpd
-
-gdb_httpd_asan:
- ${MAKE} -C libtommath asan
- ${MAKE} -C ucd2c
- ${MAKE} -C libkc3 asan
- ${MAKE} -C ikc3 asan
- ${MAKE} -C kc3s asan
- ${MAKE} -C http asan
- ${MAKE} -C httpd asan
- ${MAKE} -C test gdb_httpd_asan
-
gdb_ikc3:
${MAKE} -C libtommath debug
${MAKE} -C ucd2c
@@ -198,6 +187,7 @@ gdb_test_http:
${MAKE} -C libkc3 debug
${MAKE} -C ikc3 debug
${MAKE} -C kc3s debug
+ ${MAKE} -C json debug
${MAKE} -C http debug
${MAKE} -C test gdb_test_http
@@ -207,9 +197,32 @@ gdb_test_http_asan:
${MAKE} -C libkc3 asan
${MAKE} -C ikc3 asan
${MAKE} -C kc3s asan
+ ${MAKE} -C json asan
${MAKE} -C http asan
${MAKE} -C test gdb_test_http_asan
+gdb_test_httpd:
+ ${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 debug
+ ${MAKE} -C ikc3 debug
+ ${MAKE} -C kc3s debug
+ ${MAKE} -C json debug
+ ${MAKE} -C http debug
+ ${MAKE} -C httpd debug
+ ${MAKE} -C test gdb_test_httpd
+
+gdb_test_httpd_asan:
+ ${MAKE} -C libtommath asan
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 asan
+ ${MAKE} -C ikc3 asan
+ ${MAKE} -C kc3s asan
+ ${MAKE} -C json asan
+ ${MAKE} -C http asan
+ ${MAKE} -C httpd asan
+ ${MAKE} -C test gdb_test_httpd_asan
+
gdb_test_ikc3:
${MAKE} -C libtommath debug
${MAKE} -C ucd2c
@@ -217,6 +230,13 @@ gdb_test_ikc3:
${MAKE} -C ikc3 debug
${MAKE} -C test gdb_test_ikc3
+gdb_test_json:
+ ${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 debug
+ ${MAKE} -C ikc3 debug
+ ${MAKE} -C test gdb_test_json
+
gen:
${MAKE} -C libkc3 gen
@@ -227,6 +247,7 @@ http:
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
${MAKE} -C ekc3 build
+ ${MAKE} -C json build
${MAKE} -C http build
httpd:
@@ -236,6 +257,7 @@ httpd:
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
${MAKE} -C ekc3 build
+ ${MAKE} -C json build
${MAKE} -C http build
${MAKE} -C httpd build
@@ -272,13 +294,43 @@ ikc3_gcovr:
${MAKE} ikc3_test_cov
${MAKE} gcovr
+json:
+ ${MAKE} -C libtommath build
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 build
+ ${MAKE} -C ikc3 build
+ ${MAKE} -C json build
+
+json_asan:
+ ${MAKE} -C libtommath asan
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 asan
+ ${MAKE} -C ikc3 asan
+ ${MAKE} -C json asan
+
+json_cov:
+ ${MAKE} -C libtommath cov
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 cov
+ ${MAKE} -C ikc3 cov
+ ${MAKE} -C json cov
+
+json_debug:
+ ${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 debug
+ ${MAKE} -C ikc3 debug
+ ${MAKE} -C json debug
+
install:
${MAKE} -C libkc3 install
${MAKE} -C ikc3 install
${MAKE} -C kc3s install
${MAKE} -C ekc3 install
+ ${MAKE} -C json install
${MAKE} -C http install
${MAKE} -C httpd install
+ ${MAKE} -C json install
${MAKE} -C window install
kc3-${KC3_VERSION}.tar.gz: kc3.index
@@ -307,25 +359,39 @@ kc3.index: sources.mk Makefile
sort -u < kc3.index.tmp > kc3.index
rm kc3.index.tmp
+lib_links:
+ ${MAKE} lib_links_${ARCH}
+
+lib_links_asan:
+ ${MAKE} lib_links_${ARCH}_asan
+
+lib_links_debug:
+ ${MAKE} lib_links_${ARCH}_debug
+
+lib_links_bsd:
+ ln -sf ../../../ekc3/.libs/libekc3.so.0.0 lib/kc3/0.1/ekc3.so
+ ln -sf ../../../http/.libs/libkc3_http.so.0.0 lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json.so.0.0 lib/kc3/0.1/json.so
+
+lib_links_bsd_debug:
+ ln -sf ../../../ekc3/.libs/libekc3_debug.so.0.0 lib/kc3/0.1/ekc3.so
+ ln -sf ../../../http/.libs/libkc3_http_debug.so.0.0 lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json_debug.so.0.0 lib/kc3/0.1/json.so
+
lib_links_linux:
ln -sf ../../../ekc3/.libs/libekc3.so lib/kc3/0.1/ekc3.so
ln -sf ../../../http/.libs/libkc3_http.so lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json.so lib/kc3/0.1/json.so
lib_links_linux_asan:
ln -sf ../../../ekc3/.libs/libekc3_asan.so lib/kc3/0.1/ekc3.so
ln -sf ../../../http/.libs/libkc3_http_asan.so lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json_asan.so lib/kc3/0.1/json.so
lib_links_linux_debug:
ln -sf ../../../ekc3/.libs/libekc3_debug.so lib/kc3/0.1/ekc3.so
ln -sf ../../../http/.libs/libkc3_http_debug.so lib/kc3/0.1/http.so
-
-lib_links_bsd:
- ln -sf ../../../ekc3/.libs/libekc3.so.0.0 lib/kc3/0.1/ekc3.so
- ln -sf ../../../http/.libs/libkc3_http.so.0.0 lib/kc3/0.1/http.so
-
-lib_links_bsd_debug:
- ln -sf ../../../ekc3/.libs/libekc3_debug.so.0.0 lib/kc3/0.1/ekc3.so
- ln -sf ../../../http/.libs/libkc3_http_debug.so.0.0 lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json_debug.so lib/kc3/0.1/json.so
libkc3_gcovr:
${MAKE} clean_cov
@@ -360,6 +426,7 @@ test:
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
${MAKE} -C ekc3 build
+ ${MAKE} -C json build
${MAKE} -C http build
${MAKE} -C httpd build
${MAKE} -C test test
@@ -372,6 +439,7 @@ test_asan:
${MAKE} -C ikc3 asan
${MAKE} -C kc3s asan
${MAKE} -C ekc3 asan
+ ${MAKE} -C json asan
${MAKE} -C http asan
${MAKE} -C httpd asan
${MAKE} -C test test_asan
@@ -383,6 +451,7 @@ test_cov:
${MAKE} -C ikc3 cov clean_cov
${MAKE} -C kc3s cov clean_cov
${MAKE} -C ekc3 cov clean_cov
+ ${MAKE} -C json cov clean_cov
${MAKE} -C http cov clean_cov
${MAKE} -C httpd cov clean_cov
${MAKE} -C test test_cov
@@ -394,6 +463,7 @@ test_debug:
${MAKE} -C ikc3 debug
${MAKE} -C kc3s debug
${MAKE} -C ekc3 debug
+ ${MAKE} -C json debug
${MAKE} -C http debug
${MAKE} -C httpd debug
${MAKE} -C test test_debug
@@ -447,6 +517,7 @@ test_http:
${MAKE} -C libkc3 build
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
+ ${MAKE} -C json build
${MAKE} -C http build
${MAKE} -C test test_http
@@ -456,6 +527,7 @@ test_http_asan:
${MAKE} -C libkc3 asan
${MAKE} -C ikc3 asan
${MAKE} -C kc3s asan
+ ${MAKE} -C json asan
${MAKE} -C http asan
${MAKE} -C test test_http_asan
@@ -465,6 +537,7 @@ test_http_cov:
${MAKE} -C libkc3 cov
${MAKE} -C ikc3 cov
${MAKE} -C kc3s cov
+ ${MAKE} -C json cov
${MAKE} -C http cov
${MAKE} -C test test_http_cov
@@ -474,6 +547,7 @@ test_http_debug:
${MAKE} -C libkc3 debug
${MAKE} -C ikc3 debug
${MAKE} -C kc3s debug
+ ${MAKE} -C json debug
${MAKE} -C http debug
${MAKE} -C test test_http_debug
@@ -483,6 +557,7 @@ test_httpd:
${MAKE} -C libkc3 build
${MAKE} -C ikc3 build
${MAKE} -C kc3s build
+ ${MAKE} -C json build
${MAKE} -C http build
${MAKE} -C httpd build
${MAKE} -C test test_httpd
@@ -493,6 +568,7 @@ test_httpd_asan:
${MAKE} -C libkc3 asan
${MAKE} -C ikc3 asan
${MAKE} -C kc3s asan
+ ${MAKE} -C json asan
${MAKE} -C http asan
${MAKE} -C httpd asan
${MAKE} -C test test_httpd_asan
@@ -503,6 +579,7 @@ test_httpd_cov:
${MAKE} -C libkc3 cov
${MAKE} -C ikc3 cov
${MAKE} -C kc3s cov
+ ${MAKE} -C json cov
${MAKE} -C http cov
${MAKE} -C httpd cov
${MAKE} -C test test_httpd_cov
@@ -513,6 +590,7 @@ test_httpd_debug:
${MAKE} -C libkc3 debug
${MAKE} -C ikc3 debug
${MAKE} -C kc3s debug
+ ${MAKE} -C json debug
${MAKE} -C http debug
${MAKE} -C httpd debug
${MAKE} -C test test_httpd_debug
@@ -545,6 +623,38 @@ test_ikc3_debug:
${MAKE} -C ikc3 debug
${MAKE} -C test test_ikc3_debug
+test_json:
+ ${MAKE} -C libtommath build
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 build
+ ${MAKE} -C ikc3 build
+ ${MAKE} -C json build
+ ${MAKE} -C test test_json
+
+test_json_asan:
+ ${MAKE} -C libtommath asan
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 asan
+ ${MAKE} -C ikc3 asan
+ ${MAKE} -C json asan
+ ${MAKE} -C test test_json_asan
+
+test_json_cov:
+ ${MAKE} -C libtommath cov
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 cov
+ ${MAKE} -C ikc3 cov
+ ${MAKE} -C json cov
+ ${MAKE} -C test test_json_cov
+
+test_json_debug:
+ ${MAKE} -C libtommath debug
+ ${MAKE} -C ucd2c
+ ${MAKE} -C libkc3 debug
+ ${MAKE} -C ikc3 debug
+ ${MAKE} -C json debug
+ ${MAKE} -C test test_json_debug
+
test_libkc3:
${MAKE} -C libtommath build
${MAKE} -C ucd2c
@@ -583,10 +693,48 @@ test_libkc3_debug:
demo_gl_debug \
dist \
gcovr \
+ gdb_test \
+ gdb_test_asan \
+ gdb_test_debug \
+ gdb_test_gcovr \
+ gdb_test_ekc3 \
+ gdb_test_ekc3_asan \
+ gdb_test_ekc3_debug \
+ gdb_test_http \
+ gdb_test_http_asan \
+ gdb_test_http_debug \
+ gdb_test_httpd \
+ gdb_test_httpd_asan \
+ gdb_test_httpd_debug \
+ gdb_test_ikc3 \
+ gdb_test_ikc3_asan \
+ gdb_test_ikc3_debug \
+ gdb_test_json \
+ gdb_test_json_asan \
+ gdb_test_json_debug \
+ gdb_test_kc3s \
+ gdb_test_kc3s_asan \
+ gdb_test_kc3s_debug
+ gdb_test_libkc3 \
+ gdb_test_libkc3_asan \
+ gdb_test_libkc3_debug
http \
httpd \
ikc3 \
install \
+ json \
+ json_asan \
+ json_cov \
+ json_debug \
+ lib_links \
+ lib_links_asan \
+ lib_links_debug \
+ lib_links_bsd \
+ lib_links_bsd_asan \
+ lib_links_bsd_debug \
+ lib_links_linux \
+ lib_links_linux_asan \
+ lib_links_linux_debug \
libkc3 \
libtommath \
license \
@@ -595,7 +743,34 @@ test_libkc3_debug:
test_cov \
test_debug \
test_gcovr \
- test_ikc3
+ test_ekc3 \
+ test_ekc3_asan \
+ test_ekc3_cov \
+ test_ekc3_debug \
+ test_http \
+ test_http_asan \
+ test_http_cov \
+ test_http_debug \
+ test_httpd \
+ test_httpd_asan \
+ test_httpd_cov \
+ test_httpd_debug \
+ test_ikc3 \
+ test_ikc3_asan \
+ test_ikc3_cov \
+ test_ikc3_debug \
+ test_json \
+ test_json_asan \
+ test_json_cov \
+ test_json_debug \
+ test_kc3s \
+ test_kc3s_asan \
+ test_kc3s_cov \
+ test_kc3s_debug
+ test_libkc3 \
+ test_libkc3_asan \
+ test_libkc3_cov \
+ test_libkc3_debug
include config.mk
include sources.mk
diff --git a/configure b/configure
index 29a8b0b..4f5b180 100755
--- a/configure
+++ b/configure
@@ -36,6 +36,16 @@ echo "kc3-${KC3_VERSION}.tar.gz: $(tr '\n' ' ' < kc3.index)" \
config_asan
echo "HAVE_ASAN = ${HAVE_ASAN}" >> ${CONFIG_MK}
+ARCH="unknown"
+if uname | grep -iq bsd; then
+ ARCH=bsd
+elif uname | grep -q Linux; then
+ ARCH=linux
+elif uname | grep -q Darwin; then
+ ARCH=darwin
+fi
+echo "ARCH = $ARCH" >> ${CONFIG_MK}
+
update_config_mk
env_reset
@@ -46,6 +56,7 @@ config_subdirs \
ikc3 \
kc3s \
ekc3 \
+ json \
http \
httpd \
test \
diff --git a/json/Makefile b/json/Makefile
new file mode 100644
index 0000000..a4db491
--- /dev/null
+++ b/json/Makefile
@@ -0,0 +1,78 @@
+## kc3
+## Copyright 2022-2024 kmx.io <contact@kmx.io>
+##
+## Permission is hereby granted to use this software granted the above
+## copyright notice and this permission paragraph are included in all
+## copies and substantial portions of this software.
+##
+## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+## THIS SOFTWARE.
+
+CLEANFILES = *.a *.gcno *.la .libs *.lo *.o
+
+CLEANFILES_COV = *.css *.gcda *.html .libs/*.gcda
+
+CLEANFILES += ${CLEANFILES_COV}
+
+DISTCLEANFILES = .build ${CLEANFILES} config.h config.mk
+
+all:
+ ${MAKE} build
+ ${MAKE} debug
+ if ${HAVE_ASAN}; then ${MAKE} asan; fi
+ if ${HAVE_GCOV}; then ${MAKE} cov; fi
+
+asan:
+ ${MAKE} ${LIB_ASAN}
+
+build:
+ ${MAKE} ${LIB}
+
+clean:
+ rm -rf ${CLEANFILES}
+
+clean_cov:
+ rm -rf ${CLEANFILES_COV}
+
+cov:
+ ${MAKE} ${LIB_COV}
+
+debug:
+ ${MAKE} ${LIB_DEBUG}
+
+distclean:
+ rm -rf ${DISTCLEANFILES}
+
+gcovr:
+ gcovr --gcov-executable ${GCOV} --html-details libkc3_web.html
+
+install:
+ ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0755 -d ${prefix}/include/libkc3/ekc3
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/ekc3
+ ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0755 -d ${prefix}/lib
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${LIB} ${prefix}/lib
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${LIB_DEBUG} ${prefix}/lib
+ ${LIBTOOL} --finish ${prefix}/lib
+
+test:
+
+update_sources:
+ ./update_sources
+
+.PHONY: \
+ all \
+ asan \
+ build \
+ clean \
+ cov \
+ debug \
+ distclean \
+ gen \
+ install \
+ test \
+ update_sources \
+
+include config.mk
+include sources.mk
diff --git a/json/configure b/json/configure
new file mode 100755
index 0000000..150a098
--- /dev/null
+++ b/json/configure
@@ -0,0 +1,119 @@
+#!/bin/sh
+## kc3
+## Copyright 2022-2024 kmx.io <contact@kmx.io>
+##
+## Permission is hereby granted to use this software granted the above
+## copyright notice and this permission paragraph are included in all
+## copies and substantial portions of this software.
+##
+## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+## THIS SOFTWARE.
+
+set -e
+
+echo "$PWD/configure"
+
+export SRC_TOP="$(dirname "$PWD")"
+
+CONFIG_H_PREFIX=KC3_JSON_
+
+. ../config.subr
+
+LIB=libkc3_json.la
+LIB_ASAN=libkc3_json_asan.la
+LIB_COV=libkc3_json_cov.la
+LIB_DEBUG=libkc3_json_debug.la
+
+echo "LIB = $LIB" >> ${CONFIG_MK}
+echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
+echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
+echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
+
+. ./sources.sh
+
+OBJECTS="$(c2ext .main.lo "$SOURCES")"
+echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
+OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
+OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
+
+# Common config for all targets
+CPPFLAGS="-I.. $CPPFLAGS"
+CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
+LDFLAGS="-export-dynamic $LDFLAGS -rdynamic"
+config_asan
+config_gnu
+config_i386
+pkg_config libbsd-overlay
+pkg_config libevent
+pkg_config libffi
+pkg_config libmd
+config_define PREFIX "\"${PREFIX}\""
+update_config_h
+LIBS="$LIBS -lm -rpath ${PREFIX}/lib"
+
+# Address Sanitizer config
+CPPFLAGS_ASAN="$CPPFLAGS"
+CFLAGS_ASAN="$CFLAGS -DDEBUG -O1 -g"
+CFLAGS_ASAN="$CFLAGS_ASAN -fsanitize=address -fno-omit-frame-pointer"
+LDFLAGS_ASAN="$LDFLAGS"
+LIBS_LOCAL_ASAN="../libkc3/libkc3_asan.la"
+LIBS_ASAN="$LIBS $LIBS_LOCAL_ASAN"
+
+# Coverage config
+CPPFLAGS_COV="$CPPFLAGS"
+CFLAGS_COV="$CFLAGS -fprofile-arcs -ftest-coverage"
+LDFLAGS_COV="$LDFLAGS --coverage"
+LIBS_LOCAL_COV="../libkc3/libkc3_cov.la"
+LIBS_COV="$LIBS $LIBS_LOCAL_COV -lgcov"
+
+# Debug config
+CPPFLAGS_DEBUG="$CPPFLAGS"
+CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
+LDFLAGS_DEBUG="$LDFLAGS"
+LIBS_LOCAL_DEBUG="../libkc3/libkc3_debug.la"
+LIBS_DEBUG="$LIBS $LIBS_LOCAL_DEBUG"
+
+# Main config
+DEFAULT_CFLAGS="-O2 -fPIC"
+if [ "x$ENV_CFLAGS" = "x" ]; then
+ CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
+fi
+CFLAGS="$CFLAGS -DNDEBUG"
+LIBS_LOCAL="../libkc3/libkc3.la"
+LIBS="$LIBS $LIBS_LOCAL"
+
+echo "LIB = $LIB" >> ${CONFIG_MK}
+echo "HAVE_ASAN = $HAVE_ASAN" >> ${CONFIG_MK}
+echo "CPPFLAGS = $CPPFLAGS" >> ${CONFIG_MK}
+echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
+echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
+echo "LIBS = $LIBS" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_ASAN = $LIB_ASAN" >> ${CONFIG_MK}
+echo "CPPFLAGS_ASAN = $CPPFLAGS_ASAN" >> ${CONFIG_MK}
+echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
+echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_COV = $LIB_COV" >> ${CONFIG_MK}
+echo "CPPFLAGS_COV = $CPPFLAGS_COV" >> ${CONFIG_MK}
+echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
+echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
+echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+echo >> ${CONFIG_MK}
+echo "LIB_DEBUG = $LIB_DEBUG" >> ${CONFIG_MK}
+echo "CPPFLAGS_DEBUG = $CPPFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
+echo "LIBS_DEBUG = $LIBS_DEBUG" >> ${CONFIG_MK}
+
+update_build
+update_build_lib
+
+build_lo
+build_lib
+
+update_config_mk
diff --git a/json/json.c b/json/json.c
index cdb595a..0fe9a55 100644
--- a/json/json.c
+++ b/json/json.c
@@ -12,9 +12,6 @@
*/
#include <libkc3/kc3.h>
#include "json.h"
-#include "buf.h"
-#include "buf_parse.h"
-#include "tag.h"
static bool parse_json(const s_buf *buf, s_tag *dest) {
assert(buf);
@@ -34,4 +31,4 @@ s_tag *json_parse(const s_buf *buf, s_tag *dest) {
return NULL;
}
return dest;
-}
\ No newline at end of file
+}
diff --git a/json/sources.mk b/json/sources.mk
new file mode 100644
index 0000000..7fccffe
--- /dev/null
+++ b/json/sources.mk
@@ -0,0 +1,7 @@
+# sources.mk generated by update_sources
+HEADERS = \
+ "json.h" \
+
+SOURCES = \
+ "json.c" \
+
diff --git a/json/sources.sh b/json/sources.sh
new file mode 100644
index 0000000..d8ed55d
--- /dev/null
+++ b/json/sources.sh
@@ -0,0 +1,3 @@
+# sources.sh generated by update_sources
+HEADERS='json.h '
+SOURCES='json.c '
diff --git a/json/update_sources b/json/update_sources
new file mode 100755
index 0000000..a4101fe
--- /dev/null
+++ b/json/update_sources
@@ -0,0 +1,28 @@
+#!/bin/sh
+## kc3
+## Copyright 2022-2024 kmx.io <contact@kmx.io>
+##
+## Permission is hereby granted to use this software granted the above
+## copyright notice and this permission paragraph are included in all
+## copies and substantial portions of this software.
+##
+## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+## THIS SOFTWARE.
+
+. ../config.subr
+
+echo "$PWD/update_sources"
+
+echo "# sources.mk generated by update_sources" > ${SOURCES_MK}
+echo "# sources.sh generated by update_sources" > ${SOURCES_SH}
+
+HEADERS="$(ls *.h | grep -v '^config.h$')"
+sources HEADERS "$HEADERS"
+
+SOURCES="$(ls *.c)"
+sources SOURCES "$SOURCES"
+
+update_sources_mk
+update_sources_sh
diff --git a/test/Makefile b/test/Makefile
index 5f9c40b..caf73a7 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -71,12 +71,6 @@ distclean:
gcovr:
gcovr --gcov-executable ${GCOV} --html-details test.html
-gdb_httpd:
- cd httpd && ${GDB} ../../httpd/.libs/kc3_httpd_debug
-
-gdb_httpd_asan:
- cd httpd && ${GDB} ../../httpd/.libs/kc3_httpd_asan
-
gdb_test: debug
if [ -f libkc3_test_debug.core ]; then ${GDB} .libs/libkc3_test_debug libkc3_test_debug.core; else ${GDB} .libs/libkc3_test_debug; fi
@@ -89,9 +83,18 @@ gdb_test_http:
gdb_test_http_asan:
cd http && ${GDB} ../../ikc3/.libs/ikc3_asan
+gdb_test_httpd:
+ cd httpd && ${GDB} ../../httpd/.libs/kc3_httpd_debug
+
+gdb_test_httpd_asan:
+ cd httpd && ${GDB} ../../httpd/.libs/kc3_httpd_asan
+
gdb_test_ikc3:
cd ikc3 && ${GDB} ../../ikc3/.libs/ikc3_debug
+gdb_test_json:
+ cd json && ${GDB} ../../ikc3/.libs/ikc3_debug
+
lldb_test: debug
if [ -f libkc3_test_debug.core ]; then lldb .libs/libkc3_test_debug libkc3_test_debug.core; else lldb .libs/libkc3_test_debug; fi
@@ -167,6 +170,18 @@ test_ikc3_cov:
test_ikc3_debug:
IKC3=${SRC_TOP}/ikc3/ikc3_debug time ./ikc3_test
+test_json:
+ IKC3=${SRC_TOP}/ikc3/ikc3 time ./json_test
+
+test_json_asan:
+ IKC3=${SRC_TOP}/ikc3/ikc3_asan time ./json_test
+
+test_json_cov:
+ IKC3=${SRC_TOP}/ikc3/ikc3_cov time ./json_test
+
+test_json_debug:
+ IKC3=${SRC_TOP}/ikc3/ikc3_debug time ./json_test
+
test_libkc3: libkc3_test
time ./libkc3_test
@@ -176,7 +191,29 @@ test_libkc3_cov: libkc3_test_cov
test_valgrind: libkc3_test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./libkc3_test
-.PHONY: all asan cov debug clean clean_cov distclean ikc3_test_cov libkc3_test_cov test test_asan test_cov test_debug test_ikc3 test_valgrind
+.PHONY: all \
+ asan \
+ cov \
+ debug \
+ clean \
+ clean_cov \
+ distclean_test_cov \
+ gdb_test \
+ gdb_test_ekc3 \
+ gdb_test_http \
+ gdb_test_http_asan \
+ gdb_test_httpd \
+ gdb_test_httpd_asan \
+ gdb_test_ikc3 \
+ gdb_test_json \
+ libkc3_test_cov \
+ test \
+ test_asan \
+ test_cov \
+ test_debug \
+ test_ikc3 \
+ test_ikc3 \
+ test_valgrind
include config.mk
include sources.mk
diff --git a/test/json_test b/test/json_test
new file mode 100755
index 0000000..8a6f018
--- /dev/null
+++ b/test/json_test
@@ -0,0 +1,92 @@
+#!/bin/sh
+cd "$(dirname $0)/json" || exit
+
+TEST_COLOR_KO="[0;91m"
+TEST_COLOR_OK="[0;92m"
+TEST_COLOR_RESET="[0m"
+TEST_COUNT=0
+TEST_KO=0
+TEST_OK=0
+
+if [ "x$IKC3" = "x" ]; then
+ if [ -f ../../ikc3/ikc3 ]; then
+ IKC3=../../ikc3/ikc3
+ elif [ -f ../../ikc3 ]; then
+ IKC3=../../ikc3
+ fi
+fi
+
+test_ko() {
+ printf "%s" "${TEST_COLOR_KO}F${TEST_COLOR_RESET}"
+ echo $@ >> .test_ko
+ echo $@ >> .test
+}
+
+test_ok() {
+ printf "%s" "${TEST_COLOR_OK}.${TEST_COLOR_RESET}"
+ echo $@ >> .test_ok
+ echo $@ >> .test
+}
+
+if [ $# = 0 ]; then
+ if [ "x${IKC3_TEST}" = "x" ]; then
+ TARGETS="$(ls -1 *.kc3 | sed -e 's/[.]kc3$//')"
+ else
+ TARGETS="${IKC3_TEST}"
+ fi
+else
+ TARGETS="$@"
+fi
+
+rm -f *.diff *.out *.ret
+rm -f .test .test_ko .test_ok
+touch .test .test_ko .test_ok
+for TARGET in $TARGETS; do
+ (
+ RESULT=test_ok
+ echo $TARGET > current_test
+ $IKC3 --load ${TARGET}.kc3 --quit > ${TARGET}.out 2>&1
+ echo $? > ${TARGET}.ret
+ if ! diff -abu ${TARGET}.out.expected ${TARGET}.out \
+ > ${TARGET}.diff
+ then
+ RESULT=test_ko
+ fi
+ if ! diff -abu ${TARGET}.ret.expected ${TARGET}.ret \
+ >> ${TARGET}.diff
+ then
+ RESULT=test_ko
+ fi
+ if [ "x$RESULT" = "xtest_ok" ]; then
+ rm ${TARGET}.diff
+ test_ok ${TARGET}
+ else
+ test_ko ${TARGET}
+ fi
+ )
+ sleep 2
+done
+wait
+TEST_COUNT=$(echo $(wc -l .test) | cut -f 1 -d ' ')
+TEST_KO=$(echo $(wc -l .test_ko) | cut -f 1 -d ' ')
+TEST_OK=$(echo $(wc -l .test_ok) | cut -f 1 -d ' ')
+echo
+DIFFS="$(for TARGET in $TARGETS; do
+ if [ -f "${TARGET}.diff" ]; then
+ printf "%s " "${TARGET}.diff"
+ fi
+done)"
+if [ "x$DIFFS" != "x" ]; then
+ ls $DIFFS
+ less $DIFFS || cat $DIFFS
+fi
+echo
+printf "%s" "Total $TEST_COUNT tests. "
+printf "%s" "${TEST_COLOR_OK}OK $TEST_OK ($(($TEST_OK * 100 / $TEST_COUNT))%)${TEST_COLOR_RESET}. "
+echo "${TEST_COLOR_KO}KO $TEST_KO ($(($TEST_KO * 100 / $TEST_COUNT))%)${TEST_COLOR_RESET}."
+
+if [ "x$TEST_KO" = "x0" ]; then
+ exit 0
+fi
+
+exit 1
diff --git a/update_sources b/update_sources
index 7920de2..fea9748 100755
--- a/update_sources
+++ b/update_sources
@@ -84,6 +84,7 @@ update_sources_sh
( cd ikc3 && ./update_sources; )
( cd kc3s && ./update_sources; )
( cd ekc3 && ./update_sources; )
+( cd json && ./update_sources; )
( cd http && ./update_sources; )
( cd httpd && ./update_sources; )
( cd test && ./update_sources; )