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