Debian Codegraph @

src/shared/idn-util.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "idn-util.h"
4 #include "log.h" /* IWYU pragma: keep */
5
6 #if HAVE_LIBIDN2
7
8 #include "sd-dlopen.h"
9
10 static void* idn_dl = NULL;
11
12 DLSYM_PROTOTYPE(idn2_lookup_u8) = NULL;
13 const char *(*sym_idn2_strerror)(int rc) _const_ = NULL;
14 DLSYM_PROTOTYPE(idn2_to_unicode_8z8z) = NULL;
15
16 #endif
17
18 int dlopen_idn(int log_level) {
19 #if HAVE_LIBIDN2
20 IDN_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
21
22 return dlopen_many_sym_or_warn(
23 &idn_dl, "libidn2.so.0", log_level,
24 DLSYM_ARG(idn2_lookup_u8),
25 DLSYM_ARG(idn2_strerror),
26 DLSYM_ARG(idn2_to_unicode_8z8z));
27 #else
28 return log_full_errno(log_level, SYNTHETIC_ERRNO(EOPNOTSUPP),
29 "libidn2 support is not compiled in.");
30 #endif
31 }