Sanitize python object -> tag number exception handling
[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 #include <rpm/rpmtypes.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 /**
16  */
17 extern int _rpmte_debug;
18
19 /** \ingroup rpmte
20  * Transaction element ordering chain linkage.
21  */
22 typedef struct tsortInfo_s *            tsortInfo;
23
24 /** \ingroup rpmte
25  * Transaction element iterator.
26  */
27 typedef struct rpmtsi_s *               rpmtsi;
28
29 /** \ingroup rpmte
30  * Transaction element type.
31  */
32 typedef enum rpmElementType_e {
33     TR_ADDED            = (1 << 0),     /*!< Package will be installed. */
34     TR_REMOVED          = (1 << 1)      /*!< Package will be removed. */
35 } rpmElementType;
36
37 /** \ingroup rpmte
38  * Destroy a transaction element.
39  * @param te            transaction element
40  * @return              NULL always
41  */
42 rpmte rpmteFree(rpmte te);
43
44 /** \ingroup rpmte
45  * Create a transaction element.
46  * @param ts            transaction set
47  * @param h             header
48  * @param type          TR_ADDED/TR_REMOVED
49  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
50  * @param relocs        (TR_ADDED) package file relocations
51  * @param dboffset      unused
52  * @return              new transaction element
53  */
54 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
55                 fnpyKey key,
56                 rpmRelocation * relocs,
57                 int dboffset);
58
59 /** \ingroup rpmte
60  * Retrieve header from transaction element.
61  * @param te            transaction element
62  * @return              header
63  */
64 Header rpmteHeader(rpmte te);
65
66 /** \ingroup rpmte
67  * Save header into transaction element.
68  * @param te            transaction element
69  * @param h             header
70  * @return              NULL always
71  */
72 Header rpmteSetHeader(rpmte te, Header h);
73
74 /** \ingroup rpmte
75  * Retrieve type of transaction element.
76  * @param te            transaction element
77  * @return              type
78  */
79 rpmElementType rpmteType(rpmte te);
80
81 /** \ingroup rpmte
82  * Retrieve name string of transaction element.
83  * @param te            transaction element
84  * @return              name string
85  */
86 const char * rpmteN(rpmte te);
87
88 /** \ingroup rpmte
89  * Retrieve epoch string of transaction element.
90  * @param te            transaction element
91  * @return              epoch string
92  */
93 const char * rpmteE(rpmte te);
94
95 /** \ingroup rpmte
96  * Retrieve version string of transaction element.
97  * @param te            transaction element
98  * @return              version string
99  */
100 const char * rpmteV(rpmte te);
101
102 /** \ingroup rpmte
103  * Retrieve release string of transaction element.
104  * @param te            transaction element
105  * @return              release string
106  */
107 const char * rpmteR(rpmte te);
108
109 /** \ingroup rpmte
110  * Retrieve arch string of transaction element.
111  * @param te            transaction element
112  * @return              arch string
113  */
114 const char * rpmteA(rpmte te);
115
116 /** \ingroup rpmte
117  * Retrieve os string of transaction element.
118  * @param te            transaction element
119  * @return              os string
120  */
121 const char * rpmteO(rpmte te);
122
123 /** \ingroup rpmte
124  * Retrieve isSource attribute of transaction element.
125  * @param te            transaction element
126  * @return              isSource attribute
127  */
128 int rpmteIsSource(rpmte te);
129
130 /** \ingroup rpmte
131  * Retrieve color bits of transaction element.
132  * @param te            transaction element
133  * @return              color bits
134  */
135 rpm_color_t rpmteColor(rpmte te);
136
137 /** \ingroup rpmte
138  * Set color bits of transaction element.
139  * @param te            transaction element
140  * @param color         new color bits
141  * @return              previous color bits
142  */
143 rpm_color_t rpmteSetColor(rpmte te, rpm_color_t color);
144
145 /** \ingroup rpmte
146  * Retrieve last instance installed to the database.
147  * @param te            transaction element
148  * @return              last install instance.
149  */
150 unsigned int rpmteDBInstance(rpmte te);
151
152 /** \ingroup rpmte
153  * Set last instance installed to the database.
154  * @param te            transaction element
155  * @param instance      Database instance of last install element.
156  * @return              last install instance.
157  */
158 void rpmteSetDBInstance(rpmte te, unsigned int instance);
159
160 /** \ingroup rpmte
161  * Retrieve size in bytes of package file.
162  * @todo Signature header is estimated at 256b.
163  * @param te            transaction element
164  * @return              size in bytes of package file.
165  */
166 rpm_loff_t rpmtePkgFileSize(rpmte te);
167
168 /** \ingroup rpmte
169  * Retrieve dependency tree depth of transaction element.
170  * @param te            transaction element
171  * @return              depth
172  */
173 int rpmteDepth(rpmte te);
174
175 /** \ingroup rpmte
176  * Set dependency tree depth of transaction element.
177  * @param te            transaction element
178  * @param ndepth        new depth
179  * @return              previous depth
180  */
181 int rpmteSetDepth(rpmte te, int ndepth);
182
183 /** \ingroup rpmte
184  * Retrieve dependency tree breadth of transaction element.
185  * @param te            transaction element
186  * @return              breadth
187  */
188 int rpmteBreadth(rpmte te);
189
190 /** \ingroup rpmte
191  * Set dependency tree breadth of transaction element.
192  * @param te            transaction element
193  * @param nbreadth      new breadth
194  * @return              previous breadth
195  */
196 int rpmteSetBreadth(rpmte te, int nbreadth);
197
198 /** \ingroup rpmte
199  * Retrieve tsort no. of predecessors of transaction element.
200  * @param te            transaction element
201  * @return              no. of predecessors
202  */
203 int rpmteNpreds(rpmte te);
204
205 /** \ingroup rpmte
206  * Set tsort no. of predecessors of transaction element.
207  * @param te            transaction element
208  * @param npreds        new no. of predecessors
209  * @return              previous no. of predecessors
210  */
211 int rpmteSetNpreds(rpmte te, int npreds);
212
213 /** \ingroup rpmte
214  * Retrieve tree index of transaction element.
215  * @param te            transaction element
216  * @return              tree index
217  */
218 int rpmteTree(rpmte te);
219
220 /** \ingroup rpmte
221  * Set tree index of transaction element.
222  * @param te            transaction element
223  * @param ntree         new tree index
224  * @return              previous tree index
225  */
226 int rpmteSetTree(rpmte te, int ntree);
227
228 /** \ingroup rpmte
229  * Retrieve parent transaction element.
230  * @param te            transaction element
231  * @return              parent transaction element
232  */
233 rpmte rpmteParent(rpmte te);
234
235 /** \ingroup rpmte
236  * Set parent transaction element.
237  * @param te            transaction element
238  * @param pte           new parent transaction element
239  * @return              previous parent transaction element
240  */
241 rpmte rpmteSetParent(rpmte te, rpmte pte);
242
243 /** \ingroup rpmte
244  * Retrieve number of children of transaction element.
245  * @param te            transaction element
246  * @return              tree index
247  */
248 int rpmteDegree(rpmte te);
249
250 /** \ingroup rpmte
251  * Set number of children of transaction element.
252  * @param te            transaction element
253  * @param ndegree       new number of children
254  * @return              previous number of children
255  */
256 int rpmteSetDegree(rpmte te, int ndegree);
257
258 /** \ingroup rpmte
259  * Retrieve tsort info for transaction element.
260  * @param te            transaction element
261  * @return              tsort info
262  */
263 tsortInfo rpmteTSI(rpmte te);
264
265 /** \ingroup rpmte
266  * Destroy tsort info of transaction element.
267  * @param te            transaction element
268  */
269 void rpmteFreeTSI(rpmte te);
270
271 /** \ingroup rpmte
272  * Initialize tsort info of transaction element.
273  * @param te            transaction element
274  */
275 void rpmteNewTSI(rpmte te);
276
277 /** \ingroup rpmte
278  * Destroy dependency set info of transaction element.
279  * @param te            transaction element
280  */
281 void rpmteCleanDS(rpmte te);
282
283 /** \ingroup rpmte
284  * Set dependent element of TR_REMOVED transaction element.
285  * @param te            transaction element
286  * @param depends       dependent transaction element
287  */
288 void rpmteSetDependsOn(rpmte te, rpmte depends);
289
290 /** \ingroup rpmte
291  * Retrieve dependent element of TR_REMOVED transaction element.
292  * @param te            transaction element
293  * @return              dependent transaction element
294  */
295 rpmte rpmteDependsOn(rpmte te);
296
297 /** \ingroup rpmte
298  * Retrieve rpmdb instance of TR_REMOVED transaction element.
299  * @param te            transaction element
300  * @return              rpmdb instance
301  */
302 int rpmteDBOffset(rpmte te);
303
304 /** \ingroup rpmte
305  * Retrieve [epoch:]version-release string from transaction element.
306  * @param te            transaction element
307  * @return              [epoch:]version-release string
308  */
309 const char * rpmteEVR(rpmte te);
310
311 /** \ingroup rpmte
312  * Retrieve name-[epoch:]version-release string from transaction element.
313  * @param te            transaction element
314  * @return              name-[epoch:]version-release string
315  */
316 const char * rpmteNEVR(rpmte te);
317
318 /** \ingroup rpmte
319  * Retrieve name-[epoch:]version-release.arch string from transaction element.
320  * @param te            transaction element
321  * @return              name-[epoch:]version-release.arch string
322  */
323 const char * rpmteNEVRA(rpmte te);
324
325 /** \ingroup rpmte
326  * Retrieve file handle from transaction element.
327  * @param te            transaction element
328  * @return              file handle
329  */
330 FD_t rpmteFd(rpmte te);
331
332 /** \ingroup rpmte
333  * Retrieve key from transaction element.
334  * @param te            transaction element
335  * @return              key
336  */
337 fnpyKey rpmteKey(rpmte te);
338
339 /** \ingroup rpmte
340  * Return failed status of transaction element.
341  * @param te            transaction element
342  * @return              1 if transaction element (or its parents) failed
343  */
344 int rpmteFailed(rpmte te);
345
346 /** \ingroup rpmte
347  * Retrieve dependency tag set from transaction element.
348  * @param te            transaction element
349  * @param tag           dependency tag
350  * @return              dependency tag set
351  */
352 rpmds rpmteDS(rpmte te, rpmTag tag);
353
354 /** \ingroup rpmte
355  * Retrieve file info tag set from transaction element.
356  * @param te            transaction element
357  * @return              file info tag set
358  */
359 rpmfi rpmteFI(rpmte te);
360
361 /** \ingroup rpmte
362  * Calculate transaction element dependency colors/refs from file info.
363  * @param te            transaction element
364  * @param tag           dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
365  */
366 void rpmteColorDS(rpmte te, rpmTag tag);
367
368 /** \ingroup rpmte
369  * Return transaction element index.
370  * @param tsi           transaction element iterator
371  * @return              transaction element index
372  */
373 int rpmtsiOc(rpmtsi tsi);
374
375 /** \ingroup rpmte
376  * Destroy transaction element iterator.
377  * @param tsi           transaction element iterator
378  * @return              NULL always
379  */
380 rpmtsi rpmtsiFree(rpmtsi tsi);
381
382 /** \ingroup rpmte
383  * Create transaction element iterator.
384  * @param ts            transaction set
385  * @return              transaction element iterator
386  */
387 rpmtsi rpmtsiInit(rpmts ts);
388
389 /** \ingroup rpmte
390  * Return next transaction element of type.
391  * @param tsi           transaction element iterator
392  * @param type          transaction element type selector (0 for any)
393  * @return              next transaction element of type, NULL on termination
394  */
395 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);
396
397 #ifdef __cplusplus
398 }
399 #endif
400
401 #endif  /* H_RPMTE */