]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/dynamic.cpp
Use 'c' snomask instead of 'A' snomask for ldap auth failures, reported by drich.
[user/henk/code/inspircd.git] / src / dynamic.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 /* $Core */
15
16 #include "inspircd.h"
17 #include "dynamic.h"
18 #ifndef WIN32
19 #include <dlfcn.h>
20 #endif
21
22 DLLManager::DLLManager(InspIRCd*, const char *fname)
23 {
24         err = NULL;
25
26         if (!strstr(fname,".so"))
27         {
28                 err = "This doesn't look like a module file to me...";
29                 return;
30         }
31
32         h = dlopen(fname, RTLD_NOW|RTLD_LOCAL);
33         if (!h)
34         {
35                 err = (char*)dlerror();
36                 return;
37         }
38 }
39
40 DLLManager::~DLLManager()
41 {
42         /* close the library */
43         if (h)
44                 dlclose(h);
45 }
46
47
48
49 bool DLLManager::GetSymbol(void** v, const char* sym_name)
50 {
51         /*
52          * try extract a symbol from the library
53          * get any error message is there is any
54          */
55
56         if (h)
57         {
58                 dlerror(); // clear value
59                 *v = dlsym(h, sym_name);
60                 err = (char*)dlerror();
61                 if (!*v || err)
62                         return false;
63         }
64
65         /* succeeded :) */
66         return true;
67 }