]> git.ipfire.org Git - thirdparty/squid.git/blob - src/LoadableModule.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / LoadableModule.h
1 /*
2 * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
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
9 #ifndef SQUID_LOADABLE_MODULE_H
10 #define SQUID_LOADABLE_MODULE_H
11
12 #include "SquidString.h"
13
14 // wrapper for dlopen(3), libltdl, and friends
15 class LoadableModule
16 {
17 public:
18 enum LoadMode { lmNow, lmLazy };
19
20 public:
21 LoadableModule(const String &aName);
22 ~LoadableModule(); // unloads if loaded
23
24 bool loaded() const;
25 const String &name() const { return theName; }
26 const String &error() const { return theError; }
27
28 void load(int mode = lmNow); // throws Texc
29 void unload(); // throws Texc
30
31 protected:
32 String theName;
33 String theError;
34 void *theHandle;
35
36 private:
37 void *openModule(int mode);
38 bool closeModule();
39 const char *errorMsg();
40 };
41
42 #endif
43