summaryrefslogtreecommitdiff
path: root/lib/fprint.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>1999-10-27 23:18:10 +0000
committerjbj <devnull@localhost>1999-10-27 23:18:10 +0000
commit0d0b405c201b43f2eebc61257f5992931e1cdb0c (patch)
tree7b19eee73f74dbd86e65255cff8be16b58292035 /lib/fprint.c
parent82c75cb6a261465700ca469793b54ad68bef99a8 (diff)
downloadlibrpm-tizen-0d0b405c201b43f2eebc61257f5992931e1cdb0c.tar.gz
librpm-tizen-0d0b405c201b43f2eebc61257f5992931e1cdb0c.tar.bz2
librpm-tizen-0d0b405c201b43f2eebc61257f5992931e1cdb0c.zip
use compressed filenames on install side.
start unifying FD types, CFD_t now gone. CVS patchset: 3402 CVS date: 1999/10/27 23:18:10
Diffstat (limited to 'lib/fprint.c')
-rw-r--r--lib/fprint.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index 7e575bf0e..94f597416 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -17,23 +17,23 @@ void fpCacheFree(fingerPrintCache cache) {
static const struct fprintCacheEntry_s * cacheContainsDirectory(
fingerPrintCache cache,
- const char * dirName) {
+ const char * dirName)
+{
const void ** data;
- int count;
- if (htGetEntry(cache->ht, dirName, &data, &count, NULL)) return NULL;
+ if (htGetEntry(cache->ht, dirName, &data, NULL, NULL))
+ return NULL;
return data[0];
}
static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
- const char * baseName, int scareMemory) {
+ const char * baseName, int scareMemory)
+{
char dir[PATH_MAX];
- const char * chptr1;
- char * end, * bn;
+ char * end;
fingerPrint fp;
struct stat sb;
char * buf;
- int stripCount;
const struct fprintCacheEntry_s * cacheHit;
struct fprintCacheEntry_s * newEntry;
@@ -54,7 +54,7 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
if ( /*@-unrecog@*/ realpath(".", dir) /*@=unrecog@*/ != NULL) {
char *s = alloca(strlen(dir) + strlen(dirName) + 2);
sprintf(s, "%s/%s", dir, dirName);
- dirName = chptr1 = s;
+ dirName = s;
}
}
@@ -63,12 +63,9 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
buf = alloca(strlen(dirName) + 1);
strcpy(buf, dirName);
- end = bn = strrchr(buf, '/');
- stripCount = 0;
+ end = buf + strlen(buf);
fp.entry = NULL;
while (*buf) {
- *end = '\0';
- stripCount++;
/* as we're stating paths here, we want to follow symlinks */
@@ -87,11 +84,13 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
}
if (fp.entry) {
- chptr1 = dirName + (end - buf) + 1;
- if (scareMemory)
- fp.subdir = chptr1;
+ fp.subdir = dirName + (end - buf);
+ if (fp.subdir[0] == '/' && fp.subdir[1] != '\0')
+ fp.subdir++;
else
- fp.subdir = xstrdup(chptr1); /* XXX memory leak, but how
+ fp.subdir = "";
+ if (!scareMemory && fp.subdir != NULL)
+ fp.subdir = xstrdup(fp.subdir); /* XXX memory leak, but how
do we know we can free it?
Using the (new) cache would
work if hash tables allowed
@@ -102,6 +101,7 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
end--;
while ((end > buf) && *end != '/') end--;
+ *end = '\0';
}
/* This can't happen, or stat('/') just failed! */
@@ -113,8 +113,15 @@ static fingerPrint doLookup(fingerPrintCache cache, const char * dirName,
fingerPrint fpLookup(fingerPrintCache cache, const char * fullName,
int scareMemory) {
- /* XXX FIXME */
- abort();
+ char *dn = strcpy(alloca(strlen(fullName)+1), fullName);
+ char *bn = strrchr(dn, '/');
+
+ if (bn)
+ *bn++ = '\0';
+ else
+ bn = dn;
+
+ return doLookup(cache, dn, bn, scareMemory);
}
unsigned int fpHashFunction(const void * key)
@@ -137,7 +144,10 @@ unsigned int fpHashFunction(const void * key)
int fpEqual(const void * key1, const void * key2)
{
- return FP_EQUAL(*((const fingerPrint *) key1), *((fingerPrint *) key2));
+ const fingerPrint *k1 = key1;
+ const fingerPrint *k2 = key2;
+ /* XXX negated to preserve strcmp return behavior in ht->eq */
+ return (FP_EQUAL(*k1, *k2) ? 0 : 1);
}
void fpLookupList(fingerPrintCache cache, const char ** dirNames,