]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/LoadableModule.cc
2 * Copyright (C) 1996-2023 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 SBuf
&aName
):
20 // Initialise preloaded symbol lookup table.
21 LTDL_SET_PRELOADED_SYMBOLS();
23 throw TexcHere("internal error: cannot initialize libtool module loader");
26 LoadableModule::~LoadableModule()
30 assert(lt_dlexit() == 0); // XXX: replace with a warning
34 LoadableModule::loaded() const
36 return theHandle
!= nullptr;
40 LoadableModule::load()
43 throw TexcHere("internal error: reusing LoadableModule object");
45 theHandle
= openModule();
48 throw TexcHere(errorMsg());
52 LoadableModule::unload()
55 throw TexcHere("internal error: unloading not loaded module");
58 throw TexcHere(errorMsg());
64 LoadableModule::openModule()
66 return lt_dlopen(theName
.c_str());
70 LoadableModule::closeModule()
72 // we cast to avoid including ltdl.h in LoadableModule.h
73 return lt_dlclose(static_cast<lt_dlhandle
>(theHandle
)) == 0;
77 LoadableModule::errorMsg()