blob: 05d9fc0638a8f4f4e9cb5176f2ac3b5722f502f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "config.h"
#include "dbus_wrap.h"
#ifdef HAVE_DYNLOAD
#include <mutex>
#include <type_traits>
#include "logging.h"
void PrepareDBus()
{
const char *libname{"libdbus-1.so.3"};
dbus_handle = LoadLib(libname);
if(!dbus_handle)
{
WARN("Failed to load %s\n", libname);
return;
}
auto load_func = [](auto &f, const char *name) -> void
{ f = reinterpret_cast<std::remove_reference_t<decltype(f)>>(GetSymbol(dbus_handle, name)); };
#define LOAD_FUNC(x) do { \
load_func(p##x, #x); \
if(!p##x) \
{ \
WARN("Failed to load function %s\n", #x); \
CloseLib(dbus_handle); \
dbus_handle = nullptr; \
return; \
} \
} while(0);
DBUS_FUNCTIONS(LOAD_FUNC)
#undef LOAD_FUNC
}
#endif
|