API for accessing and creating fi->replaced
- new API is not compatible with accessing fi->replaced directly!
This commit is contained in:
parent
d0651021fd
commit
2f58ae809f
40
lib/rpmfi.c
40
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) {
|
||||
|
|
|
@ -13,9 +13,8 @@ typedef struct sharedFileInfo_s * sharedFileInfo;
|
|||
*/
|
||||
struct sharedFileInfo_s {
|
||||
int pkgFileNum;
|
||||
int otherFileNum;
|
||||
int otherPkg;
|
||||
int isRemoved;
|
||||
int otherFileNum;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -106,6 +105,8 @@ struct rpmfi_s {
|
|||
char ** apath;
|
||||
FSM_t fsm; /*!< File state machine data. */
|
||||
sharedFileInfo replaced; /*!< (TR_ADDED) */
|
||||
int numReplaced;
|
||||
int allocatedReplaced;
|
||||
rpm_off_t * replacedSizes; /*!< (TR_ADDED) */
|
||||
int magic;
|
||||
#define RPMFIMAGIC 0x09697923
|
||||
|
@ -126,6 +127,15 @@ void rpmfiSetFReplacedSize(rpmfi fi, rpm_loff_t newsize);
|
|||
RPM_GNUC_INTERNAL
|
||||
rpm_loff_t rpmfiFReplacedSize(rpmfi fi);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
void rpmfiAddReplaced(rpmfi fi, int pkgFileNum, int otherPkg, int otherFileNum);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
sharedFileInfo rpmfiGetReplaced(rpmfi fi);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
sharedFileInfo rpmfiNextReplaced(rpmfi fi , sharedFileInfo replaced);
|
||||
|
||||
/* XXX can't be internal as build code needs this */
|
||||
FSM_t rpmfiFSM(rpmfi fi);
|
||||
#endif /* _RPMFI_INTERNAL_H */
|
||||
|
|
Loading…
Reference in New Issue