Annotation of parser3/src/lib/ltdl/ltdl.h, revision 1.4

1.1       paf         1: /* ltdl.h -- generic dlopen functions
                      2: 
1.4     ! moko        3:    Copyright (C) 1998-2000, 2004-2005, 2007-2008, 2011-2019, 2021-2024
        !             4:    Free Software Foundation, Inc.
1.3       moko        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
1.2       paf        11: modify it under the terms of the GNU Lesser General Public
1.1       paf        12: License as published by the Free Software Foundation; either
                     13: version 2 of the License, or (at your option) any later version.
                     14: 
1.2       paf        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
1.3       moko       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.
1.1       paf        19: 
1.3       moko       20: GNU Libltdl is distributed in the hope that it will be useful,
1.1       paf        21: but WITHOUT ANY WARRANTY; without even the implied warranty of
1.3       moko       22: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     23: GNU Lesser General Public License for more details.
1.1       paf        24: 
1.2       paf        25: You should have received a copy of the GNU Lesser General Public
1.4     ! moko       26: License along with GNU Libltdl.  If not, see <https://www.gnu.org/licenses/>.
1.1       paf        27: */
                     28: 
                     29: /* Only include this header file once. */
1.4     ! moko       30: #if !defined LTDL_H
1.2       paf        31: #define LTDL_H 1
1.1       paf        32: 
1.3       moko       33: #include <libltdl/lt_system.h>
                     34: #include <libltdl/lt_error.h>
                     35: #include <libltdl/lt_dlloader.h>
1.1       paf        36: 
1.2       paf        37: LT_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: 
1.3       moko       46: typedef        struct lt__handle *lt_dlhandle; /* A loaded module.  */
1.2       paf        47: 
                     48: /* Initialisation and finalisation functions for libltdl. */
1.3       moko       49: LT_SCOPE int       lt_dlinit           (void);
                     50: LT_SCOPE int       lt_dlexit           (void);
1.2       paf        51: 
                     52: /* Module search path manipulation.  */
1.3       moko       53: LT_SCOPE int       lt_dladdsearchdir    (const char *search_dir);
                     54: LT_SCOPE int       lt_dlinsertsearchdir (const char *before,
                     55:                                                  const char *search_dir);
1.4     ! moko       56: LT_SCOPE int       lt_dlsetsearchpath   (const char *search_path);
1.3       moko       57: LT_SCOPE const char *lt_dlgetsearchpath         (void);
                     58: LT_SCOPE int       lt_dlforeachfile     (
1.2       paf        59:                        const char *search_path,
1.3       moko       60:                        int (*func) (const char *filename, void *data),
                     61:                        void *data);
                     62: 
                     63: /* User module loading advisors.  */
                     64: LT_SCOPE int       lt_dladvise_init     (lt_dladvise *advise);
                     65: LT_SCOPE int       lt_dladvise_destroy  (lt_dladvise *advise);
                     66: LT_SCOPE int       lt_dladvise_ext      (lt_dladvise *advise);
                     67: LT_SCOPE int       lt_dladvise_resident (lt_dladvise *advise);
                     68: LT_SCOPE int       lt_dladvise_local    (lt_dladvise *advise);
                     69: LT_SCOPE int       lt_dladvise_global   (lt_dladvise *advise);
                     70: LT_SCOPE int       lt_dladvise_preload  (lt_dladvise *advise);
1.2       paf        71: 
                     72: /* Portable libltdl versions of the system dlopen() API. */
1.3       moko       73: LT_SCOPE lt_dlhandle lt_dlopen         (const char *filename);
                     74: LT_SCOPE lt_dlhandle lt_dlopenext      (const char *filename);
                     75: LT_SCOPE lt_dlhandle lt_dlopenadvise   (const char *filename,
                     76:                                         lt_dladvise advise);
                     77: LT_SCOPE void *            lt_dlsym            (lt_dlhandle handle, const char *name);
                     78: LT_SCOPE const char *lt_dlerror                (void);
                     79: LT_SCOPE int       lt_dlclose          (lt_dlhandle handle);
1.2       paf        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. */
1.1       paf        88: typedef struct {
1.2       paf        89:   const char *name;
1.3       moko       90:   void       *address;
1.1       paf        91: } lt_dlsymlist;
                     92: 
1.3       moko       93: typedef int lt_dlpreload_callback_func (lt_dlhandle handle);
                     94: 
                     95: LT_SCOPE int   lt_dlpreload         (const lt_dlsymlist *preloaded);
                     96: LT_SCOPE int   lt_dlpreload_default (const lt_dlsymlist *preloaded);
                     97: LT_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.  */
                    102: extern LT_DLSYM_CONST lt_dlsymlist lt__PROGRAM__LTX_preloaded_symbols[];
                    103: 
                    104: #define LTDL_SET_PRELOADED_SYMBOLS() \
                    105:        lt_dlpreload_default(lt_preloaded_symbols)
1.2       paf       106: 
                    107: 
                    108: 
                    109: /* --- MODULE INFORMATION --- */
                    110: 
                    111: 
1.3       moko      112: /* Associating user data with loaded modules. */
                    113: typedef void * lt_dlinterface_id;
                    114: typedef int lt_dlhandle_interface (lt_dlhandle handle, const char *id_string);
                    115: 
                    116: LT_SCOPE lt_dlinterface_id lt_dlinterface_register (const char *id_string,
                    117:                                          lt_dlhandle_interface *iface);
                    118: LT_SCOPE void  lt_dlinterface_free (lt_dlinterface_id key);
                    119: LT_SCOPE void *        lt_dlcaller_set_data  (lt_dlinterface_id key,
                    120:                                          lt_dlhandle handle, void *data);
                    121: LT_SCOPE void *        lt_dlcaller_get_data  (lt_dlinterface_id key,
                    122:                                          lt_dlhandle handle);
                    123: 
                    124: 
1.2       paf       125: /* Read only information pertaining to a loaded module. */
                    126: typedef        struct {
1.3       moko      127:   char *       filename;       /* file name */
                    128:   char *       name;           /* module name */
                    129:   int          ref_count;      /* number of times lt_dlopened minus
1.2       paf       130:                                   number of times lt_dlclosed. */
1.3       moko      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. */
1.2       paf       136: } lt_dlinfo;
                    137: 
1.3       moko      138: LT_SCOPE const lt_dlinfo *lt_dlgetinfo     (lt_dlhandle handle);
1.2       paf       139: 
1.3       moko      140: LT_SCOPE lt_dlhandle   lt_dlhandle_iterate (lt_dlinterface_id iface,
                    141:                                             lt_dlhandle place);
                    142: LT_SCOPE lt_dlhandle   lt_dlhandle_fetch   (lt_dlinterface_id iface,
                    143:                                             const char *module_name);
                    144: LT_SCOPE int           lt_dlhandle_map     (lt_dlinterface_id iface,
                    145:                                int (*func) (lt_dlhandle handle, void *data),
                    146:                                void *data);
1.2       paf       147: 
                    148: 
                    149: 
1.3       moko      150: /* Deprecated module residency management API. */
                    151: LT_SCOPE int       lt_dlmakeresident   (lt_dlhandle handle);
                    152: LT_SCOPE int       lt_dlisresident     (lt_dlhandle handle);
1.2       paf       153: 
1.3       moko      154: #define lt_ptr void *
1.1       paf       155: 
1.2       paf       156: LT_END_C_DECLS
1.1       paf       157: 
1.4     ! moko      158: #endif /*!defined LTDL_H*/

E-mail: