rpm/lib/fprint.h

125 lines
3.3 KiB
C
Raw Normal View History

#ifndef H_FINGERPRINT
#define H_FINGERPRINT
/** \ingroup rpmtrans
* \file fprint.h
* Identify a file name path by a unique "finger print".
*/
#include <rpm/rpmtypes.h>
/**
*/
2007-09-12 00:37:03 +08:00
typedef struct fprintCache_s * fingerPrintCache;
/**
* @todo Convert to pointer and make abstract.
*/
typedef struct fingerPrint_s fingerPrint;
2008-10-21 21:45:09 +08:00
struct rpmffi_s {
rpmte p;
2008-10-21 21:45:09 +08:00
int fileno;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Create finger print cache.
* @param sizeHint number of elements expected
* @param pool string pool (or NULL for private)
* @return pointer to initialized fingerprint cache
*/
2008-10-09 20:48:46 +08:00
RPM_GNUC_INTERNAL
fingerPrintCache fpCacheCreate(int sizeHint, rpmstrPool pool);
/**
* Destroy finger print cache.
* @param cache pointer to fingerprint cache
* @return NULL always
*/
2008-10-09 20:48:46 +08:00
RPM_GNUC_INTERNAL
2007-09-12 00:37:03 +08:00
fingerPrintCache fpCacheFree(fingerPrintCache cache);
RPM_GNUC_INTERNAL
fingerPrint * fpCacheGetByFp(fingerPrintCache cache,
struct fingerPrint_s * fp, int ix,
struct rpmffi_s ** recs, int * numRecs);
RPM_GNUC_INTERNAL
void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
/* compare an existing fingerprint with a looked-up fingerprint for db/bn */
RPM_GNUC_INTERNAL
int fpLookupEquals(fingerPrintCache cache, fingerPrint * fp,
const char * dirName, const char * baseName);
RPM_GNUC_INTERNAL
int fpLookupEqualsId(fingerPrintCache cache, fingerPrint * fp,
rpmsid dirNameId, rpmsid baseNameId);
RPM_GNUC_INTERNAL
const char *fpEntryDir(fingerPrintCache cache, fingerPrint *fp);
RPM_GNUC_INTERNAL
dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp);
/**
* Return finger print of a file path.
* @param cache pointer to fingerprint cache
* @param dirName leading directory name of file path
* @param baseName base name of file path
* @param[out] fp pointer of fingerprint struct to fill out
* @return 0 on success
*/
2008-10-09 20:48:46 +08:00
RPM_GNUC_INTERNAL
int fpLookup(fingerPrintCache cache,
const char * dirName, const char * baseName,
fingerPrint **fp);
/**
* Return finger print of a file path given as ids.
* @param cache pointer to fingerprint cache
* @param dirNameId id of leading directory name of file path
* @param baseNameId id of base name of file path
* @param[out] fp pointer of fingerprint struct to fill out
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int fpLookupId(fingerPrintCache cache,
rpmsid dirNameId, rpmsid BaseNameId,
fingerPrint **fp);
/**
* Compare two finger print entries.
* This routine is exactly equivalent to the FP_EQUAL macro.
* @param key1 finger print 1
* @param key2 finger print 2
* @return result of comparing key1 and key2
*/
2008-10-09 20:48:46 +08:00
RPM_GNUC_INTERNAL
2008-10-21 21:45:09 +08:00
int fpEqual(const fingerPrint * key1, const fingerPrint * key2);
/**
* Return finger prints of an array of file paths.
* @param cache pointer to fingerprint cache
* @param pool pointer to file name pool
* @param dirNames directory names
* @param baseNames file base names
* @param dirIndexes index into dirNames for each baseNames
* @param fileCount number of file entries
* @return pointer to array of finger prints
*/
2008-10-09 20:48:46 +08:00
RPM_GNUC_INTERNAL
fingerPrint * fpLookupList(fingerPrintCache cache, rpmstrPool pool,
rpmsid * dirNames, rpmsid * baseNames,
const uint32_t * dirIndexes, int fileCount);
#ifdef __cplusplus
}
#endif
#endif