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