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