Subversion Repositories Tewi

Rev

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

Rev 217 Rev 219
Line 1... Line 1...
1
/* $Id: module.c 217 2024-10-02 19:50:16Z nishi $ */
1
/* $Id: module.c 219 2024-10-02 20:40: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 24... Line 24...
24
 
24
 
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__)
29
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
30
#include <windows.h>
30
#include <windows.h>
31
#include <direct.h>
31
#include <direct.h>
32
#else
32
#else
33
#include <dlfcn.h>
33
#include <dlfcn.h>
34
#endif
34
#endif
35
 
35
 
36
void* tw_module_load(const char* path) {
36
void* tw_module_load(const char* path) {
37
	char* p = getcwd(NULL, 0);
37
	char* p = getcwd(NULL, 0);
38
	void* lib;
38
	void* lib;
39
	chdir(config.server_root);
39
	chdir(config.server_root);
40
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
40
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
41
	lib = LoadLibraryA(path);
41
	lib = LoadLibraryA(path);
42
#else
42
#else
43
	lib = dlopen(path, RTLD_LAZY);
43
	lib = dlopen(path, RTLD_LAZY);
44
#endif
44
#endif
45
	if(lib == NULL) {
45
	if(lib == NULL) {
Line 49... Line 49...
49
	free(p);
49
	free(p);
50
	return lib;
50
	return lib;
51
}
51
}
52
 
52
 
53
void* tw_module_symbol(void* mod, const char* sym) {
53
void* tw_module_symbol(void* mod, const char* sym) {
54
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__)
54
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
55
	return GetProcAddress(mod, sym);
55
	return GetProcAddress(mod, sym);
56
#else
56
#else
57
	return dlsym(mod, sym);
57
	return dlsym(mod, sym);
58
#endif
58
#endif
59
}
59
}