summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2022-04-29 11:15:10 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2022-04-29 15:55:56 +0200
commitbe7d98907e35fcb918753255474885f4d4a4fb2f (patch)
tree249317dc73a3734133687ae73db27e6c8850ecf9
parent4de9e157f8b9f030e087146085b4543819b07b67 (diff)
downloadperl-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.PL1
-rw-r--r--RPM4/src/RPM4.xs11
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);