Continue 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 /*@unused@*/ alKey addedKey;
99 /*@unused@*/ struct {
100             alKey dependsOnKey;
101             int dboffset;
102         } removed;
103     } u;
104 /*@=fielduse@*/
105
106 };
107
108 #if defined(_NEED_TEITERATOR)
109 /**
110  * Iterator across transaction elements, forward on install, backward on erase.
111  */
112 struct teIterator_s {
113 /*@refcounted@*/
114     rpmTransactionSet ts;       /*!< transaction set. */
115     int reverse;                /*!< reversed traversal? */
116     int ocsave;                 /*!< last returned iterator index. */
117     int oc;                     /*!< iterator index. */
118 };
119 #endif
120
121 #ifdef __cplusplus
122 extern "C" {
123 #endif
124
125 /**
126  * Destroy a transaction element.
127  * @param te            transaction element
128  * @return              NULL always
129  */
130 /*@null@*/
131 transactionElement teFree(/*@only@*/ /*@null@*/ transactionElement te)
132         /*@modifies te@*/;
133 /**
134  * Create a transaction element.
135  * @param ts            transaction set
136  * @param h             header
137  * @param key           package retrieval key (e.g. file name)
138  * @param relocs        package file relocations
139  * @return              new transaction element
140  */
141 /*@only@*/ /*@null@*/
142 transactionElement teNew(const rpmTransactionSet ts, Header h,
143                 /*@exposed@*/ /*@null@*/ fnpyKey key,
144                 /*@null@*/ rpmRelocation * relocs)
145         /*@modifies ts, h @*/;
146
147 /**
148  * Retrieve type of transaction element.
149  * @param te            transaction element
150  * @return              type
151  */
152 rpmTransactionType teGetType(transactionElement te)
153         /*@*/;
154
155 /**
156  * Retrieve name string of transaction element.
157  * @param te            transaction element
158  * @return              name string
159  */
160 /*@observer@*/
161 const char * teGetN(transactionElement te)
162         /*@*/;
163
164 /**
165  * Retrieve epoch string of transaction element.
166  * @param te            transaction element
167  * @return              epoch string
168  */
169 /*@observer@*/ /*@null@*/
170 const char * teGetE(transactionElement te)
171         /*@*/;
172
173 /**
174  * Retrieve version string of transaction element.
175  * @param te            transaction element
176  * @return              version string
177  */
178 /*@observer@*/ /*@null@*/
179 const char * teGetV(transactionElement te)
180         /*@*/;
181
182 /**
183  * Retrieve release string of transaction element.
184  * @param te            transaction element
185  * @return              release string
186  */
187 /*@observer@*/ /*@null@*/
188 const char * teGetR(transactionElement te)
189         /*@*/;
190
191 /**
192  * Retrieve arch string of transaction element.
193  * @param te            transaction element
194  * @return              arch string
195  */
196 /*@observer@*/ /*@null@*/
197 const char * teGetA(transactionElement te)
198         /*@*/;
199
200 /**
201  * Retrieve os string of transaction element.
202  * @param te            transaction element
203  * @return              os string
204  */
205 /*@observer@*/ /*@null@*/
206 const char * teGetO(transactionElement te)
207         /*@*/;
208
209 /**
210  * Retrieve multlib flags of transaction element.
211  * @param te            transaction element
212  * @return              multilib flags
213  */
214 int teGetMultiLib(transactionElement te)
215         /*@*/;
216
217 /**
218  * Retrieve tsort info for transaction element.
219  * @param te            transaction element
220  * @return              tsort info
221  */
222 tsortInfo teGetTSI(transactionElement te)
223         /*@*/;
224
225 /**
226  * Retrieve pkgKey of TR_ADDED transaction element.
227  * @param te            transaction element
228  * @return              pkgKey
229  */
230 /*@exposed@*/
231 alKey teGetAddedKey(transactionElement te)
232         /*@*/;
233
234 /**
235  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
236  * @param te            transaction element
237  * @return              dependent pkgKey
238  */
239 /*@exposed@*/
240 alKey teGetDependsOnKey(transactionElement te)
241         /*@*/;
242
243 /**
244  * Retrieve rpmdb instance of TR_REMOVED transaction element.
245  * @param te            transaction element
246  * @return              rpmdb instance
247  */
248 int teGetDBOffset(transactionElement te)
249         /*@*/;
250
251 /**
252  * Retrieve name-version-release string from transaction element.
253  * @param te            transaction element
254  * @return              name-version-release string
255  */
256 /*@observer@*/
257 const char * teGetNEVR(transactionElement te)
258         /*@*/;
259
260 /**
261  * Retrieve file handle from transaction element.
262  * @param te            transaction element
263  * @return              file handle
264  */
265 FD_t teGetFd(transactionElement te)
266         /*@*/;
267
268 /**
269  * Retrieve key from transaction element.
270  * @param te            transaction element
271  * @return              key
272  */
273 /*@exposed@*/
274 fnpyKey teGetKey(transactionElement te)
275         /*@*/;
276
277 /**
278  * Retrieve dependency tag set from transaction element.
279  * @param te            transaction element
280  * @param tag           dependency tag
281  * @return              dependency tag set
282  */
283 rpmDepSet teGetDS(transactionElement te, rpmTag tag)
284         /*@*/;
285
286 /**
287  * Retrieve file info tag set from transaction element.
288  * @param te            transaction element
289  * @param tag           file info tag
290  * @return              file info tag set
291  */
292 TFI_t teGetFI(transactionElement te, rpmTag tag)
293         /*@*/;
294
295 #if defined(_NEED_TEITERATOR)
296 /**
297  * Return transaction element index.
298  * @param tei           transaction element iterator
299  * @return              transaction element index
300  */
301 int teiGetOc(teIterator tei)
302         /*@*/;
303
304 /**
305  * Destroy transaction element iterator.
306  * @param tei           transaction element iterator
307  * @return              NULL always
308  */
309 /*@null@*/
310 teIterator teFreeIterator(/*@only@*//*@null@*/ teIterator tei)
311         /*@*/;
312
313 /**
314  * Create transaction element iterator.
315  * @param ts            transaction set
316  * @return              transaction element iterator
317  */
318 /*@only@*/
319 teIterator teInitIterator(rpmTransactionSet ts)
320         /*@modifies ts @*/;
321
322 /**
323  * Return next transaction element
324  * @param tei           transaction element iterator
325  * @return              transaction element, NULL on termination
326  */
327 /*@dependent@*/ /*@null@*/
328 transactionElement teNextIterator(teIterator tei)
329         /*@modifies tei @*/;
330
331 /**
332  * Return next transaction element of type.
333  * @param tei           transaction element iterator
334  * @param type          transaction element type selector
335  * @return              next transaction element of type, NULL on termination
336  */
337 /*@dependent@*/ /*@null@*/
338 transactionElement teNext(teIterator tei, rpmTransactionType type)
339         /*@modifies tei @*/;
340
341 #endif  /* defined(_NEED_TEITERATOR) */
342
343 #ifdef __cplusplus
344 }
345 #endif
346
347 #endif  /* H_RPMTE */