if [ ! -e $(DESTDIR)$(PREFIX)/www/index.html ]; then ( ./Tool/itworks > $(DESTDIR)$(PREFIX)/www/index.html || ( rm $(DESTDIR)$(PREFIX)/www/index.html ; exit 1 ) ) ; fi
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 ./Module/*.so $(DESTDIR)$(PREFIX)/lib/tewi/
+ -cp ./Module/*.dll $(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
CC = owcc
AR = wlib
AR_FLAGS = -q -b -n -fo
-CFLAGS = -b os2v2$(END) -I $(WATCOM)/h/os2 -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC
+CFLAGS = -b os2v2$(END) -I $(WATCOM)/h/os2 -g -std=c99 -DPREFIX=\"$(PREFIX)\" -I ../Common -fPIC -D__WATCOM_LFN__
LDFLAGS = -b os2v2$(END)
LIBS =
EXEC = .exe
STATIC = lib
LIBSUF = .dll
OBJ = obj
-REQOBJS = concat.rc
-SERVADD = wrc -bt=nt -i=$(WATCOM)/h/nt concat.rc tewi.exe
#define SOURCE
-#include "tw_config.h"
-#include "tw_module.h"
+#include "../config.h"
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#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(__WATCOMC__))
#ifdef USE_WINSOCK1
#include <winsock.h>
#else
#include <cm_string.h>
#include <cm_log.h>
+#ifdef __OS2__
+#include <types.h>
+#include <netinet/in.h>
+#include <tcpustd.h>
+#endif
+
+#include "tw_config.h"
+#include "tw_module.h"
+
struct tw_config config;
struct tw_config_entry* tw_vhost_match(const char* name, int port) {
#include <stdlib.h>
#include <string.h>
-#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+#include <sys/time.h>
+#include <types.h>
+#include <tcpustd.h>
+#endif
+
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
#ifdef USE_WINSOCK1
#include <winsock.h>
#else
#include <openssl/opensslv.h>
#endif
+#ifdef __OS2__
+#include <types.h>
+#endif
+
#include <cm_log.h>
#include <cm_string.h>
#if !defined(__MINGW32__) && !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
signal(SIGCHLD, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
-#elif !defined(BUILD_GUI)
+#elif !defined(BUILD_GUI) && !defined(__OS2__)
SetConsoleTitle(tw_server);
#endif
return -1;
#else
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+#define INCL_DOSMODULEMGR
+#include <os2.h>
+#else
#include <windows.h>
#include <direct.h>
+#endif
#else
#include <dlfcn.h>
#endif
void* tw_module_load(const char* path) {
char* p = getcwd(NULL, 0);
void* lib;
+ char tmp[512];
+ unsigned long l;
chdir(config.server_root);
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+ lib = NULL;
+ l = (unsigned long)lib;
+ DosLoadModule(tmp, 512, path, &l);
+#else
lib = LoadLibraryA(path);
+#endif
#else
lib = dlopen(path, RTLD_LAZY);
#endif
void* tw_module_symbol(void* mod, const char* sym) {
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+ void* ret;
+ DosQueryProcAddr((unsigned long)mod, 0, sym, (PFN*)&ret);
+ return ret;
+#else
return GetProcAddress(mod, sym);
+#endif
#else
return dlsym(mod, sym);
#endif
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
#include <unistd.h>
#endif
+#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <stdarg.h>
#include <cm_log.h>
#include <cm_dir.h>
+#ifdef __OS2__
+#include <types.h>
+#include <sys/time.h>
+#define INCL_DOSPROCESS
+#include <os2.h>
+#include <process.h>
+#define HANDLE void*
+
+#include "strptime.h"
+typedef int socklen_t;
+
+#include <tcpustd.h>
+#endif
+
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
#ifndef NO_GETNAMEINFO
#include <ws2tcpip.h>
return 0;
} else if(*pw == '*') {
return *(pw + 1) == 0 || tw_wildcard_match(pw, pt + 1) || tw_wildcard_match(pw + 1, pt);
- } else if(*pw == '?' || (*pw == *pt)) {
+ } else if(*pw == '?' || (tolower(*pw) == tolower(*pt))) {
pw++;
pt++;
continue;
}
void close_socket(int sock) {
-#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+ soclose(sock);
+#elif defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
closesocket(sock);
#else
close(sock);
int tw_server_init(void) {
int i;
-#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && !defined(__OS2__))
WSADATA wsa;
#ifdef USE_WINSOCK1
WSAStartup(MAKEWORD(1, 1), &wsa);
#else
WSAStartup(MAKEWORD(2, 0), &wsa);
#endif
+#endif
+#ifdef __OS2__
+ sock_init();
#endif
for(i = 0; config.ports[i] != -1; i++)
;
e->addr = claddr;
#endif
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#ifdef __OS2__
+ _beginthread(tw_server_pass, 0, 0, e);
+#else
_beginthread(tw_server_pass, 0, e);
+#endif
#elif defined(_PSP) || defined(__PPU__)
tw_server_pass(e);
#elif defined(__HAIKU__)
bp = NULL;
continue;
}
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__OS2__)
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
if (1)
#else
#include <time.h>
-#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__)
+#if defined(_WIN32) || defined(_PSP) || defined(__ps2sdk__) || defined(__OS2__)
char* strptime(const char *buf, const char *fmt, struct tm *tm);
#endif
#ifdef __PPU__
#include <net/net.h>
#endif
+#if !defined(__OS2__)
#include <netinet/in.h>
+#endif
#ifdef __HAIKU__
#define NO_IPV6
#endif
#endif
-#ifdef NO_IPV6
+#if defined(NO_IPV6)
#define SOCKADDR struct sockaddr_in
#else
#define SOCKADDR struct sockaddr_in6
"OpenBSD"
#elif defined(__linux__)
"Linux"
+#elif defined(__OS2__)
+ "OS/2"
#elif defined(__MINGW32__)
"Windows-MinGW32"
#elif defined(_MSC_VER)
/* Minix does not have IPv6 */
#endif
+#if defined(__WATCOMC__) && defined(__OS2__) && !defined(NO_IPV6)
+#define NO_IPV6
+#endif
+
#endif
/*