Add support for global LDFLAGS
[platform/upstream/rpm.git] / lib / fprint.h
1 #ifndef H_FINGERPRINT
2 #define H_FINGERPRINT
3
4 /** \ingroup rpmtrans
5  * \file lib/fprint.h
6  * Identify a file name path by a unique "finger print".
7  */
8
9 #include <rpm/rpmtypes.h>
10
11 /**
12  */
13 typedef struct fprintCache_s * fingerPrintCache;
14
15 /**
16  * @todo Convert to pointer and make abstract.
17  */
18 typedef struct fingerPrint_s fingerPrint;
19
20 struct rpmffi_s {
21   rpmte p;
22   int   fileno;
23 };
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30  * Create finger print cache.
31  * @param sizeHint      number of elements expected
32  * @param pool          string pool (or NULL for private)
33  * @return pointer to initialized fingerprint cache
34  */
35 RPM_GNUC_INTERNAL
36 fingerPrintCache fpCacheCreate(int sizeHint, rpmstrPool pool);
37
38 /**
39  * Destroy finger print cache.
40  * @param cache         pointer to fingerprint cache
41  * @return              NULL always
42  */
43 RPM_GNUC_INTERNAL
44 fingerPrintCache fpCacheFree(fingerPrintCache cache);
45
46 RPM_GNUC_INTERNAL
47 fingerPrint * fpCacheGetByFp(fingerPrintCache cache,
48                              struct fingerPrint_s * fp, int ix,
49                              struct rpmffi_s ** recs, int * numRecs);
50
51 RPM_GNUC_INTERNAL
52 void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
53
54 /* compare an existing fingerprint with a looked-up fingerprint for db/bn */
55 RPM_GNUC_INTERNAL
56 int fpLookupEquals(fingerPrintCache cache, fingerPrint * fp,
57                    const char * dirName, const char * baseName);
58
59 RPM_GNUC_INTERNAL
60 const char *fpEntryDir(fingerPrintCache cache, fingerPrint *fp);
61
62 RPM_GNUC_INTERNAL
63 dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp);
64
65 /**
66  * Return finger print of a file path.
67  * @param cache         pointer to fingerprint cache
68  * @param dirName       leading directory name of file path
69  * @param baseName      base name of file path
70  * @retval fp           pointer of fingerprint struct to fill out
71  * @return              0 on success
72  */
73 RPM_GNUC_INTERNAL
74 int fpLookup(fingerPrintCache cache,
75              const char * dirName, const char * baseName,
76              fingerPrint **fp);
77
78 /**
79  * Compare two finger print entries.
80  * This routine is exactly equivalent to the FP_EQUAL macro.
81  * @param key1          finger print 1
82  * @param key2          finger print 2
83  * @return result of comparing key1 and key2
84  */
85 RPM_GNUC_INTERNAL
86 int fpEqual(const fingerPrint * key1, const fingerPrint * key2);
87
88 /**
89  * Return finger prints of an array of file paths.
90  * @param cache         pointer to fingerprint cache
91  * @param pool          pointer to file name pool
92  * @param dirNames      directory names
93  * @param baseNames     file base names
94  * @param dirIndexes    index into dirNames for each baseNames
95  * @param fileCount     number of file entries
96  * @return              pointer to array of finger prints
97  */
98 RPM_GNUC_INTERNAL
99 fingerPrint * fpLookupList(fingerPrintCache cache, rpmstrPool pool,
100                            rpmsid * dirNames, rpmsid * baseNames,
101                            const uint32_t * dirIndexes, int fileCount);
102
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif