Add doxygen grouping to rpmte methods
[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 <rpmal.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 #if     defined(_RPMTE_INTERNAL)
38 /** \ingroup rpmte
39  * Dependncy ordering information.
40  */
41 struct tsortInfo_s {
42     union {
43         int     count;
44         rpmte   suc;
45     } tsi_u;
46 #define tsi_count       tsi_u.count
47 #define tsi_suc         tsi_u.suc
48     struct tsortInfo_s * tsi_next;
49     rpmte tsi_chain;
50     int         tsi_reqx;
51     int         tsi_qcnt;
52 };
53
54 /** \ingroup rpmte
55  * A single package instance to be installed/removed atomically.
56  */
57 struct rpmte_s {
58     rpmElementType type;        /*!< Package disposition (installed/removed). */
59
60     Header h;                   /*!< Package header. */
61     const char * NEVR;          /*!< Package name-version-release. */
62     const char * NEVRA;         /*!< Package name-version-release.arch. */
63     const char * name;          /*!< Name: */
64     char * epoch;
65     char * version;             /*!< Version: */
66     char * release;             /*!< Release: */
67     const char * arch;          /*!< Architecture hint. */
68     const char * os;            /*!< Operating system hint. */
69     int archScore;              /*!< (TR_ADDED) Arch score. */
70     int osScore;                /*!< (TR_ADDED) Os score. */
71     int isSource;               /*!< (TR_ADDED) source rpm? */
72
73     rpmte parent;               /*!< Parent transaction element. */
74     int degree;                 /*!< No. of immediate children. */
75     int npreds;                 /*!< No. of predecessors. */
76     int tree;                   /*!< Tree index. */
77     int depth;                  /*!< Depth in dependency tree. */
78     int breadth;                /*!< Breadth in dependency tree. */
79     unsigned int db_instance;   /*!< Database Instance after add */
80     tsortInfo tsi;              /*!< Dependency ordering chains. */
81
82     rpmds this;                 /*!< This package's provided NEVR. */
83     rpmds provides;             /*!< Provides: dependencies. */
84     rpmds requires;             /*!< Requires: dependencies. */
85     rpmds conflicts;            /*!< Conflicts: dependencies. */
86     rpmds obsoletes;            /*!< Obsoletes: dependencies. */
87     rpmfi fi;                   /*!< File information. */
88
89     uint32_t color;             /*!< Color bit(s) from package dependencies. */
90     uint32_t pkgFileSize;       /*!< No. of bytes in package file (approx). */
91
92     fnpyKey key;                /*!< (TR_ADDED) Retrieval key. */
93     rpmRelocation * relocs;     /*!< (TR_ADDED) Payload file relocations. */
94     int nrelocs;                /*!< (TR_ADDED) No. of relocations. */
95     int autorelocatex;          /*!< (TR_ADDED) Auto relocation entry index. */
96     FD_t fd;                    /*!< (TR_ADDED) Payload file descriptor. */
97
98     union {
99         rpmalKey addedKey;
100         struct {
101             rpmalKey dependsOnKey;
102             int dboffset;
103         } removed;
104     } u;
105
106 };
107
108 /**
109  * Iterator across transaction elements, forward on install, backward on erase.
110  */
111 struct rpmtsi_s {
112     rpmts ts;           /*!< transaction set. */
113     int reverse;        /*!< reversed traversal? */
114     int ocsave;         /*!< last returned iterator index. */
115     int oc;             /*!< iterator index. */
116 };
117
118 #endif  /* _RPMTE_INTERNAL */
119
120 /** \ingroup rpmte
121  * Destroy a transaction element.
122  * @param te            transaction element
123  * @return              NULL always
124  */
125 rpmte rpmteFree(rpmte te);
126
127 /** \ingroup rpmte
128  * Create a transaction element.
129  * @param ts            transaction set
130  * @param h             header
131  * @param type          TR_ADDED/TR_REMOVED
132  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
133  * @param relocs        (TR_ADDED) package file relocations
134  * @param dboffset      (TR_REMOVED) rpmdb instance
135  * @param pkgKey        associated added package (if any)
136  * @return              new transaction element
137  */
138 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
139                 fnpyKey key,
140                 rpmRelocation * relocs,
141                 int dboffset,
142                 rpmalKey pkgKey);
143
144 /** \ingroup rpmte
145  * Retrieve header from transaction element.
146  * @param te            transaction element
147  * @return              header
148  */
149 extern Header rpmteHeader(rpmte te);
150
151 /** \ingroup rpmte
152  * Save header into transaction element.
153  * @param te            transaction element
154  * @param h             header
155  * @return              NULL always
156  */
157 extern Header rpmteSetHeader(rpmte te, Header h);
158
159 /** \ingroup rpmte
160  * Retrieve type of transaction element.
161  * @param te            transaction element
162  * @return              type
163  */
164 rpmElementType rpmteType(rpmte te);
165
166 /** \ingroup rpmte
167  * Retrieve name string of transaction element.
168  * @param te            transaction element
169  * @return              name string
170  */
171 extern const char * rpmteN(rpmte te);
172
173 /** \ingroup rpmte
174  * Retrieve epoch string of transaction element.
175  * @param te            transaction element
176  * @return              epoch string
177  */
178 extern const char * rpmteE(rpmte te);
179
180 /** \ingroup rpmte
181  * Retrieve version string of transaction element.
182  * @param te            transaction element
183  * @return              version string
184  */
185 extern const char * rpmteV(rpmte te);
186
187 /** \ingroup rpmte
188  * Retrieve release string of transaction element.
189  * @param te            transaction element
190  * @return              release string
191  */
192 extern const char * rpmteR(rpmte te);
193
194 /** \ingroup rpmte
195  * Retrieve arch string of transaction element.
196  * @param te            transaction element
197  * @return              arch string
198  */
199 extern const char * rpmteA(rpmte te);
200
201 /** \ingroup rpmte
202  * Retrieve os string of transaction element.
203  * @param te            transaction element
204  * @return              os string
205  */
206 extern const char * rpmteO(rpmte te);
207
208 /** \ingroup rpmte
209  * Retrieve isSource attribute of transaction element.
210  * @param te            transaction element
211  * @return              isSource attribute
212  */
213 extern int rpmteIsSource(rpmte te);
214
215 /** \ingroup rpmte
216  * Retrieve color bits of transaction element.
217  * @param te            transaction element
218  * @return              color bits
219  */
220 uint32_t rpmteColor(rpmte te);
221
222 /** \ingroup rpmte
223  * Set color bits of transaction element.
224  * @param te            transaction element
225  * @param color         new color bits
226  * @return              previous color bits
227  */
228 uint32_t rpmteSetColor(rpmte te, uint32_t color);
229
230 /** \ingroup rpmte
231  * Retrieve last instance installed to the database.
232  * @param te            transaction element
233  * @return              last install instance.
234  */
235 unsigned int rpmteDBInstance(rpmte te);
236
237 /** \ingroup rpmte
238  * Set last instance installed to the database.
239  * @param te            transaction element
240  * @param instance      Database instance of last install element.
241  * @return              last install instance.
242  */
243 void rpmteSetDBInstance(rpmte te, unsigned int instance);
244
245 /** \ingroup rpmte
246  * Retrieve size in bytes of package file.
247  * @todo Signature header is estimated at 256b.
248  * @param te            transaction element
249  * @return              size in bytes of package file.
250  */
251 uint32_t rpmtePkgFileSize(rpmte te);
252
253 /** \ingroup rpmte
254  * Retrieve dependency tree depth of transaction element.
255  * @param te            transaction element
256  * @return              depth
257  */
258 int rpmteDepth(rpmte te);
259
260 /** \ingroup rpmte
261  * Set dependency tree depth of transaction element.
262  * @param te            transaction element
263  * @param ndepth        new depth
264  * @return              previous depth
265  */
266 int rpmteSetDepth(rpmte te, int ndepth);
267
268 /** \ingroup rpmte
269  * Retrieve dependency tree breadth of transaction element.
270  * @param te            transaction element
271  * @return              breadth
272  */
273 int rpmteBreadth(rpmte te);
274
275 /** \ingroup rpmte
276  * Set dependency tree breadth of transaction element.
277  * @param te            transaction element
278  * @param nbreadth      new breadth
279  * @return              previous breadth
280  */
281 int rpmteSetBreadth(rpmte te, int nbreadth);
282
283 /** \ingroup rpmte
284  * Retrieve tsort no. of predecessors of transaction element.
285  * @param te            transaction element
286  * @return              no. of predecessors
287  */
288 int rpmteNpreds(rpmte te);
289
290 /** \ingroup rpmte
291  * Set tsort no. of predecessors of transaction element.
292  * @param te            transaction element
293  * @param npreds        new no. of predecessors
294  * @return              previous no. of predecessors
295  */
296 int rpmteSetNpreds(rpmte te, int npreds);
297
298 /** \ingroup rpmte
299  * Retrieve tree index of transaction element.
300  * @param te            transaction element
301  * @return              tree index
302  */
303 int rpmteTree(rpmte te);
304
305 /** \ingroup rpmte
306  * Set tree index of transaction element.
307  * @param te            transaction element
308  * @param ntree         new tree index
309  * @return              previous tree index
310  */
311 int rpmteSetTree(rpmte te, int ntree);
312
313 /** \ingroup rpmte
314  * Retrieve parent transaction element.
315  * @param te            transaction element
316  * @return              parent transaction element
317  */
318 rpmte rpmteParent(rpmte te);
319
320 /** \ingroup rpmte
321  * Set parent transaction element.
322  * @param te            transaction element
323  * @param pte           new parent transaction element
324  * @return              previous parent transaction element
325  */
326 rpmte rpmteSetParent(rpmte te, rpmte pte);
327
328 /** \ingroup rpmte
329  * Retrieve number of children of transaction element.
330  * @param te            transaction element
331  * @return              tree index
332  */
333 int rpmteDegree(rpmte te);
334
335 /** \ingroup rpmte
336  * Set number of children of transaction element.
337  * @param te            transaction element
338  * @param ndegree       new number of children
339  * @return              previous number of children
340  */
341 int rpmteSetDegree(rpmte te, int ndegree);
342
343 /** \ingroup rpmte
344  * Retrieve tsort info for transaction element.
345  * @param te            transaction element
346  * @return              tsort info
347  */
348 tsortInfo rpmteTSI(rpmte te);
349
350 /** \ingroup rpmte
351  * Destroy tsort info of transaction element.
352  * @param te            transaction element
353  */
354 void rpmteFreeTSI(rpmte te);
355
356 /** \ingroup rpmte
357  * Initialize tsort info of transaction element.
358  * @param te            transaction element
359  */
360 void rpmteNewTSI(rpmte te);
361
362 /** \ingroup rpmte
363  * Destroy dependency set info of transaction element.
364  * @param te            transaction element
365  */
366 void rpmteCleanDS(rpmte te);
367
368 /** \ingroup rpmte
369  * Retrieve pkgKey of TR_ADDED transaction element.
370  * @param te            transaction element
371  * @return              pkgKey
372  */
373 rpmalKey rpmteAddedKey(rpmte te);
374
375 /** \ingroup rpmte
376  * Set pkgKey of TR_ADDED transaction element.
377  * @param te            transaction element
378  * @param npkgKey       new pkgKey
379  * @return              previous pkgKey
380  */
381 rpmalKey rpmteSetAddedKey(rpmte te,
382                 rpmalKey npkgKey);
383
384 /** \ingroup rpmte
385  * Retrieve dependent pkgKey of TR_REMOVED transaction element.
386  * @param te            transaction element
387  * @return              dependent pkgKey
388  */
389 rpmalKey rpmteDependsOnKey(rpmte te);
390
391 /** \ingroup rpmte
392  * Retrieve rpmdb instance of TR_REMOVED transaction element.
393  * @param te            transaction element
394  * @return              rpmdb instance
395  */
396 int rpmteDBOffset(rpmte te);
397
398 /** \ingroup rpmte
399  * Retrieve name-version-release string from transaction element.
400  * @param te            transaction element
401  * @return              name-version-release string
402  */
403 extern const char * rpmteNEVR(rpmte te);
404
405 /** \ingroup rpmte
406  * Retrieve name-version-release.arch string from transaction element.
407  * @param te            transaction element
408  * @return              name-version-release.arch string
409  */
410 extern const char * rpmteNEVRA(rpmte te);
411
412 /** \ingroup rpmte
413  * Retrieve file handle from transaction element.
414  * @param te            transaction element
415  * @return              file handle
416  */
417 FD_t rpmteFd(rpmte te);
418
419 /** \ingroup rpmte
420  * Retrieve key from transaction element.
421  * @param te            transaction element
422  * @return              key
423  */
424 fnpyKey rpmteKey(rpmte te);
425
426 /** \ingroup rpmte
427  * Retrieve dependency tag set from transaction element.
428  * @param te            transaction element
429  * @param tag           dependency tag
430  * @return              dependency tag set
431  */
432 rpmds rpmteDS(rpmte te, rpmTag tag);
433
434 /** \ingroup rpmte
435  * Retrieve file info tag set from transaction element.
436  * @param te            transaction element
437  * @param tag           file info tag (RPMTAG_BASENAMES)
438  * @return              file info tag set
439  */
440 rpmfi rpmteFI(rpmte te, rpmTag tag);
441
442 /** \ingroup rpmte
443  * Calculate transaction element dependency colors/refs from file info.
444  * @param te            transaction element
445  * @param tag           dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
446  */
447 void rpmteColorDS(rpmte te, rpmTag tag);
448
449 /** \ingroup rpmte
450  * Return transaction element index.
451  * @param tsi           transaction element iterator
452  * @return              transaction element index
453  */
454 int rpmtsiOc(rpmtsi tsi);
455
456 /** \ingroup rpmte
457  * Destroy transaction element iterator.
458  * @param tsi           transaction element iterator
459  * @return              NULL always
460  */
461 rpmtsi rpmtsiFree(rpmtsi tsi);
462
463 /** \ingroup rpmte
464  * Destroy transaction element iterator.
465  * @param tsi           transaction element iterator
466  * @param fn
467  * @param ln
468  * @return              NULL always
469  */
470 rpmtsi XrpmtsiFree(rpmtsi tsi,
471                 const char * fn, unsigned int ln);
472 #define rpmtsiFree(_tsi)        XrpmtsiFree(_tsi, __FILE__, __LINE__)
473
474 /** \ingroup rpmte
475  * Create transaction element iterator.
476  * @param ts            transaction set
477  * @return              transaction element iterator
478  */
479 rpmtsi rpmtsiInit(rpmts ts);
480
481 /** \ingroup rpmte
482  * Create transaction element iterator.
483  * @param ts            transaction set
484  * @param fn
485  * @param ln
486  * @return              transaction element iterator
487  */
488 rpmtsi XrpmtsiInit(rpmts ts,
489                 const char * fn, unsigned int ln);
490 #define rpmtsiInit(_ts)         XrpmtsiInit(_ts, __FILE__, __LINE__)
491
492 /** \ingroup rpmte
493  * Return next transaction element of type.
494  * @param tsi           transaction element iterator
495  * @param type          transaction element type selector (0 for any)
496  * @return              next transaction element of type, NULL on termination
497  */
498 rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type);
499
500 #ifdef __cplusplus
501 }
502 #endif
503
504 #endif  /* H_RPMTE */