From a58cf01cb9b07d501e31aaf7ff3549579e8b1dc6 Mon Sep 17 00:00:00 2001 From: rjray Date: Fri, 18 Aug 2000 08:25:39 +0000 Subject: [PATCH] Some error-fixing around reading header data from files, and some additional fixing when reading from an ftp source. Also added a source_name() method to access the struct element that remembers the source when the header data comes from a file, ftp or http. CVS patchset: 4081 CVS date: 2000/08/18 08:25:39 --- Perl-RPM/RPM/Header.xs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Perl-RPM/RPM/Header.xs b/Perl-RPM/RPM/Header.xs index 26aba43..c01157b 100644 --- a/Perl-RPM/RPM/Header.xs +++ b/Perl-RPM/RPM/Header.xs @@ -4,7 +4,7 @@ #include "RPM.h" -static char * const rcsid = "$Id: Header.xs,v 1.14 2000/08/17 09:23:19 rjray Exp $"; +static char * const rcsid = "$Id: Header.xs,v 1.15 2000/08/18 08:25:39 rjray Exp $"; static int scalar_tag(pTHX_ SV *, int); /* @@ -206,6 +206,7 @@ static int new_from_fd(int fd, RPM_Header* new_hdr) static int new_from_fname(pTHX_ const char* source, RPM_Header* new_hdr) { FD_t fd; + int retval; if (! (fd = Fopen(source, "r"))) { @@ -216,7 +217,14 @@ static int new_from_fname(pTHX_ const char* source, RPM_Header* new_hdr) return 0; } - return(new_from_fd_t(fd, new_hdr)); + if (retval = new_from_fd_t(fd, new_hdr)) + { + Fclose(fd); + new_hdr->source_name = safemalloc(strlen(source) + 1); + strcpy(new_hdr->source_name, source); + } + + return retval; } RPM__Header rpmhdr_TIEHASH(pTHX_ SV* class, SV* source, int flags) @@ -1025,6 +1033,20 @@ int rpmhdr_cmpver(pTHX_ RPM__Header self, RPM__Header other) } /* + If the header object was read from a specific source (file, ftp, http), then + a copy of that location was kept for future reference. Now reference it. +*/ +char* rpmhdr_source_name(RPM__Header self) +{ + SV** svp; + RPM_Header* hdr; + + header_from_object(svp, hdr, self); + + return hdr->source_name; +} + +/* A matter-of-convenience function that tells whether the passed-in tag is one that returns a scalar (yields a true return value) or one that returns an array reference (yields a false value). @@ -1328,3 +1350,12 @@ rpmhdr_scalar_tag(self, tag) } OUTPUT: RETVAL + +char* +rpmhdr_source_name(self) + RPM::Header self; + PROTOTYPE: $ + CODE: + RETVAL = rpmhdr_source_name(self); + OUTPUT: + RETVAL -- 2.7.4