Subversion Repositories Tewi

Rev

Rev 313 | Rev 339 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 313 Rev 315
Line 1... Line 1...
1
/* $Id: module.c 313 2024-10-13 23:22:06Z nishi $ */
1
/* $Id: module.c 315 2024-10-14 10:01:02Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "tw_module.h"
5
#include "tw_module.h"
6
 
6
 
Line 29... Line 29...
29
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
29
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
30
#ifdef __OS2__
30
#ifdef __OS2__
31
#define INCL_DOSMODULEMGR
31
#define INCL_DOSMODULEMGR
32
#define INCL_DOSERRORS
32
#define INCL_DOSERRORS
33
#include <os2.h>
33
#include <os2.h>
-
 
34
#elif defined(__NETWARE__)
-
 
35
#include <nwadv.h>
-
 
36
#include <nwthread.h>
34
#else
37
#else
35
#include <windows.h>
38
#include <windows.h>
36
#include <direct.h>
39
#include <direct.h>
37
#endif
40
#endif
38
#else
41
#else
Line 43... Line 46...
43
	char* p = getcwd(NULL, 0);
46
	char* p = getcwd(NULL, 0);
44
	void* lib;
47
	void* lib;
45
	char tmp[512];
48
	char tmp[512];
46
#ifdef __OS2__
49
#ifdef __OS2__
47
	HMODULE mod;
50
	HMODULE mod;
-
 
51
#elif defined(__NETWARE__)
-
 
52
	unsigned int* hnd = malloc(sizeof(*hnd));
48
#endif
53
#endif
49
	chdir(config.server_root);
54
	chdir(config.server_root);
50
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
55
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
51
#ifdef __OS2__
56
#ifdef __OS2__
52
	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR){
57
	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) {
53
		return NULL;
58
		return NULL;
54
	}
59
	}
55
	lib = (void*)mod;
60
	lib = (void*)mod;
-
 
61
#elif defined(__NETWARE__)
-
 
62
	*hnd = FindNLMHandle(path);
-
 
63
	lib = (void*)hnd;
56
#else
64
#else
57
	lib = LoadLibraryA(path);
65
	lib = LoadLibraryA(path);
58
#endif
66
#endif
59
#else
67
#else
60
	lib = dlopen(path, RTLD_LAZY);
68
	lib = dlopen(path, RTLD_LAZY);
Line 70... Line 78...
70
void* tw_module_symbol(void* mod, const char* sym) {
78
void* tw_module_symbol(void* mod, const char* sym) {
71
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
79
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
72
#ifdef __OS2__
80
#ifdef __OS2__
73
	void* ret;
81
	void* ret;
74
	APIRET rc;
82
	APIRET rc;
75
	if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR){
83
	if((rc = DosQueryProcAddr((HMODULE)mod, 0, sym, (PFN*)&ret)) != NO_ERROR) {
76
		cm_log("Module", "OS/2 error %d", (int)rc);
84
		cm_log("Module", "OS/2 error %d", (int)rc);
77
		return NULL;
85
		return NULL;
78
	}
86
	}
79
	return ret;
87
	return ret;
-
 
88
#elif defined(__NETWARE__)
-
 
89
	return ImportSymbol(*(unsigned int*)mod, sym);
80
#else
90
#else
81
	return GetProcAddress(mod, sym);
91
	return GetProcAddress(mod, sym);
82
#endif
92
#endif
83
#else
93
#else
84
	return dlsym(mod, sym);
94
	return dlsym(mod, sym);