Take advantage of headerGetInstance() in rpmte
[platform/upstream/rpm.git] / lib / rpmte.h
1 #ifndef H_RPMTE
2 #define H_RPMTE
3
4 /** \ingroup rpmts rpmte
5  * \file lib/rpmte.h
6  * Structures used for an "rpmte" transaction element.
7  */
8
9 #include <rpm/rpmal.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 /**
16  */
17 extern int _rpmte_debug;
18
19 /** \ingroup rpmte
20  * Transaction element ordering chain linkage.
21  */
22 typedef struct tsortInfo_s *            tsortInfo;
23
24 /** \ingroup rpmte
25  * Transaction element iterator.
26  */
27 typedef struct rpmtsi_s *               rpmtsi;
28
29 /** \ingroup rpmte
30  * Transaction element type.
31  */
32 typedef enum rpmElementType_e {
33     TR_ADDED            = (1 << 0),     /*!< Package will be installed. */
34     TR_REMOVED          = (1 << 1)      /*!< Package will be removed. */
35 } rpmElementType;
36
37 /** \ingroup rpmte
38  * Destroy a transaction element.
39  * @param te            transaction element
40  * @return              NULL always
41  */
42 rpmte rpmteFree(rpmte te);
43
44 /** \ingroup rpmte
45  * Create a transaction element.
46  * @param ts            transaction set
47  * @param h             header
48  * @param type          TR_ADDED/TR_REMOVED
49  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
50  * @param relocs        (TR_ADDED) package file relocations
51  * @param dboffset      unused
52  * @param pkgKey        associated added package (if any)
53  * @return              new transaction element
54  */
55 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
56                 fnpyKey key,
57                 rpmRelocation * relocs,
58                 int dboffset,
59                 rpmalKey pkgKey);
60
61 /** \ingroup rpmte
62  * Retrieve header from transaction element.
63  * @param te            transaction element
64  * @return              header
65  */
66 Header rpmteHeader(rpmte te);
67
68 /** \ingroup rpmte
69  * Save header into transaction element.
70  * @param te            transaction element
71  * @param h             header
72  * @return              NULL always
73  */
74 Header rpmteSetHeader(rpmte te, Header h);
75
76 /** \ingroup rpmte
77  * Retrieve type of transaction element.
78  * @param te            transaction element
79  * @return              type
80  */
81 rpmElementType rpmteType(rpmte te);
82
83 /** \ingroup rpmte
84  * Retrieve name string of transaction element.
85  * @param te            transaction element
86  * @return              name string
87  */
88 const char * rpmteN(rpmte te);
89
90 /** \ingroup rpmte
91  * Retrieve epoch string of transaction element.
92  * @param te            transaction element
93  * @return              epoch string
94  */
95 const char * rpmteE(rpmte te);
96
97 /** \ingroup rpmte
98  * Retrieve version string of transaction element.
99  * @param te            transaction element
100  * @return              version string
101  */
102 const char * rpmteV(rpmte te);
103
104 /** \ingroup rpmte
105  * Retrieve release string of transaction element.
106  * @param te            transaction element
107  * @return              release string
108  */
109 const char * rpmteR(rpmte te);
110
111 /** \ingroup rpmte
112  * Retrieve arch string of transaction element.
113  * @param te            transaction element
114  * @return              arch string
115  */
116 const char * rpmteA(rpmte te);
117
118 /** \ingroup rpmte
119  * Retrieve os string of transaction element.
120  * @param te            transaction element
121  * @return              os string
122  */
123 const char * rpmteO(rpmte te);
124
125 /** \ingroup rpmte
126  * Retrieve isSource attribute of transaction element.
127  * @param te            transaction element
128  * @return              isSource attribute
129  */
130 int rpmteIsSource(rpmte te);
131
132 /** \ingroup rpmte
133  * Retrieve color bits of transaction element.
134  * @param te            transaction element
135  * @return              color bits
136  */
137 rpm_color_t rpmteColor(rpmte te);
138
139 /** \ingroup rpmte
140  * Set color bits of transaction element.
141  * @param te            transaction element
142  * @param color         new color bits
143  * @return              previous color bits
144  */
145 rpm_color_t rpmteSetColor(rpmte te, rpm_color_t color);
146
147 /** \ingroup rpmte
148  * Retrieve last instance installed to the database.
149  * @param te            transaction element
150  * @return              last install instance.
151  */
152 unsigned int rpmteDBInstance(rpmte te);
153
154 /** \ingroup rpmte
155  * Set last instance installed to the database.
156  * @param te            transaction element
157  * @param instance      Database instance of last install element.
158  * @return              last install instance.
159  */
160 void rpmteSetDBInstance(rpmte te, unsigned int instance);
161
162 /** \ingroup rpmte
163  * Retrieve size in bytes of package file.
164  * @todo Signature header is estimated at 256b.
165  * @param te            transaction element
166  * @return              size in bytes of package file.
167  */
168 rpm_loff_t rpmtePkgFileSize(rpmte te);
169
170 /** \ingroup rpmte
171  * Retrieve dependency tree depth of transaction element.
172  * @param te            transaction element
173  * @return              depth
174  */
175 int rpmteDepth(rpmte te);
176
177 /** \ingroup rpmte
178  * Set dependency tree depth of transaction element.
179  * @param te            transaction element
180  * @param ndepth        new depth
181  * @return              previous depth
182  */
183 int rpmteSetDepth(rpmte te, int ndepth);
184
185 /** \ingroup rpmte
186  * Retrieve dependency tree breadth of transaction element.
187  * @param te            transaction element
188  * @return              breadth
189  */
190 int rpmteBreadth(rpmte te);
191
192 /** \ingroup rpmte
193  * Set dependency tree breadth of transaction element.
194  * @param te            transaction element
195  * @param nbreadth      new breadth
196  * @return              previous breadth
197  */
198 int rpmteSetBreadth(rpmte te, int nbreadth);
199
200 /** \ingroup rpmte
201  * Retrieve tsort no. of predecessors of transaction element.
202  * @param te            transaction element
203  * @return              no. of predecessors
204  */
205 int rpmteNpreds(rpmte te);
206
207 /** \ingroup rpmte
208  * Set tsort no. of predecessors of transaction element.
209  * @param te            transaction element
210  * @param npreds        new no. of predecessors
211  * @return              previous no. of predecessors
212  */
213 int rpmteSetNpreds(rpmte te, int npreds);
214
215 /** \ingroup rpmte
216  * Retrieve tree index of transaction element.
217  * @param te            transaction element
218  * @return              tree index
219  */
220 int rpmteTree(rpmte te);
221
222 /** \ingroup rpmte
223  * Set tree index of transaction element.
224  * @param te            transaction element
225  * @param ntree         new tree index
226  * @return              previous tree index
227  */
228 int rpmteSetTree(rpmte te, int ntree);
229
230 /** \ingroup rpmte
231  * Retrieve parent transaction element.
232  * @param te            transaction element
233  * @return              parent transaction element
234  */
235 rpmte rpmteParent(rpmte te);
236
237 /** \ingroup rpmte
238  * Set parent transaction element.
239  * @param te            transaction element
240  * @param pte           new parent transaction element
241  * @return              previous parent transaction element
242  */
243 rpmte rpmteSetParent(rpmte te, rpmte pte);
244
245 /** \ingroup rpmte
246  * Retrieve number of children of transaction element.
247  * @param te            transaction element
248  * @return              tree index
249  */
250 int rpmteDegree(rpmte te);
251
252 /** \ingroup rpmte
253  * Set number of children of transaction element.
254  * @param te            transaction element
255  * @param ndegree       new number of children
256  * @return              previous number of children
257  */
258 int rpmteSetDegree(rpmte te, int ndegree);
259
260 /** \ingroup rpmte
261  * Retrieve tsort info for transaction element.
262  * @param te            transaction element
263  * @return              tsort info
264  */
265 tsortInfo rpmteTSI(rpmte te);
266
267 /** \ingroup rpmte
268  * Destroy tsort info of transaction element.
269  * @param te            transaction element
270  */
271 void rpmteFreeTSI(rpmte te);
272
273 /** \ingroup rpmte
274  * Initialize tsort info of transaction element.
275  * @param te            transaction element
276  */
277 void rpmteNewTSI(rpmte te);
278
279 /** \ingroup rpmte
280  * Destroy dependency set info of transaction element.
281  * @param te            transaction element
282  */
283 void rpmteCleanDS(rpmte te);
284
285 /** \ingroup rpmte
286  * Retrieve pkgKey of TR_ADDED transaction element.
287  * @param te            transaction element
288  * @return              pkgKey
289  */
290 rpmalKey rpmteAddedKey(rpmte te);
291
292 /** \ingroup rpmte
293  * Set pkgKey of TR_ADDED transaction element.
294  * @param te            transaction element
295  * @param npkgKey       new pkgKey
296  * @return              previous pkgKey
297  */
298 rpmalKey rpmteSetAddedKey(rpmte te,
299                 rpmalKey npkgKey);
300
301 /** \ingroup rpmte
302  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
303  * @param te            transaction element
304  * @return              dependent pkgKey
305  */
306 rpmalKey rpmteDependsOnKey(rpmte te);
307
308 /** \ingroup rpmte
309  * Retrieve rpmdb instance of TR_REMOVED transaction element.
310  * @param te            transaction element
311  * @return              rpmdb instance
312  */
313 int rpmteDBOffset(rpmte te);
314
315 /** \ingroup rpmte
316  * Retrieve [epoch:]version-release string from transaction element.
317  * @param te            transaction element
318  * @return              [epoch:]version-release string
319  */
320 const char * rpmteEVR(rpmte te);
321
322 /** \ingroup rpmte
323  * Retrieve name-[epoch:]version-release string from transaction element.
324  * @param te            transaction element
325  * @return              name-[epoch:]version-release string
326  */
327 const char * rpmteNEVR(rpmte te);
328
329 /** \ingroup rpmte
330  * Retrieve name-[epoch:]version-release.arch string from transaction element.
331  * @param te            transaction element
332  * @return              name-[epoch:]version-release.arch string
333  */
334 const char * rpmteNEVRA(rpmte te);
335
336 /** \ingroup rpmte
337  * Retrieve file handle from transaction element.
338  * @param te            transaction element
339  * @return              file handle
340  */
341 FD_t rpmteFd(rpmte te);
342
343 /** \ingroup rpmte
344  * Retrieve key from transaction element.
345  * @param te            transaction element
346  * @return              key
347  */
348 fnpyKey rpmteKey(rpmte te);
349
350 /** \ingroup rpmte
351  * Retrieve dependency tag set from transaction element.
352  * @param te            transaction element
353  * @param tag           dependency tag
354  * @return              dependency tag set
355  */
356 rpmds rpmteDS(rpmte te, rpmTag tag);
357
358 /** \ingroup rpmte
359  * Retrieve file info tag set from transaction element.
360  * @param te            transaction element
361  * @param tag           file info tag (RPMTAG_BASENAMES)
362  * @return              file info tag set
363  */
364 rpmfi rpmteFI(rpmte te, rpmTag tag);
365
366 /** \ingroup rpmte
367  * Calculate transaction element dependency colors/refs from file info.
368  * @param te            transaction element
369  * @param tag           dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
370  */
371 void rpmteColorDS(rpmte te, rpmTag tag);
372
373 /** \ingroup rpmte
374  * Return transaction element index.
375  * @param tsi           transaction element iterator
376  * @return              transaction element index
377  */
378 int rpmtsiOc(rpmtsi tsi);
379
380 /** \ingroup rpmte
381  * Destroy transaction element iterator.
382  * @param tsi           transaction element iterator
383  * @return              NULL always
384  */
385 rpmtsi rpmtsiFree(rpmtsi tsi);
386
387 /** \ingroup rpmte
388  * Create transaction element iterator.
389  * @param ts            transaction set
390  * @return              transaction element iterator
391  */
392 rpmtsi rpmtsiInit(rpmts ts);
393
394 /** \ingroup rpmte
395  * Return next transaction element of type.
396  * @param tsi           transaction element iterator
397  * @param type          transaction element type selector (0 for any)
398  * @return              next transaction element of type, NULL on termination
399  */
400 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);
401
402 #ifdef __cplusplus
403 }
404 #endif
405
406 #endif  /* H_RPMTE */