From: Panu Matilainen Date: Wed, 21 May 2008 08:50:27 +0000 (+0300) Subject: Eliminate rpmfiBuildFClasses() and rpmfiBuildFDepts() from the API+ABI X-Git-Tag: rpm-4.6.0-rc1~518 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=82b89c3b0c78b0df871879d6c9bfe4af1b5e3b9a;p=platform%2Fupstream%2Frpm.git Eliminate rpmfiBuildFClasses() and rpmfiBuildFDepts() from the API+ABI - both are only needed by tag extensions, move them there - headerGet() with extensions enabled provides a nicer API for accessing the data anyway --- diff --git a/lib/rpmfi.c b/lib/rpmfi.c index ac96032..1894825 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1340,152 +1340,6 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0)); return rpmfiLink(fi, (fi ? fi->Type : NULL)); } -void rpmfiBuildFClasses(Header h, const char *** fclassp, rpm_count_t * fcp) -{ - int scareMem = 0; - rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); - const char * FClass; - const char ** av; - int ac; - size_t nb; - char * t; - - if ((ac = rpmfiFC(fi)) <= 0) { - av = NULL; - ac = 0; - goto exit; - } - - /* Compute size of file class argv array blob. */ - nb = (ac + 1) * sizeof(*av); - fi = rpmfiInit(fi, 0); - if (fi != NULL) - while (rpmfiNext(fi) >= 0) { - FClass = rpmfiFClass(fi); - if (FClass && *FClass != '\0') - nb += strlen(FClass); - nb += 1; - } - - /* Create and load file class argv array. */ - av = xmalloc(nb); - t = ((char *) av) + ((ac + 1) * sizeof(*av)); - ac = 0; - fi = rpmfiInit(fi, 0); - if (fi != NULL) - while (rpmfiNext(fi) >= 0) { - FClass = rpmfiFClass(fi); - av[ac++] = t; - if (FClass && *FClass != '\0') - t = stpcpy(t, FClass); - *t++ = '\0'; - } - av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */ - -exit: - fi = rpmfiFree(fi); - if (fclassp) - *fclassp = av; - else - av = _free(av); - if (fcp) *fcp = ac; -} - -void rpmfiBuildFDeps(Header h, rpmTag tagN, - const char *** fdepsp, rpm_count_t * fcp) -{ - int scareMem = 0; - rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); - rpmds ds = NULL; - const char ** av; - int ac; - size_t nb; - char * t; - char deptype = 'R'; - char mydt; - const char * DNEVR; - const uint32_t * ddict; - unsigned ix; - int ndx; - - if ((ac = rpmfiFC(fi)) <= 0) { - av = NULL; - ac = 0; - goto exit; - } - - if (tagN == RPMTAG_PROVIDENAME) - deptype = 'P'; - else if (tagN == RPMTAG_REQUIRENAME) - deptype = 'R'; - - ds = rpmdsNew(h, tagN, scareMem); - - /* Compute size of file depends argv array blob. */ - nb = (ac + 1) * sizeof(*av); - fi = rpmfiInit(fi, 0); - if (fi != NULL) - while (rpmfiNext(fi) >= 0) { - ddict = NULL; - ndx = rpmfiFDepends(fi, &ddict); - if (ddict != NULL) - while (ndx-- > 0) { - ix = *ddict++; - mydt = ((ix >> 24) & 0xff); - if (mydt != deptype) - continue; - ix &= 0x00ffffff; - (void) rpmdsSetIx(ds, ix-1); - if (rpmdsNext(ds) < 0) - continue; - DNEVR = rpmdsDNEVR(ds); - if (DNEVR != NULL) - nb += strlen(DNEVR+2) + 1; - } - nb += 1; - } - - /* Create and load file depends argv array. */ - av = xmalloc(nb); - t = ((char *) av) + ((ac + 1) * sizeof(*av)); - ac = 0; - fi = rpmfiInit(fi, 0); - if (fi != NULL) - while (rpmfiNext(fi) >= 0) { - av[ac++] = t; - ddict = NULL; - ndx = rpmfiFDepends(fi, &ddict); - if (ddict != NULL) - while (ndx-- > 0) { - ix = *ddict++; - mydt = ((ix >> 24) & 0xff); - if (mydt != deptype) - continue; - ix &= 0x00ffffff; - (void) rpmdsSetIx(ds, ix-1); - if (rpmdsNext(ds) < 0) - continue; - DNEVR = rpmdsDNEVR(ds); - if (DNEVR != NULL) { - t = stpcpy(t, DNEVR+2); - *t++ = ' '; - *t = '\0'; - } - } - *t++ = '\0'; - } - av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */ - -exit: - fi = rpmfiFree(fi); - ds = rpmdsFree(ds); - if (fdepsp) - *fdepsp = av; - else - av = _free(av); - if (fcp) *fcp = ac; -} - void rpmfiBuildFNames(Header h, rpmTag tagN, const char *** fnp, rpm_count_t * fcp) { diff --git a/lib/rpmfi.h b/lib/rpmfi.h index bc1eab8..21748c8 100644 --- a/lib/rpmfi.h +++ b/lib/rpmfi.h @@ -354,32 +354,6 @@ rpmfi rpmfiFree(rpmfi fi); rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, int scareMem); /** \ingroup rpmfi - * Retrieve file classes from header. - * - * This function is used to retrieve file classes from the header. - * - * @param h header - * @retval *fclassp array of file classes - * @retval *fcp number of files - */ -void rpmfiBuildFClasses(Header h, - const char *** fclassp, rpm_count_t * fcp); - - -/** \ingroup rpmfi - * Retrieve per-file dependencies from header. - * - * This function is used to retrieve per-file dependencies from the header. - * - * @param h header - * @param tagN RPMTAG_PROVIDENAME | RPMTAG_REQUIRENAME - * @retval *fdepsp array of file dependencies - * @retval *fcp number of files - */ -void rpmfiBuildFDeps(Header h, rpmTag tagN, - const char *** fdepsp, rpm_count_t * fcp); - -/** \ingroup rpmfi * Retrieve file names from header. * * The representation of file names in package headers changed in rpm-4.0. diff --git a/lib/tagexts.c b/lib/tagexts.c index 34ad830..9b72314 100644 --- a/lib/tagexts.c +++ b/lib/tagexts.c @@ -22,6 +22,152 @@ static const struct headerTagFunc_s rpmHeaderTagExtensions[]; void *rpmHeaderTagFunc(rpmTag tag); +static void rpmfiBuildFClasses(Header h, const char *** fclassp, rpm_count_t * fcp) +{ + int scareMem = 0; + rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); + const char * FClass; + const char ** av; + int ac; + size_t nb; + char * t; + + if ((ac = rpmfiFC(fi)) <= 0) { + av = NULL; + ac = 0; + goto exit; + } + + /* Compute size of file class argv array blob. */ + nb = (ac + 1) * sizeof(*av); + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + FClass = rpmfiFClass(fi); + if (FClass && *FClass != '\0') + nb += strlen(FClass); + nb += 1; + } + + /* Create and load file class argv array. */ + av = xmalloc(nb); + t = ((char *) av) + ((ac + 1) * sizeof(*av)); + ac = 0; + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + FClass = rpmfiFClass(fi); + av[ac++] = t; + if (FClass && *FClass != '\0') + t = stpcpy(t, FClass); + *t++ = '\0'; + } + av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */ + +exit: + fi = rpmfiFree(fi); + if (fclassp) + *fclassp = av; + else + av = _free(av); + if (fcp) *fcp = ac; +} + +static void rpmfiBuildFDeps(Header h, rpmTag tagN, + const char *** fdepsp, rpm_count_t * fcp) +{ + int scareMem = 0; + rpmfi fi = rpmfiNew(NULL, h, RPMTAG_BASENAMES, scareMem); + rpmds ds = NULL; + const char ** av; + int ac; + size_t nb; + char * t; + char deptype = 'R'; + char mydt; + const char * DNEVR; + const uint32_t * ddict; + unsigned ix; + int ndx; + + if ((ac = rpmfiFC(fi)) <= 0) { + av = NULL; + ac = 0; + goto exit; + } + + if (tagN == RPMTAG_PROVIDENAME) + deptype = 'P'; + else if (tagN == RPMTAG_REQUIRENAME) + deptype = 'R'; + + ds = rpmdsNew(h, tagN, scareMem); + + /* Compute size of file depends argv array blob. */ + nb = (ac + 1) * sizeof(*av); + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + ddict = NULL; + ndx = rpmfiFDepends(fi, &ddict); + if (ddict != NULL) + while (ndx-- > 0) { + ix = *ddict++; + mydt = ((ix >> 24) & 0xff); + if (mydt != deptype) + continue; + ix &= 0x00ffffff; + (void) rpmdsSetIx(ds, ix-1); + if (rpmdsNext(ds) < 0) + continue; + DNEVR = rpmdsDNEVR(ds); + if (DNEVR != NULL) + nb += strlen(DNEVR+2) + 1; + } + nb += 1; + } + + /* Create and load file depends argv array. */ + av = xmalloc(nb); + t = ((char *) av) + ((ac + 1) * sizeof(*av)); + ac = 0; + fi = rpmfiInit(fi, 0); + if (fi != NULL) + while (rpmfiNext(fi) >= 0) { + av[ac++] = t; + ddict = NULL; + ndx = rpmfiFDepends(fi, &ddict); + if (ddict != NULL) + while (ndx-- > 0) { + ix = *ddict++; + mydt = ((ix >> 24) & 0xff); + if (mydt != deptype) + continue; + ix &= 0x00ffffff; + (void) rpmdsSetIx(ds, ix-1); + if (rpmdsNext(ds) < 0) + continue; + DNEVR = rpmdsDNEVR(ds); + if (DNEVR != NULL) { + t = stpcpy(t, DNEVR+2); + *t++ = ' '; + *t = '\0'; + } + } + *t++ = '\0'; + } + av[ac] = NULL; /* XXX tag arrays are not NULL terminated. */ + +exit: + fi = rpmfiFree(fi); + ds = rpmdsFree(ds); + if (fdepsp) + *fdepsp = av; + else + av = _free(av); + if (fcp) *fcp = ac; +} + /** * Retrieve mounted file system paths. * @param h header