Bury ordering structures and their alloc+free inside order.c
[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 type.
26  */
27 typedef enum rpmElementType_e {
28     TR_ADDED            = (1 << 0),     /*!< Package will be installed. */
29     TR_REMOVED          = (1 << 1)      /*!< Package will be removed. */
30 } rpmElementType;
31
32 /** \ingroup rpmte
33  * Destroy a transaction element.
34  * @param te            transaction element
35  * @return              NULL always
36  */
37 rpmte rpmteFree(rpmte te);
38
39 /** \ingroup rpmte
40  * Create a transaction element.
41  * @param ts            unused
42  * @param h             header
43  * @param type          TR_ADDED/TR_REMOVED
44  * @param key           (TR_ADDED) package retrieval key (e.g. file name)
45  * @param relocs        (TR_ADDED) package file relocations
46  * @param dboffset      unused
47  * @return              new transaction element
48  */
49 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
50                 fnpyKey key,
51                 rpmRelocation * relocs,
52                 int dboffset);
53
54 /** \ingroup rpmte
55  * Retrieve header from transaction element.
56  * @param te            transaction element
57  * @return              header
58  */
59 Header rpmteHeader(rpmte te);
60
61 /** \ingroup rpmte
62  * Save header into transaction element.
63  * @param te            transaction element
64  * @param h             header
65  * @return              NULL always
66  */
67 Header rpmteSetHeader(rpmte te, Header h);
68
69 /** \ingroup rpmte
70  * Retrieve type of transaction element.
71  * @param te            transaction element
72  * @return              type
73  */
74 rpmElementType rpmteType(rpmte te);
75
76 /** \ingroup rpmte
77  * Retrieve name string of transaction element.
78  * @param te            transaction element
79  * @return              name string
80  */
81 const char * rpmteN(rpmte te);
82
83 /** \ingroup rpmte
84  * Retrieve epoch string of transaction element.
85  * @param te            transaction element
86  * @return              epoch string
87  */
88 const char * rpmteE(rpmte te);
89
90 /** \ingroup rpmte
91  * Retrieve version string of transaction element.
92  * @param te            transaction element
93  * @return              version string
94  */
95 const char * rpmteV(rpmte te);
96
97 /** \ingroup rpmte
98  * Retrieve release string of transaction element.
99  * @param te            transaction element
100  * @return              release string
101  */
102 const char * rpmteR(rpmte te);
103
104 /** \ingroup rpmte
105  * Retrieve arch string of transaction element.
106  * @param te            transaction element
107  * @return              arch string
108  */
109 const char * rpmteA(rpmte te);
110
111 /** \ingroup rpmte
112  * Retrieve os string of transaction element.
113  * @param te            transaction element
114  * @return              os string
115  */
116 const char * rpmteO(rpmte te);
117
118 /** \ingroup rpmte
119  * Retrieve isSource attribute of transaction element.
120  * @param te            transaction element
121  * @return              isSource attribute
122  */
123 int rpmteIsSource(rpmte te);
124
125 /** \ingroup rpmte
126  * Retrieve color bits of transaction element.
127  * @param te            transaction element
128  * @return              color bits
129  */
130 rpm_color_t rpmteColor(rpmte te);
131
132 /** \ingroup rpmte
133  * Set color bits of transaction element.
134  * @param te            transaction element
135  * @param color         new color bits
136  * @return              previous color bits
137  */
138 rpm_color_t rpmteSetColor(rpmte te, rpm_color_t color);
139
140 /** \ingroup rpmte
141  * Retrieve last instance installed to the database.
142  * @param te            transaction element
143  * @return              last install instance.
144  */
145 unsigned int rpmteDBInstance(rpmte te);
146
147 /** \ingroup rpmte
148  * Set last instance installed to the database.
149  * @param te            transaction element
150  * @param instance      Database instance of last install element.
151  * @return              last install instance.
152  */
153 void rpmteSetDBInstance(rpmte te, unsigned int instance);
154
155 /** \ingroup rpmte
156  * Retrieve size in bytes of package file.
157  * @todo Signature header is estimated at 256b.
158  * @param te            transaction element
159  * @return              size in bytes of package file.
160  */
161 rpm_loff_t rpmtePkgFileSize(rpmte te);
162
163 /** \ingroup rpmte
164  * Retrieve parent transaction element.
165  * @param te            transaction element
166  * @return              parent transaction element
167  */
168 rpmte rpmteParent(rpmte te);
169
170 /** \ingroup rpmte
171  * Set parent transaction element.
172  * @param te            transaction element
173  * @param pte           new parent transaction element
174  * @return              previous parent transaction element
175  */
176 rpmte rpmteSetParent(rpmte te, rpmte pte);
177
178 /** \ingroup rpmte
179  * Destroy dependency set info of transaction element.
180  * @param te            transaction element
181  */
182 void rpmteCleanDS(rpmte te);
183
184 /** \ingroup rpmte
185  * Set dependent element of TR_REMOVED transaction element.
186  * @param te            transaction element
187  * @param depends       dependent transaction element
188  */
189 void rpmteSetDependsOn(rpmte te, rpmte depends);
190
191 /** \ingroup rpmte
192  * Retrieve dependent element of TR_REMOVED transaction element.
193  * @param te            transaction element
194  * @return              dependent transaction element
195  */
196 rpmte rpmteDependsOn(rpmte te);
197
198 /** \ingroup rpmte
199  * Retrieve rpmdb instance of TR_REMOVED transaction element.
200  * @param te            transaction element
201  * @return              rpmdb instance
202  */
203 int rpmteDBOffset(rpmte te);
204
205 /** \ingroup rpmte
206  * Retrieve [epoch:]version-release string from transaction element.
207  * @param te            transaction element
208  * @return              [epoch:]version-release string
209  */
210 const char * rpmteEVR(rpmte te);
211
212 /** \ingroup rpmte
213  * Retrieve name-[epoch:]version-release string from transaction element.
214  * @param te            transaction element
215  * @return              name-[epoch:]version-release string
216  */
217 const char * rpmteNEVR(rpmte te);
218
219 /** \ingroup rpmte
220  * Retrieve name-[epoch:]version-release.arch string from transaction element.
221  * @param te            transaction element
222  * @return              name-[epoch:]version-release.arch string
223  */
224 const char * rpmteNEVRA(rpmte te);
225
226 /** \ingroup rpmte
227  * Retrieve key from transaction element.
228  * @param te            transaction element
229  * @return              key
230  */
231 fnpyKey rpmteKey(rpmte te);
232
233 /** \ingroup rpmte
234  * Return failed status of transaction element.
235  * @param te            transaction element
236  * @return              1 if transaction element (or its parents) failed
237  */
238 int rpmteFailed(rpmte te);
239
240 /** \ingroup rpmte
241  * Retrieve dependency tag set from transaction element.
242  * @param te            transaction element
243  * @param tag           dependency tag
244  * @return              dependency tag set
245  */
246 rpmds rpmteDS(rpmte te, rpmTag tag);
247
248 /** \ingroup rpmte
249  * Retrieve file info tag set from transaction element.
250  * @param te            transaction element
251  * @return              file info tag set
252  */
253 rpmfi rpmteFI(rpmte te);
254
255 /** \ingroup rpmte
256  * Calculate transaction element dependency colors/refs from file info.
257  * @param te            transaction element
258  * @param tag           dependency tag (RPMTAG_PROVIDENAME, RPMTAG_REQUIRENAME)
259  */
260 void rpmteColorDS(rpmte te, rpmTag tag);
261
262 #ifdef __cplusplus
263 }
264 #endif
265
266 #endif  /* H_RPMTE */