summaryrefslogtreecommitdiff
path: root/Perl-RPM
diff options
context:
space:
mode:
authorrjray <devnull@localhost>2000-11-10 08:49:11 +0000
committerrjray <devnull@localhost>2000-11-10 08:49:11 +0000
commit843e9e77638ee94fbce8b4f5a623c4610b5854d0 (patch)
tree4055c86eaad52b0343c610a41f6b64d5566d7a41 /Perl-RPM
parent80450e23a63a38d0fae18a2d7110ca82d2184fa4 (diff)
downloadrpm-843e9e77638ee94fbce8b4f5a623c4610b5854d0.tar.gz
sync w/ desktop
CVS patchset: 4248 CVS date: 2000/11/10 08:49:11
Diffstat (limited to 'Perl-RPM')
-rw-r--r--Perl-RPM/ChangeLog17
-rw-r--r--Perl-RPM/RPM/Package.xs71
2 files changed, 86 insertions, 2 deletions
diff --git a/Perl-RPM/ChangeLog b/Perl-RPM/ChangeLog
index 6437168bb..31d5a7b5c 100644
--- a/Perl-RPM/ChangeLog
+++ b/Perl-RPM/ChangeLog
@@ -155,3 +155,20 @@ Revision history for Perl extension RPM.
generation of make rules to construct *.rpm and *.srpm files, and
generation of "rpmrc" and "rpmmacro" files to use in invoking rpm
(to force all operation into the local dir area).
+
+0.292
+ - ninth alpha
+
+ Some unused variables were found in several places.
+
+ Moved away from the self-tie mechanism and instead handled the data
+ opacity in a completely different fashion. This simplified some code,
+ muddled some, but ultimately led to the removal of several #define
+ macros, more unused variable removal, and (hopefully) more stable
+ code.
+
+ Addressed a problem in both RPM::Database and RPM::Header XS code
+ wherein destructors were not getting called when objects were
+ implicitly or explicitly freed.
+
+ Added more tests to the test suite.
diff --git a/Perl-RPM/RPM/Package.xs b/Perl-RPM/RPM/Package.xs
index 26d641815..2968772a5 100644
--- a/Perl-RPM/RPM/Package.xs
+++ b/Perl-RPM/RPM/Package.xs
@@ -4,7 +4,7 @@
#include "RPM.h"
-static char * const rcsid = "$Id: Package.xs,v 1.4 2000/10/12 05:09:45 rjray Exp $";
+static char * const rcsid = "$Id: Package.xs,v 1.5 2000/11/10 08:49:24 rjray Exp $";
/* Any constants that are specific to the RPM::Header class will be exported
from here, via this C-level constant() routine */
@@ -26,22 +26,35 @@ static int constant(pTHX_ char *name)
if (strEQ(name, "MASK"))
#ifdef RPM_HEADER_MASK
return RPM_PACKAGE_MASK;
+#else
+ goto not_found;
#endif
+ break;
case 'N':
if (strEQ(name, "NOREAD"))
#ifdef RPM_HEADER_NOREAD
return RPM_PACKAGE_NOREAD;
+#else
+ goto not_found;
#endif
+ break;
case 'R':
if (strEQ(name, "READONLY"))
#ifdef RPM_HEADER_READONLY
return RPM_PACKAGE_READONLY;
+#else
+ goto not_found;
#endif
+ break;
default:
errno = EINVAL;
return 0;
}
}
+
+ not_found:
+ errno = EINVAL;
+ return 0;
}
/* This is the class constructor for RPM::Package */
@@ -126,7 +139,7 @@ void rpmpkg_DESTROY(pTHX_ RPM__Package self)
/* Free/release the dynamic parts of the package structure */
if (self->path)
safefree(self->path);
- /* The Perl structure have their own clean-up methods that will kick in */
+ /* The Perl structures have their own clean-up methods that will kick in */
return;
}
@@ -236,6 +249,60 @@ int rpmpkg_cmpver_hdr(pTHX_ RPM__Package self, RPM__Header two)
return rpmhdr_cmpver(aTHX_ self->header, two);
}
+/*
+ * This is where we catch all callback-ish events for packages, and translate
+ * them into a Perl-ized callback mechanism with (mostly) the same arguments
+ * and argument structure.
+ */
+static void* rpmpkg_callback_handler(const Header h,
+ const rpmCallbackType what,
+ const unsigned long amount,
+ const unsigned long total,
+ const void* pkg_key,
+ void* data)
+{
+ /* We couldn't declare the thread context in the prototype because we
+ don't control the calling context of this function. */
+ dTHX;
+ RPM__Package self; /* This gets derived from "data" */
+ SV* callback; /* So that we can more easily sanity-check it */
+
+ /* This is simple, but I'm planning ahead in case it gets more complex */
+ self = data;
+ if (! (callback = (SV *)self->callback))
+ return (void *)NULL;
+
+ /* Set up the stack and the context */
+ if (SvOK(callback) && (SvTYPE(callback) == SVt_PVCV))
+ {
+ dSP;
+ ENTER;
+ SAVETMPS;
+ PUSHMARK(sp);
+
+ /* Set up the args list */
+ XPUSHs(sv_2mortal(sv_setref_pv(newSVsv(&PL_sv_undef), "RPM::Package",
+ (void *)self)));
+ XPUSHs(sv_2mortal(newSViv((I32)what)));
+ XPUSHs(sv_2mortal(newSViv(amount)));
+ XPUSHs(sv_2mortal(newSViv(total)));
+ XPUSHs(sv_2mortal(newSVpv((char *)pkg_key, 0)));
+ if (self->cb_data != Nullsv)
+ XPUSHs(sv_2mortal(newSVsv(self->cb_data)));
+
+ /* Make the call */
+ perl_call_sv((SV *)self->callback, G_DISCARD);
+
+ /* More boilerplate */
+ SPAGAIN;
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+ }
+
+ return (void *)NULL;
+}
+
MODULE = RPM::Package PACKAGE = RPM::Package PREFIX = rpmpkg_