]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/dlfcn-util.c
update TODO
[thirdparty/systemd.git] / src / basic / dlfcn-util.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "dlfcn-util.h"
4
5 int dlsym_many_and_warn(void *dl, int level, ...) {
6 va_list ap;
7 int r;
8
9 /* Tries to resolve a bunch of function symbols, and logs errors about the ones it cannot
10 * resolve. Note that this function possibly modifies the supplied function pointers if the whole
11 * operation fails */
12
13 va_start(ap, level);
14
15 for (;;) {
16 void (**fn)(void);
17 void (*tfn)(void);
18 const char *symbol;
19
20 fn = va_arg(ap, typeof(fn));
21 if (!fn)
22 break;
23
24 symbol = va_arg(ap, typeof(symbol));
25
26 tfn = (typeof(tfn)) dlsym(dl, symbol);
27 if (!tfn) {
28 r = log_full_errno(level,
29 SYNTHETIC_ERRNO(ELIBBAD),
30 "Can't find symbol %s: %s", symbol, dlerror());
31 va_end(ap);
32 return r;
33 }
34
35 *fn = tfn;
36 }
37
38 va_end(ap);
39 return 0;
40 }