From fd68c0f047bbd40d02cad5a84584cc74979c993a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 1 Jul 2009 20:45:25 +0200 Subject: ModuleManager: Benutze libdl anstatt ltdl --- CMakeLists.txt | 4 +- FindDL.cmake | 37 + FindLTDL.cmake | 97 -- libltdl/COPYING.LIB | 515 --------- libltdl/README | 37 - libltdl/argz.c | 254 ----- libltdl/argz_.h | 71 -- libltdl/libltdl/lt__alloc.h | 58 - libltdl/libltdl/lt__dirent.h | 87 -- libltdl/libltdl/lt__glibc.h | 83 -- libltdl/libltdl/lt__private.h | 148 --- libltdl/libltdl/lt__strl.h | 53 - libltdl/libltdl/lt_dlloader.h | 90 -- libltdl/libltdl/lt_error.h | 85 -- libltdl/libltdl/lt_system.h | 154 --- libltdl/libltdl/slist.h | 94 -- libltdl/loaders/dld_link.c | 158 --- libltdl/loaders/dlopen.c | 242 ----- libltdl/loaders/dyld.c | 511 --------- libltdl/loaders/load_add_on.c | 167 --- libltdl/loaders/loadlibrary.c | 251 ----- libltdl/loaders/preopen.c | 375 ------- libltdl/loaders/shl_load.c | 222 ---- libltdl/lt__alloc.c | 95 -- libltdl/lt__dirent.c | 107 -- libltdl/lt__strl.c | 127 --- libltdl/lt_dlloader.c | 210 ---- libltdl/lt_error.c | 110 -- libltdl/ltdl.c | 2392 ----------------------------------------- libltdl/ltdl.h | 161 --- libltdl/slist.c | 375 ------- src/Common/CMakeLists.txt | 3 +- src/Common/ModuleManager.cpp | 79 +- src/Common/ModuleManager.h | 13 +- 34 files changed, 90 insertions(+), 7375 deletions(-) create mode 100644 FindDL.cmake delete mode 100644 FindLTDL.cmake delete mode 100644 libltdl/COPYING.LIB delete mode 100644 libltdl/README delete mode 100644 libltdl/argz.c delete mode 100644 libltdl/argz_.h delete mode 100644 libltdl/libltdl/lt__alloc.h delete mode 100644 libltdl/libltdl/lt__dirent.h delete mode 100644 libltdl/libltdl/lt__glibc.h delete mode 100644 libltdl/libltdl/lt__private.h delete mode 100644 libltdl/libltdl/lt__strl.h delete mode 100644 libltdl/libltdl/lt_dlloader.h delete mode 100644 libltdl/libltdl/lt_error.h delete mode 100644 libltdl/libltdl/lt_system.h delete mode 100644 libltdl/libltdl/slist.h delete mode 100644 libltdl/loaders/dld_link.c delete mode 100644 libltdl/loaders/dlopen.c delete mode 100644 libltdl/loaders/dyld.c delete mode 100644 libltdl/loaders/load_add_on.c delete mode 100644 libltdl/loaders/loadlibrary.c delete mode 100644 libltdl/loaders/preopen.c delete mode 100644 libltdl/loaders/shl_load.c delete mode 100644 libltdl/lt__alloc.c delete mode 100644 libltdl/lt__dirent.c delete mode 100644 libltdl/lt__strl.c delete mode 100644 libltdl/lt_dlloader.c delete mode 100644 libltdl/lt_error.c delete mode 100644 libltdl/ltdl.c delete mode 100644 libltdl/ltdl.h delete mode 100644 libltdl/slist.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 82cc348..b621ec0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(MAD) set(CMAKE_MODULE_PATH ${MAD_SOURCE_DIR}) find_package(LibXml2 REQUIRED) -find_package(LTDL REQUIRED) +find_package(DL REQUIRED) find_package(Readline REQUIRED) #find_package(KRB5 REQUIRED gssapi) find_package(OpenSSL REQUIRED) @@ -18,7 +18,7 @@ set(INCLUDES ${MAD_BINARY_DIR} ${LIBXML2_INCLUDE_DIR} ${GNUTLS_INCLUDE_DIRS} - ${LTDL_INCLUDE_DIR} + ${DL_INCLUDE_DIR} ${READLINE_INCLUDE_DIR} # ${KRB5_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} diff --git a/FindDL.cmake b/FindDL.cmake new file mode 100644 index 0000000..584650f --- /dev/null +++ b/FindDL.cmake @@ -0,0 +1,37 @@ +# - Find dl functions +# This module finds dl libraries. +# +# It sets the following variables: +# DL_FOUND - Set to false, or undefined, if dl libraries aren't found. +# DL_INCLUDE_DIR - The dl include directory. +# DL_LIBRARY - The dl library to link against. + +INCLUDE(CheckFunctionExists) + +FIND_PATH(DL_INCLUDE_DIR NAMES dlfcn.h) +FIND_LIBRARY(DL_LIBRARY NAMES dl) + +IF (DL_LIBRARY) + SET(DL_FOUND TRUE) +ELSE (DL_LIBRARY) + # if dlopen can be found without linking in dl then, + # dlopen is part of libc, so don't need to link extra libs. + CHECK_FUNCTION_EXISTS(dlopen DL_FOUND) + SET(DL_LIBRARY "") +ENDIF (DL_LIBRARY) + +IF (DL_FOUND) + + # show which dl was found only if not quiet + IF (NOT DL_FIND_QUIETLY) + MESSAGE(STATUS "Found dl: ${DL_LIBRARY}") + ENDIF (NOT DL_FIND_QUIETLY) + +ELSE (DL_FOUND) + + # fatal error if dl is required but not found + IF (DL_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find dl") + ENDIF (DL_FIND_REQUIRED) + +ENDIF (DL_FOUND) diff --git a/FindLTDL.cmake b/FindLTDL.cmake deleted file mode 100644 index 55e29df..0000000 --- a/FindLTDL.cmake +++ /dev/null @@ -1,97 +0,0 @@ -# - Find ltdl header and library -# - -# This module defines -# LTDL_FOUND, if false, do not try to use LTDL. -# LTDL_INCLUDE_DIR, where to find ltdl.h. -# LTDL_LIBRARIES, the libraries to link against to use libltdl. -# LTDL_LIBRARY_DIR, the directory where libltdl is found. - -find_path(LTDL_INCLUDE_DIR ltdl.h /usr/local/include /usr/include) - -if(LTDL_INCLUDE_DIR) - find_library(LTDL_LIBRARIES - NAMES ltdl - PATHS /usr/local/lib /usr/lib - ) - if(LTDL_LIBRARIES) - - set(LTDL_LIBRARY_DIR "") - get_filename_component(LTDL_LIBRARY_DIR ${LTDL_LIBRARIES} PATH) - - # Define useful internal macro for finding and checking a library - include(CheckLibraryExists) - macro(_find_check_libs _library_name _function_name _lib _have_lib) - find_library( - ${_lib} - NAMES ${_library_name} - PATHS /usr/local/lib /usr/lib - ) -# message("_library_name = ${_library_name}") -# message("${_lib} = ${${_lib}}") - if(${_lib}) - get_filename_component(_path ${${_lib}} PATH) - check_library_exists( - ${_library_name} - ${_function_name} - ${_path} - ${_have_lib} - ) - endif(${_lib}) - endmacro(_find_check_libs) - - # Find and check platform-dependent libraries which - # libltdl depends upon using model given - # for determining LIBADD_DL in $prefix/share/libtool/libltdl/acinclude.m4 - - # Look for three exclusive alternatives: - # (dld shl_load; dl dlopen; svdl dlopen) - # N.B. all the different ADDLIB variables have to be different because - # of caching of results in the macro. - _find_check_libs(dld shl_load LTDL_LTDL_ADDLIB0 LTDL_LTDL_HAVE_ADDLIB0) - if(LTDL_LTDL_HAVE_ADDLIB0) - set(LTDL_LIBRARIES ${LTDL_LIBRARIES} ${LTDL_LTDL_ADDLIB0}) - set(LTDL_FOUND ON) - else(LTDL_LTDL_HAVE_ADDLIB0) - _find_check_libs(dl dlopen LTDL_LTDL_ADDLIB1 LTDL_LTDL_HAVE_ADDLIB1) - if(LTDL_LTDL_HAVE_ADDLIB1) - set(LTDL_LIBRARIES ${LTDL_LIBRARIES} ${LTDL_LTDL_ADDLIB1}) - set(LTDL_FOUND ON) - else(LTDL_LTDL_HAVE_ADDLIB1) - _find_check_libs(svdl dlopen LTDL_LTDL_ADDLIB2 LTDL_LTDL_HAVE_ADDLIB2) - if(LTDL_LTDL_HAVE_ADDLIB2) - set(LTDL_LIBRARIES ${LTDL_LIBRARIES} ${LTDL_LTDL_ADDLIB2}) - set(LTDL_FOUND ON) - else(LTDL_LTDL_HAVE_ADDLIB2) - set(LTDL_FOUND OFF) - endif(LTDL_LTDL_HAVE_ADDLIB2) - endif(LTDL_LTDL_HAVE_ADDLIB1) - endif(LTDL_LTDL_HAVE_ADDLIB0) - - # (dld dld_link) appended to any that have been found before. - _find_check_libs(dld dld_link LTDL_LTDL_ADDLIB3 LTDL_LTDL_HAVE_ADDLIB3) - if(LTDL_LTDL_HAVE_ADDLIB3) - set(LTDL_LIBRARIES ${LTDL_LIBRARIES} ${LTDL_LTDL_ADDLIB3}) - set(LTDL_FOUND ON) - endif(LTDL_LTDL_HAVE_ADDLIB3) - - endif(LTDL_LIBRARIES) -endif(LTDL_INCLUDE_DIR) - -if(LTDL_FOUND) - if(NOT LTDL_FIND_QUIETLY) - message(STATUS "Found LTDL: ${LTDL_LIBRARIES}") - endif(NOT LTDL_FIND_QUIETLY) -else(LTDL_FOUND) - if(LTDL_FIND_REQUIRED) - message(FATAL_ERROR "Could not find LTDL library") - endif(LTDL_FIND_REQUIRED) -endif(LTDL_FOUND) - -mark_as_advanced( -LTDL_LTDL_ADDLIB0 LTDL_LTDL_HAVE_ADDLIB0 -LTDL_LTDL_ADDLIB1 LTDL_LTDL_HAVE_ADDLIB1 -LTDL_LTDL_ADDLIB2 LTDL_LTDL_HAVE_ADDLIB2 -LTDL_LTDL_ADDLIB3 LTDL_LTDL_HAVE_ADDLIB3 -) - diff --git a/libltdl/COPYING.LIB b/libltdl/COPYING.LIB deleted file mode 100644 index ba2be48..0000000 --- a/libltdl/COPYING.LIB +++ /dev/null @@ -1,515 +0,0 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. -^L - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. -^L - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. -^L - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. -^L - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. -^L - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. -^L - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. -^L - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS -^L - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). - - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. - - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper -mail. - -You should also get your employer (if you work as a programmer) or -your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James -Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/libltdl/README b/libltdl/README deleted file mode 100644 index e533467..0000000 --- a/libltdl/README +++ /dev/null @@ -1,37 +0,0 @@ -This is GNU libltdl, a system independent dlopen wrapper for GNU libtool. - -It supports the following dlopen interfaces: -* dlopen (Solaris, Linux and various BSD flavors) -* shl_load (HP-UX) -* LoadLibrary (Win16 and Win32) -* load_add_on (BeOS) -* GNU DLD (emulates dynamic linking for static libraries) -* dyld (darwin/Mac OS X) -* libtool's dlpreopen --- - Copyright (C) 1999, 2003 Free Software Foundation, Inc. - Written by Thomas Tanner, 1999 - - This file is part of GNU Libtool. - -GNU Libtool is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of -the License, or (at your option) any later version. - -As a special exception to the GNU General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libtool is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Libtool; see the file COPYING. If not, a copy -can be downloaded from http://www.gnu.org/licenses/gpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - diff --git a/libltdl/argz.c b/libltdl/argz.c deleted file mode 100644 index 9576a62..0000000 --- a/libltdl/argz.c +++ /dev/null @@ -1,254 +0,0 @@ -/* argz.c -- argz implementation for non-glibc systems - - Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#if defined(LTDL) && defined LT_CONFIG_H -# include LT_CONFIG_H -#else -# include -#endif - -#include - -#include -#include -#include -#include -#include -#include - -#define EOS_CHAR '\0' - -error_t -argz_append (char **pargz, size_t *pargz_len, const char *buf, size_t buf_len) -{ - size_t argz_len; - char *argz; - - assert (pargz); - assert (pargz_len); - assert ((*pargz && *pargz_len) || (!*pargz && !*pargz_len)); - - /* If nothing needs to be appended, no more work is required. */ - if (buf_len == 0) - return 0; - - /* Ensure there is enough room to append BUF_LEN. */ - argz_len = *pargz_len + buf_len; - argz = (char *) realloc (*pargz, argz_len); - if (!argz) - return ENOMEM; - - /* Copy characters from BUF after terminating '\0' in ARGZ. */ - memcpy (argz + *pargz_len, buf, buf_len); - - /* Assign new values. */ - *pargz = argz; - *pargz_len = argz_len; - - return 0; -} - - -/* Add a string to the argz vector. */ -error_t -argz_add (char **pargz, size_t *pargz_len, const char *str) -{ - return argz_append (pargz, pargz_len, str, strlen (str) + 1); -} - - -error_t -argz_create_sep (const char *str, int delim, char **pargz, size_t *pargz_len) -{ - size_t argz_len; - char *argz = 0; - - assert (str); - assert (pargz); - assert (pargz_len); - - /* Make a copy of STR, but replacing each occurrence of - DELIM with '\0'. */ - argz_len = 1+ strlen (str); - if (argz_len) - { - const char *p; - char *q; - - argz = (char *) malloc (argz_len); - if (!argz) - return ENOMEM; - - for (p = str, q = argz; *p != EOS_CHAR; ++p) - { - if (*p == delim) - { - /* Ignore leading delimiters, and fold consecutive - delimiters in STR into a single '\0' in ARGZ. */ - if ((q > argz) && (q[-1] != EOS_CHAR)) - *q++ = EOS_CHAR; - else - --argz_len; - } - else - *q++ = *p; - } - /* Copy terminating EOS_CHAR. */ - *q = *p; - } - - /* If ARGZ_LEN has shrunk to nothing, release ARGZ's memory. */ - if (!argz_len) - argz = (free (argz), (char *) 0); - - /* Assign new values. */ - *pargz = argz; - *pargz_len = argz_len; - - return 0; -} - - -error_t -argz_insert (char **pargz, size_t *pargz_len, char *before, const char *entry) -{ - assert (pargz); - assert (pargz_len); - assert (entry && *entry); - - /* No BEFORE address indicates ENTRY should be inserted after the - current last element. */ - if (!before) - return argz_append (pargz, pargz_len, entry, 1+ strlen (entry)); - - /* This probably indicates a programmer error, but to preserve - semantics, scan back to the start of an entry if BEFORE points - into the middle of it. */ - while ((before > *pargz) && (before[-1] != EOS_CHAR)) - --before; - - { - size_t entry_len = 1+ strlen (entry); - size_t argz_len = *pargz_len + entry_len; - size_t offset = before - *pargz; - char *argz = (char *) realloc (*pargz, argz_len); - - if (!argz) - return ENOMEM; - - /* Make BEFORE point to the equivalent offset in ARGZ that it - used to have in *PARGZ incase realloc() moved the block. */ - before = argz + offset; - - /* Move the ARGZ entries starting at BEFORE up into the new - space at the end -- making room to copy ENTRY into the - resulting gap. */ - memmove (before + entry_len, before, *pargz_len - offset); - memcpy (before, entry, entry_len); - - /* Assign new values. */ - *pargz = argz; - *pargz_len = argz_len; - } - - return 0; -} - - -char * -argz_next (char *argz, size_t argz_len, const char *entry) -{ - assert ((argz && argz_len) || (!argz && !argz_len)); - - if (entry) - { - /* Either ARGZ/ARGZ_LEN is empty, or ENTRY points into an address - within the ARGZ vector. */ - assert ((!argz && !argz_len) - || ((argz <= entry) && (entry < (argz + argz_len)))); - - /* Move to the char immediately after the terminating - '\0' of ENTRY. */ - entry = 1+ strchr (entry, EOS_CHAR); - - /* Return either the new ENTRY, or else NULL if ARGZ is - exhausted. */ - return (entry >= argz + argz_len) ? 0 : (char *) entry; - } - else - { - /* This should probably be flagged as a programmer error, - since starting an argz_next loop with the iterator set - to ARGZ is safer. To preserve semantics, handle the NULL - case by returning the start of ARGZ (if any). */ - if (argz_len > 0) - return argz; - else - return 0; - } -} - - -void -argz_stringify (char *argz, size_t argz_len, int sep) -{ - assert ((argz && argz_len) || (!argz && !argz_len)); - - if (sep) - { - --argz_len; /* don't stringify the terminating EOS */ - while (--argz_len > 0) - { - if (argz[argz_len] == EOS_CHAR) - argz[argz_len] = sep; - } - } -} - - -/* Count number of elements (null bytes) in argz vector. */ - -size_t -argz_count (const char *argz, size_t argz_len) -{ - size_t count = 0; - - assert ((argz && argz_len) || (!argz && !argz_len)); - - while (argz_len > 0) - { - size_t part_len = strlen (argz); - argz += part_len + 1; - argz_len -= part_len + 1; - count++; - } - - return count; -} diff --git a/libltdl/argz_.h b/libltdl/argz_.h deleted file mode 100644 index 40d5176..0000000 --- a/libltdl/argz_.h +++ /dev/null @@ -1,71 +0,0 @@ -/* lt__argz.h -- internal argz interface for non-glibc systems - - Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if !defined(LT__ARGZ_H) -#define LT__ARGZ_H 1 - -#include -#define __need_error_t -#include -#include - -#if defined(LTDL) -# include "lt__glibc.h" -# include "lt_system.h" -#else -# define LT_SCOPE -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -LT_SCOPE error_t argz_append (char **pargz, size_t *pargz_len, - const char *buf, size_t buf_len); -LT_SCOPE error_t argz_add (char **pargz, size_t *pargz_len, - const char *str); -LT_SCOPE error_t argz_create_sep(const char *str, int delim, - char **pargz, size_t *pargz_len); -LT_SCOPE error_t argz_insert (char **pargz, size_t *pargz_len, - char *before, const char *entry); -LT_SCOPE char * argz_next (char *argz, size_t argz_len, - const char *entry); -LT_SCOPE void argz_stringify (char *argz, size_t argz_len, int sep); -LT_SCOPE size_t argz_count (const char *argz, size_t argz_len); - -#if defined(__cplusplus) -} -#endif - -#if !defined(LTDL) -# undef LT_SCOPE -#endif - -#endif /*!defined(LT__ARGZ_H)*/ diff --git a/libltdl/libltdl/lt__alloc.h b/libltdl/libltdl/lt__alloc.h deleted file mode 100644 index 1ceddf0..0000000 --- a/libltdl/libltdl/lt__alloc.h +++ /dev/null @@ -1,58 +0,0 @@ -/* lt__alloc.h -- internal memory management interface - - Copyright (C) 2004 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if !defined(LT__ALLOC_H) -#define LT__ALLOC_H 1 - -#include "lt_system.h" - -LT_BEGIN_C_DECLS - -#define MALLOC(tp, n) (tp*) lt__malloc((n) * sizeof(tp)) -#define REALLOC(tp, mem, n) (tp*) lt__realloc((mem), (n) * sizeof(tp)) -#define FREE(mem) LT_STMT_START { \ - if (mem) { free ((void *)mem); mem = NULL; } } LT_STMT_END -#define MEMREASSIGN(p, q) LT_STMT_START { \ - if ((p) != (q)) { if (p) free (p); (p) = (q); (q) = 0; } \ - } LT_STMT_END - -/* If set, this function is called when memory allocation has failed. */ -LT_SCOPE void (*lt__alloc_die) (void); - -LT_SCOPE void *lt__malloc (size_t n); -LT_SCOPE void *lt__zalloc (size_t n); -LT_SCOPE void *lt__realloc (void *mem, size_t n); -LT_SCOPE void *lt__memdup (void const *mem, size_t n); - -LT_SCOPE char *lt__strdup (const char *string); - -LT_END_C_DECLS - -#endif /*!defined(LT__ALLOC_H)*/ diff --git a/libltdl/libltdl/lt__dirent.h b/libltdl/libltdl/lt__dirent.h deleted file mode 100644 index 4f24f82..0000000 --- a/libltdl/libltdl/lt__dirent.h +++ /dev/null @@ -1,87 +0,0 @@ -/* lt__dirent.h -- internal directory entry scanning interface - - Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc. - Written by Bob Friesenhahn, 2001 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if !defined(LT__DIRENT_H) -#define LT__DIRENT_H 1 - -#if defined(LT_CONFIG_H) -# include LT_CONFIG_H -#else -# include -#endif - -#include "lt_system.h" - -#ifdef HAVE_DIRENT_H -/* We have a fully operational dirent subsystem. */ -# include -# define D_NAMLEN(dirent) (strlen((dirent)->d_name)) - -#elif defined __WINDOWS__ -/* Use some wrapper code to emulate dirent on windows.. */ -# define WINDOWS_DIRENT_EMULATION 1 - -# include - -# define D_NAMLEN(dirent) (strlen((dirent)->d_name)) -# define dirent lt__dirent -# define DIR lt__DIR -# define opendir lt__opendir -# define readdir lt__readdir -# define closedir lt__closedir - -LT_BEGIN_C_DECLS - -struct dirent -{ - char d_name[LT_FILENAME_MAX]; - int d_namlen; -}; - -typedef struct -{ - HANDLE hSearch; - WIN32_FIND_DATA Win32FindData; - BOOL firsttime; - struct dirent file_info; -} DIR; - - -LT_SCOPE DIR * opendir (const char *path); -LT_SCOPE struct dirent *readdir (DIR *entry); -LT_SCOPE void closedir (DIR *entry); - -LT_END_C_DECLS - -#else /* !defined(__WINDOWS__)*/ -ERROR - cannot find dirent -#endif /*!defined(__WINDOWS__)*/ - -#endif /*!defined(LT__DIRENT_H)*/ diff --git a/libltdl/libltdl/lt__glibc.h b/libltdl/libltdl/lt__glibc.h deleted file mode 100644 index f284773..0000000 --- a/libltdl/libltdl/lt__glibc.h +++ /dev/null @@ -1,83 +0,0 @@ -/* lt__glibc.h -- support for non glibc environments - - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if !defined(LT__GLIBC_H) -#define LT__GLIBC_H 1 - -#if defined(LT_CONFIG_H) -# include LT_CONFIG_H -#else -# include -#endif - -#if !defined(HAVE_ARGZ_H) || !defined(HAVE_WORKING_ARGZ) -/* Redefine any glibc symbols we reimplement to import the - implementations into our lt__ namespace so we don't ever - clash with the system library if our clients use argz_* - from there in addition to libltdl. */ -# undef argz_append -# define argz_append lt__argz_append -# undef argz_create_sep -# define argz_create_sep lt__argz_create_sep -# undef argz_insert -# define argz_insert lt__argz_insert -# undef argz_next -# define argz_next lt__argz_next -# undef argz_stringify -# define argz_stringify lt__argz_stringify -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef __cplusplus -} -#endif - -# define slist_concat lt__slist_concat -# define slist_cons lt__slist_cons -# define slist_delete lt__slist_delete -# define slist_remove lt__slist_remove -# define slist_reverse lt__slist_reverse -# define slist_sort lt__slist_sort -# define slist_tail lt__slist_tail -# define slist_nth lt__slist_nth -# define slist_find lt__slist_find -# define slist_length lt__slist_length -# define slist_foreach lt__slist_foreach -# define slist_box lt__slist_box -# define slist_unbox lt__slist_unbox - -#include - -#endif /*!defined(LT__GLIBC_H)*/ diff --git a/libltdl/libltdl/lt__private.h b/libltdl/libltdl/lt__private.h deleted file mode 100644 index 4ce936d..0000000 --- a/libltdl/libltdl/lt__private.h +++ /dev/null @@ -1,148 +0,0 @@ -/* lt__private.h -- internal apis for libltdl - - Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy con be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#if !defined(LT__PRIVATE_H) -#define LT__PRIVATE_H 1 - -#if defined(LT_CONFIG_H) -# include LT_CONFIG_H -#else -# include -#endif - -#include -#include -#include -#include -#include - -#if defined(HAVE_UNISTD_H) -# include -#endif - -/* Import internal interfaces... */ -#include "lt__alloc.h" -#include "lt__dirent.h" -#include "lt__strl.h" -#include "lt__glibc.h" - -/* ...and all exported interfaces. */ -#include "ltdl.h" - -#if defined(WITH_DMALLOC) -# include -#endif - -/* DLL building support on win32 hosts; mostly to workaround their - ridiculous implementation of data symbol exporting. */ -#ifndef LT_GLOBAL_DATA -# if defined(__WINDOWS__) || defined(__CYGWIN__) -# if defined(DLL_EXPORT) /* defined by libtool (if required) */ -# define LT_GLOBAL_DATA __declspec(dllexport) -# endif -# endif -# ifndef LT_GLOBAL_DATA -# define LT_GLOBAL_DATA /* static linking or !__WINDOWS__ */ -# endif -#endif - -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ -# define __attribute__(x) -# endif -#endif - -#ifndef LT__UNUSED -# define LT__UNUSED __attribute__ ((__unused__)) -#endif - - -LT_BEGIN_C_DECLS - -#if !defined(errno) -extern int errno; -#endif - -LT_SCOPE void lt__alloc_die_callback (void); - - -/* For readability: */ -#define strneq(s1, s2) (strcmp((s1), (s2)) != 0) -#define streq(s1, s2) (!strcmp((s1), (s2))) - - - -/* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */ - -/* This type is used for the array of interface data sets in each handler. */ -typedef struct { - lt_dlinterface_id key; - void * data; -} lt_interface_data; - -struct lt__handle { - lt_dlhandle next; - const lt_dlvtable * vtable; /* dlopening interface */ - lt_dlinfo info; /* user visible fields */ - int depcount; /* number of dependencies */ - lt_dlhandle * deplibs; /* dependencies */ - lt_module module; /* system module handle */ - void * system; /* system specific data */ - lt_interface_data * interface_data; /* per caller associated data */ - int flags; /* various boolean stats */ -}; - -struct lt__advise { - unsigned int try_ext:1; /* try system library extensions. */ - unsigned int is_resident:1; /* module can't be unloaded. */ - unsigned int is_symglobal:1; /* module symbols can satisfy - subsequently loaded modules. */ - unsigned int is_symlocal:1; /* module symbols are only available - locally. */ -}; - -/* --- ERROR HANDLING --- */ - -/* Extract the diagnostic strings from the error table macro in the same - order as the enumerated indices in lt_error.h. */ - -#define LT__STRERROR(name) lt__error_string(LT_CONC(LT_ERROR_,name)) - -#define LT__GETERROR(lvalue) (lvalue) = lt__get_last_error() -#define LT__SETERRORSTR(errormsg) lt__set_last_error(errormsg) -#define LT__SETERROR(errorcode) LT__SETERRORSTR(LT__STRERROR(errorcode)) - -LT_SCOPE const char *lt__error_string (int errorcode); -LT_SCOPE const char *lt__get_last_error (void); -LT_SCOPE const char *lt__set_last_error (const char *errormsg); - -LT_END_C_DECLS - -#endif /*!defined(LT__PRIVATE_H)*/ diff --git a/libltdl/libltdl/lt__strl.h b/libltdl/libltdl/lt__strl.h deleted file mode 100644 index 5799dc8..0000000 --- a/libltdl/libltdl/lt__strl.h +++ /dev/null @@ -1,53 +0,0 @@ -/* lt__strl.h -- size-bounded string copying and concatenation - - Copyright (C) 2004, 2006 Free Software Foundation, Inc. - Written by Bob Friesenhahn, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#if !defined(LT__STRL_H) -#define LT__STRL_H 1 - -#if defined(LT_CONFIG_H) -# include LT_CONFIG_H -#else -# include -#endif - -#include -#include "lt_system.h" - -#if !defined(HAVE_STRLCAT) -# define strlcat(dst,src,dstsize) lt_strlcat(dst,src,dstsize) -LT_SCOPE size_t lt_strlcat(char *dst, const char *src, const size_t dstsize); -#endif /* !defined(HAVE_STRLCAT) */ - -#if !defined(HAVE_STRLCPY) -# define strlcpy(dst,src,dstsize) lt_strlcpy(dst,src,dstsize) -LT_SCOPE size_t lt_strlcpy(char *dst, const char *src, const size_t dstsize); -#endif /* !defined(HAVE_STRLCPY) */ - -#endif /*!defined(LT__STRL_H)*/ diff --git a/libltdl/libltdl/lt_dlloader.h b/libltdl/libltdl/lt_dlloader.h deleted file mode 100644 index ae131fa..0000000 --- a/libltdl/libltdl/lt_dlloader.h +++ /dev/null @@ -1,90 +0,0 @@ -/* lt_dlloader.h -- dynamic library loader interface - - Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#if !defined(LT_DLLOADER_H) -#define LT_DLLOADER_H 1 - -#include - -LT_BEGIN_C_DECLS - -typedef void * lt_dlloader; -typedef void * lt_module; -typedef void * lt_user_data; -typedef struct lt__advise * lt_dladvise; - -/* Function pointer types for module loader vtable entries: */ -typedef lt_module lt_module_open (lt_user_data data, - const char *filename, - lt_dladvise advise); -typedef int lt_module_close (lt_user_data data, - lt_module module); -typedef void * lt_find_sym (lt_user_data data, lt_module module, - const char *symbolname); -typedef int lt_dlloader_init (lt_user_data data); -typedef int lt_dlloader_exit (lt_user_data data); - -/* Default priority is LT_DLLOADER_PREPEND if none is explicitly given. */ -typedef enum { - LT_DLLOADER_PREPEND = 0, LT_DLLOADER_APPEND -} lt_dlloader_priority; - -/* This structure defines a module loader, as populated by the get_vtable - entry point of each loader. */ -typedef struct { - const char * name; - const char * sym_prefix; - lt_module_open * module_open; - lt_module_close * module_close; - lt_find_sym * find_sym; - lt_dlloader_init * dlloader_init; - lt_dlloader_exit * dlloader_exit; - lt_user_data dlloader_data; - lt_dlloader_priority priority; -} lt_dlvtable; - -LT_SCOPE int lt_dlloader_add (const lt_dlvtable *vtable); -LT_SCOPE lt_dlloader lt_dlloader_next (const lt_dlloader loader); - -LT_SCOPE lt_dlvtable * lt_dlloader_remove (char *name); -LT_SCOPE const lt_dlvtable *lt_dlloader_find (char *name); -LT_SCOPE const lt_dlvtable *lt_dlloader_get (lt_dlloader loader); - - -/* Type of a function to get a loader's vtable: */ -typedef const lt_dlvtable *lt_get_vtable (lt_user_data data); - -#ifdef LT_DEBUG_LOADERS -LT_SCOPE void lt_dlloader_dump (void); -#endif - -LT_END_C_DECLS - -#endif /*!defined(LT_DLLOADER_H)*/ diff --git a/libltdl/libltdl/lt_error.h b/libltdl/libltdl/lt_error.h deleted file mode 100644 index e789b3a..0000000 --- a/libltdl/libltdl/lt_error.h +++ /dev/null @@ -1,85 +0,0 @@ -/* lt_error.h -- error propogation interface - - Copyright (C) 1999, 2000, 2001, 2004, 2007 Free Software Foundation, Inc. - Written by Thomas Tanner, 1999 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* Only include this header file once. */ -#if !defined(LT_ERROR_H) -#define LT_ERROR_H 1 - -#include - -LT_BEGIN_C_DECLS - -/* Defining error strings alongside their symbolic names in a macro in - this way allows us to expand the macro in different contexts with - confidence that the enumeration of symbolic names will map correctly - onto the table of error strings. \0 is appended to the strings to - expilicitely initialize the string terminator. */ -#define lt_dlerror_table \ - LT_ERROR(UNKNOWN, "unknown error\0") \ - LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available\0") \ - LT_ERROR(INVALID_LOADER, "invalid loader\0") \ - LT_ERROR(INIT_LOADER, "loader initialization failed\0") \ - LT_ERROR(REMOVE_LOADER, "loader removal failed\0") \ - LT_ERROR(FILE_NOT_FOUND, "file not found\0") \ - LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found\0") \ - LT_ERROR(NO_SYMBOLS, "no symbols defined\0") \ - LT_ERROR(CANNOT_OPEN, "can't open the module\0") \ - LT_ERROR(CANNOT_CLOSE, "can't close the module\0") \ - LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found\0") \ - LT_ERROR(NO_MEMORY, "not enough memory\0") \ - LT_ERROR(INVALID_HANDLE, "invalid module handle\0") \ - LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow\0") \ - LT_ERROR(INVALID_ERRORCODE, "invalid errorcode\0") \ - LT_ERROR(SHUTDOWN, "library already shutdown\0") \ - LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module\0") \ - LT_ERROR(INVALID_MUTEX_ARGS, "internal error (code withdrawn)\0")\ - LT_ERROR(INVALID_POSITION, "invalid search path insert position\0")\ - LT_ERROR(CONFLICTING_FLAGS, "symbol visibility can be global or local\0") - -/* Enumerate the symbolic error names. */ -enum { -#define LT_ERROR(name, diagnostic) LT_CONC(LT_ERROR_, name), - lt_dlerror_table -#undef LT_ERROR - - LT_ERROR_MAX -}; - -/* Should be max of the error string lengths above (plus one for C++) */ -#define LT_ERROR_LEN_MAX (41) - -/* These functions are only useful from inside custom module loaders. */ -LT_SCOPE int lt_dladderror (const char *diagnostic); -LT_SCOPE int lt_dlseterror (int errorcode); - - -LT_END_C_DECLS - -#endif /*!defined(LT_ERROR_H)*/ diff --git a/libltdl/libltdl/lt_system.h b/libltdl/libltdl/lt_system.h deleted file mode 100644 index dab2ab6..0000000 --- a/libltdl/libltdl/lt_system.h +++ /dev/null @@ -1,154 +0,0 @@ -/* lt_system.h -- system portability abstraction layer - - Copyright (C) 2004, 2007 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#if !defined(LT_SYSTEM_H) -#define LT_SYSTEM_H 1 - -#include -#include -#include - -/* Some systems do not define EXIT_*, even with STDC_HEADERS. */ -#if !defined(EXIT_SUCCESS) -# define EXIT_SUCCESS 0 -#endif -#if !defined(EXIT_FAILURE) -# define EXIT_FAILURE 1 -#endif - -/* Just pick a big number... */ -#define LT_FILENAME_MAX 2048 - - -/* Saves on those hard to debug '\0' typos.... */ -#define LT_EOS_CHAR '\0' - -/* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations, - so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at - the end of C declarations. */ -#if defined(__cplusplus) -# define LT_BEGIN_C_DECLS extern "C" { -# define LT_END_C_DECLS } -#else -# define LT_BEGIN_C_DECLS /* empty */ -# define LT_END_C_DECLS /* empty */ -#endif - -/* LT_STMT_START/END are used to create macros which expand to a - a single compound statement in a portable way. */ -#if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus) -# define LT_STMT_START (void)( -# define LT_STMT_END ) -#else -# if (defined (sun) || defined (__sun__)) -# define LT_STMT_START if (1) -# define LT_STMT_END else (void)0 -# else -# define LT_STMT_START do -# define LT_STMT_END while (0) -# endif -#endif - -/* Canonicalise Windows and Cygwin recognition macros. - To match the values set by recent Cygwin compilers, make sure that if - __CYGWIN__ is defined (after canonicalisation), __WINDOWS__ is NOT! */ -#if defined(__CYGWIN32__) && !defined(__CYGWIN__) -# define __CYGWIN__ __CYGWIN32__ -#endif -#if defined(__CYGWIN__) -# if defined(__WINDOWS__) -# undef __WINDOWS__ -# endif -#elif defined(_WIN32) -# define __WINDOWS__ _WIN32 -#elif defined(WIN32) -# define __WINDOWS__ WIN32 -#endif -#if defined(__CYGWIN__) && defined(__WINDOWS__) -# undef __WINDOWS__ -#endif - - -/* DLL building support on win32 hosts; mostly to workaround their - ridiculous implementation of data symbol exporting. */ -#if !defined(LT_SCOPE) -# if defined(__WINDOWS__) || defined(__CYGWIN__) -# if defined(DLL_EXPORT) /* defined by libtool (if required) */ -# define LT_SCOPE extern __declspec(dllexport) -# endif -# if defined(LIBLTDL_DLL_IMPORT) /* define if linking with this dll */ - /* note: cygwin/mingw compilers can rely instead on auto-import */ -# define LT_SCOPE extern __declspec(dllimport) -# endif -# endif -# if !defined(LT_SCOPE) /* static linking or !__WINDOWS__ */ -# define LT_SCOPE extern -# endif -#endif - -#if defined(__WINDOWS__) -/* LT_DIRSEP_CHAR is accepted *in addition* to '/' as a directory - separator when it is set. */ -# define LT_DIRSEP_CHAR '\\' -# define LT_PATHSEP_CHAR ';' -#else -# define LT_PATHSEP_CHAR ':' -#endif - -#if defined(_MSC_VER) /* Visual Studio */ -# define R_OK 4 -#endif - -/* fopen() mode flags for reading a text file */ -#undef LT_READTEXT_MODE -#if defined(__WINDOWS__) || defined(__CYGWIN__) -# define LT_READTEXT_MODE "rt" -#else -# define LT_READTEXT_MODE "r" -#endif - -/* The extra indirection to the LT__STR and LT__CONC macros is required so - that if the arguments to LT_STR() (or LT_CONC()) are themselves macros, - they will be expanded before being quoted. */ -#ifndef LT_STR -# define LT__STR(arg) #arg -# define LT_STR(arg) LT__STR(arg) -#endif - -#ifndef LT_CONC -# define LT__CONC(a, b) a##b -# define LT_CONC(a, b) LT__CONC(a, b) -#endif -#ifndef LT_CONC3 -# define LT__CONC3(a, b, c) a##b##c -# define LT_CONC3(a, b, c) LT__CONC3(a, b, c) -#endif - -#endif /*!defined(LT_SYSTEM_H)*/ diff --git a/libltdl/libltdl/slist.h b/libltdl/libltdl/slist.h deleted file mode 100644 index e4b7ead..0000000 --- a/libltdl/libltdl/slist.h +++ /dev/null @@ -1,94 +0,0 @@ -/* slist.h -- generalised singly linked lists - - Copyright (C) 2000, 2004 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2000 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* A generalised list. This is deliberately transparent so that you - can make the NEXT field of all your chained data structures first, - and then cast them to `(SList *)' so that they can be manipulated - by this API. - - Alternatively, you can generate raw SList elements using slist_new(), - and put the element data in the USERDATA field. Either way you - get to manage the memory involved by yourself. -*/ - -#if !defined(SLIST_H) -#define SLIST_H 1 - -#if defined(LTDL) -# include -# include -#else -# define LT_SCOPE -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -typedef struct slist { - struct slist *next; /* chain forward pointer*/ - const void *userdata; /* for boxed `SList' item */ -} SList; - -typedef void * SListCallback (SList *item, void *userdata); -typedef int SListCompare (const SList *item1, const SList *item2, - void *userdata); - -LT_SCOPE SList *slist_concat (SList *head, SList *tail); -LT_SCOPE SList *slist_cons (SList *item, SList *slist); - -LT_SCOPE SList *slist_delete (SList *slist, void (*delete_fct) (void *item)); -LT_SCOPE void * slist_remove (SList **phead, SListCallback *find, - void *matchdata); -LT_SCOPE SList *slist_reverse (SList *slist); -LT_SCOPE SList *slist_sort (SList *slist, SListCompare *compare, - void *userdata); - -LT_SCOPE SList *slist_tail (SList *slist); -LT_SCOPE SList *slist_nth (SList *slist, size_t n); -LT_SCOPE void * slist_find (SList *slist, SListCallback *find, - void *matchdata); -LT_SCOPE size_t slist_length (SList *slist); - -LT_SCOPE void * slist_foreach (SList *slist, SListCallback *foreach, - void *userdata); - -LT_SCOPE SList *slist_box (const void *userdata); -LT_SCOPE void * slist_unbox (SList *item); - -#if defined(__cplusplus) -} -#endif - -#if !defined(LTDL) -# undef LT_SCOPE -#endif - -#endif /*!defined(SLIST_H)*/ diff --git a/libltdl/loaders/dld_link.c b/libltdl/loaders/dld_link.c deleted file mode 100644 index 7e882c9..0000000 --- a/libltdl/loaders/dld_link.c +++ /dev/null @@ -1,158 +0,0 @@ -/* loader-dld_link.c -- dynamic linking with dld - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable dld_link_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_dld_link"; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_APPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#if defined(HAVE_DLD_H) -# include -#endif - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - lt_module module = lt__strdup (filename); - - if (dld_link (filename) != 0) - { - LT__SETERROR (CANNOT_OPEN); - FREE (module); - } - - return module; -} - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) -{ - int errors = 0; - - if (dld_unlink_by_file ((char*)(module), 1) != 0) - { - LT__SETERROR (CANNOT_CLOSE); - ++errors; - } - else - { - FREE (module); - } - - return errors; -} - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module LT__UNUSED module, - const char *name) -{ - void *address = dld_get_func (name); - - if (!address) - { - LT__SETERROR (SYMBOL_NOT_FOUND); - } - - return address; -} diff --git a/libltdl/loaders/dlopen.c b/libltdl/loaders/dlopen.c deleted file mode 100644 index b445407..0000000 --- a/libltdl/loaders/dlopen.c +++ /dev/null @@ -1,242 +0,0 @@ -/* loader-dlopen.c -- dynamic linking with dlopen/dlsym - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable dlopen_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_dlopen"; -#if defined(DLSYM_USCORE) - vtable->sym_prefix = "_"; -#endif - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_PREPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#if defined(HAVE_DLFCN_H) -# include -#endif - -#if defined(HAVE_SYS_DL_H) -# include -#endif - - -/* We may have to define LT_LAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#if !defined(LT_LAZY_OR_NOW) -# if defined(RTLD_LAZY) -# define LT_LAZY_OR_NOW RTLD_LAZY -# else -# if defined(DL_LAZY) -# define LT_LAZY_OR_NOW DL_LAZY -# endif -# endif /* !RTLD_LAZY */ -#endif -#if !defined(LT_LAZY_OR_NOW) -# if defined(RTLD_NOW) -# define LT_LAZY_OR_NOW RTLD_NOW -# else -# if defined(DL_NOW) -# define LT_LAZY_OR_NOW DL_NOW -# endif -# endif /* !RTLD_NOW */ -#endif -#if !defined(LT_LAZY_OR_NOW) -# define LT_LAZY_OR_NOW 0 -#endif /* !LT_LAZY_OR_NOW */ - -/* We only support local and global symbols from modules for loaders - that provide such a thing, otherwise the system default is used. */ -#if !defined(RTLD_GLOBAL) -# if defined(DL_GLOBAL) -# define RTLD_GLOBAL DL_GLOBAL -# endif -#endif /* !RTLD_GLOBAL */ -#if !defined(RTLD_LOCAL) -# if defined(DL_LOCAL) -# define RTLD_LOCAL DL_LOCAL -# endif -#endif /* !RTLD_LOCAL */ - -#if defined(HAVE_DLERROR) -# define DLERROR(arg) dlerror () -#else -# define DLERROR(arg) LT__STRERROR (arg) -#endif - -#define DL__SETERROR(errorcode) \ - LT__SETERRORSTR (DLERROR (errorcode)) - - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise advise) -{ - int module_flags = LT_LAZY_OR_NOW; - lt_module module; - - if (advise) - { -#ifdef RTLD_GLOBAL - /* If there is some means of asking for global symbol resolution, - do so. */ - if (advise->is_symglobal) - module_flags |= RTLD_GLOBAL; -#else - /* Otherwise, reset that bit so the caller can tell it wasn't - acted on. */ - advise->is_symglobal = 0; -#endif - -/* And similarly for local only symbol resolution. */ -#ifdef RTLD_LOCAL - if (advise->is_symlocal) - module_flags |= RTLD_LOCAL; -#else - advise->is_symlocal = 0; -#endif - } - - /* On AIX, dlopen(NULL) succeeds but dlsym of symbols fails. - In this case, fail here to let the preopen loader do the job. */ -#ifndef LTDL_DLOPEN_SELF_WORKS - if (!filename) - module = NULL; - else -#endif - module = dlopen (filename, module_flags); - - if (!module) - { - DL__SETERROR (CANNOT_OPEN); - } - - return module; -} - - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) -{ - int errors = 0; - - if (dlclose (module) != 0) - { - DL__SETERROR (CANNOT_CLOSE); - ++errors; - } - - return errors; -} - - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name) -{ - void *address = dlsym (module, name); - - if (!address) - { - DL__SETERROR (SYMBOL_NOT_FOUND); - } - - return address; -} diff --git a/libltdl/loaders/dyld.c b/libltdl/loaders/dyld.c deleted file mode 100644 index b139d6c..0000000 --- a/libltdl/loaders/dyld.c +++ /dev/null @@ -1,511 +0,0 @@ -/* loader-dyld.c -- dynamic linking on darwin and OS X - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Peter O'Gorman, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable dyld_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_init (lt_user_data loader_data); -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_dyld"; - vtable->sym_prefix = "_"; - vtable->dlloader_init = vl_init; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_APPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#if defined(HAVE_MACH_O_DYLD_H) -# if !defined(__APPLE_CC__) && !defined(__MWERKS__) && !defined(__private_extern__) - /* Is this correct? Does it still function properly? */ -# define __private_extern__ extern -# endif -# include -#endif - -#include - -/* We have to put some stuff here that isn't in older dyld.h files */ -#if !defined(ENUM_DYLD_BOOL) -# define ENUM_DYLD_BOOL -# undef FALSE -# undef TRUE - enum DYLD_BOOL { - FALSE, - TRUE - }; -#endif -#if !defined(LC_REQ_DYLD) -# define LC_REQ_DYLD 0x80000000 -#endif -#if !defined(LC_LOAD_WEAK_DYLIB) -# define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) -#endif - -#if !defined(NSADDIMAGE_OPTION_NONE) -# define NSADDIMAGE_OPTION_NONE 0x0 -#endif -#if !defined(NSADDIMAGE_OPTION_RETURN_ON_ERROR) -# define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1 -#endif -#if !defined(NSADDIMAGE_OPTION_WITH_SEARCHING) -# define NSADDIMAGE_OPTION_WITH_SEARCHING 0x2 -#endif -#if !defined(NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED) -# define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4 -#endif -#if !defined(NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME) -# define NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME 0x8 -#endif - -#if !defined(NSLOOKUPSYMBOLINIMAGE_OPTION_BIND) -# define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0 -#endif -#if !defined(NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW) -# define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW 0x1 -#endif -#if !defined(NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY) -# define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_FULLY 0x2 -#endif -#if !defined(NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) -# define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4 -#endif - -#define LT__SYMLOOKUP_OPTS (NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW \ - | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) - -#if defined(__BIG_ENDIAN__) -# define LT__MAGIC MH_MAGIC -#else -# define LT__MAGIC MH_CIGAM -#endif - -#define DYLD__SETMYERROR(errmsg) LT__SETERRORSTR (dylderror (errmsg)) -#define DYLD__SETERROR(errcode) DYLD__SETMYERROR (LT__STRERROR (errcode)) - -typedef struct mach_header mach_header; -typedef struct dylib_command dylib_command; - -static const char *dylderror (const char *errmsg); -static const mach_header *lt__nsmodule_get_header (NSModule module); -static const char *lt__header_get_instnam (const mach_header *mh); -static const mach_header *lt__match_loadedlib (const char *name); -static NSSymbol lt__linkedlib_symbol (const char *symname, const mach_header *mh); - -static const mach_header *(*lt__addimage) (const char *image_name, - unsigned long options) = 0; -static NSSymbol (*lt__image_symbol) (const mach_header *image, - const char *symbolName, - unsigned long options) = 0; -static enum DYLD_BOOL (*lt__image_symbol_p) (const mach_header *image, - const char *symbolName) = 0; -static enum DYLD_BOOL (*lt__module_export) (NSModule module) = 0; - -static int dyld_cannot_close = 0; - - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - -/* A function called through the vtable to initialise this loader. */ -static int -vl_init (lt_user_data loader_data) -{ - int errors = 0; - - if (! dyld_cannot_close) - { - if (!_dyld_present ()) - { - ++errors; - } - else - { - (void) _dyld_func_lookup ("__dyld_NSAddImage", - (unsigned long*) <__addimage); - (void) _dyld_func_lookup ("__dyld_NSLookupSymbolInImage", - (unsigned long*)<__image_symbol); - (void) _dyld_func_lookup ("__dyld_NSIsSymbolNameDefinedInImage", - (unsigned long*) <__image_symbol_p); - (void) _dyld_func_lookup ("__dyld_NSMakePrivateModulePublic", - (unsigned long*) <__module_export); - dyld_cannot_close = lt_dladderror ("can't close a dylib"); - } - } - - return errors; -} - - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - lt_module module = 0; - NSObjectFileImage ofi = 0; - - if (!filename) - { - return (lt_module) -1; - } - - switch (NSCreateObjectFileImageFromFile (filename, &ofi)) - { - case NSObjectFileImageSuccess: - module = NSLinkModule (ofi, filename, NSLINKMODULE_OPTION_RETURN_ON_ERROR - | NSLINKMODULE_OPTION_PRIVATE - | NSLINKMODULE_OPTION_BINDNOW); - NSDestroyObjectFileImage (ofi); - - if (module) - { - lt__module_export (module); - } - break; - - case NSObjectFileImageInappropriateFile: - if (lt__image_symbol_p && lt__image_symbol) - { - module = (lt_module) lt__addimage(filename, - NSADDIMAGE_OPTION_RETURN_ON_ERROR); - } - break; - - case NSObjectFileImageFailure: - case NSObjectFileImageArch: - case NSObjectFileImageFormat: - case NSObjectFileImageAccess: - /*NOWORK*/ - break; - } - - if (!module) - { - DYLD__SETERROR (CANNOT_OPEN); - } - - return module; -} - - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data loader_data, lt_module module) -{ - int errors = 0; - - if (module != (lt_module) -1) - { - const mach_header *mh = (const mach_header *) module; - int flags = 0; - if (mh->magic == LT__MAGIC) - { - lt_dlseterror (dyld_cannot_close); - ++errors; - } - else - { - /* Currently, if a module contains c++ static destructors and it - is unloaded, we get a segfault in atexit(), due to compiler and - dynamic loader differences of opinion, this works around that. */ - if ((const struct section *) NULL != - getsectbynamefromheader (lt__nsmodule_get_header (module), - "__DATA", "__mod_term_func")) - { - flags |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED; - } -#if defined(__ppc__) - flags |= NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES; -#endif - if (!NSUnLinkModule (module, flags)) - { - DYLD__SETERROR (CANNOT_CLOSE); - ++errors; - } - } - } - - return errors; -} - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data loader_data, lt_module module, const char *name) -{ - NSSymbol *nssym = 0; - const mach_header *mh = (const mach_header *) module; - char saveError[256] = "Symbol not found"; - - if (module == (lt_module) -1) - { - void *address, *unused; - _dyld_lookup_and_bind (name, (unsigned long*) &address, &unused); - return address; - } - - if (mh->magic == LT__MAGIC) - { - if (lt__image_symbol_p && lt__image_symbol) - { - if (lt__image_symbol_p (mh, name)) - { - nssym = lt__image_symbol (mh, name, LT__SYMLOOKUP_OPTS); - } - } - - } - else - { - nssym = NSLookupSymbolInModule (module, name); - } - - if (!nssym) - { - strncpy (saveError, dylderror (LT__STRERROR (SYMBOL_NOT_FOUND)), 255); - saveError[255] = 0; - if (!mh) - { - mh = (mach_header *)lt__nsmodule_get_header (module); - } - nssym = lt__linkedlib_symbol (name, mh); - } - - if (!nssym) - { - LT__SETERRORSTR (saveError); - } - - return nssym ? NSAddressOfSymbol (nssym) : 0; -} - - - - -/* --- HELPER FUNCTIONS --- */ - - -/* Return the dyld error string, or the passed in error string if none. */ -static const char * -dylderror (const char *errmsg) -{ - NSLinkEditErrors ler; - int lerno; - const char *file; - const char *errstr; - - NSLinkEditError (&ler, &lerno, &file, &errstr); - - if (! (errstr && *errstr)) - { - errstr = errmsg; - } - - return errstr; -} - -/* There should probably be an apple dyld api for this. */ -static const mach_header * -lt__nsmodule_get_header (NSModule module) -{ - int i = _dyld_image_count(); - const char *modname = NSNameOfModule (module); - const mach_header *mh = 0; - - if (!modname) - return NULL; - - while (i > 0) - { - --i; - if (strneq (_dyld_get_image_name (i), modname)) - { - mh = _dyld_get_image_header (i); - break; - } - } - - return mh; -} - -/* NSAddImage is also used to get the loaded image, but it only works if - the lib is installed, for uninstalled libs we need to check the - install_names against each other. Note that this is still broken if - DYLD_IMAGE_SUFFIX is set and a different lib was loaded as a result. */ -static const char * -lt__header_get_instnam (const mach_header *mh) -{ - unsigned long offset = sizeof(mach_header); - const char* result = 0; - int j; - - for (j = 0; j < mh->ncmds; j++) - { - struct load_command *lc; - - lc = (struct load_command*) (((unsigned long) mh) + offset); - if (LC_ID_DYLIB == lc->cmd) - { - result=(char*)(((dylib_command*) lc)->dylib.name.offset + - (unsigned long) lc); - } - offset += lc->cmdsize; - } - - return result; -} - -static const mach_header * -lt__match_loadedlib (const char *name) -{ - const mach_header *mh = 0; - int i = _dyld_image_count(); - - while (i > 0) - { - const char *id; - - --i; - id = lt__header_get_instnam (_dyld_get_image_header (i)); - if (id && strneq (id, name)) - { - mh = _dyld_get_image_header (i); - break; - } - } - - return mh; -} - -/* Safe to assume our mh is good. */ -static NSSymbol -lt__linkedlib_symbol (const char *symname, const mach_header *mh) -{ - NSSymbol symbol = 0; - - if (lt__image_symbol && NSIsSymbolNameDefined (symname)) - { - unsigned long offset = sizeof(mach_header); - struct load_command *lc; - int j; - - for (j = 0; j < mh->ncmds; j++) - { - lc = (struct load_command*) (((unsigned long) mh) + offset); - if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd)) - { - unsigned long base = ((dylib_command *) lc)->dylib.name.offset; - char *name = (char *) (base + (unsigned long) lc); - const mach_header *mh1 = lt__match_loadedlib (name); - - if (!mh1) - { - /* Maybe NSAddImage can find it */ - mh1 = lt__addimage (name, - NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED - | NSADDIMAGE_OPTION_WITH_SEARCHING - | NSADDIMAGE_OPTION_RETURN_ON_ERROR); - } - - if (mh1) - { - symbol = lt__image_symbol (mh1, symname, LT__SYMLOOKUP_OPTS); - if (symbol) - break; - } - } - - offset += lc->cmdsize; - } - } - - return symbol; -} diff --git a/libltdl/loaders/load_add_on.c b/libltdl/loaders/load_add_on.c deleted file mode 100644 index 379f9ba..0000000 --- a/libltdl/loaders/load_add_on.c +++ /dev/null @@ -1,167 +0,0 @@ -/* loader-load_add_on.c -- dynamic linking for BeOS - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable load_add_on_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_load_add_on"; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_APPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#include - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - image_id image = 0; - - if (filename) - { - image = load_add_on (filename); - } - else - { - image_info info; - int32 cookie = 0; - if (get_next_image_info (0, &cookie, &info) == B_OK) - image = load_add_on (info.name); - } - - if (image <= 0) - { - LT__SETERROR (CANNOT_OPEN); - image = 0; - } - - return (lt_module) image; -} - - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) -{ - int errors = 0; - - if (unload_add_on ((image_id) module) != B_OK) - { - LT__SETERROR (CANNOT_CLOSE); - ++errors; - } - - return errors; -} - - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name) -{ - void *address = 0; - image_id image = (image_id) module; - - if (get_image_symbol (image, name, B_SYMBOL_TYPE_ANY, address) != B_OK) - { - LT__SETERROR (SYMBOL_NOT_FOUND); - address = 0; - } - - return address; -} diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c deleted file mode 100644 index 5644676..0000000 --- a/libltdl/loaders/loadlibrary.c +++ /dev/null @@ -1,251 +0,0 @@ -/* loader-loadlibrary.c -- dynamic linking for Win32 - - Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -#if defined(__CYGWIN__) -# include -#endif - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable loadlibrary_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlinterface_id iface_id = 0; -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable); - iface_id = lt_dlinterface_register ("ltdl loadlibrary", NULL); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_loadlibrary"; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_APPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#include - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - lt_module module = 0; - char *ext; - char wpath[MAX_PATH]; - size_t len; - - if (!filename) - { - /* Get the name of main module */ - *wpath = 0; - GetModuleFileName (NULL, wpath, sizeof (wpath)); - filename = wpath; - } - else - { - len = LT_STRLEN (filename); - - if (len >= MAX_PATH) - { - LT__SETERROR (CANNOT_OPEN); - return 0; - } - -#if HAVE_DECL_CYGWIN_CONV_PATH - if (cygwin_conv_path (CCP_POSIX_TO_WIN_A, filename, wpath, MAX_PATH)) - { - LT__SETERROR (CANNOT_OPEN); - return 0; - } - len = 0; -#elif defined(__CYGWIN__) - cygwin_conv_to_full_win32_path (filename, wpath); - len = 0; -#else - strcpy(wpath, filename); -#endif - - ext = strrchr (wpath, '.'); - if (!ext) - { - /* Append a `.' to stop Windows from adding an - implicit `.dll' extension. */ - if (!len) - len = LT_STRLEN (wpath); - - if (len + 1 >= MAX_PATH) - { - LT__SETERROR (CANNOT_OPEN); - return 0; - } - - wpath[len] = '.'; - wpath[len+1] = '\0'; - } - } - - { - /* Silence dialog from LoadLibrary on some failures. - No way to get the error mode, but to set it, - so set it twice to preserve any previous flags. */ - UINT errormode = SetErrorMode(SEM_FAILCRITICALERRORS); - SetErrorMode(errormode | SEM_FAILCRITICALERRORS); - - module = LoadLibrary (wpath); - - /* Restore the error mode. */ - SetErrorMode(errormode); - } - - /* libltdl expects this function to fail if it is unable - to physically load the library. Sadly, LoadLibrary - will search the loaded libraries for a match and return - one of them if the path search load fails. - - We check whether LoadLibrary is returning a handle to - an already loaded module, and simulate failure if we - find one. */ - { - lt_dlhandle cur = 0; - - while ((cur = lt_dlhandle_iterate (iface_id, cur))) - { - if (!cur->module) - { - cur = 0; - break; - } - - if (cur->module == module) - { - break; - } - } - - if (cur || !module) - { - LT__SETERROR (CANNOT_OPEN); - module = 0; - } - } - - return module; -} - - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) -{ - int errors = 0; - - if (FreeLibrary((HMODULE) module) == 0) - { - LT__SETERROR (CANNOT_CLOSE); - ++errors; - } - - return errors; -} - - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name) -{ - void *address = (void *) GetProcAddress ((HMODULE) module, name); - - if (!address) - { - LT__SETERROR (SYMBOL_NOT_FOUND); - } - - return address; -} diff --git a/libltdl/loaders/preopen.c b/libltdl/loaders/preopen.c deleted file mode 100644 index 7149287..0000000 --- a/libltdl/loaders/preopen.c +++ /dev/null @@ -1,375 +0,0 @@ -/* loader-preopen.c -- emulate dynamic linking using preloaded_symbols - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable preopen_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_init (lt_user_data loader_data); -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = (lt_dlvtable *) lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_preopen"; - vtable->sym_prefix = 0; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_init = vl_init; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_PREPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -/* Wrapper type to chain together symbol lists of various origins. */ -typedef struct symlist_chain -{ - struct symlist_chain *next; - const lt_dlsymlist *symlist; -} symlist_chain; - - -static int add_symlist (const lt_dlsymlist *symlist); -static int free_symlists (void); - -/* The start of the symbol lists chain. */ -static symlist_chain *preloaded_symlists = 0; - -/* A symbol list preloaded before lt_init() was called. */ -static const lt_dlsymlist *default_preloaded_symbols = 0; - - -/* A function called through the vtable to initialise this loader. */ -static int -vl_init (lt_user_data LT__UNUSED loader_data) -{ - int errors = 0; - - preloaded_symlists = 0; - if (default_preloaded_symbols) - { - errors = lt_dlpreload (default_preloaded_symbols); - } - - return errors; -} - - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - free_symlists (); - return 0; -} - - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - symlist_chain *lists; - lt_module module = 0; - - if (!preloaded_symlists) - { - LT__SETERROR (NO_SYMBOLS); - goto done; - } - - /* Can't use NULL as the reflective symbol header, as NULL is - used to mark the end of the entire symbol list. Self-dlpreopened - symbols follow this magic number, chosen to be an unlikely - clash with a real module name. */ - if (!filename) - { - filename = "@PROGRAM@"; - } - - for (lists = preloaded_symlists; lists; lists = lists->next) - { - const lt_dlsymlist *symbol; - for (symbol= lists->symlist; symbol->name; ++symbol) - { - if (!symbol->address && streq (symbol->name, filename)) - { - /* If the next symbol's name and address is 0, it means - the module just contains the originator and no symbols. - In this case we pretend that we never saw the module and - hope that some other loader will be able to load the module - and have access to its symbols */ - const lt_dlsymlist *next_symbol = symbol +1; - if (next_symbol->address && next_symbol->name) - { - module = (lt_module) lists->symlist; - goto done; - } - } - } - } - - LT__SETERROR (FILE_NOT_FOUND); - - done: - return module; -} - - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module LT__UNUSED module) -{ - /* Just to silence gcc -Wall */ - module = 0; - return 0; -} - - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name) -{ - lt_dlsymlist *symbol = (lt_dlsymlist*) module; - - symbol +=2; /* Skip header (originator then libname). */ - - while (symbol->name) - { - if (streq (symbol->name, name)) - { - return symbol->address; - } - - ++symbol; - } - - LT__SETERROR (SYMBOL_NOT_FOUND); - - return 0; -} - - - -/* --- HELPER FUNCTIONS --- */ - - -/* The symbol lists themselves are not allocated from the heap, but - we can unhook them and free up the chain of links between them. */ -static int -free_symlists (void) -{ - symlist_chain *lists; - - lists = preloaded_symlists; - while (lists) - { - symlist_chain *next = lists->next; - FREE (lists); - lists = next; - } - preloaded_symlists = 0; - - return 0; -} - -/* Add a new symbol list to the global chain. */ -static int -add_symlist (const lt_dlsymlist *symlist) -{ - symlist_chain *lists; - int errors = 0; - - /* Search for duplicate entries: */ - for (lists = preloaded_symlists; - lists && lists->symlist != symlist; lists = lists->next) - /*NOWORK*/; - - /* Don't add the same list twice: */ - if (!lists) - { - symlist_chain *tmp = (symlist_chain *) lt__zalloc (sizeof *tmp); - - if (tmp) - { - tmp->symlist = symlist; - tmp->next = preloaded_symlists; - preloaded_symlists = tmp; - } - else - { - ++errors; - } - } - - return errors; -} - - - -/* --- PRELOADING API CALL IMPLEMENTATIONS --- */ - - -/* Save a default symbol list for later. */ -int -lt_dlpreload_default (const lt_dlsymlist *preloaded) -{ - default_preloaded_symbols = preloaded; - return 0; -} - - -/* Add a symbol list to the global chain, or with a NULL argument, - revert to just the default list. */ -int -lt_dlpreload (const lt_dlsymlist *preloaded) -{ - int errors = 0; - - if (preloaded) - { - errors = add_symlist (preloaded); - } - else - { - free_symlists(); - - if (default_preloaded_symbols) - { - errors = lt_dlpreload (default_preloaded_symbols); - } - } - - return errors; -} - - -/* Open all the preloaded modules from the named originator, executing - a callback for each one. If ORIGINATOR is NULL, then call FUNC for - each preloaded module from the program itself. */ -int -lt_dlpreload_open (const char *originator, lt_dlpreload_callback_func *func) -{ - symlist_chain *list; - int errors = 0; - int found = 0; - - /* For each symlist in the chain... */ - for (list = preloaded_symlists; list; list = list->next) - { - /* ...that was preloaded by the requesting ORIGINATOR... */ - if ((originator && streq (list->symlist->name, originator)) - || (!originator && streq (list->symlist->name, "@PROGRAM@"))) - { - const lt_dlsymlist *symbol; - unsigned int idx = 0; - - ++found; - - /* ...load the symbols per source compilation unit: - (we preincrement the index to skip over the originator entry) */ - while ((symbol = &list->symlist[++idx])->name != 0) - { - if ((symbol->address == 0) - && (strneq (symbol->name, "@PROGRAM@"))) - { - lt_dlhandle handle = lt_dlopen (symbol->name); - if (handle == 0) - { - ++errors; - } - else - { - errors += (*func) (handle); - } - } - } - } - } - - if (!found) - { - LT__SETERROR(CANNOT_OPEN); - ++errors; - } - - return errors; -} diff --git a/libltdl/loaders/shl_load.c b/libltdl/loaders/shl_load.c deleted file mode 100644 index 5a09d87..0000000 --- a/libltdl/loaders/shl_load.c +++ /dev/null @@ -1,222 +0,0 @@ -/* loader-shl_load.c -- dynamic linking with shl_load (HP-UX) - - Copyright (C) 1998, 1999, 2000, 2004, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -/* Use the preprocessor to rename non-static symbols to avoid namespace - collisions when the loader code is statically linked into libltdl. - Use the "_LTX_" prefix so that the symbol addresses can - be fetched from the preloaded symbol list by lt_dlsym(): */ -#define get_vtable shl_load_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS - - -/* Boilerplate code to set up the vtable for hooking this loader into - libltdl's loader list: */ -static int vl_exit (lt_user_data loader_data); -static lt_module vm_open (lt_user_data loader_data, const char *filename, - lt_dladvise advise); -static int vm_close (lt_user_data loader_data, lt_module module); -static void * vm_sym (lt_user_data loader_data, lt_module module, - const char *symbolname); - -static lt_dlvtable *vtable = 0; - -/* Return the vtable for this loader, only the name and sym_prefix - attributes (plus the virtual function implementations, obviously) - change between loaders. */ -lt_dlvtable * -get_vtable (lt_user_data loader_data) -{ - if (!vtable) - { - vtable = lt__zalloc (sizeof *vtable); - } - - if (vtable && !vtable->name) - { - vtable->name = "lt_shl_load"; - vtable->module_open = vm_open; - vtable->module_close = vm_close; - vtable->find_sym = vm_sym; - vtable->dlloader_exit = vl_exit; - vtable->dlloader_data = loader_data; - vtable->priority = LT_DLLOADER_APPEND; - } - - if (vtable && (vtable->dlloader_data != loader_data)) - { - LT__SETERROR (INIT_LOADER); - return 0; - } - - return vtable; -} - - - -/* --- IMPLEMENTATION --- */ - - -#if defined(HAVE_DL_H) -# include -#endif - -/* some flags are missing on some systems, so we provide - * harmless defaults. - * - * Mandatory: - * BIND_IMMEDIATE - Resolve symbol references when the library is loaded. - * BIND_DEFERRED - Delay code symbol resolution until actual reference. - * - * Optionally: - * BIND_FIRST - Place the library at the head of the symbol search - * order. - * BIND_NONFATAL - The default BIND_IMMEDIATE behavior is to treat all - * unsatisfied symbols as fatal. This flag allows - * binding of unsatisfied code symbols to be deferred - * until use. - * [Perl: For certain libraries, like DCE, deferred - * binding often causes run time problems. Adding - * BIND_NONFATAL to BIND_IMMEDIATE still allows - * unresolved references in situations like this.] - * BIND_NOSTART - Do not call the initializer for the shared library - * when the library is loaded, nor on a future call to - * shl_unload(). - * BIND_VERBOSE - Print verbose messages concerning possible - * unsatisfied symbols. - * - * hp9000s700/hp9000s800: - * BIND_RESTRICTED - Restrict symbols visible by the library to those - * present at library load time. - * DYNAMIC_PATH - Allow the loader to dynamically search for the - * library specified by the path argument. - */ - -#if !defined(DYNAMIC_PATH) -# define DYNAMIC_PATH 0 -#endif -#if !defined(BIND_RESTRICTED) -# define BIND_RESTRICTED 0 -#endif - -#define LT_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | DYNAMIC_PATH) - - -/* A function called through the vtable when this loader is no - longer needed by the application. */ -static int -vl_exit (lt_user_data LT__UNUSED loader_data) -{ - vtable = NULL; - return 0; -} - -/* A function called through the vtable to open a module with this - loader. Returns an opaque representation of the newly opened - module for processing with this loader's other vtable functions. */ -static lt_module -vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, - lt_dladvise LT__UNUSED advise) -{ - static shl_t self = (shl_t) 0; - lt_module module = shl_load (filename, LT_BIND_FLAGS, 0L); - - /* Since searching for a symbol against a NULL module handle will also - look in everything else that was already loaded and exported with - the -E compiler flag, we always cache a handle saved before any - modules are loaded. */ - if (!self) - { - void *address; - shl_findsym (&self, "main", TYPE_UNDEFINED, &address); - } - - if (!filename) - { - module = self; - } - else - { - module = shl_load (filename, LT_BIND_FLAGS, 0L); - - if (!module) - { - LT__SETERROR (CANNOT_OPEN); - } - } - - return module; -} - -/* A function called through the vtable when a particular module - should be unloaded. */ -static int -vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) -{ - int errors = 0; - - if (module && (shl_unload ((shl_t) (module)) != 0)) - { - LT__SETERROR (CANNOT_CLOSE); - ++errors; - } - - return errors; -} - - -/* A function called through the vtable to get the address of - a symbol loaded from a particular module. */ -static void * -vm_sym (lt_user_data LT__UNUSED loader_data, lt_module module, const char *name) -{ - void *address = 0; - - /* sys_shl_open should never return a NULL module handle */ - if (module == (lt_module) 0) - { - LT__SETERROR (INVALID_HANDLE); - } - else if (!shl_findsym((shl_t*) &module, name, TYPE_UNDEFINED, &address)) - { - if (!address) - { - LT__SETERROR (SYMBOL_NOT_FOUND); - } - } - - return address; -} diff --git a/libltdl/lt__alloc.c b/libltdl/lt__alloc.c deleted file mode 100644 index d39e17e..0000000 --- a/libltdl/lt__alloc.c +++ /dev/null @@ -1,95 +0,0 @@ -/* lt__alloc.c -- internal memory management interface - - Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" - -#include - -#include "lt__alloc.h" - -static void alloc_die_default (void); - -void (*lt__alloc_die) (void) = alloc_die_default; - -/* Unless overridden, exit on memory failure. */ -static void -alloc_die_default (void) -{ - fprintf (stderr, "Out of memory.\n"); - exit (EXIT_FAILURE); -} - -void * -lt__malloc (size_t n) -{ - void *mem; - - if (! (mem = malloc (n))) - (*lt__alloc_die) (); - - return mem; -} - -void * -lt__zalloc (size_t n) -{ - void *mem; - - if ((mem = lt__malloc (n))) - memset (mem, 0, n); - - return mem; -} - -void * -lt__realloc (void *mem, size_t n) -{ - if (! (mem = realloc (mem, n))) - (*lt__alloc_die) (); - - return mem; -} - -void * -lt__memdup (void const *mem, size_t n) -{ - void *newmem; - - if ((newmem = lt__malloc (n))) - return memcpy (newmem, mem, n); - - return 0; -} - -char * -lt__strdup (const char *string) -{ - return (char *) lt__memdup (string, strlen (string) +1); -} diff --git a/libltdl/lt__dirent.c b/libltdl/lt__dirent.c deleted file mode 100644 index 30dc072..0000000 --- a/libltdl/lt__dirent.c +++ /dev/null @@ -1,107 +0,0 @@ -/* lt__dirent.c -- internal directory entry scanning interface - - Copyright (C) 2001, 2004 Free Software Foundation, Inc. - Written by Bob Friesenhahn, 2001 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" - -#include -#include - -#include "lt__dirent.h" - -#if defined(__WINDOWS__) - -void -closedir (DIR *entry) -{ - assert (entry != (DIR *) NULL); - FindClose (entry->hSearch); - free ((void *) entry); -} - - -DIR * -opendir (const char *path) -{ - char file_spec[LT_FILENAME_MAX]; - DIR *entry; - - assert (path != (char *) 0); - if (lt_strlcpy (file_spec, path, sizeof file_spec) >= sizeof file_spec - || lt_strlcat (file_spec, "\\", sizeof file_spec) >= sizeof file_spec) - return (DIR *) 0; - entry = (DIR *) malloc (sizeof(DIR)); - if (entry != (DIR *) 0) - { - entry->firsttime = TRUE; - entry->hSearch = FindFirstFile (file_spec, &entry->Win32FindData); - - if (entry->hSearch == INVALID_HANDLE_VALUE) - { - if (lt_strlcat (file_spec, "\\*.*", sizeof file_spec) < sizeof file_spec) - { - entry->hSearch = FindFirstFile (file_spec, &entry->Win32FindData); - } - - if (entry->hSearch == INVALID_HANDLE_VALUE) - { - entry = (free (entry), (DIR *) 0); - } - } - } - - return entry; -} - - -struct dirent * -readdir (DIR *entry) -{ - int status; - - if (entry == (DIR *) 0) - return (struct dirent *) 0; - - if (!entry->firsttime) - { - status = FindNextFile (entry->hSearch, &entry->Win32FindData); - if (status == 0) - return (struct dirent *) 0; - } - - entry->firsttime = FALSE; - if (lt_strlcpy (entry->file_info.d_name, entry->Win32FindData.cFileName, - sizeof entry->file_info.d_name) >= sizeof entry->file_info.d_name) - return (struct dirent *) 0; - entry->file_info.d_namlen = strlen (entry->file_info.d_name); - - return &entry->file_info; -} - -#endif /*defined(__WINDOWS__)*/ diff --git a/libltdl/lt__strl.c b/libltdl/lt__strl.c deleted file mode 100644 index c2cee58..0000000 --- a/libltdl/lt__strl.c +++ /dev/null @@ -1,127 +0,0 @@ -/* lt__strl.c -- size-bounded string copying and concatenation - - Copyright (C) 2004 Free Software Foundation, Inc. - Written by Bob Friesenhahn, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include "lt__strl.h" - -/* - lt_strlcat appends the NULL-terminated string src to the end of dst. - It will append at most dstsize - strlen(dst) - 1 bytes, - NULL-terminating the result. The total length of the string which - would have been created given sufficient buffer size (may be longer - than dstsize) is returned. This function substitutes for strlcat() - which is available under NetBSD, FreeBSD and Solaris 9. - - Buffer overflow can be checked as follows: - - if (lt_strlcat(dst, src, dstsize) >= dstsize) - return -1; -*/ -#if !defined(HAVE_STRLCAT) -size_t -lt_strlcat(char *dst, const char *src, const size_t dstsize) -{ - size_t length; - char *p; - const char *q; - - assert(dst != NULL); - assert(src != (const char *) NULL); - assert(dstsize >= 1); - - length=strlen(dst); - - /* - Copy remaining characters from src while constraining length to - size - 1. - */ - for ( p = dst + length, q = src; - (*q != 0) && (length < dstsize - 1) ; - length++, p++, q++ ) - *p = *q; - - dst[length]='\0'; - - /* - Add remaining length of src to length. - */ - while (*q++) - length++; - - return length; -} -#endif /* !defined(HAVE_STRLCAT) */ - -/* - lt_strlcpy copies up to dstsize - 1 characters from the NULL-terminated - string src to dst, NULL-terminating the result. The total length of - the string which would have been created given sufficient buffer - size (may be longer than dstsize) is returned. This function - substitutes for strlcpy() which is available under OpenBSD, FreeBSD - and Solaris 9. - - Buffer overflow can be checked as follows: - - if (lt_strlcpy(dst, src, dstsize) >= dstsize) - return -1; -*/ -#if !defined(HAVE_STRLCPY) -size_t -lt_strlcpy(char *dst, const char *src, const size_t dstsize) -{ - size_t length=0; - char *p; - const char *q; - - assert(dst != NULL); - assert(src != (const char *) NULL); - assert(dstsize >= 1); - - /* - Copy src to dst within bounds of size-1. - */ - for ( p=dst, q=src, length=0 ; - (*q != 0) && (length < dstsize-1) ; - length++, p++, q++ ) - *p = *q; - - dst[length]='\0'; - - /* - Add remaining length of src to length. - */ - while (*q++) - length++; - - return length; -} -#endif /* !defined(HAVE_STRLCPY) */ diff --git a/libltdl/lt_dlloader.c b/libltdl/lt_dlloader.c deleted file mode 100644 index 4e66a6c..0000000 --- a/libltdl/lt_dlloader.c +++ /dev/null @@ -1,210 +0,0 @@ -/* lt_dlloader.c -- dynamic library loader interface - - Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2004 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_dlloader.h" - -#define RETURN_SUCCESS 0 -#define RETURN_FAILURE 1 - -static void * loader_callback (SList *item, void *userdata); - -/* A list of all the dlloaders we know about, each stored as a boxed - SList item: */ -static SList *loaders = 0; - - -/* Return NULL, unless the loader in this ITEM has a matching name, - in which case we return the matching item so that its address is - passed back out (for possible freeing) by slist_remove. */ -static void * -loader_callback (SList *item, void *userdata) -{ - const lt_dlvtable *vtable = (const lt_dlvtable *) item->userdata; - const char * name = (const char *) userdata; - - assert (vtable); - - return streq (vtable->name, name) ? (void *) item : NULL; -} - - -/* Hook VTABLE into our global LOADERS list according to its own - PRIORITY field value. */ -int -lt_dlloader_add (const lt_dlvtable *vtable) -{ - SList *item; - - if ((vtable == 0) /* diagnose invalid vtable fields */ - || (vtable->module_open == 0) - || (vtable->module_close == 0) - || (vtable->find_sym == 0) - || ((vtable->priority != LT_DLLOADER_PREPEND) && - (vtable->priority != LT_DLLOADER_APPEND))) - { - LT__SETERROR (INVALID_LOADER); - return RETURN_FAILURE; - } - - item = slist_box (vtable); - if (!item) - { - (*lt__alloc_die) (); - - /* Let the caller know something went wrong if lt__alloc_die - doesn't abort. */ - return RETURN_FAILURE; - } - - if (vtable->priority == LT_DLLOADER_PREPEND) - { - loaders = slist_cons (item, loaders); - } - else - { - assert (vtable->priority == LT_DLLOADER_APPEND); - loaders = slist_concat (loaders, item); - } - - return RETURN_SUCCESS; -} - -#ifdef LT_DEBUG_LOADERS -static void * -loader_dump_callback (SList *item, void *userdata) -{ - const lt_dlvtable *vtable = (const lt_dlvtable *) item->userdata; - fprintf (stderr, ", %s", (vtable && vtable->name) ? vtable->name : "(null)"); - return 0; -} - -void -lt_dlloader_dump (void) -{ - fprintf (stderr, "loaders: "); - if (!loaders) - { - fprintf (stderr, "(empty)"); - } - else - { - const lt_dlvtable *head = (const lt_dlvtable *) loaders->userdata; - fprintf (stderr, "%s", (head && head->name) ? head->name : "(null)"); - if (slist_tail (loaders)) - slist_foreach (slist_tail (loaders), loader_dump_callback, NULL); - } - fprintf (stderr, "\n"); -} -#endif - -/* An iterator for the global loader list: if LOADER is NULL, then - return the first element, otherwise the following element. */ -lt_dlloader -lt_dlloader_next (lt_dlloader loader) -{ - SList *item = (SList *) loader; - return (lt_dlloader) (item ? item->next : loaders); -} - - -/* Non-destructive unboxing of a loader. */ -const lt_dlvtable * -lt_dlloader_get (lt_dlloader loader) -{ - return (const lt_dlvtable *) (loader ? ((SList *) loader)->userdata : NULL); -} - - -/* Return the contents of the first item in the global loader list - with a matching NAME after removing it from that list. If there - was no match, return NULL; if there is an error, return NULL and - set an error for lt_dlerror; do not set an error if only resident - modules need this loader; in either case, the loader list is not - changed if NULL is returned. */ -lt_dlvtable * -lt_dlloader_remove (char *name) -{ - const lt_dlvtable * vtable = lt_dlloader_find (name); - static const char id_string[] = "lt_dlloader_remove"; - lt_dlinterface_id iface; - lt_dlhandle handle = 0; - int in_use = 0; - int in_use_by_resident = 0; - - if (!vtable) - { - LT__SETERROR (INVALID_LOADER); - return 0; - } - - /* Fail if there are any open modules which use this loader. */ - iface = lt_dlinterface_register (id_string, NULL); - while ((handle = lt_dlhandle_iterate (iface, handle))) - { - lt_dlhandle cur = handle; - if (cur->vtable == vtable) - { - in_use = 1; - if (lt_dlisresident (handle)) - in_use_by_resident = 1; - } - } - lt_dlinterface_free (iface); - if (in_use) - { - if (!in_use_by_resident) - LT__SETERROR (REMOVE_LOADER); - return 0; - } - - /* Call the loader finalisation function. */ - if (vtable && vtable->dlloader_exit) - { - if ((*vtable->dlloader_exit) (vtable->dlloader_data) != 0) - { - /* If there is an exit function, and it returns non-zero - then it must set an error, and we will not remove it - from the list. */ - return 0; - } - } - - /* If we got this far, remove the loader from our global list. */ - return (lt_dlvtable *) - slist_unbox ((SList *) slist_remove (&loaders, loader_callback, name)); -} - - -const lt_dlvtable * -lt_dlloader_find (char *name) -{ - return lt_dlloader_get (slist_find (loaders, loader_callback, name)); -} diff --git a/libltdl/lt_error.c b/libltdl/lt_error.c deleted file mode 100644 index d7af36d..0000000 --- a/libltdl/lt_error.c +++ /dev/null @@ -1,110 +0,0 @@ -/* lt_error.c -- error propogation interface - - Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc. - Written by Thomas Tanner, 1999 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_error.h" - -static const char *last_error = 0; -static const char error_strings[LT_ERROR_MAX][LT_ERROR_LEN_MAX + 1] = - { -#define LT_ERROR(name, diagnostic) diagnostic, - lt_dlerror_table -#undef LT_ERROR - }; - -static const char **user_error_strings = 0; -static int errorcount = LT_ERROR_MAX; - -int -lt_dladderror (const char *diagnostic) -{ - int errindex = 0; - int result = -1; - const char **temp = (const char **) 0; - - assert (diagnostic); - - errindex = errorcount - LT_ERROR_MAX; - temp = REALLOC (const char *, user_error_strings, 1 + errindex); - if (temp) - { - user_error_strings = temp; - user_error_strings[errindex] = diagnostic; - result = errorcount++; - } - - return result; -} - -int -lt_dlseterror (int errindex) -{ - int errors = 0; - - if (errindex >= errorcount || errindex < 0) - { - /* Ack! Error setting the error message! */ - LT__SETERROR (INVALID_ERRORCODE); - ++errors; - } - else if (errindex < LT_ERROR_MAX) - { - /* No error setting the error message! */ - LT__SETERRORSTR (error_strings[errindex]); - } - else - { - /* No error setting the error message! */ - LT__SETERRORSTR (user_error_strings[errindex - LT_ERROR_MAX]); - } - - return errors; -} - -const char * -lt__error_string (int errorcode) -{ - assert (errorcode >= 0); - assert (errorcode < LT_ERROR_MAX); - - return error_strings[errorcode]; -} - -const char * -lt__get_last_error (void) -{ - return last_error; -} - -const char * -lt__set_last_error (const char *errormsg) -{ - return last_error = errormsg; -} diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c deleted file mode 100644 index a89c6bb..0000000 --- a/libltdl/ltdl.c +++ /dev/null @@ -1,2392 +0,0 @@ -/* ltdl.c -- system independent dlopen wrapper - - Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "lt__private.h" -#include "lt_system.h" -#include "lt_dlloader.h" - - -/* --- MANIFEST CONSTANTS --- */ - - -/* Standard libltdl search path environment variable name */ -#undef LTDL_SEARCHPATH_VAR -#define LTDL_SEARCHPATH_VAR "LTDL_LIBRARY_PATH" - -/* Standard libtool archive file extension. */ -#undef LT_ARCHIVE_EXT -#define LT_ARCHIVE_EXT ".la" - -/* max. filename length */ -#if !defined(LT_FILENAME_MAX) -# define LT_FILENAME_MAX 1024 -#endif - -/* This is the maximum symbol size that won't require malloc/free */ -#undef LT_SYMBOL_LENGTH -#define LT_SYMBOL_LENGTH 128 - -/* This accounts for the _LTX_ separator */ -#undef LT_SYMBOL_OVERHEAD -#define LT_SYMBOL_OVERHEAD 5 - -/* Various boolean flags can be stored in the flags field of an - lt_dlhandle... */ -#define LT_DLIS_RESIDENT(handle) ((handle)->info.is_resident) -#define LT_DLIS_SYMGLOBAL(handle) ((handle)->info.is_symglobal) -#define LT_DLIS_SYMLOCAL(handle) ((handle)->info.is_symlocal) - - -static const char objdir[] = LT_OBJDIR; -static const char archive_ext[] = LT_ARCHIVE_EXT; -#if defined(LT_MODULE_EXT) -static const char shlib_ext[] = LT_MODULE_EXT; -#endif -#if defined(LT_DLSEARCH_PATH) -static const char sys_dlsearch_path[] = LT_DLSEARCH_PATH; -#endif - - - - -/* --- DYNAMIC MODULE LOADING --- */ - - -/* The type of a function used at each iteration of foreach_dirinpath(). */ -typedef int foreach_callback_func (char *filename, void *data1, - void *data2); -/* foreachfile_callback itself calls a function of this type: */ -typedef int file_worker_func (const char *filename, void *data); - - -static int foreach_dirinpath (const char *search_path, - const char *base_name, - foreach_callback_func *func, - void *data1, void *data2); -static int find_file_callback (char *filename, void *data1, - void *data2); -static int find_handle_callback (char *filename, void *data, - void *ignored); -static int foreachfile_callback (char *filename, void *data1, - void *data2); - - -static int canonicalize_path (const char *path, char **pcanonical); -static int argzize_path (const char *path, - char **pargz, size_t *pargz_len); -static FILE *find_file (const char *search_path, - const char *base_name, char **pdir); -static lt_dlhandle *find_handle (const char *search_path, - const char *base_name, - lt_dlhandle *handle, - lt_dladvise advise); -static int find_module (lt_dlhandle *handle, const char *dir, - const char *libdir, const char *dlname, - const char *old_name, int installed, - lt_dladvise advise); -static int has_library_ext (const char *filename); -static int load_deplibs (lt_dlhandle handle, char *deplibs); -static int trim (char **dest, const char *str); -static int try_dlopen (lt_dlhandle *handle, - const char *filename, const char *ext, - lt_dladvise advise); -static int tryall_dlopen (lt_dlhandle *handle, - const char *filename, - lt_dladvise padvise, - const lt_dlvtable *vtable); -static int unload_deplibs (lt_dlhandle handle); -static int lt_argz_insert (char **pargz, size_t *pargz_len, - char *before, const char *entry); -static int lt_argz_insertinorder (char **pargz, size_t *pargz_len, - const char *entry); -static int lt_argz_insertdir (char **pargz, size_t *pargz_len, - const char *dirnam, struct dirent *dp); -static int lt_dlpath_insertdir (char **ppath, char *before, - const char *dir); -static int list_files_by_dir (const char *dirnam, - char **pargz, size_t *pargz_len); -static int file_not_found (void); - -#ifdef HAVE_LIBDLLOADER -static int loader_init_callback (lt_dlhandle handle); -#endif /* HAVE_LIBDLLOADER */ - -static int loader_init (lt_get_vtable *vtable_func, - lt_user_data data); - -static char *user_search_path= 0; -static lt_dlhandle handles = 0; -static int initialized = 0; - -/* Our memory failure callback sets the error message to be passed back - up to the client, so we must be careful to return from mallocation - callers if allocation fails (as this callback returns!!). */ -void -lt__alloc_die_callback (void) -{ - LT__SETERROR (NO_MEMORY); -} - -#ifdef HAVE_LIBDLLOADER -/* This function is called to initialise each preloaded module loader, - and hook it into the list of loaders to be used when attempting to - dlopen an application module. */ -static int -loader_init_callback (lt_dlhandle handle) -{ - lt_get_vtable *vtable_func = (lt_get_vtable *) lt_dlsym (handle, "get_vtable"); - return loader_init (vtable_func, 0); -} -#endif /* HAVE_LIBDLLOADER */ - -static int -loader_init (lt_get_vtable *vtable_func, lt_user_data data) -{ - const lt_dlvtable *vtable = 0; - int errors = 0; - - if (vtable_func) - { - vtable = (*vtable_func) (data); - } - - /* lt_dlloader_add will LT__SETERROR if it fails. */ - errors += lt_dlloader_add (vtable); - - assert (errors || vtable); - - if ((!errors) && vtable->dlloader_init) - { - if ((*vtable->dlloader_init) (vtable->dlloader_data)) - { - LT__SETERROR (INIT_LOADER); - ++errors; - } - } - - return errors; -} - -/* Bootstrap the loader loading with the preopening loader. */ -#define get_vtable preopen_LTX_get_vtable -#define preloaded_symbols LT_CONC3(lt_, LTDLOPEN, _LTX_preloaded_symbols) - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable * get_vtable (lt_user_data data); -LT_END_C_DECLS -#ifdef HAVE_LIBDLLOADER -extern lt_dlsymlist preloaded_symbols; -#endif - -/* Initialize libltdl. */ -int -lt_dlinit (void) -{ - int errors = 0; - - /* Initialize only at first call. */ - if (++initialized == 1) - { - lt__alloc_die = lt__alloc_die_callback; - handles = 0; - user_search_path = 0; /* empty search path */ - - /* First set up the statically loaded preload module loader, so - we can use it to preopen the other loaders we linked in at - compile time. */ - errors += loader_init (get_vtable, 0); - - /* Now open all the preloaded module loaders, so the application - can use _them_ to lt_dlopen its own modules. */ -#ifdef HAVE_LIBDLLOADER - if (!errors) - { - errors += lt_dlpreload (&preloaded_symbols); - } - - if (!errors) - { - errors += lt_dlpreload_open (LT_STR(LTDLOPEN), loader_init_callback); - } -#endif /* HAVE_LIBDLLOADER */ - } - -#ifdef LT_DEBUG_LOADERS - lt_dlloader_dump(); -#endif - - return errors; -} - -int -lt_dlexit (void) -{ - /* shut down libltdl */ - lt_dlloader *loader = 0; - lt_dlhandle handle = handles; - int errors = 0; - - if (!initialized) - { - LT__SETERROR (SHUTDOWN); - ++errors; - goto done; - } - - /* shut down only at last call. */ - if (--initialized == 0) - { - int level; - - while (handles && LT_DLIS_RESIDENT (handles)) - { - handles = handles->next; - } - - /* close all modules */ - for (level = 1; handle; ++level) - { - lt_dlhandle cur = handles; - int saw_nonresident = 0; - - while (cur) - { - lt_dlhandle tmp = cur; - cur = cur->next; - if (!LT_DLIS_RESIDENT (tmp)) - { - saw_nonresident = 1; - if (tmp->info.ref_count <= level) - { - if (lt_dlclose (tmp)) - { - ++errors; - } - /* Make sure that the handle pointed to by 'cur' still exists. - lt_dlclose recursively closes dependent libraries which removes - them from the linked list. One of these might be the one - pointed to by 'cur'. */ - if (cur) - { - for (tmp = handles; tmp; tmp = tmp->next) - if (tmp == cur) - break; - if (! tmp) - cur = handles; - } - } - } - } - /* done if only resident modules are left */ - if (!saw_nonresident) - break; - } - - /* When removing loaders, we can only find out failure by testing - the error string, so avoid a spurious one from an earlier - failed command. */ - if (!errors) - LT__SETERRORSTR (0); - - /* close all loaders */ - for (loader = (lt_dlloader *) lt_dlloader_next (NULL); loader;) - { - lt_dlloader *next = (lt_dlloader *) lt_dlloader_next (loader); - lt_dlvtable *vtable = (lt_dlvtable *) lt_dlloader_get (loader); - - if ((vtable = lt_dlloader_remove ((char *) vtable->name))) - { - FREE (vtable); - } - else - { - /* ignore errors due to resident modules */ - const char *err; - LT__GETERROR (err); - if (err) - ++errors; - } - - loader = next; - } - - FREE(user_search_path); - } - - done: - return errors; -} - - -/* Try VTABLE or, if VTABLE is NULL, all available loaders for FILENAME. - If the library is not successfully loaded, return non-zero. Otherwise, - the dlhandle is stored at the address given in PHANDLE. */ -static int -tryall_dlopen (lt_dlhandle *phandle, const char *filename, - lt_dladvise advise, const lt_dlvtable *vtable) -{ - lt_dlhandle handle = handles; - const char * saved_error = 0; - int errors = 0; - -#ifdef LT_DEBUG_LOADERS - fprintf (stderr, "tryall_dlopen (%s, %s)\n", - filename ? filename : "(null)", - vtable ? vtable->name : "(ALL)"); -#endif - - LT__GETERROR (saved_error); - - /* check whether the module was already opened */ - for (;handle; handle = handle->next) - { - if ((handle->info.filename == filename) /* dlopen self: 0 == 0 */ - || (handle->info.filename && filename - && streq (handle->info.filename, filename))) - { - break; - } - } - - if (handle) - { - ++handle->info.ref_count; - *phandle = handle; - goto done; - } - - handle = *phandle; - if (filename) - { - /* Comment out the check of file permissions using access. - This call seems to always return -1 with error EACCES. - */ - /* We need to catch missing file errors early so that - file_not_found() can detect what happened. - if (access (filename, R_OK) != 0) - { - LT__SETERROR (FILE_NOT_FOUND); - ++errors; - goto done; - } */ - - handle->info.filename = lt__strdup (filename); - if (!handle->info.filename) - { - ++errors; - goto done; - } - } - else - { - handle->info.filename = 0; - } - - { - lt_dlloader loader = lt_dlloader_next (0); - const lt_dlvtable *loader_vtable; - - do - { - if (vtable) - loader_vtable = vtable; - else - loader_vtable = lt_dlloader_get (loader); - -#ifdef LT_DEBUG_LOADERS - fprintf (stderr, "Calling %s->module_open (%s)\n", - (loader_vtable && loader_vtable->name) ? loader_vtable->name : "(null)", - filename ? filename : "(null)"); -#endif - handle->module = (*loader_vtable->module_open) (loader_vtable->dlloader_data, - filename, advise); -#ifdef LT_DEBUG_LOADERS - fprintf (stderr, " Result: %s\n", - handle->module ? "Success" : "Failed"); -#endif - - if (handle->module != 0) - { - if (advise) - { - handle->info.is_resident = advise->is_resident; - handle->info.is_symglobal = advise->is_symglobal; - handle->info.is_symlocal = advise->is_symlocal; - } - break; - } - } - while (!vtable && (loader = lt_dlloader_next (loader))); - - /* If VTABLE was given but couldn't open the module, or VTABLE wasn't - given but we exhausted all loaders without opening the module, bail - out! */ - if ((vtable && !handle->module) - || (!vtable && !loader)) - { - FREE (handle->info.filename); - ++errors; - goto done; - } - - handle->vtable = loader_vtable; - } - - LT__SETERRORSTR (saved_error); - - done: - return errors; -} - - -static int -tryall_dlopen_module (lt_dlhandle *handle, const char *prefix, - const char *dirname, const char *dlname, - lt_dladvise advise) -{ - int error = 0; - char *filename = 0; - size_t filename_len = 0; - size_t dirname_len = LT_STRLEN (dirname); - - assert (handle); - assert (dirname); - assert (dlname); -#if defined(LT_DIRSEP_CHAR) - /* Only canonicalized names (i.e. with DIRSEP chars already converted) - should make it into this function: */ - assert (strchr (dirname, LT_DIRSEP_CHAR) == 0); -#endif - - if (dirname_len > 0) - if (dirname[dirname_len -1] == '/') - --dirname_len; - filename_len = dirname_len + 1 + LT_STRLEN (dlname); - - /* Allocate memory, and combine DIRNAME and MODULENAME into it. - The PREFIX (if any) is handled below. */ - filename = MALLOC (char, filename_len + 1); - if (!filename) - return 1; - - sprintf (filename, "%.*s/%s", (int) dirname_len, dirname, dlname); - - /* Now that we have combined DIRNAME and MODULENAME, if there is - also a PREFIX to contend with, simply recurse with the arguments - shuffled. Otherwise, attempt to open FILENAME as a module. */ - if (prefix) - { - error += tryall_dlopen_module (handle, (const char *) 0, - prefix, filename, advise); - } - else if (tryall_dlopen (handle, filename, advise, 0) != 0) - { - ++error; - } - - FREE (filename); - return error; -} - -static int -find_module (lt_dlhandle *handle, const char *dir, const char *libdir, - const char *dlname, const char *old_name, int installed, - lt_dladvise advise) -{ - /* Try to open the old library first; if it was dlpreopened, - we want the preopened version of it, even if a dlopenable - module is available. */ - if (old_name && tryall_dlopen (handle, old_name, advise, 0) == 0) - { - return 0; - } - - /* Try to open the dynamic library. */ - if (dlname) - { - /* try to open the installed module */ - if (installed && libdir) - { - if (tryall_dlopen_module (handle, (const char *) 0, - libdir, dlname, advise) == 0) - return 0; - } - - /* try to open the not-installed module */ - if (!installed) - { - if (tryall_dlopen_module (handle, dir, objdir, - dlname, advise) == 0) - return 0; - } - - /* maybe it was moved to another directory */ - { - if (dir && (tryall_dlopen_module (handle, (const char *) 0, - dir, dlname, advise) == 0)) - return 0; - } - } - - return 1; -} - - -static int -canonicalize_path (const char *path, char **pcanonical) -{ - char *canonical = 0; - - assert (path && *path); - assert (pcanonical); - - canonical = MALLOC (char, 1+ LT_STRLEN (path)); - if (!canonical) - return 1; - - { - size_t dest = 0; - size_t src; - for (src = 0; path[src] != LT_EOS_CHAR; ++src) - { - /* Path separators are not copied to the beginning or end of - the destination, or if another separator would follow - immediately. */ - if (path[src] == LT_PATHSEP_CHAR) - { - if ((dest == 0) - || (path[1+ src] == LT_PATHSEP_CHAR) - || (path[1+ src] == LT_EOS_CHAR)) - continue; - } - - /* Anything other than a directory separator is copied verbatim. */ - if ((path[src] != '/') -#if defined(LT_DIRSEP_CHAR) - && (path[src] != LT_DIRSEP_CHAR) -#endif - ) - { - canonical[dest++] = path[src]; - } - /* Directory separators are converted and copied only if they are - not at the end of a path -- i.e. before a path separator or - NULL terminator. */ - else if ((path[1+ src] != LT_PATHSEP_CHAR) - && (path[1+ src] != LT_EOS_CHAR) -#if defined(LT_DIRSEP_CHAR) - && (path[1+ src] != LT_DIRSEP_CHAR) -#endif - && (path[1+ src] != '/')) - { - canonical[dest++] = '/'; - } - } - - /* Add an end-of-string marker at the end. */ - canonical[dest] = LT_EOS_CHAR; - } - - /* Assign new value. */ - *pcanonical = canonical; - - return 0; -} - -static int -argzize_path (const char *path, char **pargz, size_t *pargz_len) -{ - error_t error; - - assert (path); - assert (pargz); - assert (pargz_len); - - if ((error = argz_create_sep (path, LT_PATHSEP_CHAR, pargz, pargz_len))) - { - switch (error) - { - case ENOMEM: - LT__SETERROR (NO_MEMORY); - break; - default: - LT__SETERROR (UNKNOWN); - break; - } - - return 1; - } - - return 0; -} - -/* Repeatedly call FUNC with each LT_PATHSEP_CHAR delimited element - of SEARCH_PATH and references to DATA1 and DATA2, until FUNC returns - non-zero or all elements are exhausted. If BASE_NAME is non-NULL, - it is appended to each SEARCH_PATH element before FUNC is called. */ -static int -foreach_dirinpath (const char *search_path, const char *base_name, - foreach_callback_func *func, void *data1, void *data2) -{ - int result = 0; - size_t filenamesize = 0; - size_t lenbase = LT_STRLEN (base_name); - size_t argz_len = 0; - char *argz = 0; - char *filename = 0; - char *canonical = 0; - - if (!search_path || !*search_path) - { - LT__SETERROR (FILE_NOT_FOUND); - goto cleanup; - } - - if (canonicalize_path (search_path, &canonical) != 0) - goto cleanup; - - if (argzize_path (canonical, &argz, &argz_len) != 0) - goto cleanup; - - { - char *dir_name = 0; - while ((dir_name = argz_next (argz, argz_len, dir_name))) - { - size_t lendir = LT_STRLEN (dir_name); - - if (1+ lendir + lenbase >= filenamesize) - { - FREE (filename); - filenamesize = 1+ lendir + 1+ lenbase; /* "/d" + '/' + "f" + '\0' */ - filename = MALLOC (char, filenamesize); - if (!filename) - goto cleanup; - } - - assert (filenamesize > lendir); - strcpy (filename, dir_name); - - if (base_name && *base_name) - { - if (filename[lendir -1] != '/') - filename[lendir++] = '/'; - strcpy (filename +lendir, base_name); - } - - if ((result = (*func) (filename, data1, data2))) - { - break; - } - } - } - - cleanup: - FREE (argz); - FREE (canonical); - FREE (filename); - - return result; -} - -/* If FILEPATH can be opened, store the name of the directory component - in DATA1, and the opened FILE* structure address in DATA2. Otherwise - DATA1 is unchanged, but DATA2 is set to a pointer to NULL. */ -static int -find_file_callback (char *filename, void *data1, void *data2) -{ - char **pdir = (char **) data1; - FILE **pfile = (FILE **) data2; - int is_done = 0; - - assert (filename && *filename); - assert (pdir); - assert (pfile); - - if ((*pfile = fopen (filename, LT_READTEXT_MODE))) - { - char *dirend = strrchr (filename, '/'); - - if (dirend > filename) - *dirend = LT_EOS_CHAR; - - FREE (*pdir); - *pdir = lt__strdup (filename); - is_done = (*pdir == 0) ? -1 : 1; - } - - return is_done; -} - -static FILE * -find_file (const char *search_path, const char *base_name, char **pdir) -{ - FILE *file = 0; - - foreach_dirinpath (search_path, base_name, find_file_callback, pdir, &file); - - return file; -} - -static int -find_handle_callback (char *filename, void *data, void *data2) -{ - lt_dlhandle *phandle = (lt_dlhandle *) data; - int notfound = access (filename, R_OK); - lt_dladvise advise = (lt_dladvise) data2; - - /* Bail out if file cannot be read... */ - if (notfound) - return 0; - - /* Try to dlopen the file, but do not continue searching in any - case. */ - if (tryall_dlopen (phandle, filename, advise, 0) != 0) - *phandle = 0; - - return 1; -} - -/* If HANDLE was found return it, otherwise return 0. If HANDLE was - found but could not be opened, *HANDLE will be set to 0. */ -static lt_dlhandle * -find_handle (const char *search_path, const char *base_name, - lt_dlhandle *phandle, lt_dladvise advise) -{ - if (!search_path) - return 0; - - if (!foreach_dirinpath (search_path, base_name, find_handle_callback, - phandle, advise)) - return 0; - - return phandle; -} - -#if !defined(LTDL_DLOPEN_DEPLIBS) -static int -load_deplibs (lt_dlhandle handle, char * LT__UNUSED deplibs) -{ - handle->depcount = 0; - return 0; -} - -#else /* defined(LTDL_DLOPEN_DEPLIBS) */ -static int -load_deplibs (lt_dlhandle handle, char *deplibs) -{ - char *p, *save_search_path = 0; - int depcount = 0; - int i; - char **names = 0; - int errors = 0; - - handle->depcount = 0; - - if (!deplibs) - { - return errors; - } - ++errors; - - if (user_search_path) - { - save_search_path = lt__strdup (user_search_path); - if (!save_search_path) - goto cleanup; - } - - /* extract search paths and count deplibs */ - p = deplibs; - while (*p) - { - if (!isspace ((unsigned char) *p)) - { - char *end = p+1; - while (*end && !isspace((unsigned char) *end)) - { - ++end; - } - - if (strncmp(p, "-L", 2) == 0 || strncmp(p, "-R", 2) == 0) - { - char save = *end; - *end = 0; /* set a temporary string terminator */ - if (lt_dladdsearchdir(p+2)) - { - goto cleanup; - } - *end = save; - } - else - { - ++depcount; - } - - p = end; - } - else - { - ++p; - } - } - - - if (!depcount) - { - errors = 0; - goto cleanup; - } - - names = MALLOC (char *, depcount); - if (!names) - goto cleanup; - - /* now only extract the actual deplibs */ - depcount = 0; - p = deplibs; - while (*p) - { - if (isspace ((unsigned char) *p)) - { - ++p; - } - else - { - char *end = p+1; - while (*end && !isspace ((unsigned char) *end)) - { - ++end; - } - - if (strncmp(p, "-L", 2) != 0 && strncmp(p, "-R", 2) != 0) - { - char *name; - char save = *end; - *end = 0; /* set a temporary string terminator */ - if (strncmp(p, "-l", 2) == 0) - { - size_t name_len = 3+ /* "lib" */ LT_STRLEN (p + 2); - name = MALLOC (char, 1+ name_len); - if (name) - sprintf (name, "lib%s", p+2); - } - else - name = lt__strdup(p); - - if (!name) - goto cleanup_names; - - names[depcount++] = name; - *end = save; - } - p = end; - } - } - - /* load the deplibs (in reverse order) - At this stage, don't worry if the deplibs do not load correctly, - they may already be statically linked into the loading application - for instance. There will be a more enlightening error message - later on if the loaded module cannot resolve all of its symbols. */ - if (depcount) - { - lt_dlhandle cur = handle; - int j = 0; - - cur->deplibs = MALLOC (lt_dlhandle, depcount); - if (!cur->deplibs) - goto cleanup_names; - - for (i = 0; i < depcount; ++i) - { - cur->deplibs[j] = lt_dlopenext(names[depcount-1-i]); - if (cur->deplibs[j]) - { - ++j; - } - } - - cur->depcount = j; /* Number of successfully loaded deplibs */ - errors = 0; - } - - cleanup_names: - for (i = 0; i < depcount; ++i) - { - FREE (names[i]); - } - - cleanup: - FREE (names); - /* restore the old search path */ - if (save_search_path) { - MEMREASSIGN (user_search_path, save_search_path); - } - - return errors; -} -#endif /* defined(LTDL_DLOPEN_DEPLIBS) */ - -static int -unload_deplibs (lt_dlhandle handle) -{ - int i; - int errors = 0; - lt_dlhandle cur = handle; - - if (cur->depcount) - { - for (i = 0; i < cur->depcount; ++i) - { - if (!LT_DLIS_RESIDENT (cur->deplibs[i])) - { - errors += lt_dlclose (cur->deplibs[i]); - } - } - FREE (cur->deplibs); - } - - return errors; -} - -static int -trim (char **dest, const char *str) -{ - /* remove the leading and trailing "'" from str - and store the result in dest */ - const char *end = strrchr (str, '\''); - size_t len = LT_STRLEN (str); - char *tmp; - - FREE (*dest); - - if (!end) - return 1; - - if (len > 3 && str[0] == '\'') - { - tmp = MALLOC (char, end - str); - if (!tmp) - return 1; - - memcpy(tmp, &str[1], (end - str) - 1); - tmp[(end - str) - 1] = LT_EOS_CHAR; - *dest = tmp; - } - else - { - *dest = 0; - } - - return 0; -} - -/* Read the .la file FILE. */ -static int -parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, - char **old_name, int *installed) -{ - int errors = 0; - size_t line_len = LT_FILENAME_MAX; - char * line = MALLOC (char, line_len); - - if (!line) - { - LT__SETERROR (FILE_NOT_FOUND); - return 1; - } - - while (!feof (file)) - { - line[line_len-2] = '\0'; - if (!fgets (line, (int) line_len, file)) - { - break; - } - - /* Handle the case where we occasionally need to read a line - that is longer than the initial buffer size. - Behave even if the file contains NUL bytes due to corruption. */ - while (line[line_len-2] != '\0' && line[line_len-2] != '\n' && !feof (file)) - { - line = REALLOC (char, line, line_len *2); - if (!line) - { - ++errors; - goto cleanup; - } - line[line_len * 2 - 2] = '\0'; - if (!fgets (&line[line_len -1], (int) line_len +1, file)) - { - break; - } - line_len *= 2; - } - - if (line[0] == '\n' || line[0] == '#') - { - continue; - } - -#undef STR_DLNAME -#define STR_DLNAME "dlname=" - if (strncmp (line, STR_DLNAME, sizeof (STR_DLNAME) - 1) == 0) - { - errors += trim (dlname, &line[sizeof (STR_DLNAME) - 1]); - } - -#undef STR_OLD_LIBRARY -#define STR_OLD_LIBRARY "old_library=" - else if (strncmp (line, STR_OLD_LIBRARY, - sizeof (STR_OLD_LIBRARY) - 1) == 0) - { - errors += trim (old_name, &line[sizeof (STR_OLD_LIBRARY) - 1]); - } -#undef STR_LIBDIR -#define STR_LIBDIR "libdir=" - else if (strncmp (line, STR_LIBDIR, sizeof (STR_LIBDIR) - 1) == 0) - { - errors += trim (libdir, &line[sizeof(STR_LIBDIR) - 1]); - } - -#undef STR_DL_DEPLIBS -#define STR_DL_DEPLIBS "dependency_libs=" - else if (strncmp (line, STR_DL_DEPLIBS, - sizeof (STR_DL_DEPLIBS) - 1) == 0) - { - errors += trim (deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]); - } - else if (streq (line, "installed=yes\n")) - { - *installed = 1; - } - else if (streq (line, "installed=no\n")) - { - *installed = 0; - } - -#undef STR_LIBRARY_NAMES -#define STR_LIBRARY_NAMES "library_names=" - else if (!*dlname && strncmp (line, STR_LIBRARY_NAMES, - sizeof (STR_LIBRARY_NAMES) - 1) == 0) - { - char *last_libname; - errors += trim (dlname, &line[sizeof (STR_LIBRARY_NAMES) - 1]); - if (!errors - && *dlname - && (last_libname = strrchr (*dlname, ' ')) != 0) - { - last_libname = lt__strdup (last_libname + 1); - if (!last_libname) - { - ++errors; - goto cleanup; - } - MEMREASSIGN (*dlname, last_libname); - } - } - - if (errors) - break; - } -cleanup: - FREE (line); - return errors; -} - - -/* Try to open FILENAME as a module. */ -static int -try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, - lt_dladvise advise) -{ - const char * saved_error = 0; - char * canonical = 0; - char * base_name = 0; - char * dir = 0; - char * name = 0; - char * attempt = 0; - int errors = 0; - lt_dlhandle newhandle; - - assert (phandle); - assert (*phandle == 0); - -#ifdef LT_DEBUG_LOADERS - fprintf (stderr, "try_dlopen (%s, %s)\n", - filename ? filename : "(null)", - ext ? ext : "(null)"); -#endif - - LT__GETERROR (saved_error); - - /* dlopen self? */ - if (!filename) - { - *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle)); - if (*phandle == 0) - return 1; - - newhandle = *phandle; - - /* lt_dlclose()ing yourself is very bad! Disallow it. */ - newhandle->info.is_resident = 1; - - if (tryall_dlopen (&newhandle, 0, advise, 0) != 0) - { - FREE (*phandle); - return 1; - } - - goto register_handle; - } - - assert (filename && *filename); - - if (ext) - { - attempt = MALLOC (char, LT_STRLEN (filename) + LT_STRLEN (ext) + 1); - if (!attempt) - return 1; - - sprintf(attempt, "%s%s", filename, ext); - } - else - { - attempt = lt__strdup (filename); - if (!attempt) - return 1; - } - - /* Doing this immediately allows internal functions to safely - assume only canonicalized paths are passed. */ - if (canonicalize_path (attempt, &canonical) != 0) - { - ++errors; - goto cleanup; - } - - /* If the canonical module name is a path (relative or absolute) - then split it into a directory part and a name part. */ - base_name = strrchr (canonical, '/'); - if (base_name) - { - size_t dirlen = (1+ base_name) - canonical; - - dir = MALLOC (char, 1+ dirlen); - if (!dir) - { - ++errors; - goto cleanup; - } - - strncpy (dir, canonical, dirlen); - dir[dirlen] = LT_EOS_CHAR; - - ++base_name; - } - else - MEMREASSIGN (base_name, canonical); - - assert (base_name && *base_name); - - ext = strrchr (base_name, '.'); - if (!ext) - { - ext = base_name + LT_STRLEN (base_name); - } - - /* extract the module name from the file name */ - name = MALLOC (char, ext - base_name + 1); - if (!name) - { - ++errors; - goto cleanup; - } - - /* canonicalize the module name */ - { - int i; - for (i = 0; i < ext - base_name; ++i) - { - if (isalnum ((unsigned char)(base_name[i]))) - { - name[i] = base_name[i]; - } - else - { - name[i] = '_'; - } - } - name[ext - base_name] = LT_EOS_CHAR; - } - - /* Before trawling through the filesystem in search of a module, - check whether we are opening a preloaded module. */ - if (!dir) - { - const lt_dlvtable *vtable = lt_dlloader_find ("lt_preopen"); - - if (vtable) - { - *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle)); - - if (*phandle == NULL) - { - ++errors; - goto cleanup; - } - newhandle = *phandle; - - if (tryall_dlopen (&newhandle, attempt, advise, vtable) == 0) - { - goto register_handle; - } - - /* If we're still here, there was no matching preloaded module, - so put things back as we found them, and continue searching. */ - FREE (*phandle); - newhandle = NULL; - } - } - - /* Check whether we are opening a libtool module (.la extension). */ - if (ext && streq (ext, archive_ext)) - { - /* this seems to be a libtool module */ - FILE * file = 0; - char * dlname = 0; - char * old_name = 0; - char * libdir = 0; - char * deplibs = 0; - - /* if we can't find the installed flag, it is probably an - installed libtool archive, produced with an old version - of libtool */ - int installed = 1; - - /* Now try to open the .la file. If there is no directory name - component, try to find it first in user_search_path and then other - prescribed paths. Otherwise (or in any case if the module was not - yet found) try opening just the module name as passed. */ - if (!dir) - { - const char *search_path = user_search_path; - - if (search_path) - file = find_file (user_search_path, base_name, &dir); - - if (!file) - { - search_path = getenv (LTDL_SEARCHPATH_VAR); - if (search_path) - file = find_file (search_path, base_name, &dir); - } - -#if defined(LT_MODULE_PATH_VAR) - if (!file) - { - search_path = getenv (LT_MODULE_PATH_VAR); - if (search_path) - file = find_file (search_path, base_name, &dir); - } -#endif -#if defined(LT_DLSEARCH_PATH) - if (!file && *sys_dlsearch_path) - { - file = find_file (sys_dlsearch_path, base_name, &dir); - } -#endif - } - if (!file) - { - file = fopen (attempt, LT_READTEXT_MODE); - } - - /* If we didn't find the file by now, it really isn't there. Set - the status flag, and bail out. */ - if (!file) - { - LT__SETERROR (FILE_NOT_FOUND); - ++errors; - goto cleanup; - } - - /* read the .la file */ - if (parse_dotla_file(file, &dlname, &libdir, &deplibs, - &old_name, &installed) != 0) - ++errors; - - fclose (file); - - /* allocate the handle */ - *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle)); - if (*phandle == 0) - ++errors; - - if (errors) - { - FREE (dlname); - FREE (old_name); - FREE (libdir); - FREE (deplibs); - FREE (*phandle); - goto cleanup; - } - - assert (*phandle); - - if (load_deplibs (*phandle, deplibs) == 0) - { - newhandle = *phandle; - /* find_module may replace newhandle */ - if (find_module (&newhandle, dir, libdir, dlname, old_name, - installed, advise)) - { - unload_deplibs (*phandle); - ++errors; - } - } - else - { - ++errors; - } - - FREE (dlname); - FREE (old_name); - FREE (libdir); - FREE (deplibs); - - if (errors) - { - FREE (*phandle); - goto cleanup; - } - - if (*phandle != newhandle) - { - unload_deplibs (*phandle); - } - } - else - { - /* not a libtool module */ - *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle)); - if (*phandle == 0) - { - ++errors; - goto cleanup; - } - - newhandle = *phandle; - - /* If the module has no directory name component, try to find it - first in user_search_path and then other prescribed paths. - Otherwise (or in any case if the module was not yet found) try - opening just the module name as passed. */ - if ((dir || (!find_handle (user_search_path, base_name, - &newhandle, advise) - && !find_handle (getenv (LTDL_SEARCHPATH_VAR), base_name, - &newhandle, advise) -#if defined(LT_MODULE_PATH_VAR) - && !find_handle (getenv (LT_MODULE_PATH_VAR), base_name, - &newhandle, advise) -#endif -#if defined(LT_DLSEARCH_PATH) - && !find_handle (sys_dlsearch_path, base_name, - &newhandle, advise) -#endif - ))) - { - if (tryall_dlopen (&newhandle, attempt, advise, 0) != 0) - { - newhandle = NULL; - } - } - - if (!newhandle) - { - FREE (*phandle); - ++errors; - goto cleanup; - } - } - - register_handle: - MEMREASSIGN (*phandle, newhandle); - - if ((*phandle)->info.ref_count == 0) - { - (*phandle)->info.ref_count = 1; - MEMREASSIGN ((*phandle)->info.name, name); - - (*phandle)->next = handles; - handles = *phandle; - } - - LT__SETERRORSTR (saved_error); - - cleanup: - FREE (dir); - FREE (attempt); - FREE (name); - if (!canonical) /* was MEMREASSIGNed */ - FREE (base_name); - FREE (canonical); - - return errors; -} - - -/* If the last error messge store was `FILE_NOT_FOUND', then return - non-zero. */ -static int -file_not_found (void) -{ - const char *error = 0; - - LT__GETERROR (error); - if (error == LT__STRERROR (FILE_NOT_FOUND)) - return 1; - - return 0; -} - - -/* Unless FILENAME already bears a suitable library extension, then - return 0. */ -static int -has_library_ext (const char *filename) -{ - char * ext = 0; - - assert (filename); - - ext = strrchr (filename, '.'); - - if (ext && ((streq (ext, archive_ext)) -#if defined(LT_MODULE_EXT) - || (streq (ext, shlib_ext)) -#endif - )) - { - return 1; - } - - return 0; -} - - -/* Initialise and configure a user lt_dladvise opaque object. */ - -int -lt_dladvise_init (lt_dladvise *padvise) -{ - lt_dladvise advise = (lt_dladvise) lt__zalloc (sizeof (struct lt__advise)); - *padvise = advise; - return (advise ? 0 : 1); -} - -int -lt_dladvise_destroy (lt_dladvise *padvise) -{ - if (padvise) - FREE(*padvise); - return 0; -} - -int -lt_dladvise_ext (lt_dladvise *padvise) -{ - assert (padvise && *padvise); - (*padvise)->try_ext = 1; - return 0; -} - -int -lt_dladvise_resident (lt_dladvise *padvise) -{ - assert (padvise && *padvise); - (*padvise)->is_resident = 1; - return 0; -} - -int -lt_dladvise_local (lt_dladvise *padvise) -{ - assert (padvise && *padvise); - (*padvise)->is_symlocal = 1; - return 0; -} - -int -lt_dladvise_global (lt_dladvise *padvise) -{ - assert (padvise && *padvise); - (*padvise)->is_symglobal = 1; - return 0; -} - -/* Libtool-1.5.x interface for loading a new module named FILENAME. */ -lt_dlhandle -lt_dlopen (const char *filename) -{ - return lt_dlopenadvise (filename, NULL); -} - - -/* If FILENAME has an ARCHIVE_EXT or MODULE_EXT extension, try to - open the FILENAME as passed. Otherwise try appending ARCHIVE_EXT, - and if a file is still not found try again with MODULE_EXT appended - instead. */ -lt_dlhandle -lt_dlopenext (const char *filename) -{ - lt_dlhandle handle = 0; - lt_dladvise advise; - - if (!lt_dladvise_init (&advise) && !lt_dladvise_ext (&advise)) - handle = lt_dlopenadvise (filename, advise); - - lt_dladvise_destroy (&advise); - return handle; -} - - -lt_dlhandle -lt_dlopenadvise (const char *filename, lt_dladvise advise) -{ - lt_dlhandle handle = 0; - int errors = 0; - - /* Can't have symbols hidden and visible at the same time! */ - if (advise && advise->is_symlocal && advise->is_symglobal) - { - LT__SETERROR (CONFLICTING_FLAGS); - return 0; - } - - if (!filename - || !advise - || !advise->try_ext - || has_library_ext (filename)) - { - /* Just incase we missed a code path in try_dlopen() that reports - an error, but forgot to reset handle... */ - if (try_dlopen (&handle, filename, NULL, advise) != 0) - return 0; - - return handle; - } - else if (filename && *filename) - { - - /* First try appending ARCHIVE_EXT. */ - errors += try_dlopen (&handle, filename, archive_ext, advise); - - /* If we found FILENAME, stop searching -- whether we were able to - load the file as a module or not. If the file exists but loading - failed, it is better to return an error message here than to - report FILE_NOT_FOUND when the alternatives (foo.so etc) are not - in the module search path. */ - if (handle || ((errors > 0) && !file_not_found ())) - return handle; - -#if defined(LT_MODULE_EXT) - /* Try appending SHLIB_EXT. */ - errors = try_dlopen (&handle, filename, shlib_ext, advise); - - /* As before, if the file was found but loading failed, return now - with the current error message. */ - if (handle || ((errors > 0) && !file_not_found ())) - return handle; -#endif - } - - /* Still here? Then we really did fail to locate any of the file - names we tried. */ - LT__SETERROR (FILE_NOT_FOUND); - return 0; -} - - -static int -lt_argz_insert (char **pargz, size_t *pargz_len, char *before, - const char *entry) -{ - error_t error; - - /* Prior to Sep 8, 2005, newlib had a bug where argz_insert(pargz, - pargz_len, NULL, entry) failed with EINVAL. */ - if (before) - error = argz_insert (pargz, pargz_len, before, entry); - else - error = argz_append (pargz, pargz_len, entry, 1 + strlen (entry)); - - if (error) - { - switch (error) - { - case ENOMEM: - LT__SETERROR (NO_MEMORY); - break; - default: - LT__SETERROR (UNKNOWN); - break; - } - return 1; - } - - return 0; -} - -static int -lt_argz_insertinorder (char **pargz, size_t *pargz_len, const char *entry) -{ - char *before = 0; - - assert (pargz); - assert (pargz_len); - assert (entry && *entry); - - if (*pargz) - while ((before = argz_next (*pargz, *pargz_len, before))) - { - int cmp = strcmp (entry, before); - - if (cmp < 0) break; - if (cmp == 0) return 0; /* No duplicates! */ - } - - return lt_argz_insert (pargz, pargz_len, before, entry); -} - -static int -lt_argz_insertdir (char **pargz, size_t *pargz_len, const char *dirnam, - struct dirent *dp) -{ - char *buf = 0; - size_t buf_len = 0; - char *end = 0; - size_t end_offset = 0; - size_t dir_len = 0; - int errors = 0; - - assert (pargz); - assert (pargz_len); - assert (dp); - - dir_len = LT_STRLEN (dirnam); - end = dp->d_name + D_NAMLEN(dp); - - /* Ignore version numbers. */ - { - char *p; - for (p = end; p -1 > dp->d_name; --p) - if (strchr (".0123456789", p[-1]) == 0) - break; - - if (*p == '.') - end = p; - } - - /* Ignore filename extension. */ - { - char *p; - for (p = end -1; p > dp->d_name; --p) - if (*p == '.') - { - end = p; - break; - } - } - - /* Prepend the directory name. */ - end_offset = end - dp->d_name; - buf_len = dir_len + 1+ end_offset; - buf = MALLOC (char, 1+ buf_len); - if (!buf) - return ++errors; - - assert (buf); - - strcpy (buf, dirnam); - strcat (buf, "/"); - strncat (buf, dp->d_name, end_offset); - buf[buf_len] = LT_EOS_CHAR; - - /* Try to insert (in order) into ARGZ/ARGZ_LEN. */ - if (lt_argz_insertinorder (pargz, pargz_len, buf) != 0) - ++errors; - - FREE (buf); - - return errors; -} - -static int -list_files_by_dir (const char *dirnam, char **pargz, size_t *pargz_len) -{ - DIR *dirp = 0; - int errors = 0; - - assert (dirnam && *dirnam); - assert (pargz); - assert (pargz_len); - assert (dirnam[LT_STRLEN(dirnam) -1] != '/'); - - dirp = opendir (dirnam); - if (dirp) - { - struct dirent *dp = 0; - - while ((dp = readdir (dirp))) - if (dp->d_name[0] != '.') - if (lt_argz_insertdir (pargz, pargz_len, dirnam, dp)) - { - ++errors; - break; - } - - closedir (dirp); - } - else - ++errors; - - return errors; -} - - -/* If there are any files in DIRNAME, call the function passed in - DATA1 (with the name of each file and DATA2 as arguments). */ -static int -foreachfile_callback (char *dirname, void *data1, void *data2) -{ - file_worker_func *func = *(file_worker_func **) data1; - - int is_done = 0; - char *argz = 0; - size_t argz_len = 0; - - if (list_files_by_dir (dirname, &argz, &argz_len) != 0) - goto cleanup; - if (!argz) - goto cleanup; - - { - char *filename = 0; - while ((filename = argz_next (argz, argz_len, filename))) - if ((is_done = (*func) (filename, data2))) - break; - } - - cleanup: - FREE (argz); - - return is_done; -} - - -/* Call FUNC for each unique extensionless file in SEARCH_PATH, along - with DATA. The filenames passed to FUNC would be suitable for - passing to lt_dlopenext. The extensions are stripped so that - individual modules do not generate several entries (e.g. libfoo.la, - libfoo.so, libfoo.so.1, libfoo.so.1.0.0). If SEARCH_PATH is NULL, - then the same directories that lt_dlopen would search are examined. */ -int -lt_dlforeachfile (const char *search_path, - int (*func) (const char *filename, void *data), - void *data) -{ - int is_done = 0; - file_worker_func **fpptr = &func; - - if (search_path) - { - /* If a specific path was passed, search only the directories - listed in it. */ - is_done = foreach_dirinpath (search_path, 0, - foreachfile_callback, fpptr, data); - } - else - { - /* Otherwise search the default paths. */ - is_done = foreach_dirinpath (user_search_path, 0, - foreachfile_callback, fpptr, data); - if (!is_done) - { - is_done = foreach_dirinpath (getenv(LTDL_SEARCHPATH_VAR), 0, - foreachfile_callback, fpptr, data); - } - -#if defined(LT_MODULE_PATH_VAR) - if (!is_done) - { - is_done = foreach_dirinpath (getenv(LT_MODULE_PATH_VAR), 0, - foreachfile_callback, fpptr, data); - } -#endif -#if defined(LT_DLSEARCH_PATH) - if (!is_done && *sys_dlsearch_path) - { - is_done = foreach_dirinpath (sys_dlsearch_path, 0, - foreachfile_callback, fpptr, data); - } -#endif - } - - return is_done; -} - -int -lt_dlclose (lt_dlhandle handle) -{ - lt_dlhandle cur, last; - int errors = 0; - - /* check whether the handle is valid */ - last = cur = handles; - while (cur && handle != cur) - { - last = cur; - cur = cur->next; - } - - if (!cur) - { - LT__SETERROR (INVALID_HANDLE); - ++errors; - goto done; - } - - cur = handle; - cur->info.ref_count--; - - /* Note that even with resident modules, we must track the ref_count - correctly incase the user decides to reset the residency flag - later (even though the API makes no provision for that at the - moment). */ - if (cur->info.ref_count <= 0 && !LT_DLIS_RESIDENT (cur)) - { - lt_user_data data = cur->vtable->dlloader_data; - - if (cur != handles) - { - last->next = cur->next; - } - else - { - handles = cur->next; - } - - errors += cur->vtable->module_close (data, cur->module); - errors += unload_deplibs (handle); - - /* It is up to the callers to free the data itself. */ - FREE (cur->interface_data); - - FREE (cur->info.filename); - FREE (cur->info.name); - FREE (cur); - - goto done; - } - - if (LT_DLIS_RESIDENT (handle)) - { - LT__SETERROR (CLOSE_RESIDENT_MODULE); - ++errors; - } - - done: - return errors; -} - -void * -lt_dlsym (lt_dlhandle place, const char *symbol) -{ - size_t lensym; - char lsym[LT_SYMBOL_LENGTH]; - char *sym; - void *address; - lt_user_data data; - lt_dlhandle handle; - - if (!place) - { - LT__SETERROR (INVALID_HANDLE); - return 0; - } - - handle = place; - - if (!symbol) - { - LT__SETERROR (SYMBOL_NOT_FOUND); - return 0; - } - - lensym = LT_STRLEN (symbol) + LT_STRLEN (handle->vtable->sym_prefix) - + LT_STRLEN (handle->info.name); - - if (lensym + LT_SYMBOL_OVERHEAD < LT_SYMBOL_LENGTH) - { - sym = lsym; - } - else - { - sym = MALLOC (char, lensym + LT_SYMBOL_OVERHEAD + 1); - if (!sym) - { - LT__SETERROR (BUFFER_OVERFLOW); - return 0; - } - } - - data = handle->vtable->dlloader_data; - if (handle->info.name) - { - const char *saved_error; - - LT__GETERROR (saved_error); - - /* this is a libtool module */ - if (handle->vtable->sym_prefix) - { - strcpy(sym, handle->vtable->sym_prefix); - strcat(sym, handle->info.name); - } - else - { - strcpy(sym, handle->info.name); - } - - strcat(sym, "_LTX_"); - strcat(sym, symbol); - - /* try "modulename_LTX_symbol" */ - address = handle->vtable->find_sym (data, handle->module, sym); - if (address) - { - if (sym != lsym) - { - FREE (sym); - } - return address; - } - LT__SETERRORSTR (saved_error); - } - - /* otherwise try "symbol" */ - if (handle->vtable->sym_prefix) - { - strcpy(sym, handle->vtable->sym_prefix); - strcat(sym, symbol); - } - else - { - strcpy(sym, symbol); - } - - address = handle->vtable->find_sym (data, handle->module, sym); - if (sym != lsym) - { - FREE (sym); - } - - return address; -} - -const char * -lt_dlerror (void) -{ - const char *error; - - LT__GETERROR (error); - LT__SETERRORSTR (0); - - return error ? error : NULL; -} - -static int -lt_dlpath_insertdir (char **ppath, char *before, const char *dir) -{ - int errors = 0; - char *canonical = 0; - char *argz = 0; - size_t argz_len = 0; - - assert (ppath); - assert (dir && *dir); - - if (canonicalize_path (dir, &canonical) != 0) - { - ++errors; - goto cleanup; - } - - assert (canonical && *canonical); - - /* If *PPATH is empty, set it to DIR. */ - if (*ppath == 0) - { - assert (!before); /* BEFORE cannot be set without PPATH. */ - assert (dir); /* Without DIR, don't call this function! */ - - *ppath = lt__strdup (dir); - if (*ppath == 0) - ++errors; - - goto cleanup; - } - - assert (ppath && *ppath); - - if (argzize_path (*ppath, &argz, &argz_len) != 0) - { - ++errors; - goto cleanup; - } - - /* Convert BEFORE into an equivalent offset into ARGZ. This only works - if *PPATH is already canonicalized, and hence does not change length - with respect to ARGZ. We canonicalize each entry as it is added to - the search path, and don't call this function with (uncanonicalized) - user paths, so this is a fair assumption. */ - if (before) - { - assert (*ppath <= before); - assert ((int) (before - *ppath) <= (int) strlen (*ppath)); - - before = before - *ppath + argz; - } - - if (lt_argz_insert (&argz, &argz_len, before, dir) != 0) - { - ++errors; - goto cleanup; - } - - argz_stringify (argz, argz_len, LT_PATHSEP_CHAR); - MEMREASSIGN(*ppath, argz); - - cleanup: - FREE (argz); - FREE (canonical); - - return errors; -} - -int -lt_dladdsearchdir (const char *search_dir) -{ - int errors = 0; - - if (search_dir && *search_dir) - { - if (lt_dlpath_insertdir (&user_search_path, 0, search_dir) != 0) - ++errors; - } - - return errors; -} - -int -lt_dlinsertsearchdir (const char *before, const char *search_dir) -{ - int errors = 0; - - if (before) - { - if ((before < user_search_path) - || (before >= user_search_path + LT_STRLEN (user_search_path))) - { - LT__SETERROR (INVALID_POSITION); - return 1; - } - } - - if (search_dir && *search_dir) - { - if (lt_dlpath_insertdir (&user_search_path, - (char *) before, search_dir) != 0) - { - ++errors; - } - } - - return errors; -} - -int -lt_dlsetsearchpath (const char *search_path) -{ - int errors = 0; - - FREE (user_search_path); - - if (!search_path || !LT_STRLEN (search_path)) - { - return errors; - } - - if (canonicalize_path (search_path, &user_search_path) != 0) - ++errors; - - return errors; -} - -const char * -lt_dlgetsearchpath (void) -{ - const char *saved_path; - - saved_path = user_search_path; - - return saved_path; -} - -int -lt_dlmakeresident (lt_dlhandle handle) -{ - int errors = 0; - - if (!handle) - { - LT__SETERROR (INVALID_HANDLE); - ++errors; - } - else - { - handle->info.is_resident = 1; - } - - return errors; -} - -int -lt_dlisresident (lt_dlhandle handle) -{ - if (!handle) - { - LT__SETERROR (INVALID_HANDLE); - return -1; - } - - return LT_DLIS_RESIDENT (handle); -} - - - -/* --- MODULE INFORMATION --- */ - -typedef struct { - const char *id_string; - lt_dlhandle_interface *iface; -} lt__interface_id; - -lt_dlinterface_id -lt_dlinterface_register (const char *id_string, lt_dlhandle_interface *iface) -{ - lt__interface_id *interface_id = (lt__interface_id *) lt__malloc (sizeof *interface_id); - - /* If lt__malloc fails, it will LT__SETERROR (NO_MEMORY), which - can then be detected with lt_dlerror() if we return 0. */ - if (interface_id) - { - interface_id->id_string = lt__strdup (id_string); - if (!interface_id->id_string) - FREE (interface_id); - else - interface_id->iface = iface; - } - - return (lt_dlinterface_id) interface_id; -} - -void lt_dlinterface_free (lt_dlinterface_id key) -{ - lt__interface_id *interface_id = (lt__interface_id *)key; - FREE (interface_id->id_string); - FREE (interface_id); -} - -void * -lt_dlcaller_set_data (lt_dlinterface_id key, lt_dlhandle handle, void *data) -{ - int n_elements = 0; - void *stale = (void *) 0; - lt_dlhandle cur = handle; - int i; - - if (cur->interface_data) - while (cur->interface_data[n_elements].key) - ++n_elements; - - for (i = 0; i < n_elements; ++i) - { - if (cur->interface_data[i].key == key) - { - stale = cur->interface_data[i].data; - break; - } - } - - /* Ensure that there is enough room in this handle's interface_data - array to accept a new element (and an empty end marker). */ - if (i == n_elements) - { - lt_interface_data *temp - = REALLOC (lt_interface_data, cur->interface_data, 2+ n_elements); - - if (!temp) - { - stale = 0; - goto done; - } - - cur->interface_data = temp; - - /* We only need this if we needed to allocate a new interface_data. */ - cur->interface_data[i].key = key; - cur->interface_data[1+ i].key = 0; - } - - cur->interface_data[i].data = data; - - done: - return stale; -} - -void * -lt_dlcaller_get_data (lt_dlinterface_id key, lt_dlhandle handle) -{ - void *result = (void *) 0; - lt_dlhandle cur = handle; - - /* Locate the index of the element with a matching KEY. */ - if (cur->interface_data) - { - int i; - for (i = 0; cur->interface_data[i].key; ++i) - { - if (cur->interface_data[i].key == key) - { - result = cur->interface_data[i].data; - break; - } - } - } - - return result; -} - -const lt_dlinfo * -lt_dlgetinfo (lt_dlhandle handle) -{ - if (!handle) - { - LT__SETERROR (INVALID_HANDLE); - return 0; - } - - return &(handle->info); -} - - -lt_dlhandle -lt_dlhandle_iterate (lt_dlinterface_id iface, lt_dlhandle place) -{ - lt_dlhandle handle = place; - lt__interface_id *iterator = (lt__interface_id *) iface; - - assert (iface); /* iface is a required argument */ - - if (!handle) - handle = handles; - else - handle = handle->next; - - /* advance while the interface check fails */ - while (handle && iterator->iface - && ((*iterator->iface) (handle, iterator->id_string) != 0)) - { - handle = handle->next; - } - - return handle; -} - - -lt_dlhandle -lt_dlhandle_fetch (lt_dlinterface_id iface, const char *module_name) -{ - lt_dlhandle handle = 0; - - assert (iface); /* iface is a required argument */ - - while ((handle = lt_dlhandle_iterate (iface, handle))) - { - lt_dlhandle cur = handle; - if (cur && cur->info.name && streq (cur->info.name, module_name)) - break; - } - - return handle; -} - - -int -lt_dlhandle_map (lt_dlinterface_id iface, - int (*func) (lt_dlhandle handle, void *data), void *data) -{ - lt__interface_id *iterator = (lt__interface_id *) iface; - lt_dlhandle cur = handles; - - assert (iface); /* iface is a required argument */ - - while (cur) - { - int errorcode = 0; - - /* advance while the interface check fails */ - while (cur && iterator->iface - && ((*iterator->iface) (cur, iterator->id_string) != 0)) - { - cur = cur->next; - } - - if ((errorcode = (*func) (cur, data)) != 0) - return errorcode; - } - - return 0; -} diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h deleted file mode 100644 index bc60b88..0000000 --- a/libltdl/ltdl.h +++ /dev/null @@ -1,161 +0,0 @@ -/* ltdl.h -- generic dlopen functions - - Copyright (C) 1998-2000, 2004, 2005, - 2007, 2008 Free Software Foundation, Inc. - Written by Thomas Tanner, 1998 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -/* Only include this header file once. */ -#if !defined(LTDL_H) -#define LTDL_H 1 - -#include -#include -#include - -LT_BEGIN_C_DECLS - - -/* LT_STRLEN can be used safely on NULL pointers. */ -#define LT_STRLEN(s) (((s) && (s)[0]) ? strlen (s) : 0) - - -/* --- DYNAMIC MODULE LOADING API --- */ - - -typedef struct lt__handle *lt_dlhandle; /* A loaded module. */ - -/* Initialisation and finalisation functions for libltdl. */ -LT_SCOPE int lt_dlinit (void); -LT_SCOPE int lt_dlexit (void); - -/* Module search path manipulation. */ -LT_SCOPE int lt_dladdsearchdir (const char *search_dir); -LT_SCOPE int lt_dlinsertsearchdir (const char *before, - const char *search_dir); -LT_SCOPE int lt_dlsetsearchpath (const char *search_path); -LT_SCOPE const char *lt_dlgetsearchpath (void); -LT_SCOPE int lt_dlforeachfile ( - const char *search_path, - int (*func) (const char *filename, void *data), - void *data); - -/* User module loading advisors. */ -LT_SCOPE int lt_dladvise_init (lt_dladvise *advise); -LT_SCOPE int lt_dladvise_destroy (lt_dladvise *advise); -LT_SCOPE int lt_dladvise_ext (lt_dladvise *advise); -LT_SCOPE int lt_dladvise_resident (lt_dladvise *advise); -LT_SCOPE int lt_dladvise_local (lt_dladvise *advise); -LT_SCOPE int lt_dladvise_global (lt_dladvise *advise); - -/* Portable libltdl versions of the system dlopen() API. */ -LT_SCOPE lt_dlhandle lt_dlopen (const char *filename); -LT_SCOPE lt_dlhandle lt_dlopenext (const char *filename); -LT_SCOPE lt_dlhandle lt_dlopenadvise (const char *filename, - lt_dladvise advise); -LT_SCOPE void * lt_dlsym (lt_dlhandle handle, const char *name); -LT_SCOPE const char *lt_dlerror (void); -LT_SCOPE int lt_dlclose (lt_dlhandle handle); - - - -/* --- PRELOADED MODULE SUPPORT --- */ - - -/* A preopened symbol. Arrays of this type comprise the exported - symbols for a dlpreopened module. */ -typedef struct { - const char *name; - void *address; -} lt_dlsymlist; - -typedef int lt_dlpreload_callback_func (lt_dlhandle handle); - -LT_SCOPE int lt_dlpreload (const lt_dlsymlist *preloaded); -LT_SCOPE int lt_dlpreload_default (const lt_dlsymlist *preloaded); -LT_SCOPE int lt_dlpreload_open (const char *originator, - lt_dlpreload_callback_func *func); - -#define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols -#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ - extern const lt_dlsymlist lt_preloaded_symbols[]; \ - lt_dlpreload_default(lt_preloaded_symbols); \ - }LT_STMT_END - - - - -/* --- MODULE INFORMATION --- */ - - -/* Associating user data with loaded modules. */ -typedef void * lt_dlinterface_id; -typedef int lt_dlhandle_interface (lt_dlhandle handle, const char *id_string); - -LT_SCOPE lt_dlinterface_id lt_dlinterface_register (const char *id_string, - lt_dlhandle_interface *iface); -LT_SCOPE void lt_dlinterface_free (lt_dlinterface_id key); -LT_SCOPE void * lt_dlcaller_set_data (lt_dlinterface_id key, - lt_dlhandle handle, void *data); -LT_SCOPE void * lt_dlcaller_get_data (lt_dlinterface_id key, - lt_dlhandle handle); - - -/* Read only information pertaining to a loaded module. */ -typedef struct { - char * filename; /* file name */ - char * name; /* module name */ - int ref_count; /* number of times lt_dlopened minus - number of times lt_dlclosed. */ - unsigned int is_resident:1; /* module can't be unloaded. */ - unsigned int is_symglobal:1; /* module symbols can satisfy - subsequently loaded modules. */ - unsigned int is_symlocal:1; /* module symbols are only available - locally. */ -} lt_dlinfo; - -LT_SCOPE const lt_dlinfo *lt_dlgetinfo (lt_dlhandle handle); - -LT_SCOPE lt_dlhandle lt_dlhandle_iterate (lt_dlinterface_id iface, - lt_dlhandle place); -LT_SCOPE lt_dlhandle lt_dlhandle_fetch (lt_dlinterface_id iface, - const char *module_name); -LT_SCOPE int lt_dlhandle_map (lt_dlinterface_id iface, - int (*func) (lt_dlhandle handle, void *data), - void *data); - - - -/* Deprecated module residency management API. */ -LT_SCOPE int lt_dlmakeresident (lt_dlhandle handle); -LT_SCOPE int lt_dlisresident (lt_dlhandle handle); - -#define lt_ptr void * - -LT_END_C_DECLS - -#endif /*!defined(LTDL_H)*/ diff --git a/libltdl/slist.c b/libltdl/slist.c deleted file mode 100644 index c99f399..0000000 --- a/libltdl/slist.c +++ /dev/null @@ -1,375 +0,0 @@ -/* slist.c -- generalised singly linked lists - - Copyright (C) 2000, 2004, 2007, 2008 Free Software Foundation, Inc. - Written by Gary V. Vaughan, 2000 - - NOTE: The canonical source of this file is maintained with the - GNU Libtool package. Report bugs to bug-libtool@gnu.org. - -GNU Libltdl is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2 of the License, or (at your option) any later version. - -As a special exception to the GNU Lesser General Public License, -if you distribute this file as part of a program or library that -is built using GNU Libtool, you may include this file under the -same distribution terms that you use for the rest of that program. - -GNU Libltdl is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with GNU Libltdl; see the file COPYING.LIB. If not, a -copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, -or obtained by writing to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include - -#include "slist.h" -#include - -static SList * slist_sort_merge (SList *left, SList *right, - SListCompare *compare, void *userdata); - - -/* Call DELETE repeatedly on each element of HEAD. - - CAVEAT: If you call this when HEAD is the start of a list of boxed - items, you must remember that each item passed back to your - DELETE function will be a boxed item that must be slist_unbox()ed - before operating on its contents. - - e.g. void boxed_delete (void *item) { item_free (slist_unbox (item)); } - ... - slist = slist_delete (slist, boxed_delete); - ... -*/ -SList * -slist_delete (SList *head, void (*delete_fct) (void *item)) -{ - assert (delete_fct); - - while (head) - { - SList *next = head->next; - (*delete_fct) (head); - head = next; - } - - return 0; -} - -/* Call FIND repeatedly with MATCHDATA and each item of *PHEAD, until - FIND returns non-NULL, or the list is exhausted. If a match is found - the matching item is destructively removed from *PHEAD, and the value - returned by the matching call to FIND is returned. - - CAVEAT: To avoid memory leaks, unless you already have the address of - the stale item, you should probably return that from FIND if - it makes a successful match. Don't forget to slist_unbox() - every item in a boxed list before operating on its contents. */ -void * -slist_remove (SList **phead, SListCallback *find, void *matchdata) -{ - SList *stale = 0; - void *result = 0; - - assert (find); - - if (!phead || !*phead) - return 0; - - /* Does the head of the passed list match? */ - result = (*find) (*phead, matchdata); - if (result) - { - stale = *phead; - *phead = stale->next; - } - /* what about the rest of the elements? */ - else - { - SList *head; - for (head = *phead; head->next; head = head->next) - { - result = (*find) (head->next, matchdata); - if (result) - { - stale = head->next; - head->next = stale->next; - break; - } - } - } - - return result; -} - -/* Call FIND repeatedly with each element of SLIST and MATCHDATA, until - FIND returns non-NULL, or the list is exhausted. If a match is found - the value returned by the matching call to FIND is returned. */ -void * -slist_find (SList *slist, SListCallback *find, void *matchdata) -{ - void *result = 0; - - assert (find); - - for (; slist; slist = slist->next) - { - result = (*find) (slist, matchdata); - if (result) - break; - } - - return result; -} - -/* Return a single list, composed by destructively concatenating the - items in HEAD and TAIL. The values of HEAD and TAIL are undefined - after calling this function. - - CAVEAT: Don't mix boxed and unboxed items in a single list. - - e.g. slist1 = slist_concat (slist1, slist2); */ -SList * -slist_concat (SList *head, SList *tail) -{ - SList *last; - - if (!head) - { - return tail; - } - - last = head; - while (last->next) - last = last->next; - - last->next = tail; - - return head; -} - -/* Return a single list, composed by destructively appending all of - the items in SLIST to ITEM. The values of ITEM and SLIST are undefined - after calling this function. - - CAVEAT: Don't mix boxed and unboxed items in a single list. - - e.g. slist1 = slist_cons (slist_box (data), slist1); */ -SList * -slist_cons (SList *item, SList *slist) -{ - if (!item) - { - return slist; - } - - assert (!item->next); - - item->next = slist; - return item; -} - -/* Return a list starting at the second item of SLIST. */ -SList * -slist_tail (SList *slist) -{ - return slist ? slist->next : NULL; -} - -/* Return a list starting at the Nth item of SLIST. If SLIST is less - than N items long, NULL is returned. Just to be confusing, list items - are counted from 1, to get the 2nd element of slist: - - e.g. shared_list = slist_nth (slist, 2); */ -SList * -slist_nth (SList *slist, size_t n) -{ - for (;n > 1 && slist; n--) - slist = slist->next; - - return slist; -} - -/* Return the number of items in SLIST. We start counting from 1, so - the length of a list with no items is 0, and so on. */ -size_t -slist_length (SList *slist) -{ - size_t n; - - for (n = 0; slist; ++n) - slist = slist->next; - - return n; -} - -/* Destructively reverse the order of items in SLIST. The value of SLIST - is undefined after calling this function. - - CAVEAT: You must store the result of this function, or you might not - be able to get all the items except the first one back again. - - e.g. slist = slist_reverse (slist); */ -SList * -slist_reverse (SList *slist) -{ - SList *result = 0; - SList *next; - - while (slist) - { - next = slist->next; - slist->next = result; - result = slist; - slist = next; - } - - return result; -} - -/* Call FOREACH once for each item in SLIST, passing both the item and - USERDATA on each call. */ -void * -slist_foreach (SList *slist, SListCallback *foreach, void *userdata) -{ - void *result = 0; - - assert (foreach); - - while (slist) - { - SList *next = slist->next; - result = (*foreach) (slist, userdata); - - if (result) - break; - - slist = next; - } - - return result; -} - -/* Destructively merge the items of two ordered lists LEFT and RIGHT, - returning a single sorted list containing the items of both -- Part of - the quicksort algorithm. The values of LEFT and RIGHT are undefined - after calling this function. - - At each iteration, add another item to the merged list by taking the - lowest valued item from the head of either LEFT or RIGHT, determined - by passing those items and USERDATA to COMPARE. COMPARE should return - less than 0 if the head of LEFT has the lower value, greater than 0 if - the head of RIGHT has the lower value, otherwise 0. */ -static SList * -slist_sort_merge (SList *left, SList *right, SListCompare *compare, - void *userdata) -{ - SList merged, *insert; - - insert = &merged; - - while (left && right) - { - if ((*compare) (left, right, userdata) <= 0) - { - insert = insert->next = left; - left = left->next; - } - else - { - insert = insert->next = right; - right = right->next; - } - } - - insert->next = left ? left : right; - - return merged.next; -} - -/* Perform a destructive quicksort on the items in SLIST, by repeatedly - calling COMPARE with a pair of items from SLIST along with USERDATA - at every iteration. COMPARE is a function as defined above for - slist_sort_merge(). The value of SLIST is undefined after calling - this function. - - e.g. slist = slist_sort (slist, compare, 0); */ -SList * -slist_sort (SList *slist, SListCompare *compare, void *userdata) -{ - SList *left, *right; - - if (!slist) - return slist; - - /* Be sure that LEFT and RIGHT never contain the same item. */ - left = slist; - right = slist->next; - - /* Skip two items with RIGHT and one with SLIST, until RIGHT falls off - the end. SLIST must be about half way along. */ - while (right && (right = right->next)) - { - if (!right || !(right = right->next)) - break; - slist = slist->next; - } - right = slist->next; - slist->next = 0; - - /* Sort LEFT and RIGHT, then merge the two. */ - return slist_sort_merge (slist_sort (left, compare, userdata), - slist_sort (right, compare, userdata), - compare, userdata); -} - - -/* Aside from using the functions above to manage chained structures of - any type that has a NEXT pointer as its first field, SLISTs can - be comprised of boxed items. The boxes are chained together in - that case, so there is no need for a NEXT field in the item proper. - Some care must be taken to slist_box and slist_unbox each item in - a boxed list at the appropriate points to avoid leaking the memory - used for the boxes. It us usually a very bad idea to mix boxed and - non-boxed items in a single list. */ - -/* Return a `boxed' freshly mallocated 1 element list containing - USERDATA. */ -SList * -slist_box (const void *userdata) -{ - SList *item = (SList *) malloc (sizeof *item); - - if (item) - { - item->next = 0; - item->userdata = userdata; - } - - return item; -} - -/* Return the contents of a `boxed' ITEM, recycling the box itself. */ -void * -slist_unbox (SList *item) -{ - void *userdata = 0; - - if (item) - { - /* Strip the const, because responsibility for this memory - passes to the caller on return. */ - userdata = (void *) item->userdata; - free (item); - } - - return userdata; -} diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 74c5029..6076561 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -4,7 +4,6 @@ add_subdirectory(Requests) include_directories(${INCLUDES}) -link_directories(${LTDL_LIBRARY_DIR}) add_library(Common Application.cpp Application.h @@ -27,4 +26,4 @@ add_library(Common UserManager.cpp UserManager.h XmlPacket.cpp XmlPacket.h ) -target_link_libraries(Common Backends RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${LTDL_LIBRARIES}) +target_link_libraries(Common Backends RequestHandlers Requests Net ${LIBXML2_LIBRARIES} ${DL_LIBRARY}) diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp index 25b0ee9..74c424d 100644 --- a/src/Common/ModuleManager.cpp +++ b/src/Common/ModuleManager.cpp @@ -26,37 +26,29 @@ #include #include -//extern const lt_dlsymlist lt_preloaded_symbols[]; +#include namespace Mad { namespace Common { -/*int ModuleManager::preopenCallback(lt_dlhandle handle) { - moduleManager.modules.insert(std::make_pair(lt_dlgetinfo(handle)->name, std::make_pair(handle, false))); - - return 0; -}*/ - ModuleManager::ModuleManager(Application *application0) : application(application0) { - lt_dlinit(); - - //lt_dlpreload_default(lt_preloaded_symbols); - //lt_dlpreload(0); - //lt_dlpreload_open("@PROGRAM@", &ModuleManager::preopenCallback); - application->getConfigManager()->registerConfigurable(this); } ModuleManager::~ModuleManager() { application->getConfigManager()->unregisterConfigurable(this); + boost::shared_lock lock(mutex); while(!moduleOrder.empty()) { - unloadModule(moduleOrder.top()); + std::string mod = moduleOrder.top(); + + lock.unlock(); + unloadModule(mod); + lock.lock(); + moduleOrder.pop(); } - - lt_dlexit(); } bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { @@ -73,38 +65,55 @@ bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handl return false; } -lt_dlhandle ModuleManager::loadModule(const std::string &name) { - std::map >::iterator mod = modules.find(name); +bool ModuleManager::loadModule(const std::string &name) { + { + boost::shared_lock lock(mutex); - if(mod == modules.end()) { - lt_dlhandle handle = lt_dlopen((name + MODULE_SUFFIX).c_str()); + if(modules.find(name) != modules.end()) + return true; + } - if(!handle) - return 0; + ModuleHandle handle = dlopen((name + MODULE_SUFFIX).c_str(), RTLD_NOW | RTLD_GLOBAL); - mod = modules.insert(std::make_pair(lt_dlgetinfo(handle)->name, std::make_pair(handle, (Module*)0))).first; + if(!handle) { + application->log(Core::LoggerBase::VERBOSE, std::string("loadModule: Can't open module: ") + std::string(dlerror())); + return false; } - if(!mod->second.second) { - ModuleLoadFunc loader; - *(void**)&loader = lt_dlsym(mod->second.first, (name + "_create").c_str()); - if(!loader) - return 0; + ModuleLoadFunc loader; + *(void**)&loader = dlsym(handle, (name + "_create").c_str()); - mod->second.second = loader(application); + if(!loader) { + application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Invalid module"); + return false; + } - if(mod->second.second) - moduleOrder.push(name); + Module *mod = loader(application); + + if(!mod) { + application->log(Core::LoggerBase::VERBOSE, "loadModule: Can't open module: Internal module error"); + return false; } - return mod->second.first; + modules.insert(std::make_pair(name, std::make_pair(handle, mod))).first; + moduleOrder.push(name); + + return true; } void ModuleManager::unloadModule(const std::string &name) { - delete modules[name].second; - lt_dlclose(modules[name].first); + boost::upgrade_lock lock(mutex); + + std::map >::iterator mod = modules.find(name); + if(mod == modules.end()) + return; + + boost::upgrade_to_unique_lock upgradeLock(lock); + + delete mod->second.second; + dlclose(mod->second.first); - modules.erase(name); + modules.erase(mod); } } diff --git a/src/Common/ModuleManager.h b/src/Common/ModuleManager.h index eb8c800..9d722c4 100644 --- a/src/Common/ModuleManager.h +++ b/src/Common/ModuleManager.h @@ -23,14 +23,12 @@ #include "Module.h" #include -#include +#include #include #include #include -#include - namespace Mad { namespace Common { @@ -40,14 +38,15 @@ class ModuleManager : public Core::Configurable, private boost::noncopyable { private: friend class Application; - typedef Module* (*ModuleLoadFunc)(Application*); + typedef void *ModuleHandle; + typedef Module *(*ModuleLoadFunc)(Application*); Application *application; - std::map > modules; + std::map > modules; std::stack moduleOrder; - //static int preopenCallback(lt_dlhandle handle); + boost::shared_mutex mutex; ModuleManager(Application *application0); ~ModuleManager(); @@ -58,7 +57,7 @@ class ModuleManager : public Core::Configurable, private boost::noncopyable { virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled); public: - lt_dlhandle loadModule(const std::string &name); + bool loadModule(const std::string &name); }; } -- cgit v1.2.3