Commit | Line | Data |
---|---|---|
d9898ee8 | 1 | /* ltdl.h -- generic dlopen functions |
d9898ee8 | 2 | |
8d138742 CE |
3 | Copyright (C) 1998-2000, 2004, 2005, |
4 | 2007, 2008 Free Software Foundation, Inc. | |
5 | Written by Thomas Tanner, 1998 | |
6 | ||
7 | NOTE: The canonical source of this file is maintained with the | |
8 | GNU Libtool package. Report bugs to bug-libtool@gnu.org. | |
9 | ||
10 | GNU Libltdl is free software; you can redistribute it and/or | |
d9898ee8 | 11 | modify it under the terms of the GNU Lesser General Public |
12 | License as published by the Free Software Foundation; either | |
13 | version 2 of the License, or (at your option) any later version. | |
14 | ||
15 | As a special exception to the GNU Lesser General Public License, | |
16 | if you distribute this file as part of a program or library that | |
8d138742 CE |
17 | is built using GNU Libtool, you may include this file under the |
18 | same distribution terms that you use for the rest of that program. | |
d9898ee8 | 19 | |
8d138742 | 20 | GNU Libltdl is distributed in the hope that it will be useful, |
d9898ee8 | 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
8d138742 CE |
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | GNU Lesser General Public License for more details. | |
d9898ee8 | 24 | |
25 | You should have received a copy of the GNU Lesser General Public | |
8d138742 CE |
26 | License along with GNU Libltdl; see the file COPYING.LIB. If not, a |
27 | copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, | |
28 | or obtained by writing to the Free Software Foundation, Inc., | |
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
d9898ee8 | 30 | */ |
31 | ||
32 | /* Only include this header file once. */ | |
8d138742 | 33 | #if !defined(LTDL_H) |
d9898ee8 | 34 | #define LTDL_H 1 |
35 | ||
8d138742 CE |
36 | #include <libltdl/lt_system.h> |
37 | #include <libltdl/lt_error.h> | |
38 | #include <libltdl/lt_dlloader.h> | |
d9898ee8 | 39 | |
40 | LT_BEGIN_C_DECLS | |
41 | ||
42 | ||
d9898ee8 | 43 | /* LT_STRLEN can be used safely on NULL pointers. */ |
44 | #define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0) | |
45 | ||
d9898ee8 | 46 | \f |
47 | /* --- DYNAMIC MODULE LOADING API --- */ | |
48 | ||
49 | ||
8d138742 | 50 | typedef struct lt__handle *lt_dlhandle; /* A loaded module. */ |
d9898ee8 | 51 | |
52 | /* Initialisation and finalisation functions for libltdl. */ | |
8d138742 CE |
53 | LT_SCOPE int lt_dlinit (void); |
54 | LT_SCOPE int lt_dlexit (void); | |
d9898ee8 | 55 | |
56 | /* Module search path manipulation. */ | |
8d138742 CE |
57 | LT_SCOPE int lt_dladdsearchdir (const char *search_dir); |
58 | LT_SCOPE int lt_dlinsertsearchdir (const char *before, | |
59 | const char *search_dir); | |
60 | LT_SCOPE int lt_dlsetsearchpath (const char *search_path); | |
61 | LT_SCOPE const char *lt_dlgetsearchpath (void); | |
62 | LT_SCOPE int lt_dlforeachfile ( | |
d9898ee8 | 63 | const char *search_path, |
8d138742 CE |
64 | int (*func) (const char *filename, void *data), |
65 | void *data); | |
66 | ||
67 | /* User module loading advisors. */ | |
68 | LT_SCOPE int lt_dladvise_init (lt_dladvise *advise); | |
69 | LT_SCOPE int lt_dladvise_destroy (lt_dladvise *advise); | |
70 | LT_SCOPE int lt_dladvise_ext (lt_dladvise *advise); | |
71 | LT_SCOPE int lt_dladvise_resident (lt_dladvise *advise); | |
72 | LT_SCOPE int lt_dladvise_local (lt_dladvise *advise); | |
73 | LT_SCOPE int lt_dladvise_global (lt_dladvise *advise); | |
74 | LT_SCOPE int lt_dladvise_preload (lt_dladvise *advise); | |
d9898ee8 | 75 | |
76 | /* Portable libltdl versions of the system dlopen() API. */ | |
8d138742 CE |
77 | LT_SCOPE lt_dlhandle lt_dlopen (const char *filename); |
78 | LT_SCOPE lt_dlhandle lt_dlopenext (const char *filename); | |
79 | LT_SCOPE lt_dlhandle lt_dlopenadvise (const char *filename, | |
80 | lt_dladvise advise); | |
81 | LT_SCOPE void * lt_dlsym (lt_dlhandle handle, const char *name); | |
82 | LT_SCOPE const char *lt_dlerror (void); | |
83 | LT_SCOPE int lt_dlclose (lt_dlhandle handle); | |
d9898ee8 | 84 | |
85 | ||
d9898ee8 | 86 | |
d9898ee8 | 87 | /* --- PRELOADED MODULE SUPPORT --- */ |
88 | ||
89 | ||
90 | /* A preopened symbol. Arrays of this type comprise the exported | |
91 | symbols for a dlpreopened module. */ | |
92 | typedef struct { | |
93 | const char *name; | |
8d138742 | 94 | void *address; |
d9898ee8 | 95 | } lt_dlsymlist; |
96 | ||
8d138742 | 97 | typedef int lt_dlpreload_callback_func (lt_dlhandle handle); |
d9898ee8 | 98 | |
8d138742 CE |
99 | LT_SCOPE int lt_dlpreload (const lt_dlsymlist *preloaded); |
100 | LT_SCOPE int lt_dlpreload_default (const lt_dlsymlist *preloaded); | |
101 | LT_SCOPE int lt_dlpreload_open (const char *originator, | |
102 | lt_dlpreload_callback_func *func); | |
103 | ||
104 | #define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols | |
105 | #define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ | |
d9898ee8 | 106 | extern const lt_dlsymlist lt_preloaded_symbols[]; \ |
107 | lt_dlpreload_default(lt_preloaded_symbols); \ | |
8d138742 | 108 | }LT_STMT_END |
d9898ee8 | 109 | |
110 | ||
111 | ||
112 | \f | |
113 | /* --- MODULE INFORMATION --- */ | |
114 | ||
115 | ||
d9898ee8 | 116 | /* Associating user data with loaded modules. */ |
8d138742 CE |
117 | typedef void * lt_dlinterface_id; |
118 | typedef int lt_dlhandle_interface (lt_dlhandle handle, const char *id_string); | |
d9898ee8 | 119 | |
8d138742 CE |
120 | LT_SCOPE lt_dlinterface_id lt_dlinterface_register (const char *id_string, |
121 | lt_dlhandle_interface *iface); | |
122 | LT_SCOPE void lt_dlinterface_free (lt_dlinterface_id key); | |
123 | LT_SCOPE void * lt_dlcaller_set_data (lt_dlinterface_id key, | |
124 | lt_dlhandle handle, void *data); | |
125 | LT_SCOPE void * lt_dlcaller_get_data (lt_dlinterface_id key, | |
126 | lt_dlhandle handle); | |
d9898ee8 | 127 | |
128 | ||
8d138742 CE |
129 | /* Read only information pertaining to a loaded module. */ |
130 | typedef struct { | |
131 | char * filename; /* file name */ | |
132 | char * name; /* module name */ | |
133 | int ref_count; /* number of times lt_dlopened minus | |
134 | number of times lt_dlclosed. */ | |
135 | unsigned int is_resident:1; /* module can't be unloaded. */ | |
136 | unsigned int is_symglobal:1; /* module symbols can satisfy | |
137 | subsequently loaded modules. */ | |
138 | unsigned int is_symlocal:1; /* module symbols are only available | |
139 | locally. */ | |
140 | } lt_dlinfo; | |
d9898ee8 | 141 | |
8d138742 | 142 | LT_SCOPE const lt_dlinfo *lt_dlgetinfo (lt_dlhandle handle); |
d9898ee8 | 143 | |
8d138742 CE |
144 | LT_SCOPE lt_dlhandle lt_dlhandle_iterate (lt_dlinterface_id iface, |
145 | lt_dlhandle place); | |
146 | LT_SCOPE lt_dlhandle lt_dlhandle_fetch (lt_dlinterface_id iface, | |
147 | const char *module_name); | |
148 | LT_SCOPE int lt_dlhandle_map (lt_dlinterface_id iface, | |
149 | int (*func) (lt_dlhandle handle, void *data), | |
150 | void *data); | |
d9898ee8 | 151 | |
152 | ||
d9898ee8 | 153 | |
8d138742 CE |
154 | /* Deprecated module residency management API. */ |
155 | LT_SCOPE int lt_dlmakeresident (lt_dlhandle handle); | |
156 | LT_SCOPE int lt_dlisresident (lt_dlhandle handle); | |
d9898ee8 | 157 | |
8d138742 | 158 | #define lt_ptr void * |
d9898ee8 | 159 | |
160 | LT_END_C_DECLS | |
161 | ||
8d138742 | 162 | #endif /*!defined(LTDL_H)*/ |