void *dlcall( void *lib, char *func )
{
void (*handle)();
if( (handle = dlsym(lib,func)) == NULL )
{
log_string(dlerror());
return *dler; //custom func to just handle errors/log/etc
}
else
return *handle;
}
//from included header
#define SOCIAL_LIB "/home/matt/muds/active/vortex/src/sociallib.so"
#define HELP_LIB "/home/matt/muds/active/vortex/src/helplib.so"
extern void *sociallib;
extern void *helplib;
//end include snippet
void load_libraries()
{
sh_int lib_count = 0;
void (*handle)();
if( (sociallib = dlopen(SOCIAL_LIB, RTLD_LAZY | RTLD_GLOBAL)) == NULL)
log_string(dlerror());
else
lib_count++;
if( (helplib = dlopen(HELP_LIB, RTLD_LAZY | RTLD_GLOBAL)) == NULL)
log_string(dlerror());
else
lib_count++;
xprintf_2(log_buf,"%d of %d libraries loaded successfully.",lib_count,LIB_TOTAL);
log_string(log_buf);
log_buf[0] = '\0';
handle = dlcall(sociallib,"load_socials");
(*handle)();
handle = dlcall(helplib,"load_help_table");
(*handle)();
return;
}
cc -c -O2 -g -Wall -DIMC -DIMCMERC -fpic sociallib.c
cc -o sociallib.so o/sociallib.o -lcrypt -ldl -rdynamic -L/usr/include/mysql -lmysqlclient -lm -shared
Thanks in advance.