#include <sys/stat.h>
#if !defined(_MSC_VER) && !defined(__WATCOMC__)
#include <dirent.h>
+#elif defined(__NETWARE__)
+#include <dirent.h>
#elif defined(__WATCOMC__) || defined(_MSC_VER)
#include <direct.h>
#endif
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
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 $@ $<
res->status = 403;
return TW_MODULE_STOP;
}
+
+#ifdef __NETWARE__
+int main() { return 0; }
+#endif
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
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
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
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
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
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
+#include <errno.h>
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
#include <unistd.h>
strcpy(config.hostname, "ps3");
#elif defined(__ps2sdk__)
strcpy(config.hostname, "ps2");
+#elif defined(__NETWARE__)
+ strcpy(config.hostname, "netware");
#else
gethostname(config.hostname, 1024);
#endif
return stop;
}
} else {
+ printf("%d\n", errno);
cm_log("Config", "Could not open the file");
return 1;
}
#include <tcpustd.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(__NETWARE__))
#ifdef USE_WINSOCK1
#include <winsock.h>
#else
#include <winsock2.h>
#endif
+#elif defined(__NETWARE__)
+#include <sys/socket.h>
#else
#ifdef USE_POLL
#ifdef __PPU__
#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 <windows.h>
+#elif defined(__NETWARE__)
+#include <nwconio.h>
+#include <nwthread.h>
#endif
#ifdef _PSP
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;
#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;
while(1)
;
#endif
+#ifdef __NETWARE__
+ return;
+#else
return st;
+#endif
#endif
}
tw_server_loop();
#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) {
#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;
#define INCL_DOSMODULEMGR
#define INCL_DOSERRORS
#include <os2.h>
+#elif defined(__NETWARE__)
+#include <nwadv.h>
+#include <nwthread.h>
#else
#include <windows.h>
#include <direct.h>
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
#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
#include <tcpustd.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(__NETWARE__))
#ifndef NO_GETNAMEINFO
#include <ws2tcpip.h>
#include <wspiapi.h>
#include "strptime.h"
typedef int socklen_t;
+#elif defined(__NETWARE__)
+#include <sys/socket.h>
+#include <nwthread.h>
+
+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__
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
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);
#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);
#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);
#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
struct thread_entry {
#ifdef __HAIKU__
thread_id thread;
+#elif defined(__NETWARE__)
+ int thread;
#else
HANDLE handle;
#endif
#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
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
+#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <stdint.h>
#ifdef __WATCOMC__
+#ifndef __NETWARE__
#include <strings.h>
#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);
#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]);
}
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
#include <time.h>
-#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
#include <stdint.h>
#include <stdbool.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__))
#ifdef USE_WINSOCK1
#include <winsock.h>
#else
#ifdef __PPU__
#include <net/net.h>
#endif
-#if !defined(__OS2__)
+#if !defined(__OS2__) && !defined(__NETWARE__)
#include <netinet/in.h>
#endif
#ifdef __HAIKU__
#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
#define INCL_DOSERRORS
#include <os2.h>
#define MODULE_DECL __export APIENTRY
+#elif defined(__WATCOMC__)
+#define MODULE_DECL __export
#else
#define MODULE_DECL
#endif
#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);
#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
#define NO_IPV6
#endif
+#if defined(__WATCOMC__) && defined(__NETWARE__) && !defined(NO_IPV6)
+#define NO_IPV6
+#endif
+
#endif
/*