forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpmdb_internal.h
218 lines (192 loc) · 5.68 KB
/
rpmdb_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#ifndef H_RPMDB_INTERNAL
#define H_RPMDB_INTERNAL
#include <assert.h>
#include <rpm/rpmsw.h>
#include <rpm/rpmtypes.h>
#include <rpm/rpmutil.h>
#include "lib/backend/dbi.h"
#ifdef __cplusplus
extern "C" {
#endif
#undef HASHTYPE
#undef HTKEYTYPE
#undef HTDATATYPE
#define HASHTYPE packageHash
#define HTKEYTYPE unsigned int
#define HTDATATYPE struct rpmte_s *
#include "rpmhash.H"
#undef HASHTYPE
#undef HTKEYTYPE
#undef HTDATATYPE
/** \ingroup rpmdb
* Reference a database instance.
* @param db rpm database
* @return new rpm database reference
*/
rpmdb rpmdbLink(rpmdb db);
/** \ingroup rpmdb
* Open rpm database.
* @param prefix path to top of install tree
* @retval dbp address of rpm database
* @param mode open(2) flags: O_RDWR or O_RDONLY (O_CREAT also)
* @param perms database permissions
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbOpen (const char * prefix, rpmdb * dbp, int mode, int perms);
/** \ingroup rpmdb
* Initialize database.
* @param prefix path to top of install tree
* @param perms database permissions
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbInit(const char * prefix, int perms);
/** \ingroup rpmdb
* Close all database indices and free rpmdb.
* @param db rpm database
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbClose (rpmdb db);
/** \ingroup rpmdb
* Rebuild database indices from package headers.
* @param prefix path to top of install tree
* @param ts transaction set (or NULL)
* @param (*hdrchk) headerCheck() vector (or NULL)
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbRebuild(const char * prefix, rpmts ts,
rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg));
/** \ingroup rpmdb
* Verify database components.
* @param prefix path to top of install tree
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbVerify(const char * prefix);
/** \ingroup rpmdb
* Add package header to rpm database and indices.
* @param db rpm database
* @param h header
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbAdd(rpmdb db, Header h);
/** \ingroup rpmdb
* Remove package header from rpm database and indices.
* @param db rpm database
* @param hdrNum package instance number in database
* @return 0 on success
*/
RPM_GNUC_INTERNAL
int rpmdbRemove(rpmdb db, unsigned int hdrNum);
/** \ingroup rpmdb
* Return rpmdb home directory (depending on chroot state)
* param db rpmdb handle
* return db home directory (or NULL on error)
*/
RPM_GNUC_INTERNAL
const char *rpmdbHome(rpmdb db);
/** \ingroup rpmdb
* Return database iterator.
* @param mi rpm database iterator
* @param keyp key data (NULL for sequential access)
* @param keylen key data length (0 will use strlen(keyp))
* @return 0 on success
*/
int rpmdbExtendIterator(rpmdbMatchIterator mi,
const void * keyp, size_t keylen);
/** \ingroup rpmdb
* sort the iterator by (recnum, filenum)
* Return database iterator.
* @param mi rpm database iterator
*/
void rpmdbSortIterator(rpmdbMatchIterator mi);
/** \ingroup rpmdb
* uniq the iterator by recnum
* Return database iterator.
* @param mi rpm database iterator
*/
void rpmdbUniqIterator(rpmdbMatchIterator mi);
/** \ingroup rpmdb
* If neg equals to zero then it leaves in iterator only packages that
* header numbers are in hdrNums. If neg is not zero then removes from iterator
* all packages that header numbers are in hdrNums.
* @param mi rpm database iterator
* @param hdrNums hash of package numbers
* @param neg mode
* return 0 on success, 1 on failure (bad args)
*/
int rpmdbFilterIterator(rpmdbMatchIterator mi, packageHash hdrNums, int neg);
/** \ingroup rpmdb
* Remove items from set of package instances to iterate.
* @note Sorted hdrNums are always passed in rpmlib.
* @param mi rpm database iterator
* @param hdrNums hash of package instances
* @return 0 on success, 1 on failure (bad args)
*/
int rpmdbPruneIterator(rpmdbMatchIterator mi, packageHash hdrNums);
/** \ingroup rpmdb
* Create a new, empty match iterator (for purposes of extending it
* through other means)
* @param db rpm database
* @param dbitag database index tag
* @return empty match iterator
*/
RPM_GNUC_INTERNAL
rpmdbMatchIterator rpmdbNewIterator(rpmdb db, rpmDbiTagVal dbitag);
/** \ingroup rpmdb
* Return database iterator that iterates over database items
* starting with pfx.
* @param db rpm database
* @param rpmtag database index tag
* @param pfx prefix data
* @param plen prefix data length (0 will use strlen(keyp))
* @return NULL on failure
*/
RPM_GNUC_INTERNAL
rpmdbMatchIterator rpmdbInitPrefixIterator(rpmdb db, rpmDbiTagVal rpmtag,
const void * pfx, size_t plen);
/** \ingroup rpmdb
* Get package offsets of entries
* @param ii index iterator
* @return db offsets of pkgs
*/
RPM_GNUC_INTERNAL
const unsigned int *rpmdbIndexIteratorPkgOffsets(rpmdbIndexIterator ii);
/** \ingroup rpmdb
* Return current index (position) in iterator.
* @param mi rpm database iterator
* @return current index
*/
RPM_GNUC_INTERNAL
int rpmdbGetIteratorIndex(rpmdbMatchIterator mi);
/** \ingroup rpmdb
* Set iterator index.
* @param mi rpm database iterator
* @param ix index
*/
RPM_GNUC_INTERNAL
void rpmdbSetIteratorIndex(rpmdbMatchIterator mi, unsigned int ix);
/** \ingroup rpmdb
* Return offset of package with given index.
* @param mi rpm database iterator
* @param ix index
* @return package offset
*/
RPM_GNUC_INTERNAL
unsigned int rpmdbGetIteratorOffsetFor(rpmdbMatchIterator mi, unsigned int ix);
/** \ingroup rpmdb
* Return header located in rpmdb at given offset.
* @param db rpm database
* @param offset database offset
* @return header at given offset
*/
RPM_GNUC_INTERNAL
Header rpmdbGetHeaderAt(rpmdb db, unsigned int offset);
#ifdef __cplusplus
}
#endif
#endif