5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
22 /* Load shared object */
24 SilcDll silc_dll_load(const char *object_path)
27 #if defined(HAVE_DLOPEN)
29 return dlopen(object_path, RTLD_NOW);
30 #elif defined(RTLD_LAZY)
31 return dlopen(object_path, RTLD_LAZY);
33 return dlopen(object_path, 0);
35 #endif /* HAVE_DLOPEN */
37 return LoadLibrary(object_path);
40 #endif /* SILC_UNIX */
41 silc_set_errno_reason(SILC_ERR_NOT_SUPPORTED,
42 "Shared objects are not supported on this platform");
46 /* Close shared object */
48 void silc_dll_close(SilcDll dll)
56 #endif /* SILC_UNIX */
59 /* Get symbol address from shared object */
61 void *silc_dll_getsym(SilcDll dll, const char *symbol)
64 return (void *)dlsym(dll, symbol);
66 return (void *)GetProcAddress(dll, symbol);
69 #endif /* SILC_UNIX */
70 silc_set_errno_reason(SILC_ERR_NOT_SUPPORTED,
71 "Shared objects are not supported on this platform");
75 /* Get error string */
77 const char *silc_dll_error(SilcDll dll)
85 #endif /* SILC_UNIX */