From 164693ff7c109ae0db4503eaf858e17ae4dc74b2 Mon Sep 17 00:00:00 2001 From: Steffen Pohle Date: Sat, 1 Nov 2025 16:41:07 +0100 Subject: [PATCH] remove webserver stuff --- Makefile | 2 +- UDPTCPNetwork.h | 8 +++++++- network.cc | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ test-ssl.cc | 2 +- webserver.cc | 0 5 files changed, 61 insertions(+), 3 deletions(-) delete mode 100644 webserver.cc diff --git a/Makefile b/Makefile index 457d1a7..126f3b6 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ DEFAULT_TCPPORT=6131 DEFAULT_UDPPORT=6131 DEFAULT_SERVER=localhost -OBJLIB=network.o udp.o tcp.o unix.o ssl.o webserver.o json.o +OBJLIB=network.o udp.o tcp.o unix.o ssl.o json.o INCLIB=UDPTCPNetwork.h DISTNAME=libUDPTCPNetwork-$(VERSION) diff --git a/UDPTCPNetwork.h b/UDPTCPNetwork.h index 65af24d..517b169 100644 --- a/UDPTCPNetwork.h +++ b/UDPTCPNetwork.h @@ -40,7 +40,6 @@ #endif -#include "UDPTCPNetwork-json.h" #include #include @@ -74,6 +73,12 @@ std::string string_to_lower(std::string s); std::string string_to_upper(std::string s); int file_is_readable (const char *fname); +void _debug (char *srcfile, int srcline, char *srcfunc, char *fmt,...); +void _errorexit (char *srcfile, int srcline, char *srcfunc, char *fmt,...); + +#define debug(...) _debug ((char*)__FILE__, __LINE__, (char*)__FUNCTION__, (char*)__VA_ARGS__) +#define errorexit(...) _errorexit ((char*)__FILE__, __LINE__, (char*)__FUNCTION__, (char*)__VA_ARGS__) + /************************************************************************ * * udp related functions @@ -223,6 +228,7 @@ public: }; #endif +#include "UDPTCPNetwork-json.h" #endif diff --git a/network.cc b/network.cc index e9a8a11..0931b44 100644 --- a/network.cc +++ b/network.cc @@ -95,4 +95,56 @@ std::string string_to_lower(std::string s) { }; +#define LEN_TEXT 128 +#define DEBUG_TEXT1LEN 2048 +#define DEBUG_TEXT2LEN (DEBUG_TEXT1LEN+LEN_TEXT) +void _debug (char *srcfile, int srcline, char *srcfunc, char *fmt,...) { + va_list args; + char texttime[LEN_TEXT]; + char text1[DEBUG_TEXT1LEN]; + char text2[DEBUG_TEXT2LEN]; + pid_t pid = gettid(); + int tms; + struct timeval tv; + struct tm tmp; + struct tm *tmptr = NULL; + + va_start (args, fmt); + vsnprintf (text1, (DEBUG_TEXT1LEN-1), fmt, args); + va_end (args); + texttime[0] = 0; + text1[DEBUG_TEXT1LEN-1] = 0; + text2[DEBUG_TEXT2LEN-1] = 0; + + gettimeofday (&tv, NULL); + tmptr = localtime_r(&tv.tv_sec, &tmp); + if (tmptr != NULL) + strftime(texttime, LEN_TEXT, "%H:%M:%S", &tmp); + + snprintf (text2, DEBUG_TEXT2LEN-1, "%s.%03d %d %s:%d %s %s", texttime, tv.tv_usec/1000, pid, + srcfile, srcline, srcfunc, text1); + printf ("%s", text2); +/* + if (type == 0 || (type & _debuglevel) != 0) { + FILE *f; + printf ("%s\n", text2); + f= fopen(DEBUG_FILE, "a"); + if (f) { + fprintf (f, "%s\n", text2); + fclose (f); + } + } +*/ +}; + + +void _errorexit (char *srcfile, int srcline, char *srcfunc, char *fmt,...) { + va_list args; + + va_start (args, fmt); + _debug (srcfile, srcline, srcfunc, fmt, args); + va_end (args); + + exit (1); +} diff --git a/test-ssl.cc b/test-ssl.cc index 2be2f6f..6c233cf 100644 --- a/test-ssl.cc +++ b/test-ssl.cc @@ -19,7 +19,7 @@ int test_sha256() { printf ("test for sha256 hash failed. please fix function getsha256sum()\n"); exit (1); } - else printf ("ok\n"); + else printf ("test for sha256 hash - ok\n"); return 0; }; diff --git a/webserver.cc b/webserver.cc deleted file mode 100644 index e69de29..0000000