rpm  4.5
Functions
fprint.c File Reference
#include "system.h"
#include <rpmdb.h>
#include <rpmmacro.h>
#include "fprint.h"
#include "debug.h"
Include dependency graph for fprint.c:

Go to the source code of this file.

Functions

fingerPrintCache fpCacheCreate (int sizeHint)
 Create finger print cache. More...
 
fingerPrintCache fpCacheFree (fingerPrintCache cache)
 Destroy finger print cache. More...
 
static struct fprintCacheEntry_scacheContainsDirectory (fingerPrintCache cache, const char *dirName)
 Find directory name entry in cache. More...
 
static fingerPrint doLookup (fingerPrintCache cache, const char *dirName, const char *baseName, int scareMem)
 Return finger print of a file path. More...
 
fingerPrint fpLookup (fingerPrintCache cache, const char *dirName, const char *baseName, int scareMem)
 Return finger print of a file path. More...
 
uint32_t fpHashFunction (uint32_t h, const void *data, size_t size)
 Return hash value for a finger print. More...
 
int fpEqual (const void *key1, const void *key2)
 Compare two finger print entries. More...
 
void fpLookupList (fingerPrintCache cache, const char **dirNames, const char **baseNames, const uint_32 *dirIndexes, int fileCount, fingerPrint *fpList)
 Return finger prints of an array of file paths. More...
 

Function Documentation

static struct fprintCacheEntry_s* cacheContainsDirectory ( fingerPrintCache  cache,
const char *  dirName 
)
staticread

Find directory name entry in cache.

Parameters
cachepointer to fingerprint cache
dirNamestring to locate in cache
Returns
pointer to directory name entry (or NULL if not found).

Definition at line 35 of file fprint.c.

References fprintCache_s::ht, and htGetEntry().

Referenced by doLookup().

static fingerPrint doLookup ( fingerPrintCache  cache,
const char *  dirName,
const char *  baseName,
int  scareMem 
)
static

Return finger print of a file path.

Parameters
cachepointer to fingerprint cache
dirNameleading directory name of path
baseNamefile name of path
scareMem
Returns
pointer to the finger print associated with a file path.

Definition at line 58 of file fprint.c.

References alloca(), fingerPrint_s::baseName, cacheContainsDirectory(), fprintCacheEntry_s::dev, dirName, fprintCacheEntry_s::dirName, fingerPrint_s::entry, fprintCache_s::ht, htAddEntry(), fprintCacheEntry_s::ino, PATH_MAX, realpath(), rpmCleanPath(), stpncpy(), fingerPrint_s::subDir, xmalloc(), and xstrdup().

Referenced by fpLookup(), and fpLookupList().

fingerPrintCache fpCacheCreate ( int  sizeHint)

Create finger print cache.

Parameters
sizeHintnumber of elements expected
Returns
pointer to initialized fingerprint cache

Definition at line 13 of file fprint.c.

References fprintCache_s::ht, htCreate(), and xmalloc().

Referenced by rpmdbFindByFile(), rpmdbFindFpList(), and rpmtsRun().

fingerPrintCache fpCacheFree ( fingerPrintCache  cache)

Destroy finger print cache.

Parameters
cachepointer to fingerprint cache
Returns
NULL always

Definition at line 22 of file fprint.c.

References fprintCache_s::ht, and htFree().

Referenced by rpmdbFindByFile(), rpmdbFindFpList(), and rpmtsRun().

int fpEqual ( const void *  key1,
const void *  key2 
)

Compare two finger print entries.

This routine is exactly equivalent to the FP_EQUAL macro.

Parameters
key1finger print 1
key2finger print 2
Returns
result of comparing key1 and key2

Definition at line 212 of file fprint.c.

References FP_EQUAL.

Referenced by rpmtsRun().

uint32_t fpHashFunction ( uint32_t  h,
const void *  data,
size_t  size 
)

Return hash value for a finger print.

Hash based on dev and inode only!

Parameters
hhash initial value
*datafinger print entry
sizesize of fingerprint entry
Returns
hash value

Definition at line 194 of file fprint.c.

References fingerPrint_s::baseName, fprintCacheEntry_s::dev, fingerPrint_s::entry, and fprintCacheEntry_s::ino.

Referenced by rpmtsRun().

fingerPrint fpLookup ( fingerPrintCache  cache,
const char *  dirName,
const char *  baseName,
int  scareMem 
)

Return finger print of a file path.

Parameters
cachepointer to fingerprint cache
dirNameleading directory name of file path
baseNamebase name of file path
scareMem
Returns
pointer to the finger print associated with a file path.

Definition at line 188 of file fprint.c.

References doLookup().

Referenced by rpmdbFindByFile().

void fpLookupList ( fingerPrintCache  cache,
const char **  dirNames,
const char **  baseNames,
const uint_32 dirIndexes,
int  fileCount,
fingerPrint fpList 
)

Return finger prints of an array of file paths.

Warning
: scareMem is assumed!
Parameters
cachepointer to fingerprint cache
dirNamesdirectory names
baseNamesfile base names
dirIndexesindex into dirNames for each baseNames
fileCountnumber of file entries
Return values
*fpListarray of finger prints

Definition at line 232 of file fprint.c.

References fingerPrint_s::baseName, doLookup(), fingerPrint_s::entry, and fingerPrint_s::subDir.

Referenced by rpmdbFindFpList(), and rpmtsRun().