]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/LoadableModule.cc
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "base/TextException.h"
11 #include "libltdl/ltdl.h" /* generated file */
12 #include "LoadableModule.h"
14 // Note: We must use preprocessor instead of C ifs because if dlopen()
15 // is seen by the static linker, the linker will complain.
17 LoadableModule::LoadableModule(const String
&aName
): theName(aName
), theHandle(0)
19 // Initialise preloaded symbol lookup table.
20 LTDL_SET_PRELOADED_SYMBOLS();
22 throw TexcHere("internal error: cannot initialize libtool module loader");
25 LoadableModule::~LoadableModule()
29 assert(lt_dlexit() == 0); // XXX: replace with a warning
33 LoadableModule::loaded() const
35 return theHandle
!= 0;
39 LoadableModule::load(int mode
)
42 throw TexcHere("internal error: reusing LoadableModule object");
44 theHandle
= openModule(mode
);
47 throw TexcHere(errorMsg());
51 LoadableModule::unload()
54 throw TexcHere("internal error: unloading not loaded module");
57 throw TexcHere(errorMsg());
63 LoadableModule::openModule(int mode
)
65 return lt_dlopen(theName
.termedBuf());
69 LoadableModule::closeModule()
71 // we cast to avoid including ltdl.h in LoadableModule.h
72 return lt_dlclose(static_cast<lt_dlhandle
>(theHandle
)) == 0;
76 LoadableModule::errorMsg()