summaryrefslogtreecommitdiff
path: root/Perl-RPM/RPM
diff options
context:
space:
mode:
Diffstat (limited to 'Perl-RPM/RPM')
-rw-r--r--Perl-RPM/RPM/Package.pm36
-rw-r--r--Perl-RPM/RPM/Package.xs50
2 files changed, 78 insertions, 8 deletions
diff --git a/Perl-RPM/RPM/Package.pm b/Perl-RPM/RPM/Package.pm
index 82f698f68..f4a68fedb 100644
--- a/Perl-RPM/RPM/Package.pm
+++ b/Perl-RPM/RPM/Package.pm
@@ -7,18 +7,18 @@
#
###############################################################################
#
-# $Id: Package.pm,v 1.4 2000/10/08 10:09:26 rjray Exp $
+# $Id: Package.pm,v 1.5 2000/10/12 05:09:45 rjray Exp $
#
# Description: Perl-level glue and such for the RPM::Package class, the
# methods and accessors to package operations.
#
-# Functions:
+# Functions: AUTOLOAD
#
# Libraries: RPM
#
-# Global Consts:
+# Global Consts: $VERSION
#
-# Environment:
+# Environment: None.
#
###############################################################################
@@ -26,13 +26,35 @@ package RPM::Package;
use 5.005;
use strict;
-use vars qw($VERSION $revision);
-use subs qw();
+use vars qw($VERSION $revision @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
+use subs qw(AUTOLOAD);
+
+require Exporter;
use RPM;
$VERSION = '0.29';
-$revision = do { my @r=(q$Revision: 1.4 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
+$revision = do { my @r=(q$Revision: 1.5 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
+
+@ISA = qw(Exporter);
+@EXPORT = ();
+@EXPORT_OK = qw(RPM_PACKAGE_MASK RPM_PACKAGE_NOREAD RPM_PACKAGE_READONLY);
+%EXPORT_TAGS = (all => \@EXPORT_OK);
+
+sub AUTOLOAD
+{
+ my $constname;
+ ($constname = $AUTOLOAD) =~ s/.*:://;
+ die "& not defined" if $constname eq 'constant';
+ my $val = constant($constname);
+ if ($! != 0)
+ {
+ die "Your vendor has not defined RPM macro $constname";
+ }
+ no strict 'refs';
+ *$AUTOLOAD = sub { $val };
+ goto &$AUTOLOAD;
+}
1;
diff --git a/Perl-RPM/RPM/Package.xs b/Perl-RPM/RPM/Package.xs
index e3ead6803..26d641815 100644
--- a/Perl-RPM/RPM/Package.xs
+++ b/Perl-RPM/RPM/Package.xs
@@ -4,8 +4,47 @@
#include "RPM.h"
-static char * const rcsid = "$Id: Package.xs,v 1.3 2000/10/08 10:09:26 rjray Exp $";
+static char * const rcsid = "$Id: Package.xs,v 1.4 2000/10/12 05:09:45 rjray Exp $";
+/* Any constants that are specific to the RPM::Header class will be exported
+ from here, via this C-level constant() routine */
+static int constant(pTHX_ char *name)
+{
+ errno = 0;
+
+ if (strncmp((const char *)name, "RPM_PACKAGE_", 12))
+ {
+ errno = ENOENT;
+ return 0;
+ }
+ else
+ {
+ name += 12;
+ switch (*name)
+ {
+ case 'M':
+ if (strEQ(name, "MASK"))
+#ifdef RPM_HEADER_MASK
+ return RPM_PACKAGE_MASK;
+#endif
+ case 'N':
+ if (strEQ(name, "NOREAD"))
+#ifdef RPM_HEADER_NOREAD
+ return RPM_PACKAGE_NOREAD;
+#endif
+ case 'R':
+ if (strEQ(name, "READONLY"))
+#ifdef RPM_HEADER_READONLY
+ return RPM_PACKAGE_READONLY;
+#endif
+ default:
+ errno = EINVAL;
+ return 0;
+ }
+ }
+}
+
+/* This is the class constructor for RPM::Package */
RPM__Package rpmpkg_new(pTHX_ char* class, SV* source, int flags)
{
char* fname;
@@ -316,3 +355,12 @@ rpmpkg_cmpver(self, other)
}
OUTPUT:
RETVAL
+
+int
+constant(name)
+ char* name;
+ PROTOTYPE: $
+ CODE:
+ RETVAL = constant(aTHX_ name);
+ OUTPUT:
+ RETVAL