diff options
author | jbj <devnull@localhost> | 2001-11-09 19:22:29 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2001-11-09 19:22:29 +0000 |
commit | 978a87ed82871b869addf3cd0e8e3fd43546f65b (patch) | |
tree | d8ad078d08bfd0d7b9e5915162a81e68fe465963 /lib | |
parent | ac15c68ca55ee520177bfb0e1576b1069d9fbccf (diff) | |
download | librpm-tizen-978a87ed82871b869addf3cd0e8e3fd43546f65b.tar.gz librpm-tizen-978a87ed82871b869addf3cd0e8e3fd43546f65b.tar.bz2 librpm-tizen-978a87ed82871b869addf3cd0e8e3fd43546f65b.zip |
Start deconstructing TFI_t in favor of a per-transactionElement rpmFNSet.
CVS patchset: 5164
CVS date: 2001/11/09 19:22:29
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rpmal.c | 46 | ||||
-rw-r--r-- | lib/rpmds.c | 91 | ||||
-rw-r--r-- | lib/rpmds.h | 33 |
3 files changed, 109 insertions, 61 deletions
diff --git a/lib/rpmal.c b/lib/rpmal.c index 4dc7e0a2e..99b047b5f 100644 --- a/lib/rpmal.c +++ b/lib/rpmal.c @@ -199,7 +199,7 @@ int alGetFilesCount(const availableList al, alKey pkgKey) int_32 filesCount = 0; if (alp != NULL) if (alp->fns != NULL) - filesCount = alp->fns->Count; + filesCount = alp->fns->fc; return filesCount; } #endif @@ -369,7 +369,7 @@ fprintf(stderr, "*** del %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v /* Delete directory/file info entries from added package list. */ if ((fns = alp->fns) != NULL) - if (fns->BN != NULL && fns->Count > 0) { + if (fns->bnl != NULL && fns->fc > 0) { int origNumDirs = al->numDirs; int dirNum; dirInfo dieNeedle = @@ -381,12 +381,12 @@ fprintf(stderr, "*** del %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v /* XXX FIXME: We ought to relocate the directory list here */ if (al->dirs != NULL) - if (fns->DN != NULL) - for (dirNum = fns->DCount - 1; dirNum >= 0; dirNum--) { + if (fns->dnl != NULL) + for (dirNum = fns->dc - 1; dirNum >= 0; dirNum--) { fileIndexEntry fie; /*@-assignexpose@*/ - dieNeedle->dirName = (char *) fns->DN[dirNum]; + dieNeedle->dirName = (char *) fns->dnl[dirNum]; /*@=assignexpose@*/ dieNeedle->dirNameLen = strlen(dieNeedle->dirName); die = bsearch(dieNeedle, al->dirs, al->numDirs, @@ -510,7 +510,7 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v alp->fns = fns = fnsNew(h, RPMTAG_BASENAMES, scareMem); - if (fns && fns->Count > 0) { + if (fns && fns->fc > 0) { int * dirMapping; dirInfo dieNeedle = memset(alloca(sizeof(*dieNeedle)), 0, sizeof(*dieNeedle)); @@ -520,20 +520,20 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v /* XXX FIXME: We ought to relocate the directory list here */ - dirMapping = alloca(sizeof(*dirMapping) * fns->DCount); + dirMapping = alloca(sizeof(*dirMapping) * fns->dc); /* allocated enough space for all the directories we could possible need to add */ al->dirs = xrealloc(al->dirs, - (al->numDirs + fns->DCount) * sizeof(*al->dirs)); + (al->numDirs + fns->dc) * sizeof(*al->dirs)); origNumDirs = al->numDirs; - if (fns->DN != NULL) - for (dirNum = 0; dirNum < fns->DCount; dirNum++) { + if (fns->dnl != NULL) + for (dirNum = 0; dirNum < fns->dc; dirNum++) { /*@-assignexpose@*/ - dieNeedle->dirName = (char *) fns->DN[dirNum]; + dieNeedle->dirName = (char *) fns->dnl[dirNum]; /*@=assignexpose@*/ - dieNeedle->dirNameLen = strlen(fns->DN[dirNum]); + dieNeedle->dirNameLen = strlen(fns->dnl[dirNum]); die = bsearch(dieNeedle, al->dirs, origNumDirs, sizeof(*dieNeedle), dieCompare); if (die) { @@ -541,7 +541,7 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v } else { dirMapping[dirNum] = al->numDirs; die = al->dirs + al->numDirs; - die->dirName = xstrdup(fns->DN[dirNum]); + die->dirName = xstrdup(fns->dnl[dirNum]); die->dirNameLen = strlen(die->dirName); die->files = NULL; die->numFiles = 0; @@ -550,34 +550,34 @@ fprintf(stderr, "*** add %p[%d] %s-%s-%s\n", al->list, pkgNum, alp->name, alp->v } last = 0; - for (first = 0; first < fns->Count; first = last + 1) { + for (first = 0; first < fns->fc; first = last + 1) { fileIndexEntry fie; - if (fns->DI == NULL) /* XXX can't happen */ + if (fns->dil == NULL) /* XXX can't happen */ continue; - for (last = first; (last + 1) < fns->Count; last++) { - if (fns->DI[first] != fns->DI[last + 1]) + for (last = first; (last + 1) < fns->fc; last++) { + if (fns->dil[first] != fns->dil[last + 1]) /*@innerbreak@*/ break; } - die = al->dirs + dirMapping[fns->DI[first]]; + die = al->dirs + dirMapping[fns->dil[first]]; die->files = xrealloc(die->files, (die->numFiles + last - first + 1) * sizeof(*die->files)); fie = die->files + die->numFiles; for (fns->i = first; fns->i <= last; fns->i++) { - if (fns->BN == NULL) /* XXX can't happen */ + if (fns->bnl == NULL) /* XXX can't happen */ /*@innercontinue@*/ continue; - if (fns->Flags == NULL) /* XXX can't happen */ + if (fns->fflags == NULL) /* XXX can't happen */ /*@innercontinue@*/ continue; /*@-assignexpose@*/ - fie->baseName = fns->BN[fns->i]; - fie->baseNameLen = strlen(fns->BN[fns->i]); + fie->baseName = fns->bnl[fns->i]; + fie->baseNameLen = strlen(fns->bnl[fns->i]); /*@=assignexpose@*/ fie->pkgNum = pkgNum; - fie->fileFlags = fns->Flags[fns->i]; + fie->fileFlags = fns->fflags[fns->i]; die->numFiles++; fie++; } diff --git a/lib/rpmds.c b/lib/rpmds.c index 667e08887..e57826ae6 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -44,20 +44,32 @@ rpmFNSet fnsFree(rpmFNSet fns) /*@-modfilesystem@*/ if (_fns_debug) -fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->Count); +fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->fc); /*@=modfilesystem@*/ /*@-branchstate@*/ - if (fns->Count > 0) { - fns->DN = hfd(fns->DN, fns->DNt); - fns->BN = hfd(fns->BN, fns->BNt); + if (fns->fc > 0) { + fns->bnl = hfd(fns->bnl, -1); + fns->dnl = hfd(fns->dnl, -1); + + fns->flinks = hfd(fns->flinks, -1); + fns->flangs = hfd(fns->flangs, -1); + fns->fmd5s = hfd(fns->fmd5s, -1); + + fns->fstates = _free(fns->fstates); + /*@-evalorder@*/ - fns->DI = - (fns->h != NULL ? hfd(fns->DI, fns->DIt) : _free(fns->DI)); - fns->Flags = - (fns->h != NULL ? hfd(fns->Flags, fns->Ft) : _free(fns->Flags)); + if (fns->h != NULL) { + fns->h = headerFree(fns->h, "fnsFree"); + } else { + fns->fmtimes = _free(fns->fmtimes); + fns->fmodes = _free(fns->fmodes); + fns->fflags = _free(fns->fflags); + fns->fsizes = _free(fns->fsizes); + fns->frdevs = _free(fns->frdevs); + fns->dil = _free(fns->dil); + } /*@=evalorder@*/ - fns->h = headerFree(fns->h, "fnsFree"); } /*@=branchstate@*/ @@ -66,6 +78,11 @@ fprintf(stderr, "*** fns %p -- %s[%d]\n", fns, fns->Type, fns->Count); return NULL; } +#define _fdupe(_fns, _data) \ + if ((_fns)->_data != NULL) \ + (_fns)->_data = memcpy(xmalloc((_fns)->fc * sizeof(*(_fns)->_data)), \ + (_fns)->_data, (_fns)->fc * sizeof(*(_fns)->_data)) + rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem) { HGE_t hge = @@ -75,52 +92,64 @@ rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem) const char ** N; rpmTagType Nt; int_32 Count; - rpmTag tagBN, tagDI, tagF, tagDN; if (tagN == RPMTAG_BASENAMES) { Type = "Files"; - tagBN = tagN; - tagDI = RPMTAG_DIRINDEXES; - tagF = RPMTAG_FILEFLAGS; - tagDN = RPMTAG_DIRNAMES; } else goto exit; /*@-branchstate@*/ - if (hge(h, tagBN, &Nt, (void **) &N, &Count) + if (hge(h, tagN, &Nt, (void **) &N, &Count) && N != NULL && Count > 0) { int xx; fns = xcalloc(1, sizeof(*fns)); - fns->h = (scareMem ? headerLink(h, "fnsNew") : NULL); + fns->h = headerLink(h, "fnsNew"); fns->i = -1; fns->Type = Type; fns->tagN = tagN; - fns->BN = N; - fns->BNt = Nt; - fns->Count = Count; - - xx = hge(h, tagDN, &fns->DNt, (void **) &fns->DN, &fns->DCount); - xx = hge(h, tagDI, &fns->DIt, (void **) &fns->DI, NULL); - if (!scareMem && fns->DI != NULL) - fns->DI = memcpy(xmalloc(fns->Count * sizeof(*fns->DI)), - fns->DI, fns->Count * sizeof(*fns->DI)); - xx = hge(h, tagF, &fns->Ft, (void **) &fns->Flags, NULL); - if (!scareMem && fns->Flags != NULL) - fns->Flags = memcpy(xmalloc(fns->Count * sizeof(*fns->Flags)), - fns->Flags, fns->Count * sizeof(*fns->Flags)); + fns->bnl = N; + fns->fc = Count; + + xx = hge(h, RPMTAG_DIRNAMES, NULL, (void **) &fns->dnl, &fns->dc); + + xx = hge(h, RPMTAG_FILELINKTOS, NULL, (void **) &fns->flinks, NULL); + xx = hge(h, RPMTAG_FILELANGS, NULL, (void **) &fns->flangs, NULL); + xx = hge(h, RPMTAG_FILEMD5S, NULL, (void **) &fns->fmd5s, NULL); + + xx = hge(h, RPMTAG_FILEMTIMES, NULL, (void **) &fns->fmtimes, NULL); + xx = hge(h, RPMTAG_FILEMODES, NULL, (void **) &fns->fmodes, NULL); + xx = hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &fns->fflags, NULL); + xx = hge(h, RPMTAG_FILESIZES, NULL, (void **) &fns->fsizes, NULL); + xx = hge(h, RPMTAG_FILERDEVS, NULL, (void **) &fns->frdevs, NULL); + xx = hge(h, RPMTAG_DIRINDEXES, NULL, (void **) &fns->dil, NULL); + + xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &fns->fstates, NULL); + _fdupe(fns, fstates); + if (xx == 0 || fns->fstates == NULL) + fns->fstates = xcalloc(fns->fc, sizeof(*fns->fstates)); + + if (!scareMem) { + _fdupe(fns, fmtimes); + _fdupe(fns, fmodes); + _fdupe(fns, fflags); + _fdupe(fns, fsizes); + _fdupe(fns, frdevs); + _fdupe(fns, dil); + fns->h = headerFree(fns->h, "fnsNew"); + } /*@-modfilesystem@*/ if (_fns_debug) -fprintf(stderr, "*** fns %p ++ %s[%d]\n", fns, fns->Type, fns->Count); +fprintf(stderr, "*** fns %p ++ %s[%d]\n", fns, fns->Type, fns->fc); /*@=modfilesystem@*/ } /*@-branchstate@*/ exit: - /*@-nullret@*/ /* FIX: fns->{DI,Flags} may be NULL. */ + /*@-nullret@*/ /* FIX: fns->{dil,fflags} may be NULL. */ /*@i@*/ return fns; /*@=nullret@*/ } diff --git a/lib/rpmds.h b/lib/rpmds.h index bf6999d93..8aec0c2eb 100644 --- a/lib/rpmds.h +++ b/lib/rpmds.h @@ -24,16 +24,35 @@ struct rpmFNSet_s { Header h; /*!< Header for file name set (or NULL) */ /*@only@*/ - const char ** BN; /*!< File base name(s). */ + const char ** bnl; /*!< Base name(s) (from header) */ /*@only@*/ - const int_32 * DI; /*!< File directory index. */ + const char ** dnl; /*!< Directory name(s) (from header) */ + +/*@only@*/ + const char ** fmd5s; /*!< File MD5 sum(s) (from header) */ +/*@only@*/ + const char ** flinks; /*!< File link(s) (from header) */ +/*@only@*/ + const char ** flangs; /*!< File lang(s) */ + +/*@only@*/ + const uint_32 * dil; /*!< Directory indice(s) (from header) */ /*@only@*/ - const uint_32 * Flags; /*!< File flags. */ + const uint_32 * fflags; /*!< File flag(s) (from header) */ /*@only@*/ - const char ** DN; /*!< Directory name(s). */ - int_32 DCount; /*!< No. of directories. */ - rpmTagType BNt, DIt, Ft, DNt; /*!< Tag data types. */ - int_32 Count; /*!< No. of files. */ + const uint_32 * fsizes; /*!< File size(s) (from header) */ +/*@only@*/ + const uint_32 * fmtimes; /*!< File modification time(s) (from header) */ +/*@only@*/ + const uint_16 * fmodes; /*!< File mode(s) (from header) */ +/*@only@*/ + const uint_16 * frdevs; /*!< File rdev(s) (from header) */ + +/*@only@*/ + char * fstates; /*!< File state(s) (from header) */ + + int_32 dc; /*!< No. of directories. */ + int_32 fc; /*!< No. of files. */ }; /** |