diff --git a/Makefile b/Makefile
index 7fd3c1a..122747b 100644
--- a/Makefile
+++ b/Makefile
@@ -880,6 +880,16 @@ lib_links_windows:
ln -sf ../../../smtp/.libs/libkc3_smtp-0.dll lib/kc3/0.1/smtp.so
ln -sf ../../../socket/.libs/libkc3_socket-0.dll lib/kc3/0.1/socket.so
+lib_links_windows_debug:
+ ln -sf ../../../ekc3/.libs/libekc3_debug-0.dll lib/kc3/0.1/ekc3.so
+ ln -sf ../../../event/.libs/libkc3_event_debug-0.dll lib/kc3/0.1/event.so
+ ln -sf ../../../gtk4/.libs/libkc3_gtk4_debug-0.dll lib/kc3/0.1/gtk4.so
+ ln -sf ../../../http/.libs/libkc3_http_debug-0.dll lib/kc3/0.1/http.so
+ ln -sf ../../../json/.libs/libkc3_json_debug-0.dll lib/kc3/0.1/json.so
+ ln -sf ../../../markdown/.libs/libkc3_markdown_debug-0.dll lib/kc3/0.1/markdown.so
+ ln -sf ../../../smtp/.libs/libkc3_smtp_debug-0.dll lib/kc3/0.1/smtp.so
+ ln -sf ../../../socket/.libs/libkc3_socket_debug-0.dll lib/kc3/0.1/socket.so
+
libkc3_gcovr:
${MAKE} clean_cov
${MAKE} libkc3_test_cov
@@ -1280,6 +1290,25 @@ test_socket_debug: lib_links_debug
${MAKE} -C socket debug
${MAKE} -C test test_socket_debug
+uninstall:
+ rm -rf ${prefix}/lib/kc3
+ rm -rf ${prefix}/share/kc3
+ ${MAKE} -C libtommath uninstall
+ ${MAKE} -C libkc3 uninstall
+ ${MAKE} -C ikc3 uninstall
+ ${MAKE} -C kc3s uninstall
+ ${MAKE} -C ekc3 uninstall
+ ${MAKE} -C event uninstall
+ ${MAKE} -C json uninstall
+ ${MAKE} -C markdown uninstall
+ ${MAKE} -C smtp uninstall
+ ${MAKE} -C socket uninstall
+ ${MAKE} -C http uninstall
+ ${MAKE} -C httpd uninstall
+ ${MAKE} -C window uninstall
+ ${MAKE} -C gtk4 uninstall
+# ${MAKE} -C fs uninstall
+
.PHONY: all \
asan \
assets \
@@ -1424,4 +1453,5 @@ test_socket_debug: lib_links_debug
test_socket \
test_socket_asan \
test_socket_cov \
- test_socket_debug
+ test_socket_debug \
+ uninstall
diff --git a/config.subr b/config.subr
index 3030982..a9b82d6 100644
--- a/config.subr
+++ b/config.subr
@@ -412,7 +412,7 @@ config_lib_have() {
echo "/* generated by configure */" > "$OUT_C"
echo "int main (void) { return 0; }" >> "$OUT_C"
if $LIBTOOL --tag CC --mode link ${CC} ${CPPFLAGS} ${CFLAGS} \
- "$OUT_C" ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
+ "$OUT_C" ${LDFLAGS} ${LIBS} $@ -o "$OUT" >/dev/null 2>&1; then
eval "HAVE_$NAME=true"
echo "HAVE_$NAME = true" >> ${CONFIG_MK}
else
diff --git a/ekc3/Makefile b/ekc3/Makefile
index f963fcc..be98ca6 100644
--- a/ekc3/Makefile
+++ b/ekc3/Makefile
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/ekc3
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
@@ -73,6 +78,7 @@ update_sources:
install \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/event/Makefile b/event/Makefile
index f963fcc..7ba25d9 100644
--- a/event/Makefile
+++ b/event/Makefile
@@ -49,8 +49,8 @@ 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}/include/libkc3/event
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/event
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/event
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
diff --git a/fs/Makefile b/fs/Makefile
index 09bcd65..bc74d3d 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -43,6 +43,9 @@ gcovr:
install:
# ${MAKE} -C fuse install
+uninstall:
+# ${MAKE} -C fuse uninstall
+
.PHONY: \
all \
asan \
@@ -52,4 +55,5 @@ install:
debug \
distclean \
fuse \
- install
+ install \
+ uninstall
diff --git a/gtk4/Makefile b/gtk4/Makefile
index 1d41dc2..73b25b5 100644
--- a/gtk4/Makefile
+++ b/gtk4/Makefile
@@ -49,8 +49,8 @@ gcovr:
gcovr --gcov-executable ${GCOV} --html-details libkc3_gtk4.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}/include/libkc3/gtk4
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/gtk4
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+install:
+ rm -rf ${prefix}/include/libkc3/gtk4
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
@@ -73,6 +78,7 @@ update_sources:
install \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/http/Makefile b/http/Makefile
index f963fcc..7048174 100644
--- a/http/Makefile
+++ b/http/Makefile
@@ -49,8 +49,8 @@ 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}/include/libkc3/http
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/http
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/http
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
@@ -73,6 +78,7 @@ update_sources:
install \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/httpd/Makefile b/httpd/Makefile
index f7012d0..5309aef 100644
--- a/httpd/Makefile
+++ b/httpd/Makefile
@@ -66,11 +66,14 @@ gdb_httpd: debug
install:
mkdir -p ${prefix}/bin
- install -m 755 .libs/kc3_httpd ${prefix}/bin/kc3_httpd
+ ${INSTALL} -m 755 .libs/kc3_httpd ${prefix}/bin/kc3_httpd
lldb_httpd: debug
if [ -f kc3_httpd_debug.core ]; then lldb .libs/kc3_httpd_debug kc3_httpd_debug.core; else lldb .libs/kc3_httpd_debug; fi
+uninstall:
+ rm -f ${prefix}/bin/kc3_httpd
+
.PHONY: \
all \
asan \
@@ -83,6 +86,7 @@ lldb_httpd: debug
install \
lldb_httpd \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/ikc3/Makefile b/ikc3/Makefile
index 7e888c0..1dd07a5 100644
--- a/ikc3/Makefile
+++ b/ikc3/Makefile
@@ -51,11 +51,14 @@ gdb_ikc3_asan: asan
install:
mkdir -p ${prefix}/bin
- install -m 755 .libs/ikc3 ${prefix}/bin/ikc3
+ ${INSTALL} -m 755 .libs/ikc3 ${prefix}/bin/ikc3
lldb_ikc3: debug
if [ -f ikc3_debug.core ]; then lldb .libs/ikc3_debug ikc3_debug.core; else lldb .libs/ikc3_debug; fi
+uninstall:
+ rm -f ${prefix}/bin/ikc3
+
.PHONY: \
all \
asan \
@@ -69,6 +72,7 @@ lldb_ikc3: debug
install \
lldb_ikc3 \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/json/Makefile b/json/Makefile
index f963fcc..d98855a 100644
--- a/json/Makefile
+++ b/json/Makefile
@@ -49,8 +49,8 @@ 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}/include/libkc3/json
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/json
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/json
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
@@ -73,6 +78,7 @@ update_sources:
install \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/kc3s/Makefile b/kc3s/Makefile
index a9a2ff6..0b46c32 100644
--- a/kc3s/Makefile
+++ b/kc3s/Makefile
@@ -50,7 +50,10 @@ install:
mkdir -p ${prefix}/bin
install -m 755 .libs/kc3s ${prefix}/bin/kc3s
-.PHONY: all asan cov debug clean clean_cov distclean
+uninstall:
+ rm -f ${prefix}/bin/kc3s
+
+.PHONY: all asan cov debug clean clean_cov distclean install uninstall
include config.mk
include sources.mk
diff --git a/libkc3/Makefile b/libkc3/Makefile
index e844b7e..cc7b0b8 100644
--- a/libkc3/Makefile
+++ b/libkc3/Makefile
@@ -64,6 +64,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
diff --git a/libkc3/struct.c b/libkc3/struct.c
index 384060d..23b86ce 100644
--- a/libkc3/struct.c
+++ b/libkc3/struct.c
@@ -160,24 +160,24 @@ void struct_delete (s_struct *s)
if (env_global()->pass_by_copy)
assert(s->ref_count == 1);
else {
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_lock(&s->mutex);
#endif
if (s->ref_count <= 0) {
err_puts("struct_delete: invalid reference count");
assert(! "struct_delete: invalid reference count");
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&s->mutex);
#endif
return;
}
if (--s->ref_count) {
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&s->mutex);
#endif
return;
}
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&s->mutex);
#endif
}
@@ -285,7 +285,7 @@ s_struct * struct_init (s_struct *s, const s_sym *module)
}
}
tmp.ref_count = 1;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*s = tmp;
@@ -339,7 +339,7 @@ s_struct * struct_init_copy (s_struct *s, s_struct *src)
i++;
}
}
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*s = tmp;
@@ -420,7 +420,7 @@ s_struct * struct_init_with_data (s_struct *s, const s_sym *module,
tmp.data = data;
tmp.free_data = free_data;
tmp.ref_count = 1;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*s = tmp;
@@ -434,7 +434,7 @@ s_struct * struct_init_with_type (s_struct *s, s_struct_type *st)
assert(st);
pstruct_type_init_copy(&tmp.pstruct_type, &st);
tmp.ref_count = 1;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*s = tmp;
@@ -471,7 +471,7 @@ s_struct * struct_new_copy (s_struct *src)
s_struct * struct_new_ref (s_struct *s)
{
assert(s);
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_lock(&s->mutex);
#endif
if (s->ref_count <= 0) {
@@ -480,7 +480,7 @@ s_struct * struct_new_ref (s_struct *s)
return NULL;
}
s->ref_count++;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&s->mutex);
#endif
return s;
diff --git a/libkc3/struct_type.c b/libkc3/struct_type.c
index 1cf36e1..1669ddb 100644
--- a/libkc3/struct_type.c
+++ b/libkc3/struct_type.c
@@ -72,7 +72,7 @@ void struct_type_delete (s_struct_type *st)
if (env_global()->pass_by_copy)
assert(st->ref_count == 1);
else {
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_lock(&st->mutex);
#endif
if (st->ref_count <= 0) {
@@ -81,12 +81,12 @@ void struct_type_delete (s_struct_type *st)
abort();
}
if (--st->ref_count) {
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&st->mutex);
#endif
return;
}
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&st->mutex);
#endif
}
@@ -204,7 +204,7 @@ s_struct_type * struct_type_init (s_struct_type *st,
#endif
}
tmp.ref_count = 1;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*st = tmp;
@@ -232,7 +232,7 @@ s_struct_type * struct_type_init_copy (s_struct_type *st,
memcpy(tmp.offset, src->offset, tmp.map.count * sizeof(uw));
tmp.size = src->size;
tmp.ref_count = 1;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_init(&tmp.mutex);
#endif
*st = tmp;
@@ -288,19 +288,19 @@ s_struct_type * struct_type_new_copy (const s_struct_type *src)
s_struct_type * struct_type_new_ref (s_struct_type *st)
{
assert(st);
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_lock(&st->mutex);
#endif
if (st->ref_count <= 0) {
err_puts("struct_type_new_ref: invalid reference count");
assert(! "struct_type_new_ref: invalid reference count");
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&st->mutex);
#endif
return NULL;
}
st->ref_count++;
-#ifdef HAVE_PTHREAD
+#if HAVE_PTHREAD
mutex_unlock(&st->mutex);
#endif
return st;
diff --git a/libtommath b/libtommath
index 2b4f8c8..3ccbcc8 160000
--- a/libtommath
+++ b/libtommath
@@ -1 +1 @@
-Subproject commit 2b4f8c862fd5564945aa4fa60460c1920315e318
+Subproject commit 3ccbcc870bec6d8f310696ae869f55a29e407911
diff --git a/markdown/Makefile b/markdown/Makefile
index f963fcc..07fc465 100644
--- a/markdown/Makefile
+++ b/markdown/Makefile
@@ -49,8 +49,8 @@ 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}/include/libkc3/markdown
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/markdown
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/markdown
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
diff --git a/smtp b/smtp
index cd1e59c..366ad84 160000
--- a/smtp
+++ b/smtp
@@ -1 +1 @@
-Subproject commit cd1e59cb718ba91dcf28684b27cf5a4f48f9f78d
+Subproject commit 366ad848ad346cc06ccdbad1097fbe1d28e6580f
diff --git a/socket/Makefile b/socket/Makefile
index f963fcc..81f6b12 100644
--- a/socket/Makefile
+++ b/socket/Makefile
@@ -49,8 +49,8 @@ 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}/include/libkc3/socket
+ ${LIBTOOL} --tag=CC --mode=install ${INSTALL} -o ${OWNER} -g ${GROUP} -m 0644 ${HEADERS} ${prefix}/include/libkc3/socket
${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
@@ -61,6 +61,11 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/socket
+ rm -f ${prefix}/lib/${LIB}
+ rm -f ${prefix}/lib/${LIB_DEBUG}
+
.PHONY: \
all \
asan \
@@ -73,6 +78,7 @@ update_sources:
install \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/socket/socket.c b/socket/socket.c
index 376f1a6..0fbda4b 100644
--- a/socket/socket.c
+++ b/socket/socket.c
@@ -26,10 +26,18 @@
#include "socket.h"
#include "socket_buf.h"
+
+#if (defined(WIN32) || defined(WIN64))
+static bool g_socket_init = false;
+#endif
+
void socket_clean (void)
{
-#ifdef WIN32
- WSACleanup();
+#if (defined(WIN32) || defined(WIN64))
+ if (g_socket_init) {
+ WSACleanup();
+ g_socket_init = false;
+ }
#endif
}
@@ -42,12 +50,16 @@ void socket_close (p_socket s)
bool socket_init (void)
{
-#ifdef WIN32
+#if (defined(WIN32) || defined(WIN64))
static WSADATA wsa_data;
s32 r;
- if ((r = WSAStartup(MAKEWORD(2,2), &wsa_data))) {
- printf("WSAStartup failed with error: %d\n", r);
- return false;
+ if (! g_socket_init) {
+ printf("socket_init: WSAStartup\n");
+ if ((r = WSAStartup(MAKEWORD(2,2), &wsa_data))) {
+ printf("socket_init: WSAStartup failed with error: %d\n", r);
+ return false;
+ }
+ g_socket_init = true;
}
#endif
return true;
@@ -90,7 +102,8 @@ p_socket socket_init_listen (p_socket s, const s_str *host,
t_socket sockfd;
assert(s);
assert(host);
- hints.ai_family = AF_INET;
+ if (! socket_init())
+ return NULL;
e = getaddrinfo(host->ptr.pchar, service->ptr.pchar, &hints, &res0);
if (e) {
err_write_1("socket_init_listen(");
@@ -98,6 +111,8 @@ p_socket socket_init_listen (p_socket s, const s_str *host,
err_write_1(", ");
err_write_1(service->ptr.pchar);
err_write_1("): getaddrinfo: ");
+ err_inspect_s32_decimal(&e);
+ err_write_1(" ");
err_puts((char *) gai_strerror(e));
assert(! "socket_init_listen: getaddrinfo");
return NULL;
diff --git a/socket/socket_buf.c b/socket/socket_buf.c
index 968c29d..175edbc 100644
--- a/socket/socket_buf.c
+++ b/socket/socket_buf.c
@@ -16,6 +16,8 @@
#ifdef WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
+# undef errno
+# define errno WSAGetLastError()
#else
# include <netdb.h>
# include <netinet/in.h>
@@ -23,6 +25,7 @@
#include <unistd.h>
#include <libkc3/kc3.h>
+#include "socket.h"
#include "socket_addr.h"
#include "socket_buf.h"
@@ -126,6 +129,8 @@ s_socket_buf * socket_buf_init_connect (s_socket_buf *sb,
assert(sb);
assert(host);
assert(service);
+ if (! socket_init())
+ return NULL;
hints.ai_family = AF_INET;
e = getaddrinfo(host->ptr.pchar, service->ptr.pchar, &hints, &res0);
if (e) {
@@ -134,7 +139,9 @@ s_socket_buf * socket_buf_init_connect (s_socket_buf *sb,
err_write_1(", ");
err_write_1(service->ptr.pchar);
err_write_1("): getaddrinfo: ");
- err_puts((const char *) gai_strerror(e));
+ err_inspect_s32_decimal(&e);
+ err_write_1(" ");
+ err_puts((const char *) gai_strerrorA(e));
assert(! "socket_buf_init_connect: getaddrinfo");
return NULL;
}
diff --git a/socket/types.h b/socket/types.h
index b769875..e71bc7c 100644
--- a/socket/types.h
+++ b/socket/types.h
@@ -13,10 +13,14 @@
#ifndef HTTP_TYPES_H
#define HTTP_TYPES_H
-#ifdef WIN32
-# include <winsock2.h>
+#ifdef WIN64
+# include <ws2tcpip.h>
#else
-# include <sys/socket.h>
+# ifdef WIN32
+# include <winsock2.h>
+# else
+# include <sys/socket.h>
+# endif
#endif
#include <libkc3/types.h>
diff --git a/test/Makefile b/test/Makefile
index e99907a..d00bf55 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -240,6 +240,18 @@ test_markdown_cov:
test_markdown_debug:
IKC3=${SRC_TOP}/ikc3/ikc3_debug time ./markdown_test
+test_socket:
+ IKC3=${SRC_TOP}/ikc3/ikc3 time ./socket_test
+
+test_socket_asan:
+ IKC3=${SRC_TOP}/ikc3/ikc3_asan time ./socket_test
+
+test_socket_cov:
+ IKC3=${SRC_TOP}/ikc3/ikc3_cov time ./socket_test
+
+test_socket_debug:
+ IKC3=${SRC_TOP}/ikc3/ikc3_debug time ./socket_test
+
test_valgrind: libkc3_test
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./libkc3_test
@@ -272,6 +284,7 @@ test_valgrind: libkc3_test
test_httpd_debug \
test_ikc3 \
test_kc3s \
+ test_socket \
test_valgrind
include config.mk
diff --git a/test/kc3s/comments.out b/test/kc3s/comments.out
index 9766475..0aee968 100644
--- a/test/kc3s/comments.out
+++ b/test/kc3s/comments.out
@@ -1 +1 @@
-ok
+ok
diff --git a/window/Makefile b/window/Makefile
index d8609e8..1bc0d8c 100644
--- a/window/Makefile
+++ b/window/Makefile
@@ -107,6 +107,12 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/window
+ rm -f ${prefix}/lib/${LIB}
+ if ${HAVE_CAIRO}; then ${MAKE} -C cairo uninstall; fi
+ if ${HAVE_SDL2}; then ${MAKE} -C sdl2 uninstall; fi
+
.PHONY: \
all \
asan \
@@ -129,7 +135,8 @@ update_sources:
lldb_demo \
lldb_demo_gl \
test \
- update_sources
+ update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/cairo/Makefile b/window/cairo/Makefile
index a576bcd..a32f02b 100644
--- a/window/cairo/Makefile
+++ b/window/cairo/Makefile
@@ -104,6 +104,13 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/window/cairo
+ rm -f ${prefix}/lib/${LIB}
+ if ${HAVE_COCOA}; then ${MAKE} -C quartz uninstall; fi
+ if ${HAVE_WIN32}; then ${MAKE} -C win32 uninstall; fi
+ if ${HAVE_XCB}; then ${MAKE} -C xcb uninstall; fi
+
.PHONY: \
all \
asan \
@@ -120,7 +127,8 @@ update_sources:
install \
lldb_demo \
test \
- update_sources
+ update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/cairo/quartz/Makefile b/window/cairo/quartz/Makefile
index d4521b2..ef6ea38 100644
--- a/window/cairo/quartz/Makefile
+++ b/window/cairo/quartz/Makefile
@@ -57,6 +57,8 @@ distclean:
gdb_demo: debug
${MAKE} -C demo gdb_demo
+install:
+
lldb_demo: debug
${MAKE} -C demo lldb_demo
@@ -66,6 +68,8 @@ test: build
update_sources:
./update_sources
+uninstall:
+
.PHONY: \
all \
asan \
@@ -79,7 +83,8 @@ update_sources:
gen \
install \
test \
- update_sources
+ update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/cairo/win32/Makefile b/window/cairo/win32/Makefile
index eda903f..1ea53ba 100644
--- a/window/cairo/win32/Makefile
+++ b/window/cairo/win32/Makefile
@@ -67,12 +67,16 @@ distclean:
gdb_demo: debug
${MAKE} -C demo gdb_demo
+install:
+
test: build
${MAKE} -C demo test
update_sources:
./update_sources
+uninstall:
+
.PHONY: \
all \
asan \
@@ -86,7 +90,8 @@ update_sources:
gen \
install \
test \
- update_sources
+ update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/cairo/xcb/Makefile b/window/cairo/xcb/Makefile
index 3b53c45..0b4c6cd 100644
--- a/window/cairo/xcb/Makefile
+++ b/window/cairo/xcb/Makefile
@@ -84,6 +84,11 @@ test: build
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libc3/window/cairo/xcb
+ rm -f ${prefix}/lib/${LIB}
+ ${MAKE} -C demo uninstall
+
.PHONY: \
all \
asan \
diff --git a/window/cairo/xcb/demo/Makefile b/window/cairo/xcb/demo/Makefile
index 8afd285..c153507 100644
--- a/window/cairo/xcb/demo/Makefile
+++ b/window/cairo/xcb/demo/Makefile
@@ -68,8 +68,8 @@ gdb_demo: debug
if [ -f ${PROG_DEBUG}.core ]; then gdb .libs/${PROG_DEBUG} ${PROG_DEBUG}.core; else gdb .libs/${PROG_DEBUG}; fi
install:
- install -m 755 -d ${prefix}/bin
- install -m 755 ${PROG} ${prefix}/bin/${PROG}
+ ${INSTALL} -m 755 -d ${prefix}/bin
+ ${INSTALL} -m 755 ${PROG} ${prefix}/bin/${PROG}
lldb_demo: debug
if [ -f ${PROG_DEBUG}.core ]; then lldb .libs/${PROG_DEBUG} ${PROG_DEBUG}.core; else lldb .libs/${PROG_DEBUG}; fi
@@ -77,6 +77,9 @@ lldb_demo: debug
update_sources:
./update_sources
+uninstall:
+ rm -f ${prefix}/bin/${PROG}
+
.PHONY: \
all \
asan \
@@ -94,6 +97,7 @@ update_sources:
install \
lldb_demo \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/sdl2/Makefile b/window/sdl2/Makefile
index 0d7849e..6ad0f81 100644
--- a/window/sdl2/Makefile
+++ b/window/sdl2/Makefile
@@ -107,6 +107,12 @@ test:
update_sources:
./update_sources
+uninstall:
+ rm -rf ${prefix}/include/libkc3/window/sdl2
+ rm -f ${prefix}/lib/${LIB}
+ ${MAKE} -C demo uninstall
+ ! test -d kubz || ${MAKE} -C kubz uninstall
+
.PHONY: \
all \
asan \
@@ -124,6 +130,7 @@ update_sources:
lldb_demo \
test \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/sdl2/configure b/window/sdl2/configure
index 453a39b..0eb9288 100755
--- a/window/sdl2/configure
+++ b/window/sdl2/configure
@@ -46,6 +46,9 @@ config_gnu
config_i386
config_win32
config_win64
+if $HAVE_WIN32; then
+ LIBS="$LIBS -lglu32 -lopengl32"
+fi
pkg_config libbsd-overlay
pkg_config libmd
pkg_config freetype2
diff --git a/window/sdl2/demo/Makefile b/window/sdl2/demo/Makefile
index fecdb0e..60a078b 100644
--- a/window/sdl2/demo/Makefile
+++ b/window/sdl2/demo/Makefile
@@ -85,6 +85,9 @@ lldb_demo: debug
update_sources:
./update_sources
+uninstall:
+ rm -f ${prefix}/bin/${PROG}
+
.PHONY: \
all \
asan \
@@ -102,6 +105,7 @@ update_sources:
install \
lldb_demo \
update_sources \
+ uninstall
include config.mk
include sources.mk
diff --git a/window/sdl2/demo/configure b/window/sdl2/demo/configure
index 6b10c52..90fcb76 100755
--- a/window/sdl2/demo/configure
+++ b/window/sdl2/demo/configure
@@ -67,6 +67,9 @@ pkg_config libpng
if ${HAVE_COCOA}; then
config_lib OPENGL -framework OpenGL
fi
+if ${HAVE_WIN32}; then
+ LIBS="$LIBS -lSDL2Main"
+fi
config_lib OPENGL -lopengl32 -lglu32
config_lib OPENMP -fopenmp
config_define HAVE_OPENMP "${HAVE_OPENMP}"
diff --git a/window/sdl2/demo/img/earth.png b/window/sdl2/demo/img/earth.png
new file mode 100644
index 0000000..df1fe95
Binary files /dev/null and b/window/sdl2/demo/img/earth.png differ
diff --git a/window/sdl2/kubz b/window/sdl2/kubz
index bfdfcf4..4bd361a 160000
--- a/window/sdl2/kubz
+++ b/window/sdl2/kubz
@@ -1 +1 @@
-Subproject commit bfdfcf4416f3abb75ddb8cf74bf0a45a7b27fcbc
+Subproject commit 4bd361ae1a05e6a663a96dea85c599f741f03913