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