diff options
author | Thierry Vignaud <thierry.vignaud@gmail.com> | 2022-04-29 11:15:10 +0200 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2022-04-29 15:55:56 +0200 |
commit | be7d98907e35fcb918753255474885f4d4a4fb2f (patch) | |
tree | 249317dc73a3734133687ae73db27e6c8850ecf9 | |
parent | 4de9e157f8b9f030e087146085b4543819b07b67 (diff) | |
download | perl-RPM4-be7d98907e35fcb918753255474885f4d4a4fb2f.tar perl-RPM4-be7d98907e35fcb918753255474885f4d4a4fb2f.tar.gz perl-RPM4-be7d98907e35fcb918753255474885f4d4a4fb2f.tar.bz2 perl-RPM4-be7d98907e35fcb918753255474885f4d4a4fb2f.tar.xz perl-RPM4-be7d98907e35fcb918753255474885f4d4a4fb2f.zip |
(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
-rw-r--r-- | RPM4/src/Makefile.PL | 1 | ||||
-rw-r--r-- | RPM4/src/RPM4.xs | 11 |
2 files changed, 12 insertions, 0 deletions
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); |