}
static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
- char * baseName, int scareMemory) {
+ const char * baseName, int scareMemory) {
char dir[PATH_MAX];
const char * chptr1;
char * end, * bn;
return FP_EQUAL(*((const fingerPrint *) key1), *((fingerPrint *) key2));
}
-void fpLookupList(fingerPrintCache cache, char ** dirNames, char ** baseNames,
- int * dirIndexes, int fileCount, fingerPrint * fpList) {
+void fpLookupList(fingerPrintCache cache, const char ** dirNames,
+ const char ** baseNames, const int * dirIndexes,
+ int fileCount, fingerPrint * fpList) {
int i;
for (i = 0; i < fileCount; i++) {
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList) {
int fileCount;
- char ** baseNames, ** dirNames;
+ const char ** baseNames, ** dirNames;
int_32 * dirIndexes;
- if (!headerGetEntry(h, RPMTAG_COMPFILELIST, NULL, (void **) &baseNames,
- &fileCount)) return;
- headerGetEntry(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirNames, NULL);
+ if (!headerGetEntryMinMemory(h, RPMTAG_COMPFILELIST, NULL,
+ (void **) &baseNames, &fileCount)) return;
+ headerGetEntryMinMemory(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirNames,
+ NULL);
headerGetEntry(h, RPMTAG_COMPFILEDIRS, NULL, (void **) &dirIndexes, NULL);
fpLookupList(cache, dirNames, baseNames, dirIndexes, fileCount, fpList);
int fpEqual(const void * key1, const void * key2);
/* scareMemory is assumed for both of these! */
-void fpLookupList(fingerPrintCache cache, char ** dirNames, char ** baseNames,
- int * dirIndexes, int fileCount, fingerPrint * fpList);
+void fpLookupList(fingerPrintCache cache, const char ** dirNames,
+ const char ** baseNames, const int * dirIndexes,
+ int fileCount, fingerPrint * fpList);
void fpLookupHeader(fingerPrintCache cache, Header h, fingerPrint * fpList);
#ifdef __cplusplus
*memPtr = mem;
- if (!headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &mem->names,
- fileCountPtr))
- return 0;
+ if (!headerIsEntry(h, RPMTAG_COMPFILELIST)) return 0;
-#if 0
- if (!headerGetEntry(h, RPMTAG_ORIGFILENAMES, NULL,
- (void **) &mem->cpioNames, NULL))
- headerGetEntry(h, RPMTAG_OLDFILENAMES, NULL, (void **) &mem->cpioNames,
- fileCountPtr);
- headerRemoveEntry(h, RPMTAG_ORIGFILENAMES);
-#endif
+ buildFileList(h, (char ***) &mem->names, fileCountPtr);
+
+ if (headerIsEntry(h, RPMTAG_ORIGCOMPFILELIST)) {
+ buildOrigFileList(h, (char ***) &mem->cpioNames, fileCountPtr);
+ } else {
+ buildFileList(h, (char ***) &mem->cpioNames, fileCountPtr);
+ }
fileCount = *fileCountPtr;
return rpmvercmp(one, two);
}
-const char *const fileActionString(enum fileActions a)
+const char * fileActionString(enum fileActions a)
{
switch (a) {
case FA_UNKNOWN: return "unknown";
/* this is pretty straight-forward. The only thing that even resembles a trick
is getting all of this into a single xmalloc'd block */
-void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+static void doBuildFileList(Header h, char *** fileListPtr,
+ int * fileCountPtr, int baseNameTag,
+ int dirListTag, int dirIndexesTag) {
int * dirList;
char ** dirs;
char ** tails;
char * data;
int i;
- if (!headerGetEntry(h, RPMTAG_COMPFILELIST, NULL, (void **) &tails,
+ if (!headerGetEntry(h, baseNameTag, NULL, (void **) &tails,
&count))
/* no file list */
return;
- headerGetEntry(h, RPMTAG_COMPDIRLIST, NULL, (void **) &dirs,
+ headerGetEntry(h, dirListTag, NULL, (void **) &dirs,
&count);
- headerGetEntry(h, RPMTAG_COMPFILEDIRS, NULL, (void **) &dirList,
+ headerGetEntry(h, dirIndexesTag, NULL, (void **) &dirList,
&count);
size = sizeof(*fileList) * count;
*fileListPtr = fileList;
*fileCountPtr = count;
}
+
+void buildFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+ doBuildFileList(h, fileListPtr, fileCountPtr, RPMTAG_COMPFILELIST,
+ RPMTAG_COMPDIRLIST, RPMTAG_COMPFILEDIRS);
+}
+
+void buildOrigFileList(Header h, char *** fileListPtr, int * fileCountPtr) {
+ doBuildFileList(h, fileListPtr, fileCountPtr, RPMTAG_ORIGCOMPFILELIST,
+ RPMTAG_ORIGCOMPDIRLIST, RPMTAG_ORIGCOMPFILEDIRS);
+}
/*@out@*/ FD_t * fdptr);
char * currentDirectory(void); /* result needs to be freed */
void compressFilelist(Header h);
-void buildFileList(Header h, /*@out@*/ char *** fileListPtr, /*@out@*/ int * fileCountPtr);
+void buildFileList(Header h, /*@out@*/ char *** fileListPtr,
+ /*@out@*/ int * fileCountPtr);
+void buildOrigFileList(Header h, /*@out@*/ char *** fileListPtr,
+ /*@out@*/ int * fileCountPtr);
#ifdef __cplusplus
}
int start, end;
int num;
int_32 fc;
- char ** dirNames, ** fullBaseNames, ** baseNames;
+ const char ** dirNames, ** baseNames;
+ const char ** fullBaseNames;
int_32 * dirIndexes, * fullDirIndexes;
fingerPrintCache fpc;
const void * key, Header h, const char * dirName,
const char * baseName, Header altH, unsigned long ulong1)
{
- char * str = alloca(strlen(dirName) + strlen(baseName) + 2);
+ char * str = alloca(strlen(dirName) + strlen(baseName) + 1);
- sprintf(str, "%s/%s", dirName, baseName);
+ sprintf(str, "%s%s", dirName, baseName);
psAppend(probs, type, key, h, str, altH, ulong1);
}
int k;
haveRelocatedFile = 1;
- newDirList = xmalloc(sizeof(*newDirList) * (dirCount + 1));
+ newDirList = malloc(sizeof(*newDirList) * (dirCount + 1));
for (k = 0; k < dirCount; k++) {
newDirList[k] = alloca(strlen(dirNames[k]) + 1);
strcpy(newDirList[k], dirNames[k]);
free(dirNames);
dirNames = newDirList;
} else {
- dirNames = xrealloc(dirNames,
+ dirNames = realloc(dirNames,
sizeof(*dirNames) * (dirCount + 1));
}
/* Start off by relocating directories. */
for (i = dirCount - 1; i >= 0; i--) {
for (j = numRelocations - 1; j >= 0; j--) {
+ int len;
len = strlen(relocations[j].oldPath);
if (strncmp(relocations[j].oldPath, dirNames[i], len))
struct stat sb;
int i, rc;
int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
- char * filespec = alloca(strlen(dirName) + strlen(baseName) + 2);
+ char * filespec = alloca(strlen(dirName) + strlen(baseName) + 1);
- sprintf(filespec, "%s/%s", dirName, baseName);
+ sprintf(filespec, "%s%s", dirName, baseName);
if (lstat(filespec, &sb)) {
/*
if (XFA_SKIPPING(fi->actions[i]))
continue;
- j = strlen(strlen(fi->dnl[fi->dil[i]]) + fi->bnl[i] + 2);
+ j = strlen(fi->dnl[fi->dil[i]]) + strlen(fi->bnl[i]) + 1;
if (j > fileSpecAlloced) {
fileSpecAlloced = j * 2;
filespec = xrealloc(filespec, fileSpecAlloced);
}
- sprintf(filespec, "%s/%s", fi->dnl[fi->dil[i]], fi->bnl[i]);
+ sprintf(filespec, "%s%s", fi->dnl[fi->dil[i]], fi->bnl[i]);
if (dsl) {
ds = dsl;
if (languages) freeSplitString((char **)languages);
}
-#define NOTIFY(_x) if (notify) (void) notify _x
+#define NOTIFY(_x) if (notify) notify _x
/* Return -1 on error, > 0 if newProbs is set, 0 if everything happened */
}
headerGetEntry(fi->h, RPMTAG_COMPFILEDIRS, NULL, (void **) &fi->dil,
- &fi->fc);
+ NULL);
headerGetEntry(fi->h, RPMTAG_COMPDIRLIST, NULL, (void **) &fi->dnl,
- &fi->fc);
+ NULL);
/* actions is initialized earlier for added packages */
if (fi->actions == NULL)
fi->fmodes, fi->fc * sizeof(*fi->fmodes));
fi->fstates = memcpy(xmalloc(fi->fc * sizeof(*fi->fstates)),
fi->fstates, fi->fc * sizeof(*fi->fstates));
+ fi->dil = memcpy(xmalloc(fi->fc * sizeof(*fi->dil)),
+ fi->dil, fi->fc * sizeof(*fi->dil));
headerFree(fi->h);
fi->h = NULL;
break;
}
chdir("/");
- /*@-unrecog@*/ chroot(ts->root); /*@=unrecog@*/
+ chroot(ts->root);
ht = htCreate(totalFileCount * 2, 0, fpHashFunction, fpEqual);
fpc = fpCacheCreate(totalFileCount);
* Add fingerprint for each file not skipped.
*/
for (fi = flList; (fi - flList) < flEntries; fi++) {
- fpLookupHeader(fpc, fi->h, fi->fps);
+ fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps);
for (i = 0; i < fi->fc; i++) {
if (XFA_SKIPPING(fi->actions[i]))
continue;
headerFree(hdrs[i]);
rc = rpmReadPackageHeader(fd, &h, NULL, NULL, NULL);
if (rc) {
- (void)notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
+ notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
alp->key, notifyData);
ourrc++;
fd = NULL;
headerFree(hdrs[i]);
if (alp->fd == NULL && fd)
- (void)notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
+ notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0, alp->key,
notifyData);
break;
case TR_REMOVED: