From be7d98907e35fcb918753255474885f4d4a4fb2f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 29 Apr 2022 11:15:10 +0200 Subject: (Header_string) make it compile again with rpm < 4.19 Technically headerUnload() has been deprecated by headerExport() in rpm-4.10, but let's keep using the old testedcode path in rpm < 4.18 but starts using and testing the new code path in 4.18+ before headerUnload() removal in 4.19 --- RPM4/src/Makefile.PL | 1 + RPM4/src/RPM4.xs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/RPM4/src/Makefile.PL b/RPM4/src/Makefile.PL index 025f5c8..c39ef23 100644 --- a/RPM4/src/Makefile.PL +++ b/RPM4/src/Makefile.PL @@ -42,6 +42,7 @@ foreach (qw( 4.12.0 4.12.90 4.15.0 + 4.18.0 )) { my $v = $_; my $vobj = version->declare("v$_"); diff --git a/RPM4/src/RPM4.xs b/RPM4/src/RPM4.xs index 5000e7e..0ba8b52 100644 --- a/RPM4/src/RPM4.xs +++ b/RPM4/src/RPM4.xs @@ -946,11 +946,22 @@ Header_string(h, no_header_magic = 0) PREINIT: char * string = NULL; char * ptr = NULL; +#if defined(RPM4_18_0) unsigned int hsize = 0; +#else + int hsize = 0; +#endif PPCODE: +#if defined(RPM4_18_0) string = headerExport(h, &hsize); +#else + hsize = headerSizeof(h, no_header_magic ? HEADER_MAGIC_NO : HEADER_MAGIC_YES); + string = headerUnload(h); +#endif if (! no_header_magic) { +#if defined(RPM4_18_0) hsize +=sizeof(header_magic); // Adjust for header_magic +#endif ptr = malloc(hsize); memcpy(ptr, header_magic, 8); memcpy(ptr + 8, string, hsize - 8); -- cgit v1.2.1