dynamic.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "inspircd.h"
00017 #include "dynamic.h"
00018 #ifndef WIN32
00019 #include <dlfcn.h>
00020 #endif
00021
00022 DLLManager::DLLManager(InspIRCd*, const char *fname)
00023 {
00024 err = NULL;
00025
00026 if (!strstr(fname,".so"))
00027 {
00028 err = "This doesn't look like a module file to me...";
00029 return;
00030 }
00031
00032 h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
00033 if (!h)
00034 {
00035 err = (char*)dlerror();
00036 return;
00037 }
00038 }
00039
00040 DLLManager::~DLLManager()
00041 {
00042
00043 if (h)
00044 dlclose(h);
00045 }
00046
00047
00048
00049 bool DLLManager::GetSymbol(void** v, const char* sym_name)
00050 {
00051
00052
00053
00054
00055
00056 if (h)
00057 {
00058 dlerror();
00059 *v = dlsym(h, sym_name);
00060 err = (char*)dlerror();
00061 if (!*v || err)
00062 return false;
00063 }
00064
00065
00066 return true;
00067 }