Subversion Repositories Tewi

Rev

Rev 402 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 402 Rev 416
Line 1... Line 1...
1
/* $Id: module.c 402 2024-11-03 10:39:59Z nishi $ */
1
/* $Id: module.c 416 2024-11-19 07:54:58Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "tw_module.h"
5
#include "tw_module.h"
6
 
6
 
Line 49... Line 49...
49
#ifdef __OS2__
49
#ifdef __OS2__
50
	HMODULE mod;
50
	HMODULE mod;
51
#elif defined(__NETWARE__)
51
#elif defined(__NETWARE__)
52
	unsigned int* hnd = malloc(sizeof(*hnd));
52
	unsigned int* hnd = malloc(sizeof(*hnd));
53
#endif
53
#endif
-
 
54
#ifndef WINCE
54
	chdir(config.server_root);
55
	chdir(config.server_root);
-
 
56
#endif
55
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
57
#if defined(__MINGW32__) || defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
56
#ifdef __OS2__
58
#ifdef __OS2__
57
	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) {
59
	if(DosLoadModule(tmp, 512, path, &mod) != NO_ERROR) {
58
		return NULL;
60
		return NULL;
59
	}
61
	}
Line 64... Line 66...
64
		free(hnd);
66
		free(hnd);
65
		hnd = NULL;
67
		hnd = NULL;
66
	}
68
	}
67
	lib = (void*)hnd;
69
	lib = (void*)hnd;
68
#else
70
#else
69
	lib = LoadLibraryA(path);
71
	lib = LoadLibrary(path);
70
#endif
72
#endif
71
#else
73
#else
72
	lib = dlopen(path, RTLD_LAZY);
74
	lib = dlopen(path, RTLD_LAZY);
73
#endif
75
#endif
74
	if(lib == NULL) {
76
	if(lib == NULL) {
75
		cm_log("Module", "Could not load %s", path);
77
		cm_log("Module", "Could not load %s", path);
76
	}
78
	}
-
 
79
#ifndef WINCE
77
	chdir(p);
80
	chdir(p);
-
 
81
#endif
78
	free(p);
82
	free(p);
79
	return lib;
83
	return lib;
80
}
84
}
81
 
85
 
82
void* tw_module_symbol(void* mod, const char* sym) {
86
void* tw_module_symbol(void* mod, const char* sym) {
Line 89... Line 93...
89
		return NULL;
93
		return NULL;
90
	}
94
	}
91
	return ret;
95
	return ret;
92
#elif defined(__NETWARE__)
96
#elif defined(__NETWARE__)
93
	return ImportSymbol(*(unsigned int*)mod, sym);
97
	return ImportSymbol(*(unsigned int*)mod, sym);
-
 
98
#elif defined(WINCE)
-
 
99
	return GetProcAddressW(mod, sym);
94
#else
100
#else
95
	return GetProcAddress(mod, sym);
101
	return GetProcAddress(mod, sym);
96
#endif
102
#endif
97
#else
103
#else
98
	return dlsym(mod, sym);
104
	return dlsym(mod, sym);