From 3f5225d7f301f70c9418122cf1e1989ccb33ea76 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Oct 2022 14:21:43 +0200 Subject: [PATCH] qrcode-util: Add support for libqrencode 3.0 They didn't actually change API between major versions, so let's support the previous version as well so we can add CentOS 8 Stream back to CI. --- meson.build | 2 +- src/shared/qrcode-util.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 2c6a061a90..dfe18f7e7b 100644 --- a/meson.build +++ b/meson.build @@ -1388,7 +1388,7 @@ conf.set10('HAVE_LIBIPTC', have) want_qrencode = get_option('qrencode') if want_qrencode != 'false' and not skip_deps libqrencode = dependency('libqrencode', - version : '>= 4', + version : '>= 3', required : want_qrencode == 'true') have = libqrencode.found() else diff --git a/src/shared/qrcode-util.c b/src/shared/qrcode-util.c index 1ad3474b3f..4a33c28bf2 100644 --- a/src/shared/qrcode-util.c +++ b/src/shared/qrcode-util.c @@ -8,6 +8,7 @@ #include "dlfcn-util.h" #include "locale-util.h" #include "log.h" +#include "strv.h" #include "terminal-util.h" #define ANSI_WHITE_ON_BLACK "\033[40;37;1m" @@ -21,10 +22,18 @@ static QRcode* (*sym_QRcode_encodeString)(const char *string, int version, QRecL static void (*sym_QRcode_free)(QRcode *qrcode) = NULL; int dlopen_qrencode(void) { - return dlopen_many_sym_or_warn( - &qrcode_dl, "libqrencode.so.4", LOG_DEBUG, + int r; + + FOREACH_STRING(s, "libqrencode.so.4", "libqrencode.so.3") { + r = dlopen_many_sym_or_warn( + &qrcode_dl, s, LOG_DEBUG, DLSYM_ARG(QRcode_encodeString), DLSYM_ARG(QRcode_free)); + if (r >= 0) + break; + } + + return r; } static void print_border(FILE *output, unsigned width) {