]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
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. | |
7 | */ | |
8 | ||
ff9d9458 FC |
9 | #ifndef SQUID_SRC_LOADABLEMODULE_H |
10 | #define SQUID_SRC_LOADABLEMODULE_H | |
57afc994 | 11 | |
1c464a53 | 12 | #include "sbuf/SBuf.h" |
57afc994 AR |
13 | |
14 | // wrapper for dlopen(3), libltdl, and friends | |
26ac0430 AJ |
15 | class LoadableModule |
16 | { | |
57afc994 | 17 | public: |
1c464a53 | 18 | explicit LoadableModule(const SBuf &aName); |
57afc994 AR |
19 | ~LoadableModule(); // unloads if loaded |
20 | ||
21 | bool loaded() const; | |
1c464a53 AJ |
22 | const auto &name() const { return theName; } |
23 | const auto &error() const { return theError; } | |
57afc994 | 24 | |
8b082ed9 | 25 | void load(); // throws Texc |
57afc994 AR |
26 | void unload(); // throws Texc |
27 | ||
28 | protected: | |
1c464a53 AJ |
29 | SBuf theName; |
30 | SBuf theError; | |
31 | void *theHandle = nullptr; | |
57afc994 AR |
32 | |
33 | private: | |
8b082ed9 | 34 | void *openModule(); |
57afc994 AR |
35 | bool closeModule(); |
36 | const char *errorMsg(); | |
37 | }; | |
38 | ||
ff9d9458 | 39 | #endif /* SQUID_SRC_LOADABLEMODULE_H */ |
f53969cc | 40 |