| 1 | /* lt__private.h -- internal apis for libltdl |
| 2 | |
| 3 | Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
| 4 | Written by Gary V. Vaughan, 2004 |
| 5 | |
| 6 | NOTE: The canonical source of this file is maintained with the |
| 7 | GNU Libtool package. Report bugs to bug-libtool@gnu.org. |
| 8 | |
| 9 | This library is free software; you can redistribute it and/or |
| 10 | modify it under the terms of the GNU Lesser General Public |
| 11 | License as published by the Free Software Foundation; either |
| 12 | version 2 of the License, or (at your option) any later version. |
| 13 | |
| 14 | As a special exception to the GNU Lesser General Public License, |
| 15 | if you distribute this file as part of a program or library that |
| 16 | is built using GNU libtool, you may include this file under the |
| 17 | same distribution terms that you use for the rest of that program. |
| 18 | |
| 19 | GNU Libltdl is distributed in the hope that it will be useful, |
| 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | GNU Lesser General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU Lesser General Public |
| 25 | License along with GNU Libltdl; see the file COPYING.LIB. If not, a |
| 26 | copy con be downloaded from http://www.gnu.org/licenses/lgpl.html, |
| 27 | or obtained by writing to the Free Software Foundation, Inc., |
| 28 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 29 | */ |
| 30 | |
| 31 | #if !defined(LT__PRIVATE_H) |
| 32 | #define LT__PRIVATE_H 1 |
| 33 | |
| 34 | #if defined(LT_CONFIG_H) |
| 35 | # include LT_CONFIG_H |
| 36 | #else |
| 37 | # include <config.h> |
| 38 | #endif |
| 39 | |
| 40 | #include <stdio.h> |
| 41 | #include <ctype.h> |
| 42 | #include <assert.h> |
| 43 | #include <errno.h> |
| 44 | #include <string.h> |
| 45 | |
| 46 | #if defined(HAVE_UNISTD_H) |
| 47 | # include <unistd.h> |
| 48 | #endif |
| 49 | |
| 50 | /* Import internal interfaces... */ |
| 51 | #include "lt__alloc.h" |
| 52 | #include "lt__dirent.h" |
| 53 | #include "lt__strl.h" |
| 54 | #include "lt__glibc.h" |
| 55 | |
| 56 | /* ...and all exported interfaces. */ |
| 57 | #include "ltdl.h" |
| 58 | |
| 59 | #if defined(WITH_DMALLOC) |
| 60 | # include <dmalloc.h> |
| 61 | #endif |
| 62 | |
| 63 | /* DLL building support on win32 hosts; mostly to workaround their |
| 64 | ridiculous implementation of data symbol exporting. */ |
| 65 | #ifndef LT_GLOBAL_DATA |
| 66 | # if defined(__WINDOWS__) || defined(__CYGWIN__) |
| 67 | # if defined(DLL_EXPORT) /* defined by libtool (if required) */ |
| 68 | # define LT_GLOBAL_DATA __declspec(dllexport) |
| 69 | # endif |
| 70 | # endif |
| 71 | # ifndef LT_GLOBAL_DATA |
| 72 | # define LT_GLOBAL_DATA /* static linking or !__WINDOWS__ */ |
| 73 | # endif |
| 74 | #endif |
| 75 | |
| 76 | #ifndef __attribute__ |
| 77 | # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ |
| 78 | # define __attribute__(x) |
| 79 | # endif |
| 80 | #endif |
| 81 | |
| 82 | #ifndef LT__UNUSED |
| 83 | # define LT__UNUSED __attribute__ ((__unused__)) |
| 84 | #endif |
| 85 | |
| 86 | |
| 87 | LT_BEGIN_C_DECLS |
| 88 | |
| 89 | #if !defined(errno) |
| 90 | extern int errno; |
| 91 | #endif |
| 92 | |
| 93 | LT_SCOPE void lt__alloc_die_callback (void); |
| 94 | |
| 95 | |
| 96 | /* For readability: */ |
| 97 | #define strneq(s1, s2) (strcmp((s1), (s2)) != 0) |
| 98 | #define streq(s1, s2) (!strcmp((s1), (s2))) |
| 99 | |
| 100 | |
| 101 | |
| 102 | /* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */ |
| 103 | |
| 104 | /* This type is used for the array of interface data sets in each handler. */ |
| 105 | typedef struct { |
| 106 | lt_dlinterface_id key; |
| 107 | void * data; |
| 108 | } lt_interface_data; |
| 109 | |
| 110 | struct lt__handle { |
| 111 | lt_dlhandle next; |
| 112 | const lt_dlvtable * vtable; /* dlopening interface */ |
| 113 | lt_dlinfo info; /* user visible fields */ |
| 114 | int depcount; /* number of dependencies */ |
| 115 | lt_dlhandle * deplibs; /* dependencies */ |
| 116 | lt_module module; /* system module handle */ |
| 117 | void * system; /* system specific data */ |
| 118 | lt_interface_data * interface_data; /* per caller associated data */ |
| 119 | int flags; /* various boolean stats */ |
| 120 | }; |
| 121 | |
| 122 | struct lt__advise { |
| 123 | unsigned int try_ext:1; /* try system library extensions. */ |
| 124 | unsigned int is_resident:1; /* module can't be unloaded. */ |
| 125 | unsigned int is_symglobal:1; /* module symbols can satisfy |
| 126 | subsequently loaded modules. */ |
| 127 | unsigned int is_symlocal:1; /* module symbols are only available |
| 128 | locally. */ |
| 129 | unsigned int try_preload_only:1;/* only preloaded modules will be tried. */ |
| 130 | }; |
| 131 | |
| 132 | /* --- ERROR HANDLING --- */ |
| 133 | |
| 134 | /* Extract the diagnostic strings from the error table macro in the same |
| 135 | order as the enumerated indices in lt_error.h. */ |
| 136 | |
| 137 | #define LT__STRERROR(name) lt__error_string(LT_CONC(LT_ERROR_,name)) |
| 138 | |
| 139 | #define LT__GETERROR(lvalue) (lvalue) = lt__get_last_error() |
| 140 | #define LT__SETERRORSTR(errormsg) lt__set_last_error(errormsg) |
| 141 | #define LT__SETERROR(errorcode) LT__SETERRORSTR(LT__STRERROR(errorcode)) |
| 142 | |
| 143 | LT_SCOPE const char *lt__error_string (int errorcode); |
| 144 | LT_SCOPE const char *lt__get_last_error (void); |
| 145 | LT_SCOPE const char *lt__set_last_error (const char *errormsg); |
| 146 | |
| 147 | LT_END_C_DECLS |
| 148 | |
| 149 | #endif /*!defined(LT__PRIVATE_H)*/ |