Subversion Repositories Tewi

Rev

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

Rev 219 Rev 312
Line 1... Line 1...
1
/* $Id: module.c 219 2024-10-02 20:40:37Z nishi $ */
1
/* $Id: module.c 312 2024-10-13 18:17:37Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "tw_module.h"
5
#include "tw_module.h"
6
 
6
 
Line 25... Line 25...
25
int tw_module_init(void* mod) { return 1; }
25
int tw_module_init(void* mod) { return 1; }
26
 
26
 
27
#else
27
#else
28
 
28
 
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__
-
 
31
#define INCL_DOSMODULEMGR
-
 
32
#include <os2.h>
-
 
33
#else
30
#include <windows.h>
34
#include <windows.h>
31
#include <direct.h>
35
#include <direct.h>
-
 
36
#endif
32
#else
37
#else
33
#include <dlfcn.h>
38
#include <dlfcn.h>
34
#endif
39
#endif
35
 
40
 
36
void* tw_module_load(const char* path) {
41
void* tw_module_load(const char* path) {
37
	char* p = getcwd(NULL, 0);
42
	char* p = getcwd(NULL, 0);
38
	void* lib;
43
	void* lib;
-
 
44
	char tmp[512];
-
 
45
	unsigned long l;
39
	chdir(config.server_root);
46
	chdir(config.server_root);
40
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
47
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
-
 
48
#ifdef __OS2__
-
 
49
	lib = NULL;
-
 
50
	l = (unsigned long)lib;
-
 
51
	DosLoadModule(tmp, 512, path, &l);
-
 
52
#else
41
	lib = LoadLibraryA(path);
53
	lib = LoadLibraryA(path);
-
 
54
#endif
42
#else
55
#else
43
	lib = dlopen(path, RTLD_LAZY);
56
	lib = dlopen(path, RTLD_LAZY);
44
#endif
57
#endif
45
	if(lib == NULL) {
58
	if(lib == NULL) {
46
		cm_log("Module", "Could not load %s", path);
59
		cm_log("Module", "Could not load %s", path);
Line 50... Line 63...
50
	return lib;
63
	return lib;
51
}
64
}
52
 
65
 
53
void* tw_module_symbol(void* mod, const char* sym) {
66
void* tw_module_symbol(void* mod, const char* sym) {
54
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
67
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
-
 
68
#ifdef __OS2__
-
 
69
	void* ret;
-
 
70
	DosQueryProcAddr((unsigned long)mod, 0, sym, (PFN*)&ret);
-
 
71
	return ret;
-
 
72
#else
55
	return GetProcAddress(mod, sym);
73
	return GetProcAddress(mod, sym);
-
 
74
#endif
56
#else
75
#else
57
	return dlsym(mod, sym);
76
	return dlsym(mod, sym);
58
#endif
77
#endif
59
}
78
}
60
 
79