diff options
Diffstat (limited to 'libltdl/ltdl.h')
-rw-r--r-- | libltdl/ltdl.h | 350 |
1 files changed, 0 insertions, 350 deletions
diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h deleted file mode 100644 index b64b5b89..00000000 --- a/libltdl/ltdl.h +++ /dev/null | |||
@@ -1,350 +0,0 @@ | |||
1 | /* ltdl.h -- generic dlopen functions | ||
2 | Copyright (C) 1998-2000 Free Software Foundation, Inc. | ||
3 | Originally by Thomas Tanner <tanner@ffii.org> | ||
4 | This file is part of GNU Libtool. | ||
5 | |||
6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Lesser General Public | ||
8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | ||
10 | |||
11 | As a special exception to the GNU Lesser General Public License, | ||
12 | if you distribute this file as part of a program or library that | ||
13 | is built using GNU libtool, you may include it under the same | ||
14 | distribution terms that you use for the rest of that program. | ||
15 | |||
16 | This library is distributed in the hope that it will be useful, | ||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | Lesser General Public License for more details. | ||
20 | |||
21 | You should have received a copy of the GNU Lesser General Public | ||
22 | License along with this library; if not, write to the Free | ||
23 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
24 | 02111-1307 USA | ||
25 | */ | ||
26 | |||
27 | /* Only include this header file once. */ | ||
28 | #ifndef LTDL_H | ||
29 | #define LTDL_H 1 | ||
30 | |||
31 | #include <sys/types.h> /* for size_t declaration */ | ||
32 | |||
33 | |||
34 | /* --- MACROS FOR PORTABILITY --- */ | ||
35 | |||
36 | |||
37 | /* Saves on those hard to debug '\0' typos.... */ | ||
38 | #define LT_EOS_CHAR '\0' | ||
39 | |||
40 | /* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations, | ||
41 | so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at | ||
42 | the end of C declarations. */ | ||
43 | #ifdef __cplusplus | ||
44 | # define LT_BEGIN_C_DECLS extern "C" { | ||
45 | # define LT_END_C_DECLS } | ||
46 | #else | ||
47 | # define LT_BEGIN_C_DECLS /* empty */ | ||
48 | # define LT_END_C_DECLS /* empty */ | ||
49 | #endif | ||
50 | |||
51 | LT_BEGIN_C_DECLS | ||
52 | /* LT_PARAMS is a macro used to wrap function prototypes, so that compilers | ||
53 | that don't understand ANSI C prototypes still work, and ANSI C | ||
54 | compilers can issue warnings about type mismatches. */ | ||
55 | #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus) | ||
56 | # define LT_PARAMS(protos) protos | ||
57 | # define lt_ptr void* | ||
58 | #else | ||
59 | # define LT_PARAMS(protos) () | ||
60 | # define lt_ptr char* | ||
61 | #endif | ||
62 | /* LT_STMT_START/END are used to create macros which expand to a | ||
63 | a single compound statement in a portable way. */ | ||
64 | #if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) | ||
65 | # define LT_STMT_START (void)( | ||
66 | # define LT_STMT_END ) | ||
67 | #else | ||
68 | # if (defined (sun) || defined (__sun__)) | ||
69 | # define LT_STMT_START if (1) | ||
70 | # define LT_STMT_END else (void)0 | ||
71 | # else | ||
72 | # define LT_STMT_START do | ||
73 | # define LT_STMT_END while (0) | ||
74 | # endif | ||
75 | #endif | ||
76 | /* LT_CONC creates a new concatenated symbol for the compiler | ||
77 | in a portable way. */ | ||
78 | #if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER) | ||
79 | # define LT_CONC(s,t) s##t | ||
80 | #else | ||
81 | # define LT_CONC(s,t) s/**/t | ||
82 | #endif | ||
83 | /* LT_STRLEN can be used safely on NULL pointers. */ | ||
84 | #define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0) | ||
85 | /* --- WINDOWS SUPPORT --- */ | ||
86 | /* Canonicalise Windows and Cygwin recognition macros. */ | ||
87 | #ifdef __CYGWIN32__ | ||
88 | # ifndef __CYGWIN__ | ||
89 | # define __CYGWIN__ __CYGWIN32__ | ||
90 | # endif | ||
91 | #endif | ||
92 | #if defined(_WIN32) || defined(WIN32) | ||
93 | # ifndef __WINDOWS__ | ||
94 | # ifdef _WIN32 | ||
95 | # define __WINDOWS__ _WIN32 | ||
96 | # else | ||
97 | # ifdef WIN32 | ||
98 | # define __WINDOWS__ WIN32 | ||
99 | # endif | ||
100 | # endif | ||
101 | # endif | ||
102 | #endif | ||
103 | #ifdef __WINDOWS__ | ||
104 | # ifndef __CYGWIN__ | ||
105 | /* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory | ||
106 | separator when it is set. */ | ||
107 | # define LT_DIRSEP_CHAR '\\' | ||
108 | # define LT_PATHSEP_CHAR ';' | ||
109 | # endif | ||
110 | #endif | ||
111 | #ifndef LT_PATHSEP_CHAR | ||
112 | # define LT_PATHSEP_CHAR ':' | ||
113 | #endif | ||
114 | /* DLL building support on win32 hosts; mostly to workaround their | ||
115 | ridiculous implementation of data symbol exporting. */ | ||
116 | #ifndef LT_SCOPE | ||
117 | # ifdef __WINDOWS__ | ||
118 | # ifdef DLL_EXPORT /* defined by libtool (if required) */ | ||
119 | # define LT_SCOPE __declspec(dllexport) | ||
120 | # endif | ||
121 | # ifdef LIBLTDL_DLL_IMPORT /* define if linking with this dll */ | ||
122 | # define LT_SCOPE extern __declspec(dllimport) | ||
123 | # endif | ||
124 | # endif | ||
125 | # ifndef LT_SCOPE /* static linking or !__WINDOWS__ */ | ||
126 | # define LT_SCOPE extern | ||
127 | # endif | ||
128 | #endif | ||
129 | #if defined(_MSC_VER) /* Visual Studio */ | ||
130 | # define R_OK 4 | ||
131 | #endif | ||
132 | /* --- DYNAMIC MODULE LOADING API --- */ | ||
133 | typedef struct lt_dlhandle_struct *lt_dlhandle; /* A loaded module. */ | ||
134 | |||
135 | /* Initialisation and finalisation functions for libltdl. */ | ||
136 | LT_SCOPE int lt_dlinit LT_PARAMS ((void)); | ||
137 | LT_SCOPE int lt_dlexit LT_PARAMS ((void)); | ||
138 | |||
139 | /* Module search path manipulation. */ | ||
140 | LT_SCOPE int lt_dladdsearchdir LT_PARAMS ((const char *search_dir)); | ||
141 | LT_SCOPE int lt_dlinsertsearchdir LT_PARAMS ((const char *before, | ||
142 | const char *search_dir)); | ||
143 | LT_SCOPE int lt_dlsetsearchpath LT_PARAMS ((const char *search_path)); | ||
144 | LT_SCOPE const char *lt_dlgetsearchpath LT_PARAMS ((void)); | ||
145 | LT_SCOPE int lt_dlforeachfile LT_PARAMS ((const char *search_path, | ||
146 | int (*func) (const char *filename, | ||
147 | lt_ptr data), | ||
148 | lt_ptr data)); | ||
149 | |||
150 | /* Portable libltdl versions of the system dlopen() API. */ | ||
151 | LT_SCOPE lt_dlhandle lt_dlopen LT_PARAMS ((const char *filename)); | ||
152 | LT_SCOPE lt_dlhandle lt_dlopenext LT_PARAMS ((const char *filename)); | ||
153 | LT_SCOPE lt_ptr lt_dlsym LT_PARAMS ((lt_dlhandle handle, const char *name)); | ||
154 | LT_SCOPE const char *lt_dlerror LT_PARAMS ((void)); | ||
155 | LT_SCOPE int lt_dlclose LT_PARAMS ((lt_dlhandle handle)); | ||
156 | |||
157 | /* Module residency management. */ | ||
158 | LT_SCOPE int lt_dlmakeresident LT_PARAMS ((lt_dlhandle handle)); | ||
159 | LT_SCOPE int lt_dlisresident LT_PARAMS ((lt_dlhandle handle)); | ||
160 | |||
161 | |||
162 | |||
163 | |||
164 | /* --- GNUNET_Mutex LOCKING --- */ | ||
165 | |||
166 | |||
167 | typedef void lt_dlmutex_lock LT_PARAMS ((void)); | ||
168 | typedef void lt_dlmutex_unlock LT_PARAMS ((void)); | ||
169 | typedef void lt_dlmutex_seterror LT_PARAMS ((const char *errmsg)); | ||
170 | typedef const char *lt_dlmutex_geterror LT_PARAMS ((void)); | ||
171 | |||
172 | LT_SCOPE int lt_dlmutex_register LT_PARAMS ((lt_dlmutex_lock * lock, | ||
173 | lt_dlmutex_unlock * unlock, | ||
174 | lt_dlmutex_seterror * seterror, | ||
175 | lt_dlmutex_geterror * geterror)); | ||
176 | |||
177 | |||
178 | |||
179 | |||
180 | /* --- MEMORY HANDLING --- */ | ||
181 | |||
182 | |||
183 | /* By default, the realloc function pointer is set to our internal | ||
184 | realloc implementation which iself uses lt_dlmalloc and lt_dlfree. | ||
185 | libltdl relies on a featureful realloc, but if you are sure yours | ||
186 | has the right semantics then you can assign it directly. Generally, | ||
187 | it is safe to assign just a malloc() and a free() function. */ | ||
188 | LT_SCOPE | ||
189 | lt_ptr (*lt_dlmalloc) | ||
190 | LT_PARAMS ((size_t size)); | ||
191 | LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS ((lt_ptr ptr, size_t size)); | ||
192 | LT_SCOPE void (*lt_dlfree) LT_PARAMS ((lt_ptr ptr)); | ||
193 | |||
194 | |||
195 | |||
196 | |||
197 | /* --- PRELOADED MODULE SUPPORT --- */ | ||
198 | |||
199 | |||
200 | /* A preopened symbol. Arrays of this type comprise the exported | ||
201 | symbols for a dlpreopened module. */ | ||
202 | typedef struct | ||
203 | { | ||
204 | const char *name; | ||
205 | lt_ptr address; | ||
206 | } lt_dlsymlist; | ||
207 | |||
208 | LT_SCOPE int lt_dlpreload LT_PARAMS ((const lt_dlsymlist * preloaded)); | ||
209 | LT_SCOPE int lt_dlpreload_default | ||
210 | LT_PARAMS ((const lt_dlsymlist * preloaded)); | ||
211 | |||
212 | #define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ | ||
213 | extern const lt_dlsymlist lt_preloaded_symbols[]; \ | ||
214 | lt_dlpreload_default(lt_preloaded_symbols); \ | ||
215 | }LT_STMT_END | ||
216 | |||
217 | |||
218 | |||
219 | |||
220 | /* --- MODULE INFORMATION --- */ | ||
221 | |||
222 | |||
223 | /* Read only information pertaining to a loaded module. */ | ||
224 | typedef struct | ||
225 | { | ||
226 | char *filename; /* file name */ | ||
227 | char *name; /* module name */ | ||
228 | int ref_count; /* number of times lt_dlopened minus | ||
229 | number of times lt_dlclosed. */ | ||
230 | } lt_dlinfo; | ||
231 | |||
232 | LT_SCOPE const lt_dlinfo *lt_dlgetinfo LT_PARAMS ((lt_dlhandle handle)); | ||
233 | LT_SCOPE lt_dlhandle lt_dlhandle_next LT_PARAMS ((lt_dlhandle place)); | ||
234 | LT_SCOPE int lt_dlforeach | ||
235 | LT_PARAMS ((int (*func) (lt_dlhandle handle, lt_ptr data), | ||
236 | lt_ptr data)); | ||
237 | |||
238 | /* Associating user data with loaded modules. */ | ||
239 | typedef unsigned lt_dlcaller_id; | ||
240 | |||
241 | LT_SCOPE lt_dlcaller_id lt_dlcaller_register LT_PARAMS ((void)); | ||
242 | LT_SCOPE lt_ptr lt_dlcaller_set_data LT_PARAMS ((lt_dlcaller_id key, | ||
243 | lt_dlhandle handle, | ||
244 | lt_ptr data)); | ||
245 | LT_SCOPE lt_ptr lt_dlcaller_get_data LT_PARAMS ((lt_dlcaller_id key, | ||
246 | lt_dlhandle handle)); | ||
247 | |||
248 | |||
249 | |||
250 | /* --- USER MODULE LOADER API --- */ | ||
251 | |||
252 | |||
253 | typedef struct lt_dlloader lt_dlloader; | ||
254 | typedef lt_ptr lt_user_data; | ||
255 | typedef lt_ptr lt_module; | ||
256 | |||
257 | /* Function pointer types for creating user defined module loaders. */ | ||
258 | typedef lt_module lt_module_open LT_PARAMS ((lt_user_data loader_data, | ||
259 | const char *filename)); | ||
260 | typedef int lt_module_close LT_PARAMS ((lt_user_data loader_data, | ||
261 | lt_module handle)); | ||
262 | typedef lt_ptr lt_find_sym LT_PARAMS ((lt_user_data loader_data, | ||
263 | lt_module handle, | ||
264 | const char *symbol)); | ||
265 | typedef int lt_dlloader_exit LT_PARAMS ((lt_user_data loader_data)); | ||
266 | |||
267 | struct lt_user_dlloader | ||
268 | { | ||
269 | const char *sym_prefix; | ||
270 | lt_module_open *module_open; | ||
271 | lt_module_close *module_close; | ||
272 | lt_find_sym *find_sym; | ||
273 | lt_dlloader_exit *dlloader_exit; | ||
274 | lt_user_data dlloader_data; | ||
275 | }; | ||
276 | |||
277 | LT_SCOPE lt_dlloader *lt_dlloader_next LT_PARAMS ((lt_dlloader * place)); | ||
278 | LT_SCOPE lt_dlloader *lt_dlloader_find | ||
279 | LT_PARAMS ((const char *loader_name)); | ||
280 | LT_SCOPE const char *lt_dlloader_name LT_PARAMS ((lt_dlloader * place)); | ||
281 | LT_SCOPE lt_user_data *lt_dlloader_data | ||
282 | LT_PARAMS ((lt_dlloader * place)); | ||
283 | LT_SCOPE int lt_dlloader_add | ||
284 | LT_PARAMS ((lt_dlloader * place, | ||
285 | const struct lt_user_dlloader * dlloader, | ||
286 | const char *loader_name)); | ||
287 | LT_SCOPE int lt_dlloader_remove LT_PARAMS ((const char *loader_name)); | ||
288 | |||
289 | |||
290 | |||
291 | /* --- ERROR MESSAGE HANDLING --- */ | ||
292 | |||
293 | |||
294 | /* Defining error strings alongside their symbolic names in a macro in | ||
295 | this way allows us to expand the macro in different contexts with | ||
296 | confidence that the enumeration of symbolic names will map correctly | ||
297 | onto the table of error strings. */ | ||
298 | #define lt_dlerror_table \ | ||
299 | LT_ERROR(UNKNOWN, "unknown error") \ | ||
300 | LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available") \ | ||
301 | LT_ERROR(INVALID_LOADER, "invalid loader") \ | ||
302 | LT_ERROR(INIT_LOADER, "loader initialization failed") \ | ||
303 | LT_ERROR(REMOVE_LOADER, "loader removal failed") \ | ||
304 | LT_ERROR(FILE_NOT_FOUND, "file not found") \ | ||
305 | LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found") \ | ||
306 | LT_ERROR(NO_SYMBOLS, "no symbols defined") \ | ||
307 | LT_ERROR(CANNOT_OPEN, "can't open the module") \ | ||
308 | LT_ERROR(CANNOT_CLOSE, "can't close the module") \ | ||
309 | LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found") \ | ||
310 | LT_ERROR(NO_MEMORY, "not enough memory") \ | ||
311 | LT_ERROR(INVALID_HANDLE, "invalid module handle") \ | ||
312 | LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow") \ | ||
313 | LT_ERROR(INVALID_ERRORCODE, "invalid errorcode") \ | ||
314 | LT_ERROR(SHUTDOWN, "library already shutdown") \ | ||
315 | LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module") \ | ||
316 | LT_ERROR(INVALID_MUTEX_ARGS, "invalid mutex handler registration") \ | ||
317 | LT_ERROR(INVALID_POSITION, "invalid search path insert position") | ||
318 | |||
319 | /* Enumerate the symbolic error names. */ | ||
320 | enum | ||
321 | { | ||
322 | #define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name), | ||
323 | lt_dlerror_table | ||
324 | #undef LT_ERROR | ||
325 | LT_ERROR_MAX | ||
326 | }; | ||
327 | |||
328 | /* These functions are only useful from inside custom module loaders. */ | ||
329 | LT_SCOPE int lt_dladderror LT_PARAMS ((const char *diagnostic)); | ||
330 | LT_SCOPE int lt_dlseterror LT_PARAMS ((int errorcode)); | ||
331 | |||
332 | |||
333 | |||
334 | |||
335 | /* --- SOURCE COMPATIBILITY WITH OLD LIBLTDL --- */ | ||
336 | |||
337 | |||
338 | #ifdef LT_NON_POSIX_NAMESPACE | ||
339 | # define lt_ptr_t lt_ptr | ||
340 | # define lt_module_t lt_module | ||
341 | # define lt_module_open_t lt_module_open | ||
342 | # define lt_module_close_t lt_module_close | ||
343 | # define lt_find_sym_t lt_find_sym | ||
344 | # define lt_dlloader_exit_t lt_dlloader_exit | ||
345 | # define lt_dlloader_t lt_dlloader | ||
346 | # define lt_dlloader_data_t lt_user_data | ||
347 | #endif | ||
348 | |||
349 | LT_END_C_DECLS | ||
350 | #endif /* !LTDL_H */ | ||