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