summaryrefslogtreecommitdiff
path: root/Perl-RPM/RPM.xs
diff options
context:
space:
mode:
Diffstat (limited to 'Perl-RPM/RPM.xs')
-rw-r--r--Perl-RPM/RPM.xs49
1 files changed, 28 insertions, 21 deletions
diff --git a/Perl-RPM/RPM.xs b/Perl-RPM/RPM.xs
index ae401f497..aef87f673 100644
--- a/Perl-RPM/RPM.xs
+++ b/Perl-RPM/RPM.xs
@@ -4,7 +4,7 @@
#include "RPM.h"
-static char * const rcsid = "$Id: RPM.xs,v 1.3 2000/05/30 01:03:13 rjray Exp $";
+static char * const rcsid = "$Id: RPM.xs,v 1.4 2000/06/02 07:51:51 rjray Exp $";
extern XS(boot_RPM__Constants);
extern XS(boot_RPM__Header);
@@ -26,11 +26,11 @@ static void setup_tag_mappings(pTHX)
num2tag_priv = perl_get_hv("RPM::num2tag", TRUE);
for (idx = 0; idx < rpmTagTableSize; idx++)
{
- //
- // For future reference: The offset of 7 used in referring to the
- // (const char *) tag and its length is to discard the "RPMTAG_"
- // prefix inherent in the tag names.
- //
+ /*
+ For future reference: The offset of 7 used in referring to the
+ (const char *) tag and its length is to discard the "RPMTAG_"
+ prefix inherent in the tag names.
+ */
tag = rpmTagTable[idx].name;
num = rpmTagTable[idx].val;
hv_store(tag2num_priv, (char *)tag + 7, strlen(tag) - 7,
@@ -46,10 +46,10 @@ int tag2num(pTHX_ const char* tag)
{
SV** svp;
- // Get the #define value for the tag from the hash made at boot-up
+ /* Get the #define value for the tag from the hash made at boot-up */
svp = hv_fetch(tag2num_priv, (char *)tag, strlen(tag), FALSE);
if (! (svp && SvOK(*svp) && SvIOK(*svp)))
- // Later we may need to set some sort of error message
+ /* Later we may need to set some sort of error message */
return 0;
return (SvIV(*svp));
@@ -88,27 +88,32 @@ char* rpm_rpm_archname(void)
return arch_name;
}
-// This is a callback routine that the bootstrapper will register with the RPM
-// lib so as to catch any errors. (I hope)
-static void rpm_catch_errors(pTHX)
+/*
+ This is a callback routine that the bootstrapper will register with the RPM
+ lib so as to catch any errors. (I hope)
+*/
+static void rpm_catch_errors(void)
{
+ /* Because rpmErrorSetCallback expects (void)fn(void), we have to declare
+ our thread context here */
+ dTHX;
int error_code;
char* error_string;
error_code = rpmErrorCode();
error_string = rpmErrorString();
- // Set the string part, first
+ /* Set the string part, first */
sv_setsv(errSV, newSVpv(error_string, strlen(error_string)));
- // Set the IV part
+ /* Set the IV part */
sv_setiv(errSV, error_code);
- // Doing that didn't erase the PV part, but it cleared the flag:
+ /* Doing that didn't erase the PV part, but it cleared the flag: */
SvPOK_on(errSV);
- // If there is a current callback, invoke it:
+ /* If there is a current callback, invoke it: */
if (err_callback != NULL)
{
- // This is just standard boilerplate for calling perl from C
+ /* This is just standard boilerplate for calling perl from C */
dSP;
ENTER;
SAVETMPS;
@@ -117,10 +122,10 @@ static void rpm_catch_errors(pTHX)
XPUSHs(sv_2mortal(newSVpv(error_string, strlen(error_string))));
PUTBACK;
- // The actual call
+ /* The actual call */
perl_call_sv((SV *)err_callback, G_DISCARD);
- // More boilerplate
+ /* More boilerplate */
SPAGAIN;
PUTBACK;
FREETMPS;
@@ -130,7 +135,7 @@ static void rpm_catch_errors(pTHX)
return;
}
-// This is just to make available an easy way to clear both sides of $RPM::err
+/* This is just to offer an easy way to clear both sides of $RPM::err */
void clear_errors(pTHX)
{
sv_setsv(errSV, newSVpv("", 0));
@@ -174,7 +179,7 @@ SV* set_error_callback(pTHX_ SV* newcb)
return oldcb;
}
-void rpm_error(int code, const char* message)
+void rpm_error(pTHX_ int code, const char* message)
{
rpmError(code, (char *)message);
}
@@ -203,6 +208,8 @@ rpm_error(code, message)
int code;
char* message;
PROTOTYPE: $$
+ CODE:
+ rpm_error(aTHX_ code, message);
MODULE = RPM PACKAGE = RPM PREFIX = rpm_
@@ -229,7 +236,7 @@ BOOT:
sv_setiv(config_loaded, TRUE);
}
- setup_tag_mappings();
+ setup_tag_mappings(aTHX);
rpmErrorSetCallback(rpm_catch_errors);
err_callback = Nullcv;