2001-05-11 12:06:12 +08:00
|
|
|
#ifndef H_FINGERPRINT
|
|
|
|
#define H_FINGERPRINT
|
|
|
|
|
|
|
|
/** \ingroup rpmtrans
|
2022-03-09 20:07:36 +08:00
|
|
|
* \file fprint.h
|
2001-05-11 12:06:12 +08:00
|
|
|
* Identify a file name path by a unique "finger print".
|
|
|
|
*/
|
|
|
|
|
2012-09-14 03:41:41 +08:00
|
|
|
#include <rpm/rpmtypes.h>
|
2001-05-11 12:06:12 +08:00
|
|
|
|
2002-02-01 23:19:44 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 00:37:03 +08:00
|
|
|
typedef struct fprintCache_s * fingerPrintCache;
|
2002-02-01 23:19:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Convert to pointer and make abstract.
|
|
|
|
*/
|
|
|
|
typedef struct fingerPrint_s fingerPrint;
|
|
|
|
|
2008-10-21 21:45:09 +08:00
|
|
|
struct rpmffi_s {
|
2008-11-26 23:29:55 +08:00
|
|
|
rpmte p;
|
2008-10-21 21:45:09 +08:00
|
|
|
int fileno;
|
2002-02-01 23:19:44 +08:00
|
|
|
};
|
2001-05-11 12:06:12 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create finger print cache.
|
|
|
|
* @param sizeHint number of elements expected
|
2012-09-14 19:21:10 +08:00
|
|
|
* @param pool string pool (or NULL for private)
|
2001-05-11 12:06:12 +08:00
|
|
|
* @return pointer to initialized fingerprint cache
|
|
|
|
*/
|
2008-10-09 20:48:46 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
2012-09-14 19:21:10 +08:00
|
|
|
fingerPrintCache fpCacheCreate(int sizeHint, rpmstrPool pool);
|
2001-05-11 12:06:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy finger print cache.
|
|
|
|
* @param cache pointer to fingerprint cache
|
2002-05-18 05:08:39 +08:00
|
|
|
* @return NULL always
|
2001-05-11 12:06:12 +08:00
|
|
|
*/
|
2008-10-09 20:48:46 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
2007-09-12 00:37:03 +08:00
|
|
|
fingerPrintCache fpCacheFree(fingerPrintCache cache);
|
2001-05-11 12:06:12 +08:00
|
|
|
|
2012-09-14 02:52:38 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
2012-09-14 14:28:50 +08:00
|
|
|
fingerPrint * fpCacheGetByFp(fingerPrintCache cache,
|
|
|
|
struct fingerPrint_s * fp, int ix,
|
|
|
|
struct rpmffi_s ** recs, int * numRecs);
|
2012-09-14 02:52:38 +08:00
|
|
|
|
2012-09-14 03:19:40 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
|
|
|
void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
|
|
|
|
|
2012-09-14 05:10:45 +08:00
|
|
|
/* 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);
|
|
|
|
|
2020-02-20 21:43:54 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
|
|
|
int fpLookupEqualsId(fingerPrintCache cache, fingerPrint * fp,
|
|
|
|
rpmsid dirNameId, rpmsid baseNameId);
|
|
|
|
|
2012-09-14 12:45:44 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
|
|
|
const char *fpEntryDir(fingerPrintCache cache, fingerPrint *fp);
|
|
|
|
|
|
|
|
RPM_GNUC_INTERNAL
|
|
|
|
dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp);
|
|
|
|
|
2001-05-11 12:06:12 +08:00
|
|
|
/**
|
|
|
|
* 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
|
2020-10-28 15:50:45 +08:00
|
|
|
* @param[out] fp pointer of fingerprint struct to fill out
|
2012-09-06 17:53:05 +08:00
|
|
|
* @return 0 on success
|
2001-05-11 12:06:12 +08:00
|
|
|
*/
|
2008-10-09 20:48:46 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
2012-09-06 17:53:05 +08:00
|
|
|
int fpLookup(fingerPrintCache cache,
|
2012-09-14 19:19:32 +08:00
|
|
|
const char * dirName, const char * baseName,
|
2012-09-14 13:41:01 +08:00
|
|
|
fingerPrint **fp);
|
2001-05-11 12:06:12 +08:00
|
|
|
|
2020-02-20 21:43:54 +08:00
|
|
|
/**
|
|
|
|
* 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
|
2020-10-28 15:50:45 +08:00
|
|
|
* @param[out] fp pointer of fingerprint struct to fill out
|
2020-02-20 21:43:54 +08:00
|
|
|
* @return 0 on success
|
|
|
|
*/
|
|
|
|
RPM_GNUC_INTERNAL
|
|
|
|
int fpLookupId(fingerPrintCache cache,
|
|
|
|
rpmsid dirNameId, rpmsid BaseNameId,
|
|
|
|
fingerPrint **fp);
|
|
|
|
|
2001-05-11 12:06:12 +08:00
|
|
|
/**
|
|
|
|
* Compare two finger print entries.
|
2002-05-06 05:49:45 +08:00
|
|
|
* This routine is exactly equivalent to the FP_EQUAL macro.
|
2001-05-11 12:06:12 +08:00
|
|
|
* @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);
|
2001-05-11 12:06:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return finger prints of an array of file paths.
|
|
|
|
* @param cache pointer to fingerprint cache
|
2012-09-08 16:25:16 +08:00
|
|
|
* @param pool pointer to file name pool
|
2001-05-11 12:06:12 +08:00
|
|
|
* @param dirNames directory names
|
|
|
|
* @param baseNames file base names
|
|
|
|
* @param dirIndexes index into dirNames for each baseNames
|
|
|
|
* @param fileCount number of file entries
|
2012-09-14 05:21:04 +08:00
|
|
|
* @return pointer to array of finger prints
|
2001-05-11 12:06:12 +08:00
|
|
|
*/
|
2008-10-09 20:48:46 +08:00
|
|
|
RPM_GNUC_INTERNAL
|
2012-09-14 05:21:04 +08:00
|
|
|
fingerPrint * fpLookupList(fingerPrintCache cache, rpmstrPool pool,
|
|
|
|
rpmsid * dirNames, rpmsid * baseNames,
|
|
|
|
const uint32_t * dirIndexes, int fileCount);
|
2001-05-11 12:06:12 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|