- sparc: make dbenv per-rpmdb, not per-dbi.
[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 #if defined(_NEED_TEITERATOR)
114 /**
115  * Iterator across transaction elements, forward on install, backward on erase.
116  */
117 struct teIterator_s {
118 /*@refcounted@*/
119     rpmTransactionSet ts;       /*!< transaction set. */
120     int reverse;                /*!< reversed traversal? */
121     int ocsave;                 /*!< last returned iterator index. */
122     int oc;                     /*!< iterator index. */
123 };
124 #endif
125
126 #ifdef __cplusplus
127 extern "C" {
128 #endif
129
130 /**
131  * Destroy a transaction element.
132  * @param te            transaction element
133  * @return              NULL always
134  */
135 /*@null@*/
136 transactionElement teFree(/*@only@*/ /*@null@*/ transactionElement te)
137         /*@modifies te@*/;
138 /**
139  * Create a transaction element.
140  * @param ts            transaction set
141  * @param h             header
142  * @param type          TR_ADDED/TR_REMOVED
143  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
144  * @param relocs        (TR_ADDED) package file relocations
145  * @param dboffset      (TR_REMOVED) rpmdb instance
146  * @param pkgKey        associated added package (if any)
147  * @return              new transaction element
148  */
149 /*@only@*/ /*@null@*/
150 transactionElement teNew(const rpmTransactionSet ts, Header h,
151                 rpmTransactionType type,
152                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
153                 /*@null@*/ rpmRelocation * relocs,
154                 int dboffset,
155                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
156         /*@modifies ts, h @*/;
157
158 /**
159  * Retrieve type of transaction element.
160  * @param te            transaction element
161  * @return              type
162  */
163 rpmTransactionType teGetType(transactionElement te)
164         /*@*/;
165
166 /**
167  * Retrieve name string of transaction element.
168  * @param te            transaction element
169  * @return              name string
170  */
171 /*@observer@*/
172 const char * teGetN(transactionElement te)
173         /*@*/;
174
175 /**
176  * Retrieve epoch string of transaction element.
177  * @param te            transaction element
178  * @return              epoch string
179  */
180 /*@observer@*/ /*@null@*/
181 const char * teGetE(transactionElement te)
182         /*@*/;
183
184 /**
185  * Retrieve version string of transaction element.
186  * @param te            transaction element
187  * @return              version string
188  */
189 /*@observer@*/ /*@null@*/
190 const char * teGetV(transactionElement te)
191         /*@*/;
192
193 /**
194  * Retrieve release string of transaction element.
195  * @param te            transaction element
196  * @return              release string
197  */
198 /*@observer@*/ /*@null@*/
199 const char * teGetR(transactionElement te)
200         /*@*/;
201
202 /**
203  * Retrieve arch string of transaction element.
204  * @param te            transaction element
205  * @return              arch string
206  */
207 /*@observer@*/ /*@null@*/
208 const char * teGetA(transactionElement te)
209         /*@*/;
210
211 /**
212  * Retrieve os string of transaction element.
213  * @param te            transaction element
214  * @return              os string
215  */
216 /*@observer@*/ /*@null@*/
217 const char * teGetO(transactionElement te)
218         /*@*/;
219
220 /**
221  * Retrieve multlib flags of transaction element.
222  * @param te            transaction element
223  * @return              multilib flags
224  */
225 int teGetMultiLib(transactionElement te)
226         /*@*/;
227
228 /**
229  * Set multlib flags of transaction element.
230  * @param te            transaction element
231  * @param nmultiLib     new multilib flags
232  * @return              previous multilib flags
233  */
234 int teSetMultiLib(transactionElement te, int nmultiLib)
235         /*@modifies te @*/;
236
237 /**
238  * Retrieve tsort tree depth of transaction element.
239  * @param te            transaction element
240  * @return              depth
241  */
242 int teGetDepth(transactionElement te)
243         /*@*/;
244
245 /**
246  * Set tsort tree depth of transaction element.
247  * @param te            transaction element
248  * @param ndepth        new depth
249  * @return              previous depth
250  */
251 int teSetDepth(transactionElement te, int ndepth)
252         /*@modifies te @*/;
253
254 /**
255  * Retrieve tsort no. of predecessors of transaction element.
256  * @param te            transaction element
257  * @return              no. of predecessors
258  */
259 int teGetNpreds(transactionElement te)
260         /*@*/;
261
262 /**
263  * Set tsort no. of predecessors of transaction element.
264  * @param te            transaction element
265  * @param npreds        new no. of predecessors
266  * @return              previous no. of predecessors
267  */
268 int teSetNpreds(transactionElement te, int npreds)
269         /*@modifies te @*/;
270
271 /**
272  * Retrieve tree index of transaction element.
273  * @param te            transaction element
274  * @return              tree index
275  */
276 int teGetTree(transactionElement te)
277         /*@*/;
278
279 /**
280  * Set tree index of transaction element.
281  * @param te            transaction element
282  * @param ntree         new tree index
283  * @return              previous tree index
284  */
285 int teSetTree(transactionElement te, int ntree)
286         /*@modifies te @*/;
287
288 /**
289  * Retrieve parent transaction element.
290  * @param te            transaction element
291  * @return              parent transaction element
292  */
293 /*@observer@*/ /*@unused@*/
294 transactionElement teGetParent(transactionElement te)
295         /*@*/;
296
297 /**
298  * Set parent transaction element.
299  * @param te            transaction element
300  * @param pte           new parent transaction element
301  * @return              previous parent transaction element
302  */
303 transactionElement teSetParent(transactionElement te, transactionElement pte)
304         /*@modifies te @*/;
305
306 /**
307  * Retrieve number of children of transaction element.
308  * @param te            transaction element
309  * @return              tree index
310  */
311 int teGetDegree(transactionElement te)
312         /*@*/;
313
314 /**
315  * Set number of children of transaction element.
316  * @param te            transaction element
317  * @param ndegree       new number of children
318  * @return              previous number of children
319  */
320 int teSetDegree(transactionElement te, int ndegree)
321         /*@modifies te @*/;
322
323 /**
324  * Retrieve tsort info for transaction element.
325  * @param te            transaction element
326  * @return              tsort info
327  */
328 tsortInfo teGetTSI(transactionElement te)
329         /*@*/;
330
331 /**
332  * Destroy tsort info of transaction element.
333  * @param te            transaction element
334  */
335 void teFreeTSI(transactionElement te)
336         /*@modifies te @*/;
337
338 /**
339  * Initialize tsort info of transaction element.
340  * @param te            transaction element
341  */
342 void teNewTSI(transactionElement te)
343         /*@modifies te @*/;
344
345 /**
346  * Destroy dependency set info of transaction element.
347  * @param te            transaction element
348  */
349 /*@unused@*/
350 void teCleanDS(transactionElement te)
351         /*@modifies te @*/;
352
353 /**
354  * Retrieve pkgKey of TR_ADDED transaction element.
355  * @param te            transaction element
356  * @return              pkgKey
357  */
358 /*@exposed@*/ /*@dependent@*/ /*@null@*/
359 alKey teGetAddedKey(transactionElement te)
360         /*@*/;
361
362 /**
363  * Set pkgKey of TR_ADDED transaction element.
364  * @param te            transaction element
365  * @param npkgKey       new pkgKey
366  * @return              previous pkgKey
367  */
368 /*@exposed@*/ /*@dependent@*/ /*@null@*/
369 alKey teSetAddedKey(transactionElement te,
370                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
371         /*@modifies te @*/;
372
373 /**
374  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
375  * @param te            transaction element
376  * @return              dependent pkgKey
377  */
378 /*@exposed@*/ /*@dependent@*/ /*@null@*/
379 alKey teGetDependsOnKey(transactionElement te)
380         /*@*/;
381
382 /**
383  * Retrieve rpmdb instance of TR_REMOVED transaction element.
384  * @param te            transaction element
385  * @return              rpmdb instance
386  */
387 int teGetDBOffset(transactionElement te)
388         /*@*/;
389
390 /**
391  * Retrieve name-version-release string from transaction element.
392  * @param te            transaction element
393  * @return              name-version-release string
394  */
395 /*@observer@*/
396 const char * teGetNEVR(transactionElement te)
397         /*@*/;
398
399 /**
400  * Retrieve file handle from transaction element.
401  * @param te            transaction element
402  * @return              file handle
403  */
404 FD_t teGetFd(transactionElement te)
405         /*@*/;
406
407 /**
408  * Retrieve key from transaction element.
409  * @param te            transaction element
410  * @return              key
411  */
412 /*@exposed@*/
413 fnpyKey teGetKey(transactionElement te)
414         /*@*/;
415
416 /**
417  * Retrieve dependency tag set from transaction element.
418  * @param te            transaction element
419  * @param tag           dependency tag
420  * @return              dependency tag set
421  */
422 rpmDepSet teGetDS(transactionElement te, rpmTag tag)
423         /*@*/;
424
425 /**
426  * Retrieve file info tag set from transaction element.
427  * @param te            transaction element
428  * @param tag           file info tag
429  * @return              file info tag set
430  */
431 TFI_t teGetFI(transactionElement te, rpmTag tag)
432         /*@*/;
433
434 #if defined(_NEED_TEITERATOR)
435 /**
436  * Return transaction element index.
437  * @param tei           transaction element iterator
438  * @return              transaction element index
439  */
440 int teiGetOc(teIterator tei)
441         /*@*/;
442
443 /**
444  * Destroy transaction element iterator.
445  * @param tei           transaction element iterator
446  * @return              NULL always
447  */
448 /*@unused@*/ /*@null@*/
449 teIterator teFreeIterator(/*@only@*//*@null@*/ teIterator tei)
450         /*@*/;
451
452 /**
453  * Destroy transaction element iterator.
454  * @param tei           transaction element iterator
455  * @return              NULL always
456  */
457 /*@null@*/
458 teIterator XteFreeIterator(/*@only@*//*@null@*/ teIterator tei,
459                 const char * fn, unsigned int ln)
460         /*@*/;
461 #define teFreeIterator(_tei)    XteFreeIterator(_tei, __FILE__, __LINE__)
462
463 /**
464  * Create transaction element iterator.
465  * @param ts            transaction set
466  * @return              transaction element iterator
467  */
468 /*@unused@*/ /*@only@*/
469 teIterator teInitIterator(rpmTransactionSet ts)
470         /*@modifies ts @*/;
471
472 /**
473  * Create transaction element iterator.
474  * @param ts            transaction set
475  * @return              transaction element iterator
476  */
477 /*@unused@*/ /*@only@*/
478 teIterator XteInitIterator(rpmTransactionSet ts,
479                 const char * fn, unsigned int ln)
480         /*@modifies ts @*/;
481 #define teInitIterator(_ts)     XteInitIterator(_ts, __FILE__, __LINE__)
482
483 /**
484  * Return next transaction element
485  * @param tei           transaction element iterator
486  * @return              transaction element, NULL on termination
487  */
488 /*@dependent@*/ /*@null@*/
489 transactionElement teNextIterator(teIterator tei)
490         /*@modifies tei @*/;
491
492 /**
493  * Return next transaction element of type.
494  * @param tei           transaction element iterator
495  * @param type          transaction element type selector
496  * @return              next transaction element of type, NULL on termination
497  */
498 /*@dependent@*/ /*@null@*/
499 transactionElement teNext(teIterator tei, rpmTransactionType type)
500         /*@modifies tei @*/;
501
502 #endif  /* defined(_NEED_TEITERATOR) */
503
504 #ifdef __cplusplus
505 }
506 #endif
507
508 #endif  /* H_RPMTE */