]> Git repositories of Nishi - tewi.git/commitdiff
dll does not work somehow
authorNishi <nishi@nishi.boats>
Sun, 13 Oct 2024 23:22:06 +0000 (23:22 +0000)
committerNishi <nishi@nishi.boats>
Sun, 13 Oct 2024 23:22:06 +0000 (23:22 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@313 8739d7e6-ffea-ec47-b151-bdff447c6205

Module/mod_cgi.c
Module/mod_example.c
Module/mod_proxy.c
README
README.tmpl
Server/module.c
Server/tw_module.h

index 6659043e3fd0dfbdaf334ea9e018efb4576e49f2..da9e232951640790476922f6fd08429e3ce4c171 100644 (file)
@@ -4,20 +4,20 @@
 
 #include <cm_string.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
        tools->log("CGI", "Initializing CGI module");
        tools->add_version("CGI/1.1");
        return 0;
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) {
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) {
        if(cm_strcaseequ(argv[0], "AllowCGI")) {
                return TW_CONFIG_PARSED;
        }
        return TW_CONFIG_NOTME;
 }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) {
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) {
        res->status = 403;
        return TW_MODULE_STOP;
 }
index a554de5ccef69c79c770b2f9174139e565bed058..6472128d1840679c8068ee47a820d297437867bd 100644 (file)
@@ -3,12 +3,12 @@
 
 #include <tw_module.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
        tools->log("Example", "This is an example module");
        tools->add_version("Example/0.0");
        return 0;
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; }
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_PARSED; }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); }
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_ERROR(403); }
index 4c091444d3ad5986e70f0a1156caf9eb40496c19..96076a66292e4fc81ea060a3792bbcf0458d9ead 100644 (file)
@@ -4,12 +4,12 @@
 
 #include <cm_string.h>
 
-int mod_init(struct tw_config* config, struct tw_tool* tools) {
+int MODULE_DECL mod_init(struct tw_config* config, struct tw_tool* tools) {
        tools->log("CGI", "Initializing Proxy module");
        tools->add_version("Proxy/1.0");
        return 0;
 }
 
-int mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_NOTME; }
+int MODULE_DECL mod_config(struct tw_tool* tools, char** argv, int argc) { return TW_CONFIG_NOTME; }
 
-int mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; }
+int MODULE_DECL mod_request(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res) { return TW_MODULE_PASS; }
diff --git a/README b/README
index 8a1286b67369609491e2aeb757a771edd3f97301..064721e07241ae32b6fc360fa3248c7e6eb6b6f4 100644 (file)
--- a/README
+++ b/README
@@ -44,6 +44,7 @@ OpenBSD                  Working
 Haiku                    Working
 Minix                    Working
 UnixWare                 Working on 7.1.1
+OS/2                     Mostly working, module is broken. Help required!
 PlayStation Portable     Working, missing module support
                          TODO: Get multi-threading working (maybe)
 PlayStation 2            Not working
index b40ced2bcab351532dcc0814069a2f3e36d1dd5b..b32db4d4230645acf223abc8dae96234d546cd7c 100644 (file)
@@ -44,6 +44,7 @@ OpenBSD                  Working
 Haiku                    Working
 Minix                    Working
 UnixWare                 Working on 7.1.1
+OS/2                     Mostly working, module is broken. Help required!
 PlayStation Portable     Working, missing module support
                          TODO: Get multi-threading working (maybe)
 PlayStation 2            Not working
index d7639002fec100969d6db26113c38541ea59d98a..e92aece5cf03d962eabbe3352f07f4f73443aed1 100644 (file)
@@ -29,6 +29,7 @@ int tw_module_init(void* mod) { return 1; }
 #if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
 #ifdef __OS2__
 #define INCL_DOSMODULEMGR
+#define INCL_DOSERRORS
 #include <os2.h>
 #else
 #include <windows.h>
@@ -42,13 +43,16 @@ void* tw_module_load(const char* path) {
        char* p = getcwd(NULL, 0);
        void* lib;
        char tmp[512];
-       unsigned long l;
+#ifdef __OS2__
+       HMODULE mod;
+#endif
        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);
+       if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR){
+               return NULL;
+       }
+       lib = (void*)mod;
 #else
        lib = LoadLibraryA(path);
 #endif
@@ -67,7 +71,11 @@ 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);
+       APIRET rc;
+       if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR){
+               cm_log("Module", "OS/2 error %d", (int)rc);
+               return NULL;
+       }
        return ret;
 #else
        return GetProcAddress(mod, sym);
@@ -80,7 +88,7 @@ void* tw_module_symbol(void* mod, const char* sym) {
 int tw_module_init(void* mod) {
        tw_mod_init_t mod_init = (tw_mod_init_t)tw_module_symbol(mod, "mod_init");
        if(mod_init == NULL) {
-               cm_log("Module", "Could not init a module");
+               cm_log("Module", "Could not find a init call");
                return 1;
        } else {
                struct tw_tool tools;
index 890fbc16d502832310c2739341ce9ab094531c3b..e50d6ecfbd8bc39c23200090217bcb53e0ec770b 100644 (file)
@@ -10,6 +10,15 @@ extern "C" {
 #include "tw_config.h"
 #include "tw_http.h"
 
+#if defined(__OS2__)
+#define INCL_DOSMODULEMGR
+#define INCL_DOSERRORS
+#include <os2.h>
+#define MODULE_DECL APIENTRY
+#else
+#define MODULE_DECL
+#endif
+
 struct tw_tool {
        void (*log)(const char* name, const char* log, ...);
        void (*add_version)(const char* string);
@@ -37,9 +46,9 @@ enum TW_MODULE_RETURN {
 #define TW_CONFIG_NOTME _TW_CONFIG_NOTME
 #define TW_CONFIG_ERROR _TW_CONFIG_ERROR
 
-typedef int (*tw_mod_init_t)(struct tw_config* config, struct tw_tool* tools);
-typedef int (*tw_mod_request_t)(struct tw_tool* tools, struct tw_http_request* req, struct tw_http_response* res);
-typedef int (*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);