From: Nishi Date: Thu, 3 Oct 2024 05:54:55 +0000 (+0000) Subject: winsock1 support X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=fdca60fd9e96a70e67f43a75e3f75d1944b26b9f;p=tewi.git winsock1 support git-svn-id: file:///raid/svn-personal/tewi/trunk@240 8739d7e6-ffea-ec47-b151-bdff447c6205 --- diff --git a/Makefile b/Makefile index 77f48c1..7344a0a 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PWD = `pwd` PLATFORM = generic +PLATFORM_IDENT = NOT_WINDOWS PREFIX = /usr/local MODULE = ./Module @@ -23,7 +24,7 @@ all: ./Server $(MODULE) cc -o $@ ./Tool/itworks.c ./Server:: ./Common ./Tool/option ./Tool/genconf ./Tool/itworks - $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`" + $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../ $(PLATFORM_IDENT)`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`" ./Module:: ./Common $(MAKE) -C $@ $(FLAGS) diff --git a/Platform/bcc.mk b/Platform/bcc.mk index 7fc5c67..42e6f64 100644 --- a/Platform/bcc.mk +++ b/Platform/bcc.mk @@ -2,13 +2,14 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = ../bcc.sh AR = tlib AR_FLAGS = AR_PROC = grep -Eo "[^ ]+" | xargs -I {} echo + {} CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC LDFLAGS = -LIBS = -lws2_32 +LIBS = EXEC = STATIC = lib LIBSUF = .dll diff --git a/Platform/vc6.mk b/Platform/vc6.mk index f0105be..bcf8baa 100644 --- a/Platform/vc6.mk +++ b/Platform/vc6.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = ../vc6.sh AR = lib AR_FLAGS = /nologo /out: CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC LDFLAGS = -LIBS = -lws2_32 -ladvapi32 -llibcmt +LIBS = -ladvapi32 -llibcmt EXEC = STATIC = lib LIBSUF = .dll diff --git a/Platform/watcom.mk b/Platform/watcom.mk index a3a7efb..ee4393e 100644 --- a/Platform/watcom.mk +++ b/Platform/watcom.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS_WATCOM CC = owcc AR = wlib AR_FLAGS = -q -b -n -fo CFLAGS = -b nt$(END) -I $(WATCOM)/h/nt -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC LDFLAGS = -b nt$(END) -LIBS = ws2_32.lib +LIBS = EXEC = .exe STATIC = lib LIBSUF = .dll diff --git a/Platform/win32-service.mk b/Platform/win32-service.mk index 751b6ba..cd786de 100644 --- a/Platform/win32-service.mk +++ b/Platform/win32-service.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = i686-w64-mingw32-gcc AR = i686-w64-mingw32-ar WINDRES = i686-w64-mingw32-windres CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC -DSERVICE -mwindows LDFLAGS = -mwindows -LIBS = -lws2_32 +LIBS = EXEC = .exe LIBSUF = .dll PREOBJS = tewi.res diff --git a/Platform/win32.mk b/Platform/win32.mk index 857d339..33682c3 100644 --- a/Platform/win32.mk +++ b/Platform/win32.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = i686-w64-mingw32-gcc AR = i686-w64-mingw32-ar WINDRES = i686-w64-mingw32-windres CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC LDFLAGS = -LIBS = -lws2_32 +LIBS = EXEC = .exe LIBSUF = .dll PREOBJS = tewi.res diff --git a/Platform/win64-service.mk b/Platform/win64-service.mk index d52befc..6ec458d 100644 --- a/Platform/win64-service.mk +++ b/Platform/win64-service.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = x86_64-w64-mingw32-gcc AR = x86_64-w64-mingw32-ar WINDRES = x86_64-w64-mingw32-windres CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC -DSERVICE -mwindows LDFLAGS = -mwindows -LIBS = -lws2_32 +LIBS = EXEC = .exe LIBSUF = .dll PREOBJS = tewi.res diff --git a/Platform/win64.mk b/Platform/win64.mk index 1d74ff9..f2e5842 100644 --- a/Platform/win64.mk +++ b/Platform/win64.mk @@ -2,12 +2,13 @@ PREFIX = C:/Tewi +PLATFORM_IDENT = WINDOWS CC = x86_64-w64-mingw32-gcc AR = x86_64-w64-mingw32-ar WINDRES = x86_64-w64-mingw32-windres CFLAGS = -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -fPIC LDFLAGS = -LIBS = -lws2_32 +LIBS = EXEC = .exe LIBSUF = .dll PREOBJS = tewi.res diff --git a/Server/config.c b/Server/config.c index 3a320af..f2bf958 100644 --- a/Server/config.c +++ b/Server/config.c @@ -15,8 +15,12 @@ #endif #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) +#ifdef USE_WINSOCK1 +#include +#else #include #endif +#endif #include #include diff --git a/Server/http.c b/Server/http.c index b98e0ae..e0c69f3 100644 --- a/Server/http.c +++ b/Server/http.c @@ -16,7 +16,11 @@ #include #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef USE_WINSOCK1 +#include +#else #include +#endif #else #ifdef USE_POLL #ifdef __PPU__ diff --git a/Server/server.c b/Server/server.c index 3dc7226..190339e 100644 --- a/Server/server.c +++ b/Server/server.c @@ -37,7 +37,11 @@ #include #include #endif +#ifdef USE_WINSOCK1 +#include +#else #include +#endif #include #include @@ -122,7 +126,11 @@ int tw_server_init(void) { int i; #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) WSADATA wsa; +#ifdef USE_WINSOCK1 + WSAStartup(MAKEWORD(1, 1), &wsa); +#else WSAStartup(MAKEWORD(2, 0), &wsa); +#endif #endif for(i = 0; config.ports[i] != -1; i++) ; diff --git a/Server/tw_config.h b/Server/tw_config.h index 6059e07..2cca1ba 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -15,7 +15,11 @@ extern "C" { #include #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef USE_WINSOCK1 +#include +#else #include +#endif #define NO_IPV6 #else #ifdef __PPU__ diff --git a/Tool/option.c b/Tool/option.c index 473f8be..c3b556a 100644 --- a/Tool/option.c +++ b/Tool/option.c @@ -26,6 +26,19 @@ int main(int argc, char** argv) { #ifndef NO_SSL printf("-lssl -lcrypto"); #endif + if(strcmp(argv[3], "WINDOWS") == 0){ +#ifdef USE_WINSOCK1 + printf(" -lwsock32"); +#else + printf(" -lws2_32"); +#endif + }else if(strcmp(argv[3], "WINDOWS_WATCOM") == 0){ +#ifdef USE_WINSOCK1 + printf(" wsock32.lib"); +#else + printf(" ws2_32.lib"); +#endif + } } printf("\n"); return 0; diff --git a/bcc.sh b/bcc.sh index 4d796cb..7a92a46 100755 --- a/bcc.sh +++ b/bcc.sh @@ -31,7 +31,9 @@ for i in "$@"; do elif [ "`echo "$i" | grep -Eo "^-D"`" = "-D" ]; then options="$options -`echo "$i" | sed "s/^-//g"`" elif [ "`echo "$i" | grep -Eo "^-l"`" = "-l" ]; then - libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib" + if [ ! "$i" = "-lwsock32" ]; then + libraries="$libraries `echo "$i" | sed "s/^-l//g"`.lib" + fi elif [ "$dowhat" = "output" ]; then dowhat="" outfile="$i" diff --git a/config.h.tmpl b/config.h.tmpl index 97801a2..45fabd2 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -10,6 +10,7 @@ #define USE_POLL #define HAS_CHROOT #undef NO_GETADDRINFO +#undef USE_WINSOCK1 /* DO NOT EDIT BELOW THIS LINE */ @@ -21,6 +22,10 @@ #undef USE_POLL /* Force select(2) for Windows */ #endif +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(USE_WINSOCK1) && !defined(NO_GETADDRINFO) +#define NO_GETADDRINFO +/* getaddrinfo is not on winsock 1 */ +#endif #if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)) && defined(HAS_CHROOT) #undef HAS_CHROOT