5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 - 2008 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.
20 /****h* silcutil/Shared Object Interface
24 * Platform independent iterface for loading and using shared objects and
25 * dynamically linked libraries (DLLs).
30 * SilcFuncCb function;
32 * dll = silc_dll_load("/path/to/my.so");
33 * function = silc_dll_getsym(dll, "my_function");
36 * function(arg1, arg2);
38 * silc_dll_close(dll);
45 /****s* silcutil/SilcDll
49 * typedef void *SilcDll;
53 * This context represents the shared object and it is allocated by
54 * silc_dll_load and is destroyed with silc_dll_close functions.
55 * The context is given as argument to all funtions in this interface.
59 typedef void *SilcDll;
61 typedef HMODULE SilcDll;
63 typedef void *SilcDll;
64 #endif /* SILC_UNIX */
66 /****f* silcutil/silc_dll_load
70 * SilcDll silc_dll_load(const char *object_path);
74 * Load shared object or DLL indicated by the `object_path'. The path
75 * must include the absolute path to the object and the object name.
76 * Returns the SilcDll context or NULL on error. The actual error
77 * message may be available by calling silc_dll_error function. Symbols
78 * may be retrieved from the returned context by calling silc_dll_getsym.
81 SilcDll silc_dll_load(const char *object_path);
83 /****f* silcutil/silc_dll_close
87 * void silc_dll_close(SilcDll dll);
91 * Closes the shared object indicated by `dll'. Any symbol retrieved
92 * from the `dll' with silc_dll_getsym will become invalid and cannot
96 void silc_dll_close(SilcDll dll);
98 /****f* silcutil/silc_dll_getsym
102 * void *silc_dll_getsym(SilcDll dll, const char *symbol);
106 * Returns the memory address of the symbol indicated by `symbol' from
107 * the shared object indicated by `dll'. If such symbol does not exist
111 void *silc_dll_getsym(SilcDll dll, const char *symbol);
113 /****f* silcutil/silc_dll_error
117 * const char *silc_dll_error(SilcDll dll);
121 * This routine may return error string after an error has occured with
122 * the shared object indicated by `dll'. If error string is not available
123 * this will return NULL.
126 const char *silc_dll_error(SilcDll dll);
128 #endif /* SILCDLL_H */