1 #ifndef H_RPMDB_INTERNAL
2 #define H_RPMDB_INTERNAL
8 #include <rpm/rpmtypes.h>
9 #include <rpm/rpmutil.h>
10 #include "lib/backend/dbi.h"
17 * Reference a database instance.
18 * @param db rpm database
19 * @return new rpm database reference
21 rpmdb rpmdbLink(rpmdb db);
25 * @param prefix path to top of install tree
26 * @retval dbp address of rpm database
27 * @param mode open(2) flags: O_RDWR or O_RDONLY (O_CREAT also)
28 * @param perms database permissions
29 * @return 0 on success
32 int rpmdbOpen (const char * prefix, rpmdb * dbp, int mode, int perms);
35 * Initialize database.
36 * @param prefix path to top of install tree
37 * @param perms database permissions
38 * @return 0 on success
41 int rpmdbInit(const char * prefix, int perms);
44 * Close all database indices and free rpmdb.
45 * @param db rpm database
46 * @return 0 on success
49 int rpmdbClose (rpmdb db);
52 * Sync all database indices.
53 * @param db rpm database
54 * @return 0 on success
57 int rpmdbSync (rpmdb db);
60 * Rebuild database indices from package headers.
61 * @param prefix path to top of install tree
62 * @param ts transaction set (or NULL)
63 * @param (*hdrchk) headerCheck() vector (or NULL)
64 * @return 0 on success
67 int rpmdbRebuild(const char * prefix, rpmts ts,
68 rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg));
71 * Verify database components.
72 * @param prefix path to top of install tree
73 * @return 0 on success
76 int rpmdbVerify(const char * prefix);
79 * Add package header to rpm database and indices.
80 * @param db rpm database
82 * @return 0 on success
85 int rpmdbAdd(rpmdb db, Header h);
88 * Remove package header from rpm database and indices.
89 * @param db rpm database
90 * @param hdrNum package instance number in database
91 * @return 0 on success
94 int rpmdbRemove(rpmdb db, unsigned int hdrNum);
97 * Return rpmdb home directory (depending on chroot state)
98 * param db rpmdb handle
99 * return db home directory (or NULL on error)
102 const char *rpmdbHome(rpmdb db);
105 * Return database iterator.
106 * @param mi rpm database iterator
107 * @param keyp key data (NULL for sequential access)
108 * @param keylen key data length (0 will use strlen(keyp))
109 * @return 0 on success
111 int rpmdbExtendIterator(rpmdbMatchIterator mi,
112 const void * keyp, size_t keylen);
115 * sort the iterator by (recnum, filenum)
116 * Return database iterator.
117 * @param mi rpm database iterator
119 void rpmdbSortIterator(rpmdbMatchIterator mi);
121 /* avoid importing rpmts_internal.h */
125 #define HASHTYPE intHash
126 #define HTKEYTYPE unsigned int
132 * Remove items from set of package instances to iterate.
133 * @note Sorted hdrNums are always passed in rpmlib.
134 * @param mi rpm database iterator
135 * @param hdrNums hash of package instances
136 * @return 0 on success, 1 on failure (bad args)
138 int rpmdbPruneIterator(rpmdbMatchIterator mi, intHash hdrNums);
141 * Create a new, empty match iterator (for purposes of extending it
142 * through other means)
143 * @param db rpm database
144 * @param dbitag database index tag
145 * @return empty match iterator
148 rpmdbMatchIterator rpmdbNewIterator(rpmdb db, rpmDbiTagVal dbitag);
152 * * Mergesort, same arguments as qsort(2).
155 int mergesort(void *base, size_t nmemb, size_t size,
156 int (*cmp) (const void *, const void *));
158 /* mergesort is defined in stdlib.h on Mac OS X */
159 #endif /* __APPLE__ */