diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-11-27 11:52:55 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-11-27 11:52:55 +0200 |
commit | 5fa08529cb805bb36a8b9a1d7300cade13d05e4b (patch) | |
tree | 624b3b52b0409019664ec96e526aa3a76d7201bd | |
parent | fbf0cb4441816b70a6a8e5ecef37d54b152b9db0 (diff) | |
download | rpm-5fa08529cb805bb36a8b9a1d7300cade13d05e4b.tar.gz rpm-5fa08529cb805bb36a8b9a1d7300cade13d05e4b.tar.bz2 rpm-5fa08529cb805bb36a8b9a1d7300cade13d05e4b.zip |
Move rpmfiBuildFNames() to rpmfi now that it's possible
-rw-r--r-- | lib/formats.c | 1 | ||||
-rw-r--r-- | lib/legacy.c | 56 | ||||
-rw-r--r-- | lib/legacy.h | 20 | ||||
-rw-r--r-- | lib/psm.c | 1 | ||||
-rw-r--r-- | lib/rpmfi.c | 56 | ||||
-rw-r--r-- | lib/rpmfi.h | 20 | ||||
-rw-r--r-- | python/header-py.c | 2 |
7 files changed, 78 insertions, 78 deletions
diff --git a/lib/formats.c b/lib/formats.c index fdb6a5f4f..f9f8627fa 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -9,7 +9,6 @@ #include <rpmfi.h> -#include "lib/legacy.h" /* XXX rpmfiBuildFNames() */ #include "lib/manifest.h" #include "debug.h" diff --git a/lib/legacy.c b/lib/legacy.c index 6a8e2534d..267b136e4 100644 --- a/lib/legacy.c +++ b/lib/legacy.c @@ -7,6 +7,7 @@ #include <rpmlib.h> #include <rpmmacro.h> #include <rpmstring.h> +#include <rpmfi.h> #include "lib/legacy.h" #include "debug.h" @@ -115,61 +116,6 @@ exit: xx = hre(h, RPMTAG_OLDFILENAMES); } -void rpmfiBuildFNames(Header h, rpmTag tagN, - const char *** fnp, int * fcp) -{ - HGE_t hge = (HGE_t)headerGetEntryMinMemory; - HFD_t hfd = headerFreeData; - const char ** baseNames; - const char ** dirNames; - uint32_t * dirIndexes; - int count; - const char ** fileNames; - int size; - rpmTag dirNameTag = 0; - rpmTag dirIndexesTag = 0; - rpmTagType bnt, dnt; - char * t; - int i, xx; - - if (tagN == RPMTAG_BASENAMES) { - dirNameTag = RPMTAG_DIRNAMES; - dirIndexesTag = RPMTAG_DIRINDEXES; - } else if (tagN == RPMTAG_ORIGBASENAMES) { - dirNameTag = RPMTAG_ORIGDIRNAMES; - dirIndexesTag = RPMTAG_ORIGDIRINDEXES; - } - - if (!hge(h, tagN, &bnt, (void **) &baseNames, &count)) { - if (fnp) *fnp = NULL; - if (fcp) *fcp = 0; - return; /* no file list */ - } - - xx = hge(h, dirNameTag, &dnt, (void **) &dirNames, NULL); - xx = hge(h, dirIndexesTag, NULL, (void **) &dirIndexes, &count); - - size = sizeof(*fileNames) * count; - for (i = 0; i < count; i++) - size += strlen(baseNames[i]) + strlen(dirNames[dirIndexes[i]]) + 1; - - fileNames = xmalloc(size); - t = ((char *) fileNames) + (sizeof(*fileNames) * count); - for (i = 0; i < count; i++) { - fileNames[i] = t; - t = stpcpy( stpcpy(t, dirNames[dirIndexes[i]]), baseNames[i]); - *t++ = '\0'; - } - baseNames = hfd(baseNames, bnt); - dirNames = hfd(dirNames, dnt); - - if (fnp) - *fnp = fileNames; - else - fileNames = _free(fileNames); - if (fcp) *fcp = count; -} - void expandFilelist(Header h) { HAE_t hae = (HAE_t)headerAddEntry; diff --git a/lib/legacy.h b/lib/legacy.h index fcec32b8e..95a9640f0 100644 --- a/lib/legacy.h +++ b/lib/legacy.h @@ -21,26 +21,6 @@ extern "C" { void compressFilelist(Header h); /** - * Retrieve file names from header. - * - * The representation of file names in package headers changed in rpm-4.0. - * Originally, file names were stored as an array of absolute paths. - * In rpm-4.0, file names are stored as separate arrays of dirname's and - * basename's, * with a dirname index to associate the correct dirname - * with each basname. - * - * This function is used to retrieve file names independent of how the - * file names are represented in the package header. - * - * @param h header - * @param tagN RPMTAG_BASENAMES | PMTAG_ORIGBASENAMES - * @retval *fnp array of file names - * @retval *fcp number of files - */ -void rpmfiBuildFNames(Header h, rpmTag tagN, - const char *** fnp, int * fcp); - -/** * Convert (dirname,basename,dirindex) tags to absolute path tag. * @param h header */ @@ -27,7 +27,6 @@ #include "lib/rpmlead.h" /* writeLead proto */ #include "lib/signature.h" /* signature constants */ -#include "lib/legacy.h" /* XXX rpmfiBuildFNames() */ #include <rpmfileutil.h> /* rpmMkTempFile() */ #include "lib/misc.h" /* XXX rpmMkdirPath, doputenv */ #include <rpmdb.h> /* XXX for db_chrootDone */ diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 0a210303f..faca4145f 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1539,3 +1539,59 @@ exit: av = _free(av); if (fcp) *fcp = ac; } + +void rpmfiBuildFNames(Header h, rpmTag tagN, + const char *** fnp, int * fcp) +{ + HGE_t hge = (HGE_t)headerGetEntryMinMemory; + HFD_t hfd = headerFreeData; + const char ** baseNames; + const char ** dirNames; + uint32_t * dirIndexes; + int count; + const char ** fileNames; + int size; + rpmTag dirNameTag = 0; + rpmTag dirIndexesTag = 0; + rpmTagType bnt, dnt; + char * t; + int i, xx; + + if (tagN == RPMTAG_BASENAMES) { + dirNameTag = RPMTAG_DIRNAMES; + dirIndexesTag = RPMTAG_DIRINDEXES; + } else if (tagN == RPMTAG_ORIGBASENAMES) { + dirNameTag = RPMTAG_ORIGDIRNAMES; + dirIndexesTag = RPMTAG_ORIGDIRINDEXES; + } + + if (!hge(h, tagN, &bnt, (void **) &baseNames, &count)) { + if (fnp) *fnp = NULL; + if (fcp) *fcp = 0; + return; /* no file list */ + } + + xx = hge(h, dirNameTag, &dnt, (void **) &dirNames, NULL); + xx = hge(h, dirIndexesTag, NULL, (void **) &dirIndexes, &count); + + size = sizeof(*fileNames) * count; + for (i = 0; i < count; i++) + size += strlen(baseNames[i]) + strlen(dirNames[dirIndexes[i]]) + 1; + + fileNames = xmalloc(size); + t = ((char *) fileNames) + (sizeof(*fileNames) * count); + for (i = 0; i < count; i++) { + fileNames[i] = t; + t = stpcpy( stpcpy(t, dirNames[dirIndexes[i]]), baseNames[i]); + *t++ = '\0'; + } + baseNames = hfd(baseNames, bnt); + dirNames = hfd(dirNames, dnt); + + if (fnp) + *fnp = fileNames; + else + fileNames = _free(fileNames); + if (fcp) *fcp = count; +} + diff --git a/lib/rpmfi.h b/lib/rpmfi.h index 17bf8036c..ec460941b 100644 --- a/lib/rpmfi.h +++ b/lib/rpmfi.h @@ -447,6 +447,26 @@ void rpmfiBuildFDeps(Header h, rpmTag tagN, const char *** fdepsp, int * fcp); /** \ingroup rpmfi + * Retrieve file names from header. + * + * The representation of file names in package headers changed in rpm-4.0. + * Originally, file names were stored as an array of absolute paths. + * In rpm-4.0, file names are stored as separate arrays of dirname's and + * basename's, * with a dirname index to associate the correct dirname + * with each basname. + * + * This function is used to retrieve file names independent of how the + * file names are represented in the package header. + * + * @param h header + * @param tagN RPMTAG_BASENAMES | PMTAG_ORIGBASENAMES + * @retval *fnp array of file names + * @retval *fcp number of files + */ +void rpmfiBuildFNames(Header h, rpmTag tagN, + const char *** fnp, int * fcp); + +/** \ingroup rpmfi * Return file type from mode_t. * @param mode file mode bits (from header) * @return file type diff --git a/python/header-py.c b/python/header-py.c index 165743eea..cfd5e1772 100644 --- a/python/header-py.c +++ b/python/header-py.c @@ -7,7 +7,7 @@ #include <rpmlib.h> #include <rpmstring.h> -#include "lib/legacy.h" +#include "lib/legacy.h" /* XXX expand/compressFilelist(), providePackageNVR() */ #include <rpmts.h> /* XXX rpmtsCreate/rpmtsFree */ |