From: Nishi Date: Mon, 14 Oct 2024 10:01:02 +0000 (+0000) Subject: wip X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=431d67440f97efc18b0e6f3607f6a9d7a50caa8c;p=tewi.git wip git-svn-id: file:///raid/svn-personal/tewi/trunk@315 8739d7e6-ffea-ec47-b151-bdff447c6205 --- diff --git a/Common/dir.c b/Common/dir.c index 0a27687..77fef96 100644 --- a/Common/dir.c +++ b/Common/dir.c @@ -7,6 +7,8 @@ #include #if !defined(_MSC_VER) && !defined(__WATCOMC__) #include +#elif defined(__NETWARE__) +#include #elif defined(__WATCOMC__) || defined(_MSC_VER) #include #endif diff --git a/Makefile b/Makefile index f86e025..bddd35e 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,10 @@ install: all ./Tool/genconf ./Tool/itworks if [ ! -e $(DESTDIR)$(PREFIX)/www/pbtewi.gif ]; then ( cp Binary/pbtewi.gif $(DESTDIR)$(PREFIX)/www/ || ( rm $(DESTDIR)$(PREFIX)/www/pbtewi.gif ; exit 1 ) ) ; fi -cp ./Server/tewi $(DESTDIR)$(PREFIX)/bin/ -cp ./Server/tewi.exe $(DESTDIR)$(PREFIX)/bin/ + -cp ./Server/tewi.nlm $(DESTDIR)$(PREFIX)/bin/ -cp ./Module/*.so $(DESTDIR)$(PREFIX)/lib/tewi/ -cp ./Module/*.dll $(DESTDIR)$(PREFIX)/lib/tewi/ + -cp ./Module/*.nlm $(DESTDIR)$(PREFIX)/lib/tewi/ format: clang-format --verbose -i `find ./Server ./Common ./Module ./Tool "(" -name "*.c" -or -name "*.h" ")" -and -not -name "strptime.*"` config.h diff --git a/Module/Makefile b/Module/Makefile index 2f7070f..3790510 100644 --- a/Module/Makefile +++ b/Module/Makefile @@ -12,7 +12,7 @@ include $(PWD)/Platform/$(PLATFORM).mk all: mod_cgi$(LIBSUF) mod_proxy$(LIBSUF) .$(OBJ)$(LIBSUF): - $(CC) $(LDFLAGS) $(SHARED) -o $@ $< ../Common/common.$(STATIC) $(LIBS) + $(CC) $(LDFLAGS) $(SHARED) -o $@ $< $(LIBEXTRA) ../Common/common.$(STATIC) $(LIBS) .c.$(OBJ): $(CC) $(CFLAGS) -I ../Server -c -o $@ $< diff --git a/Module/mod_cgi.c b/Module/mod_cgi.c index da9e232..e300307 100644 --- a/Module/mod_cgi.c +++ b/Module/mod_cgi.c @@ -21,3 +21,7 @@ int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, res->status = 403; return TW_MODULE_STOP; } + +#ifdef __NETWARE__ +int main() { return 0; } +#endif diff --git a/Module/mod_example.c b/Module/mod_example.c index 6472128..7b7ce0f 100644 --- a/Module/mod_example.c +++ b/Module/mod_example.c @@ -12,3 +12,7 @@ int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) { int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; } int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); } + +#ifdef __NETWARE__ +int main() { return 0; } +#endif diff --git a/Module/mod_proxy.c b/Module/mod_proxy.c index ab26a42..ac276b0 100644 --- a/Module/mod_proxy.c +++ b/Module/mod_proxy.c @@ -13,3 +13,7 @@ int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) { int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_NOTME; } int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; } + +#ifdef __NETWARE__ +int main() { return 0; } +#endif diff --git a/README b/README index 064721e..2199757 100644 --- a/README +++ b/README @@ -44,7 +44,8 @@ OpenBSD Working Haiku Working Minix Working UnixWare Working on 7.1.1 -OS/2 Mostly working, module is broken. Help required! +OS/2 Working +NetWare WIP PlayStation Portable Working, missing module support TODO: Get multi-threading working (maybe) PlayStation 2 Not working diff --git a/README.tmpl b/README.tmpl index a91c3ee..36a2ae5 100644 --- a/README.tmpl +++ b/README.tmpl @@ -45,7 +45,7 @@ Haiku Working Minix Working UnixWare Working on 7.1.1 OS/2 Working -NetWare WIP +NetWare WIP, cannot run fopen somehow PlayStation Portable Working, missing module support TODO: Get multi-threading working (maybe) PlayStation 2 Not working diff --git a/Server/Makefile b/Server/Makefile index f987608..ef480ad 100644 --- a/Server/Makefile +++ b/Server/Makefile @@ -59,4 +59,4 @@ concat.rc: tewi.rc gui.rc cat tewi.rc gui.rc > concat.rc clean: - rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc *.tds + rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg *.obj concat.rc *.tds *.nlm diff --git a/Server/config.c b/Server/config.c index fdcbc06..bf5c236 100644 --- a/Server/config.c +++ b/Server/config.c @@ -9,6 +9,7 @@ #include #include #include +#include #if !defined(_MSC_VER) && !defined(__BORLANDC__) #include @@ -124,6 +125,8 @@ void tw_config_init(void) { strcpy(config.hostname, "ps3"); #elif defined(__ps2sdk__) strcpy(config.hostname, "ps2"); +#elif defined(__NETWARE__) + strcpy(config.hostname, "netware"); #else gethostname(config.hostname, 1024); #endif @@ -583,6 +586,7 @@ int tw_config_read(const char* path) { return stop; } } else { + printf("%d\n", errno); cm_log("Config", "Could not open the file"); return 1; } diff --git a/Server/http.c b/Server/http.c index b875c18..10713f1 100644 --- a/Server/http.c +++ b/Server/http.c @@ -21,12 +21,14 @@ #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) #ifdef USE_WINSOCK1 #include #else #include #endif +#elif defined(__NETWARE__) +#include #else #ifdef USE_POLL #ifdef __PPU__ diff --git a/Server/main.c b/Server/main.c index 7b8abe2..a14fd8c 100644 --- a/Server/main.c +++ b/Server/main.c @@ -34,8 +34,11 @@ #include "tw_server.h" #include "tw_version.h" -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) #include +#elif defined(__NETWARE__) +#include +#include #endif #ifdef _PSP @@ -92,7 +95,7 @@ char tw_server[2048]; int startup(int argc, char** argv); -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__) char* get_registry(const char* main, const char* sub) { DWORD bufsize = 512; HKEY handle; @@ -532,8 +535,32 @@ void show_png(void) { #endif #if !defined(BUILD_GUI_VALID) +void thread_stuff(void* pargs); + +struct arg_struct { + int argc; + char** argv; +}; + int main(int argc, char** argv) { int st; +#ifdef __NETWARE__ + struct arg_struct* parg = malloc(sizeof(*parg)); + parg->argc = argc; + parg->argv = argv; + DestroyScreen(GetCurrentScreen()); + SetCurrentScreen(CreateScreen("Tewi Console", 0)); + BeginThread(thread_stuff, NULL, 0, parg); + ThreadSwitch(); + ExitThread(EXIT_THREAD, 0); + return 0; +} + +void thread_stuff(void* pargs) { + int st; + int argc = ((struct arg_struct*)pargs)->argc; + char** argv = ((struct arg_struct*)pargs)->argv; +#endif #ifdef SERVICE SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}}; logfile = stderr; @@ -706,7 +733,11 @@ int main(int argc, char** argv) { while(1) ; #endif +#ifdef __NETWARE__ + return; +#else return st; +#endif #endif } tw_server_loop(); @@ -714,14 +745,18 @@ int main(int argc, char** argv) { #ifdef _PSP sceKernelExitGame(); #endif +#ifdef __NETWARE__ + return; +#else return 0; +#endif } #endif int startup(int argc, char** argv) { int i; char* r; -#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__)) || defined(__BORLANDC__) +#if defined(__MINGW32__) || defined(_MSC_VER) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) || defined(__BORLANDC__) char* confpath = cm_strdup(PREFIX "/etc/tewi.conf"); char* regpath = get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir"); if(regpath != NULL) { @@ -805,7 +840,7 @@ int startup(int argc, char** argv) { #if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__) signal(SIGCHLD, SIG_IGN); signal(SIGPIPE, SIG_IGN); -#elif !defined(BUILD_GUI) && !defined(__OS2__) +#elif !defined(BUILD_GUI) && !defined(__OS2__) && !defined(__NETWARE__) SetConsoleTitle(tw_server); #endif return -1; diff --git a/Server/module.c b/Server/module.c index e92aece..28a597d 100644 --- a/Server/module.c +++ b/Server/module.c @@ -31,6 +31,9 @@ int tw_module_init(void* mod) { return 1; } #define INCL_DOSMODULEMGR #define INCL_DOSERRORS #include +#elif defined(__NETWARE__) +#include +#include #else #include #include @@ -45,14 +48,19 @@ void* tw_module_load(const char* path) { char tmp[512]; #ifdef __OS2__ HMODULE mod; +#elif defined(__NETWARE__) + unsigned int* hnd = malloc(sizeof(*hnd)); #endif chdir(config.server_root); #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #ifdef __OS2__ - if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR){ + if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) { return NULL; } lib = (void*)mod; +#elif defined(__NETWARE__) + *hnd = FindNLMHandle(path); + lib = (void*)hnd; #else lib = LoadLibraryA(path); #endif @@ -72,11 +80,13 @@ void* tw_module_symbol(void* mod, const char* sym) { #ifdef __OS2__ void* ret; APIRET rc; - if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR){ + if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR) { cm_log("Module", "OS/2 error %d", (int)rc); return NULL; } return ret; +#elif defined(__NETWARE__) + return ImportSymbol(*(unsigned int*)mod, sym); #else return GetProcAddress(mod, sym); #endif diff --git a/Server/server.c b/Server/server.c index 05236d6..ffa6d78 100644 --- a/Server/server.c +++ b/Server/server.c @@ -47,7 +47,7 @@ typedef int socklen_t; #include #endif -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) #ifndef NO_GETNAMEINFO #include #include @@ -62,6 +62,15 @@ typedef int socklen_t; #include "strptime.h" typedef int socklen_t; +#elif defined(__NETWARE__) +#include +#include + +typedef int socklen_t; +#define IPPROTO_TCP 0 +#define INADDR_ANY 0 +#define htons(x) x +#include "strptime.h" #else #ifdef USE_POLL #ifdef __PPU__ @@ -136,6 +145,8 @@ int tw_wildcard_match(const char* wildcard, const char* target) { void close_socket(int sock) { #ifdef __OS2__ soclose(sock); +#elif defined(__NETWARE__) + shutdown(sock, 2); #elif defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) closesocket(sock); #else @@ -145,7 +156,7 @@ void close_socket(int sock) { int tw_server_init(void) { int i; -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) WSADATA wsa; #ifdef USE_WINSOCK1 WSAStartup(MAKEWORD(1, 1), &wsa); @@ -521,10 +532,12 @@ int tw_server_pass(void* ptr) { #ifndef NO_GETNAMEINFO struct sockaddr* sa = (struct sockaddr*)&addr; getnameinfo(sa, sizeof(addr), address, 512, NULL, 0, NI_NUMERICHOST); +#elif defined(__NETWARE__) + address[0] = 0; #else - addrstr = inet_ntoa(addr.sin_addr); - strcpy(address, addrstr); - address[strlen(addrstr)] = 0; + addrstr = inet_ntoa(addr.sin_addr); + strcpy(address, addrstr); + address[strlen(addrstr)] = 0; #endif #ifdef FREE_PTR free(ptr); @@ -631,7 +644,7 @@ int tw_server_pass(void* ptr) { #ifdef __OS2__ tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "MOD_REQUEST"); #else - tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "mod_request"); + tw_mod_request_t mod_req = (tw_mod_request_t)tw_module_symbol(config.modules[i], "mod_request"); #endif if(mod_req != NULL) { int ret = mod_req(&tools, &req, &res); @@ -940,7 +953,11 @@ cleanup: #endif close_socket(sock); #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#ifdef __NETWARE__ + ExitThread(EXIT_THREAD, 0); +#else _endthread(); +#endif #elif defined(__HAIKU__) exit_thread(0); #endif @@ -958,6 +975,8 @@ extern SERVICE_STATUS_HANDLE status_handle; struct thread_entry { #ifdef __HAIKU__ thread_id thread; +#elif defined(__NETWARE__) + int thread; #else HANDLE handle; #endif @@ -1045,6 +1064,8 @@ void tw_server_loop(void) { #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) #ifdef __OS2__ _beginthread(tw_server_pass, 0, 0, e); +#elif defined(__NETWARE__) + BeginThread(tw_server_pass, 0, 0, e); #else _beginthread(tw_server_pass, 0, e); #endif diff --git a/Server/strptime.c b/Server/strptime.c index 02dbe55..b809da9 100644 --- a/Server/strptime.c +++ b/Server/strptime.c @@ -37,14 +37,17 @@ #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#include #include #include #include #include #ifdef __WATCOMC__ +#ifndef __NETWARE__ #include #endif +#endif static const unsigned char *conv_num(const unsigned char *, int *, unsigned int, unsigned int); static const unsigned char *find_string(const unsigned char *, int *, const char * const *, const char * const *, int); @@ -116,14 +119,18 @@ static const unsigned char *find_string(const unsigned char *, int *, const char #define _tzset tzset #endif -#ifdef __BORLANDC__ +#if defined(__BORLANDC__) || defined(__NETWARE__) char* cm_strdup(const char* str); +#ifdef __NETWARE__ +#define strncasecmp _strnicmp +#endif + int _strnicmp(const char* _a, const char* _b, int len){ char* a = cm_strdup(_a); char* b = cm_strdup(_b); int i; - char* r; + int r; for(i = 0; a[i] != 0; i++){ a[i] = tolower(a[i]); } @@ -428,7 +435,7 @@ recurse: continue; #ifndef TIME_MAX -#if defined(_MSC_VER) || defined(__BORLANDC__) +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__NETWARE__) #define TIME_MAX INT32_MAX #else #define TIME_MAX INT64_MAX diff --git a/Server/strptime.h b/Server/strptime.h index da44d6a..e33979a 100644 --- a/Server/strptime.h +++ b/Server/strptime.h @@ -7,7 +7,7 @@ extern "C" { #include -#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) +#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__) || defined(__NETWARE__) char* strptime(const char *buf, const char *fmt, struct tm *tm); #endif diff --git a/Server/tw_config.h b/Server/tw_config.h index 93cefb9..80c93c5 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -14,7 +14,7 @@ extern "C" { #include #include -#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__)) +#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__)) #ifdef USE_WINSOCK1 #include #else @@ -25,7 +25,7 @@ extern "C" { #ifdef __PPU__ #include #endif -#if !defined(__OS2__) +#if !defined(__OS2__) && !defined(__NETWARE__) #include #endif #ifdef __HAIKU__ @@ -33,6 +33,19 @@ extern "C" { #endif #endif +#ifdef __NETWARE__ +struct in_addr { + unsigned int s_addr; +}; + +struct sockaddr_in { + unsigned short sin_family; + unsigned short sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; +#endif + #if defined(NO_IPV6) #define SOCKADDR struct sockaddr_in #else diff --git a/Server/tw_module.h b/Server/tw_module.h index 1c345d6..346d48c 100644 --- a/Server/tw_module.h +++ b/Server/tw_module.h @@ -15,6 +15,8 @@ extern "C" { #define INCL_DOSERRORS #include #define MODULE_DECL __export APIENTRY +#elif defined(__WATCOMC__) +#define MODULE_DECL __export #else #define MODULE_DECL #endif @@ -46,9 +48,9 @@ enum TW_MODULE_RETURN { #define TW_CONFIG_NOTME _TW_CONFIG_NOTME #define TW_CONFIG_ERROR _TW_CONFIG_ERROR -typedef int (MODULE_DECL *tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools); -typedef int (MODULE_DECL *tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res); -typedef int (MODULE_DECL *tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc); +typedef int(MODULE_DECL* tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools); +typedef int(MODULE_DECL* tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res); +typedef int(MODULE_DECL* tw_mod_config_t)(struct tw_tool* tools, char** argv, int argc); #ifdef SOURCE void* tw_module_load(const char* path); diff --git a/config.h.tmpl b/config.h.tmpl index 5323cf4..5ad6089 100644 --- a/config.h.tmpl +++ b/config.h.tmpl @@ -19,7 +19,7 @@ #define SSL void #endif -#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))) && defined(BUILD_GUI) && !defined(SERVICE) +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__) && !defined(__NETWARE__))) && defined(BUILD_GUI) && !defined(SERVICE) #define BUILD_GUI_VALID #endif @@ -72,6 +72,10 @@ #define NO_IPV6 #endif +#if defined(__WATCOMC__) && defined(__NETWARE__) && !defined(NO_IPV6) +#define NO_IPV6 +#endif + #endif /*