diff options
author | Florian Festi <ffesti@redhat.com> | 2008-11-19 17:09:57 +0100 |
---|---|---|
committer | Florian Festi <ffesti@redhat.com> | 2008-11-24 14:03:16 +0100 |
commit | 2f58ae809f18aa9fa5ce76900f298ad17ea24283 (patch) | |
tree | 8059198c8e0a1836e4e3938b2c0abddc291bdcc5 /lib/rpmfi.c | |
parent | d0651021fd0f8edc31332f9f440ce8b51d9b1b2e (diff) | |
download | librpm-tizen-2f58ae809f18aa9fa5ce76900f298ad17ea24283.tar.gz librpm-tizen-2f58ae809f18aa9fa5ce76900f298ad17ea24283.tar.bz2 librpm-tizen-2f58ae809f18aa9fa5ce76900f298ad17ea24283.zip |
API for accessing and creating fi->replaced
- new API is not compatible with accessing fi->replaced directly!
Diffstat (limited to 'lib/rpmfi.c')
-rw-r--r-- | lib/rpmfi.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 858c7931c..e77b078fa 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -1257,6 +1257,8 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, fi->Type, fi->fc); fi->actions = _free(fi->actions); fi->replacedSizes = _free(fi->replacedSizes); fi->replaced = _free(fi->replaced); + fi->numReplaced = 0; + fi->allocatedReplaced = 0; fi->h = headerFree(fi->h); @@ -1313,6 +1315,9 @@ rpmfi rpmfiNew(const rpmts ts, Header h, rpmTag tagN, rpmfiFlags flags) if (fi == NULL) /* XXX can't happen */ goto exit; + fi->replaced = NULL; + fi->numReplaced = fi->allocatedReplaced = 0; + fi->magic = RPMFIMAGIC; fi->Type = Type; fi->i = -1; @@ -1557,6 +1562,41 @@ rpm_loff_t rpmfiFReplacedSize(rpmfi fi) return rsize; } +void rpmfiAddReplaced(rpmfi fi, int pkgFileNum, int otherPkg, int otherFileNum) +{ + if (!fi->replaced) { + fi->replaced = xcalloc(3, sizeof(*fi->replaced)); + fi->allocatedReplaced = 3; + } + if (fi->numReplaced>=fi->allocatedReplaced) { + fi->allocatedReplaced += (fi->allocatedReplaced>>1) + 2; + fi->replaced = xrealloc(fi->replaced, fi->allocatedReplaced*sizeof(*fi->replaced)); + } + fi->replaced[fi->numReplaced].pkgFileNum = pkgFileNum; + fi->replaced[fi->numReplaced].otherPkg = otherPkg; + fi->replaced[fi->numReplaced].otherFileNum = otherFileNum; + + fi->numReplaced++; +} + +sharedFileInfo rpmfiGetReplaced(rpmfi fi) +{ + if (fi && fi->numReplaced) + return fi->replaced; + else + return NULL; +} + +sharedFileInfo rpmfiNextReplaced(rpmfi fi , sharedFileInfo replaced) +{ + if (fi && replaced) { + replaced++; + if (replaced - fi->replaced < fi->numReplaced) + return replaced; + } + return NULL; +} + FSM_t rpmfiFSM(rpmfi fi) { if (fi != NULL && fi->fsm == NULL) { |