- methods to complete making transactionElement opaque.
[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,                   /*!< Package will be installed. */
43     TR_REMOVED                  /*!< 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     int npreds;                 /*!< No. of predecessors. */
70     int depth;                  /*!< Max. depth in dependency tree. */
71 /*@owned@*/
72     tsortInfo tsi;              /*!< Dependency ordering chains. */
73
74 /*@refcounted@*/ /*@null@*/
75     rpmDepSet this;             /*!< This package's provided NEVR. */
76 /*@refcounted@*/ /*@null@*/
77     rpmDepSet provides;         /*!< Provides: dependencies. */
78 /*@refcounted@*/ /*@null@*/
79     rpmDepSet requires;         /*!< Requires: dependencies. */
80 /*@refcounted@*/ /*@null@*/
81     rpmDepSet conflicts;        /*!< Conflicts: dependencies. */
82 /*@refcounted@*/ /*@null@*/
83     rpmDepSet obsoletes;        /*!< Obsoletes: dependencies. */
84 /*@refcounted@*/ /*@null@*/
85     TFI_t fi;                   /*!< File information. */
86
87     uint_32 multiLib;           /*!< (TR_ADDED) MULTILIB */
88
89 /*@exposed@*/ /*@dependent@*/ /*@null@*/
90     fnpyKey key;                /*!< (TR_ADDED) Retrieval key. */
91 /*@owned@*/ /*@null@*/
92     rpmRelocation * relocs;     /*!< (TR_ADDED) Payload file relocations. */
93 /*@refcounted@*/ /*@null@*/     
94     FD_t fd;                    /*!< (TR_ADDED) Payload file descriptor. */
95
96 /*@-fielduse@*/ /* LCL: confused by union? */
97     union { 
98 /*@exposed@*/ /*@dependent@*/ /*@null@*/
99         alKey addedKey;
100         struct {
101 /*@exposed@*/ /*@dependent@*/ /*@null@*/
102             alKey dependsOnKey;
103             int dboffset;
104         } removed;
105     } u;
106 /*@=fielduse@*/
107
108 };
109
110 #if defined(_NEED_TEITERATOR)
111 /**
112  * Iterator across transaction elements, forward on install, backward on erase.
113  */
114 struct teIterator_s {
115 /*@refcounted@*/
116     rpmTransactionSet ts;       /*!< transaction set. */
117     int reverse;                /*!< reversed traversal? */
118     int ocsave;                 /*!< last returned iterator index. */
119     int oc;                     /*!< iterator index. */
120 };
121 #endif
122
123 #ifdef __cplusplus
124 extern "C" {
125 #endif
126
127 /**
128  * Destroy a transaction element.
129  * @param te            transaction element
130  * @return              NULL always
131  */
132 /*@null@*/
133 transactionElement teFree(/*@only@*/ /*@null@*/ transactionElement te)
134         /*@modifies te@*/;
135 /**
136  * Create a transaction element.
137  * @param ts            transaction set
138  * @param h             header
139  * @param type          TR_ADDED/TR_REMOVED
140  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
141  * @param relocs        (TR_ADDED) package file relocations
142  * @param dboffset      (TR_REMOVED) rpmdb instance
143  * @param pkgKey        associated added package (if any)
144  * @return              new transaction element
145  */
146 /*@only@*/ /*@null@*/
147 transactionElement teNew(const rpmTransactionSet ts, Header h,
148                 rpmTransactionType type,
149                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
150                 /*@null@*/ rpmRelocation * relocs,
151                 int dboffset,
152                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
153         /*@modifies ts, h @*/;
154
155 /**
156  * Retrieve type of transaction element.
157  * @param te            transaction element
158  * @return              type
159  */
160 rpmTransactionType teGetType(transactionElement te)
161         /*@*/;
162
163 /**
164  * Retrieve name string of transaction element.
165  * @param te            transaction element
166  * @return              name string
167  */
168 /*@observer@*/
169 const char * teGetN(transactionElement te)
170         /*@*/;
171
172 /**
173  * Retrieve epoch string of transaction element.
174  * @param te            transaction element
175  * @return              epoch string
176  */
177 /*@observer@*/ /*@null@*/
178 const char * teGetE(transactionElement te)
179         /*@*/;
180
181 /**
182  * Retrieve version string of transaction element.
183  * @param te            transaction element
184  * @return              version string
185  */
186 /*@observer@*/ /*@null@*/
187 const char * teGetV(transactionElement te)
188         /*@*/;
189
190 /**
191  * Retrieve release string of transaction element.
192  * @param te            transaction element
193  * @return              release string
194  */
195 /*@observer@*/ /*@null@*/
196 const char * teGetR(transactionElement te)
197         /*@*/;
198
199 /**
200  * Retrieve arch string of transaction element.
201  * @param te            transaction element
202  * @return              arch string
203  */
204 /*@observer@*/ /*@null@*/
205 const char * teGetA(transactionElement te)
206         /*@*/;
207
208 /**
209  * Retrieve os string of transaction element.
210  * @param te            transaction element
211  * @return              os string
212  */
213 /*@observer@*/ /*@null@*/
214 const char * teGetO(transactionElement te)
215         /*@*/;
216
217 /**
218  * Retrieve multlib flags of transaction element.
219  * @param te            transaction element
220  * @return              multilib flags
221  */
222 int teGetMultiLib(transactionElement te)
223         /*@*/;
224
225 /**
226  * Set multlib flags of transaction element.
227  * @param te            transaction element
228  * @param nmultiLib     new multilib flags
229  * @return              previous multilib flags
230  */
231 int teSetMultiLib(transactionElement te, int nmultiLib)
232         /*@modifies te @*/;
233
234 /**
235  * Retrieve tsort tree depth of transaction element.
236  * @param te            transaction element
237  * @return              depth
238  */
239 int teGetDepth(transactionElement te)
240         /*@*/;
241
242 /**
243  * Set tsort tree depth of transaction element.
244  * @param te            transaction element
245  * @param ndepth        new depth
246  * @return              previous depth
247  */
248 int teSetDepth(transactionElement te, int ndepth)
249         /*@modifies te @*/;
250
251 /**
252  * Retrieve tsort no. of predecessors of transaction element.
253  * @param te            transaction element
254  * @return              no. of predecessors
255  */
256 int teGetNpreds(transactionElement te)
257         /*@*/;
258
259 /**
260  * Set tsort no. of predecessors of transaction element.
261  * @param te            transaction element
262  * @param ndepth        new no. of predecessors
263  * @return              previous no. of predecessors
264  */
265 int teSetNpreds(transactionElement te, int npreds)
266         /*@modifies te @*/;
267
268 /**
269  * Retrieve tsort info for transaction element.
270  * @param te            transaction element
271  * @return              tsort info
272  */
273 tsortInfo teGetTSI(transactionElement te)
274         /*@*/;
275
276 /**
277  * Destroy tsort info of transaction element.
278  * @param te            transaction element
279  */
280 void teFreeTSI(transactionElement te)
281         /*@modifies te @*/;
282
283 /**
284  * Initialize tsort info of transaction element.
285  * @param te            transaction element
286  */
287 void teNewTSI(transactionElement te)
288         /*@modifies te @*/;
289
290 /**
291  * Destroy dependency set info of transaction element.
292  * @param te            transaction element
293  */
294 void teCleanDS(transactionElement te)
295         /*@modifies te @*/;
296
297 /**
298  * Retrieve pkgKey of TR_ADDED transaction element.
299  * @param te            transaction element
300  * @return              pkgKey
301  */
302 /*@exposed@*/ /*@dependent@*/ /*@null@*/
303 alKey teGetAddedKey(transactionElement te)
304         /*@*/;
305
306 /**
307  * Set pkgKey of TR_ADDED transaction element.
308  * @param te            transaction element
309  * @param npkgKey       new pkgKey
310  * @return              previous pkgKey
311  */
312 /*@exposed@*/ /*@dependent@*/ /*@null@*/
313 alKey teSetAddedKey(transactionElement te,
314                 /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
315         /*@modifies te @*/;
316
317 /**
318  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
319  * @param te            transaction element
320  * @return              dependent pkgKey
321  */
322 /*@exposed@*/ /*@dependent@*/ /*@null@*/
323 alKey teGetDependsOnKey(transactionElement te)
324         /*@*/;
325
326 /**
327  * Retrieve rpmdb instance of TR_REMOVED transaction element.
328  * @param te            transaction element
329  * @return              rpmdb instance
330  */
331 int teGetDBOffset(transactionElement te)
332         /*@*/;
333
334 /**
335  * Retrieve name-version-release string from transaction element.
336  * @param te            transaction element
337  * @return              name-version-release string
338  */
339 /*@observer@*/
340 const char * teGetNEVR(transactionElement te)
341         /*@*/;
342
343 /**
344  * Retrieve file handle from transaction element.
345  * @param te            transaction element
346  * @return              file handle
347  */
348 FD_t teGetFd(transactionElement te)
349         /*@*/;
350
351 /**
352  * Retrieve key from transaction element.
353  * @param te            transaction element
354  * @return              key
355  */
356 /*@exposed@*/
357 fnpyKey teGetKey(transactionElement te)
358         /*@*/;
359
360 /**
361  * Retrieve dependency tag set from transaction element.
362  * @param te            transaction element
363  * @param tag           dependency tag
364  * @return              dependency tag set
365  */
366 rpmDepSet teGetDS(transactionElement te, rpmTag tag)
367         /*@*/;
368
369 /**
370  * Retrieve file info tag set from transaction element.
371  * @param te            transaction element
372  * @param tag           file info tag
373  * @return              file info tag set
374  */
375 TFI_t teGetFI(transactionElement te, rpmTag tag)
376         /*@*/;
377
378 #if defined(_NEED_TEITERATOR)
379 /**
380  * Return transaction element index.
381  * @param tei           transaction element iterator
382  * @return              transaction element index
383  */
384 int teiGetOc(teIterator tei)
385         /*@*/;
386
387 /**
388  * Destroy transaction element iterator.
389  * @param tei           transaction element iterator
390  * @return              NULL always
391  */
392 /*@null@*/
393 teIterator teFreeIterator(/*@only@*//*@null@*/ teIterator tei)
394         /*@*/;
395
396 /**
397  * Create transaction element iterator.
398  * @param ts            transaction set
399  * @return              transaction element iterator
400  */
401 /*@only@*/
402 teIterator teInitIterator(rpmTransactionSet ts)
403         /*@modifies ts @*/;
404
405 /**
406  * Return next transaction element
407  * @param tei           transaction element iterator
408  * @return              transaction element, NULL on termination
409  */
410 /*@dependent@*/ /*@null@*/
411 transactionElement teNextIterator(teIterator tei)
412         /*@modifies tei @*/;
413
414 /**
415  * Return next transaction element of type.
416  * @param tei           transaction element iterator
417  * @param type          transaction element type selector
418  * @return              next transaction element of type, NULL on termination
419  */
420 /*@dependent@*/ /*@null@*/
421 transactionElement teNext(teIterator tei, rpmTransactionType type)
422         /*@modifies tei @*/;
423
424 #endif  /* defined(_NEED_TEITERATOR) */
425
426 #ifdef __cplusplus
427 }
428 #endif
429
430 #endif  /* H_RPMTE */