int module_close(struct module_entry_t *m);
int modules_shutdown(void);
-extern void *module_utility_fptr; /* This gets us through the ISO C warnings about our POSIX compliance macros */
/* Iterate through Module List */
#define MODULE_ITER(m) for(m = module_list ; m != NULL ; m = m->next)
/* Retrieve Module Function */
/* This Macro can only be used for non-returning calls */
#define MODULE_FUNC(h, m, func, ...) \
- module_utility_fptr = lt_dlsym(m, func); \
- memcpy(&h, &module_utility_fptr, sizeof(module_utility_fptr)); \
+ *((void **) (&h)) = lt_dlsym(m, func); \
if(h) { \
h(__VA_ARGS__); \
}
#define MODULE_FUNC_NOARGS(h, m, func) \
- module_utility_fptr = lt_dlsym(m, func); \
- memcpy(&h, &module_utility_fptr, sizeof(module_utility_fptr)); \
+ *((void **) (&h)) = lt_dlsym(m, func); \
if(h) { \
h(); \
}
-#define MODULE_FUNCRET(m, func) lt_dlsym(m, func)
+#define MODULE_FUNCRET(var, m, func) *((void **) (&var)) = lt_dlsym(m, func)
#endif /* _MODULES_H_ */
#ifdef COMPILE_CONSOLE
d = initializesock(0, "localhost", "127.0.0.1", 0);
- if (2 >= maxd)
- maxd = 3;
#else
if (!restarting) {
sock = make_socket(port, SOCK_STREAM, NULL, NULL, MUSH_IP_ADDR);
/* Function utility pointer for module system macros.
* This gets us through the ISO C warnings about our posix compliance issues.
**/
-void *module_utility_fptr;
/* Ads a module entry and returns */
struct module_entry_t *module_entry_add(char *name) {
}
/* Some OSes may need symbols to be prefixed with _.. Will need to look into autoconfig code for this */
- /* FIXME: This is hideous, but ISO C prohibits casting from an object pointer
- * to a function pointer and lt_dlsym() returns void *. */
- *((void **) (&module_loader)) = MODULE_FUNCRET(handle, "module_load");
+ MODULE_FUNCRET(module_loader, handle, "module_load");
if(!module_loader) {
do_rawlog(LT_ERR, "Error Loading Module: Could not call module_load | %s", file);
}
module->handle = handle;
module->load = module_loader;
- /* FIXME: See comment above. */
- *((void **) (&module->unload)) = MODULE_FUNCRET(handle, "module_unload");
+ MODULE_FUNCRET(module->unload, handle, "module_unload");
/* Grab info and version from module & put it in */
/* Success.. Call the module */
/* This function can override standard checks! */
/* This doohicky is the replacement for local_can_interact_first */
MODULE_ITER(m) {
- /* FIXME: This is hideous but is required because ISO C prohibits assignment
- * from void * to a function pointer. */
- *((void **) &handle) = MODULE_FUNCRET(m->handle, "module_can_interact_first");
+ MODULE_FUNCRET(handle, m->handle, "module_can_interact_first");
if (handle) {
if ((lci = handle(from, to , type)) != NOTHING)
return lci;
return 1;
MODULE_ITER(m) {
- /* TODO: This is required because ISO C prohibits assignment from void *
- * to function pointer. */
- *((void **) &handle) = MODULE_FUNCRET(m->handle, "module_can_interact_last");
+ MODULE_FUNCRET(handle, m->handle, "module_can_interact_last");
if (handle) {
if ((lci = handle(from, to , type)) != NOTHING)
return lci;