libg722_1 0.1.0
ltdl.h
1/* ltdl.h -- generic dlopen functions
2
3 Copyright (C) 1998-2000, 2004-2005, 2007-2008, 2011-2019, 2021-2024
4 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. If not, see <https://www.gnu.org/licenses/>.
27*/
28
29/* Only include this header file once. */
30#if !defined LTDL_H
31#define LTDL_H 1
32
33#include <libltdl/lt_system.h>
34#include <libltdl/lt_error.h>
35#include <libltdl/lt_dlloader.h>
36
37LT_BEGIN_C_DECLS
38
39
40/* LT_STRLEN can be used safely on NULL pointers. */
41#define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0)
42
43/* --- DYNAMIC MODULE LOADING API --- */
44
45
46typedef struct lt__handle *lt_dlhandle; /* A loaded module. */
47
48/* Initialisation and finalisation functions for libltdl. */
49LT_SCOPE int lt_dlinit (void);
50LT_SCOPE int lt_dlexit (void);
51
52/* Module search path manipulation. */
53LT_SCOPE int lt_dladdsearchdir (const char *search_dir);
54LT_SCOPE int lt_dlinsertsearchdir (const char *before,
55 const char *search_dir);
56LT_SCOPE int lt_dlsetsearchpath (const char *search_path);
57LT_SCOPE const char *lt_dlgetsearchpath (void);
58LT_SCOPE int lt_dlforeachfile (
59 const char *search_path,
60 int (*func) (const char *filename, void *data),
61 void *data);
62
63/* User module loading advisors. */
64LT_SCOPE int lt_dladvise_init (lt_dladvise *advise);
65LT_SCOPE int lt_dladvise_destroy (lt_dladvise *advise);
66LT_SCOPE int lt_dladvise_ext (lt_dladvise *advise);
67LT_SCOPE int lt_dladvise_resident (lt_dladvise *advise);
68LT_SCOPE int lt_dladvise_local (lt_dladvise *advise);
69LT_SCOPE int lt_dladvise_global (lt_dladvise *advise);
70LT_SCOPE int lt_dladvise_preload (lt_dladvise *advise);
71
72/* Portable libltdl versions of the system dlopen() API. */
73LT_SCOPE lt_dlhandle lt_dlopen (const char *filename);
74LT_SCOPE lt_dlhandle lt_dlopenext (const char *filename);
75LT_SCOPE lt_dlhandle lt_dlopenadvise (const char *filename,
76 lt_dladvise advise);
77LT_SCOPE void * lt_dlsym (lt_dlhandle handle, const char *name);
78LT_SCOPE const char *lt_dlerror (void);
79LT_SCOPE int lt_dlclose (lt_dlhandle handle);
80
81
82
83/* --- PRELOADED MODULE SUPPORT --- */
84
85
86/* A preopened symbol. Arrays of this type comprise the exported
87 symbols for a dlpreopened module. */
88typedef struct {
89 const char *name;
90 void *address;
92
93typedef int lt_dlpreload_callback_func (lt_dlhandle handle);
94
95LT_SCOPE int lt_dlpreload (const lt_dlsymlist *preloaded);
96LT_SCOPE int lt_dlpreload_default (const lt_dlsymlist *preloaded);
97LT_SCOPE int lt_dlpreload_open (const char *originator,
98 lt_dlpreload_callback_func *func);
99
100#define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols
101/* Ensure C linkage. */
102extern LT_DLSYM_CONST lt_dlsymlist lt__PROGRAM__LTX_preloaded_symbols[];
103
104#define LTDL_SET_PRELOADED_SYMBOLS() \
105 lt_dlpreload_default(lt_preloaded_symbols)
106
107
108
109/* --- MODULE INFORMATION --- */
110
111
112/* Associating user data with loaded modules. */
113typedef void * lt_dlinterface_id;
114typedef int lt_dlhandle_interface (lt_dlhandle handle, const char *id_string);
115
116LT_SCOPE lt_dlinterface_id lt_dlinterface_register (const char *id_string,
117 lt_dlhandle_interface *iface);
118LT_SCOPE void lt_dlinterface_free (lt_dlinterface_id key);
119LT_SCOPE void * lt_dlcaller_set_data (lt_dlinterface_id key,
120 lt_dlhandle handle, void *data);
121LT_SCOPE void * lt_dlcaller_get_data (lt_dlinterface_id key,
122 lt_dlhandle handle);
123
124
125/* Read only information pertaining to a loaded module. */
126typedef struct {
127 char * filename; /* file name */
128 char * name; /* module name */
129 int ref_count; /* number of times lt_dlopened minus
130 number of times lt_dlclosed. */
131 unsigned int is_resident:1; /* module can't be unloaded. */
132 unsigned int is_symglobal:1; /* module symbols can satisfy
133 subsequently loaded modules. */
134 unsigned int is_symlocal:1; /* module symbols are only available
135 locally. */
136} lt_dlinfo;
137
138LT_SCOPE const lt_dlinfo *lt_dlgetinfo (lt_dlhandle handle);
139
140LT_SCOPE lt_dlhandle lt_dlhandle_iterate (lt_dlinterface_id iface,
141 lt_dlhandle place);
142LT_SCOPE lt_dlhandle lt_dlhandle_fetch (lt_dlinterface_id iface,
143 const char *module_name);
144LT_SCOPE int lt_dlhandle_map (lt_dlinterface_id iface,
145 int (*func) (lt_dlhandle handle, void *data),
146 void *data);
147
148
149
150/* Deprecated module residency management API. */
151LT_SCOPE int lt_dlmakeresident (lt_dlhandle handle);
152LT_SCOPE int lt_dlisresident (lt_dlhandle handle);
153
154#define lt_ptr void *
155
156LT_END_C_DECLS
157
158#endif /*!defined LTDL_H*/
Definition lt__private.h:108
Definition ltdl.h:126
Definition ltdl.h:88