diff options
Diffstat (limited to 'src/journal/pcre2-dlopen.c')
-rw-r--r-- | src/journal/pcre2-dlopen.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/journal/pcre2-dlopen.c b/src/journal/pcre2-dlopen.c index 210e39a0ae..475d7eb26d 100644 --- a/src/journal/pcre2-dlopen.c +++ b/src/journal/pcre2-dlopen.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "alloc-util.h" #include "dlfcn-util.h" +#include "log.h" #include "pcre2-dlopen.h" #if HAVE_PCRE2 @@ -16,17 +16,6 @@ int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, u PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *); int dlopen_pcre2(void) { - _cleanup_(dlclosep) void *dl = NULL; - int r; - - if (pcre2_dl) - return 0; /* Already loaded */ - - dl = dlopen("libpcre2-8.so.0", RTLD_LAZY); - if (!dl) - return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), - "PCRE2 support is not installed: %s", dlerror()); - /* So here's something weird: PCRE2 actually renames the symbols exported by the library via C * macros, so that the exported symbols carry a suffix "_8" but when used from C the suffix is * gone. In the argument list below we ignore this mangling. Surprisingly (at least to me), we @@ -35,25 +24,15 @@ int dlopen_pcre2(void) { * string actually contains the "_8" suffix already due to that and we don't have to append it * manually anymore. C is weird. 🤯 */ - r = dlsym_many_or_warn( - dl, - LOG_ERR, + return dlopen_many_sym_or_warn( + &pcre2_dl, "libpcre2-8.so.0", LOG_ERR, DLSYM_ARG(pcre2_match_data_create), DLSYM_ARG(pcre2_match_data_free), DLSYM_ARG(pcre2_code_free), DLSYM_ARG(pcre2_compile), DLSYM_ARG(pcre2_get_error_message), DLSYM_ARG(pcre2_match), - DLSYM_ARG(pcre2_get_ovector_pointer), - NULL); - if (r < 0) - return r; - - /* Note that we never release the reference here, because there's no real reason to, after all this - * was traditionally a regular shared library dependency which lives forever too. */ - pcre2_dl = TAKE_PTR(dl); - - return 1; + DLSYM_ARG(pcre2_get_ovector_pointer)); } #else |