- fix: synthesize unpacking progress callbacks for packages w/o files.
[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 /**
10  * Transaction element ordering chain linkage.
11  */
12 typedef /*@abstract@*/ struct tsortInfo_s *             tsortInfo;
13
14 /**
15  * Transaction element iterator.
16  */
17 typedef /*@abstract@*/ struct rpmtei_s *                rpmtei;
18
19 /** \ingroup rpmte
20  * Transaction element type.
21  */
22 typedef enum rpmElementType_e {
23     TR_ADDED            = (1 << 0),     /*!< Package will be installed. */
24     TR_REMOVED          = (1 << 1)      /*!< Package will be removed. */
25 } rpmElementType;
26
27 /*@-exportlocal@*/
28 /*@unchecked@*/
29 extern int _te_debug;
30 /*@=exportlocal@*/
31
32 #if     defined(_RPMTE_INTERNAL)
33 /** \ingroup rpmte
34  * Dependncy ordering information.
35  */
36 /*@-fielduse@*/ /* LCL: confused by union? */
37 struct tsortInfo_s {
38     union {
39         int     count;
40         /*@exposed@*/ /*@dependent@*/ /*@null@*/
41         rpmte   suc;
42     } tsi_u;
43 #define tsi_count       tsi_u.count
44 #define tsi_suc         tsi_u.suc
45 /*@owned@*/ /*@null@*/
46     struct tsortInfo_s * tsi_next;
47 /*@exposed@*/ /*@dependent@*/ /*@null@*/
48     rpmte tsi_chain;
49     int         tsi_reqx;
50     int         tsi_qcnt;
51 };
52 /*@=fielduse@*/
53
54 /** \ingroup rpmte
55  * A single package instance to be installed/removed atomically.
56  */
57 struct rpmte_s {
58     rpmElementType type;        /*!< Package disposition (installed/removed). */
59
60 /*@refcounted@*/ /*@null@*/
61     Header h;                   /*!< Package header. */
62 /*@only@*/
63     const char * NEVR;          /*!< Package name-version-release. */
64 /*@owned@*/
65     const char * name;          /*!< Name: */
66 /*@only@*/ /*@null@*/
67     char * epoch;
68 /*@dependent@*/ /*@null@*/
69     char * version;             /*!< Version: */
70 /*@dependent@*/ /*@null@*/
71     char * release;             /*!< Release: */
72 /*@only@*/ /*@null@*/
73     const char * arch;          /*!< Architecture hint. */
74 /*@only@*/ /*@null@*/
75     const char * os;            /*!< Operating system hint. */
76
77     rpmte parent;               /*!< Parent transaction element. */
78     int degree;                 /*!< No. of immediate children. */
79     int depth;                  /*!< Max. depth in dependency tree. */
80     int npreds;                 /*!< No. of predecessors. */
81     int tree;                   /*!< Tree index. */
82 /*@owned@*/
83     tsortInfo tsi;              /*!< Dependency ordering chains. */
84
85 /*@refcounted@*/ /*@null@*/
86     rpmds this;                 /*!< This package's provided NEVR. */
87 /*@refcounted@*/ /*@null@*/
88     rpmds provides;             /*!< Provides: dependencies. */
89 /*@refcounted@*/ /*@null@*/
90     rpmds requires;             /*!< Requires: dependencies. */
91 /*@refcounted@*/ /*@null@*/
92     rpmds conflicts;            /*!< Conflicts: dependencies. */
93 /*@refcounted@*/ /*@null@*/
94     rpmds obsoletes;            /*!< Obsoletes: dependencies. */
95 /*@refcounted@*/ /*@null@*/
96     rpmfi fi;                   /*!< File information. */
97
98     uint_32 multiLib;           /*!< (TR_ADDED) MULTILIB */
99
100 /*@exposed@*/ /*@dependent@*/ /*@null@*/
101     fnpyKey key;                /*!< (TR_ADDED) Retrieval key. */
102 /*@owned@*/ /*@null@*/
103     rpmRelocation * relocs;     /*!< (TR_ADDED) Payload file relocations. */
104 /*@refcounted@*/ /*@null@*/     
105     FD_t fd;                    /*!< (TR_ADDED) Payload file descriptor. */
106
107 /*@-fielduse@*/ /* LCL: confused by union? */
108     union { 
109 /*@exposed@*/ /*@dependent@*/ /*@null@*/
110         alKey addedKey;
111         struct {
112 /*@exposed@*/ /*@dependent@*/ /*@null@*/
113             alKey dependsOnKey;
114             int dboffset;
115         } removed;
116     } u;
117 /*@=fielduse@*/
118
119 };
120
121 /**
122  * Iterator across transaction elements, forward on install, backward on erase.
123  */
124 struct rpmtei_s {
125 /*@refcounted@*/
126     rpmts ts;           /*!< transaction set. */
127     int reverse;        /*!< reversed traversal? */
128     int ocsave;         /*!< last returned iterator index. */
129     int oc;             /*!< iterator index. */
130 };
131
132 #endif  /* _RPMTE_INTERNAL */
133
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137
138 /**
139  * Destroy a transaction element.
140  * @param te            transaction element
141  * @return              NULL always
142  */
143 /*@null@*/
144 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
145         /*@modifies te@*/;
146
147 /**
148  * Create a transaction element.
149  * @param ts            transaction set
150  * @param h             header
151  * @param type          TR_ADDED/TR_REMOVED
152  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
153  * @param relocs        (TR_ADDED) package file relocations
154  * @param dboffset      (TR_REMOVED) rpmdb instance
155  * @param pkgKey        associated added package (if any)
156  * @return              new transaction element
157  */
158 /*@only@*/ /*@null@*/
159 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
160                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
161                 /*@null@*/ rpmRelocation * relocs,
162                 int dboffset,
163                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
164         /*@modifies ts, h @*/;
165
166 /**
167  * Retrieve type of transaction element.
168  * @param te            transaction element
169  * @return              type
170  */
171 rpmElementType rpmteType(rpmte te)
172         /*@*/;
173
174 /**
175  * Retrieve name string of transaction element.
176  * @param te            transaction element
177  * @return              name string
178  */
179 /*@observer@*/
180 const char * rpmteN(rpmte te)
181         /*@*/;
182
183 /**
184  * Retrieve epoch string of transaction element.
185  * @param te            transaction element
186  * @return              epoch string
187  */
188 /*@observer@*/ /*@null@*/
189 const char * rpmteE(rpmte te)
190         /*@*/;
191
192 /**
193  * Retrieve version string of transaction element.
194  * @param te            transaction element
195  * @return              version string
196  */
197 /*@observer@*/ /*@null@*/
198 const char * rpmteV(rpmte te)
199         /*@*/;
200
201 /**
202  * Retrieve release string of transaction element.
203  * @param te            transaction element
204  * @return              release string
205  */
206 /*@observer@*/ /*@null@*/
207 const char * rpmteR(rpmte te)
208         /*@*/;
209
210 /**
211  * Retrieve arch string of transaction element.
212  * @param te            transaction element
213  * @return              arch string
214  */
215 /*@observer@*/ /*@null@*/
216 const char * rpmteA(rpmte te)
217         /*@*/;
218
219 /**
220  * Retrieve os string of transaction element.
221  * @param te            transaction element
222  * @return              os string
223  */
224 /*@observer@*/ /*@null@*/
225 const char * rpmteO(rpmte te)
226         /*@*/;
227
228 /**
229  * Retrieve multlib flags of transaction element.
230  * @param te            transaction element
231  * @return              multilib flags
232  */
233 int rpmteMultiLib(rpmte te)
234         /*@*/;
235
236 /**
237  * Set multlib flags of transaction element.
238  * @param te            transaction element
239  * @param nmultiLib     new multilib flags
240  * @return              previous multilib flags
241  */
242 int rpmteSetMultiLib(rpmte te, int nmultiLib)
243         /*@modifies te @*/;
244
245 /**
246  * Retrieve tsort tree depth of transaction element.
247  * @param te            transaction element
248  * @return              depth
249  */
250 int rpmteDepth(rpmte te)
251         /*@*/;
252
253 /**
254  * Set tsort tree depth of transaction element.
255  * @param te            transaction element
256  * @param ndepth        new depth
257  * @return              previous depth
258  */
259 int rpmteSetDepth(rpmte te, int ndepth)
260         /*@modifies te @*/;
261
262 /**
263  * Retrieve tsort no. of predecessors of transaction element.
264  * @param te            transaction element
265  * @return              no. of predecessors
266  */
267 int rpmteNpreds(rpmte te)
268         /*@*/;
269
270 /**
271  * Set tsort no. of predecessors of transaction element.
272  * @param te            transaction element
273  * @param npreds        new no. of predecessors
274  * @return              previous no. of predecessors
275  */
276 int rpmteSetNpreds(rpmte te, int npreds)
277         /*@modifies te @*/;
278
279 /**
280  * Retrieve tree index of transaction element.
281  * @param te            transaction element
282  * @return              tree index
283  */
284 int rpmteTree(rpmte te)
285         /*@*/;
286
287 /**
288  * Set tree index of transaction element.
289  * @param te            transaction element
290  * @param ntree         new tree index
291  * @return              previous tree index
292  */
293 int rpmteSetTree(rpmte te, int ntree)
294         /*@modifies te @*/;
295
296 /**
297  * Retrieve parent transaction element.
298  * @param te            transaction element
299  * @return              parent transaction element
300  */
301 /*@observer@*/ /*@unused@*/
302 rpmte rpmteParent(rpmte te)
303         /*@*/;
304
305 /**
306  * Set parent transaction element.
307  * @param te            transaction element
308  * @param pte           new parent transaction element
309  * @return              previous parent transaction element
310  */
311 rpmte rpmteSetParent(rpmte te, rpmte pte)
312         /*@modifies te @*/;
313
314 /**
315  * Retrieve number of children of transaction element.
316  * @param te            transaction element
317  * @return              tree index
318  */
319 int rpmteDegree(rpmte te)
320         /*@*/;
321
322 /**
323  * Set number of children of transaction element.
324  * @param te            transaction element
325  * @param ndegree       new number of children
326  * @return              previous number of children
327  */
328 int rpmteSetDegree(rpmte te, int ndegree)
329         /*@modifies te @*/;
330
331 /**
332  * Retrieve tsort info for transaction element.
333  * @param te            transaction element
334  * @return              tsort info
335  */
336 tsortInfo rpmteTSI(rpmte te)
337         /*@*/;
338
339 /**
340  * Destroy tsort info of transaction element.
341  * @param te            transaction element
342  */
343 void rpmteFreeTSI(rpmte te)
344         /*@modifies te @*/;
345
346 /**
347  * Initialize tsort info of transaction element.
348  * @param te            transaction element
349  */
350 void rpmteNewTSI(rpmte te)
351         /*@modifies te @*/;
352
353 /**
354  * Destroy dependency set info of transaction element.
355  * @param te            transaction element
356  */
357 /*@unused@*/
358 void rpmteCleanDS(rpmte te)
359         /*@modifies te @*/;
360
361 /**
362  * Retrieve pkgKey of TR_ADDED transaction element.
363  * @param te            transaction element
364  * @return              pkgKey
365  */
366 /*@exposed@*/ /*@dependent@*/ /*@null@*/
367 alKey rpmteAddedKey(rpmte te)
368         /*@*/;
369
370 /**
371  * Set pkgKey of TR_ADDED transaction element.
372  * @param te            transaction element
373  * @param npkgKey       new pkgKey
374  * @return              previous pkgKey
375  */
376 /*@exposed@*/ /*@dependent@*/ /*@null@*/
377 alKey rpmteSetAddedKey(rpmte te,
378                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
379         /*@modifies te @*/;
380
381 /**
382  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
383  * @param te            transaction element
384  * @return              dependent pkgKey
385  */
386 /*@exposed@*/ /*@dependent@*/ /*@null@*/
387 alKey rpmteDependsOnKey(rpmte te)
388         /*@*/;
389
390 /**
391  * Retrieve rpmdb instance of TR_REMOVED transaction element.
392  * @param te            transaction element
393  * @return              rpmdb instance
394  */
395 int rpmteDBOffset(rpmte te)
396         /*@*/;
397
398 /**
399  * Retrieve name-version-release string from transaction element.
400  * @param te            transaction element
401  * @return              name-version-release string
402  */
403 /*@observer@*/
404 const char * rpmteNEVR(rpmte te)
405         /*@*/;
406
407 /**
408  * Retrieve file handle from transaction element.
409  * @param te            transaction element
410  * @return              file handle
411  */
412 FD_t rpmteFd(rpmte te)
413         /*@*/;
414
415 /**
416  * Retrieve key from transaction element.
417  * @param te            transaction element
418  * @return              key
419  */
420 /*@exposed@*/
421 fnpyKey rpmteKey(rpmte te)
422         /*@*/;
423
424 /**
425  * Retrieve dependency tag set from transaction element.
426  * @param te            transaction element
427  * @param tag           dependency tag
428  * @return              dependency tag set
429  */
430 rpmds rpmteDS(rpmte te, rpmTag tag)
431         /*@*/;
432
433 /**
434  * Retrieve file info tag set from transaction element.
435  * @param te            transaction element
436  * @param tag           file info tag
437  * @return              file info tag set
438  */
439 rpmfi rpmteFI(rpmte te, rpmTag tag)
440         /*@*/;
441
442 /**
443  * Return transaction element index.
444  * @param tei           transaction element iterator
445  * @return              transaction element index
446  */
447 int rpmteiGetOc(rpmtei tei)
448         /*@*/;
449
450 /**
451  * Destroy transaction element iterator.
452  * @param tei           transaction element iterator
453  * @return              NULL always
454  */
455 /*@unused@*/ /*@null@*/
456 rpmtei rpmteiFree(/*@only@*//*@null@*/ rpmtei tei)
457         /*@*/;
458
459 /**
460  * Destroy transaction element iterator.
461  * @param tei           transaction element iterator
462  * @param fn
463  * @param ln
464  * @return              NULL always
465  */
466 /*@null@*/
467 rpmtei XrpmteiFree(/*@only@*//*@null@*/ rpmtei tei,
468                 const char * fn, unsigned int ln)
469         /*@*/;
470 #define rpmteiFree(_tei)        XrpmteiFree(_tei, __FILE__, __LINE__)
471
472 /**
473  * Create transaction element iterator.
474  * @param ts            transaction set
475  * @return              transaction element iterator
476  */
477 /*@unused@*/ /*@only@*/
478 rpmtei rpmteiInit(rpmts ts)
479         /*@modifies ts @*/;
480
481 /**
482  * Create transaction element iterator.
483  * @param ts            transaction set
484  * @param fn
485  * @param ln
486  * @return              transaction element iterator
487  */
488 /*@unused@*/ /*@only@*/
489 rpmtei XrpmteiInit(rpmts ts,
490                 const char * fn, unsigned int ln)
491         /*@modifies ts @*/;
492 #define rpmteiInit(_ts)         XrpmteiInit(_ts, __FILE__, __LINE__)
493
494 /**
495  * Return next transaction element of type.
496  * @param tei           transaction element iterator
497  * @param type          transaction element type selector (0 for any)
498  * @return              next transaction element of type, NULL on termination
499  */
500 /*@dependent@*/ /*@null@*/
501 rpmte rpmteiNext(rpmtei tei, rpmElementType type)
502         /*@modifies tei @*/;
503
504 #ifdef __cplusplus
505 }
506 #endif
507
508 #endif  /* H_RPMTE */