Move rpmps typedef into rpmtypes.h, its common enuf
[platform/upstream/rpm.git] / lib / rpmps.h
1 #ifndef H_RPMPS
2 #define H_RPMPS
3
4 /** \ingroup rpmps
5  * \file lib/rpmps.h
6  * Structures and prototypes used for an "rpmps" problem set.
7  */
8
9 #include <stdio.h>
10 #include <rpm/rpmtypes.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 extern int _rpmps_debug;
17
18 /** \ingroup rpmps
19  * @todo Generalize filter mechanism.
20  */
21 typedef enum rpmprobFilterFlags_e {
22     RPMPROB_FILTER_NONE         = 0,
23     RPMPROB_FILTER_IGNOREOS     = (1 << 0),     /*!< from --ignoreos */
24     RPMPROB_FILTER_IGNOREARCH   = (1 << 1),     /*!< from --ignorearch */
25     RPMPROB_FILTER_REPLACEPKG   = (1 << 2),     /*!< from --replacepkgs */
26     RPMPROB_FILTER_FORCERELOCATE= (1 << 3),     /*!< from --badreloc */
27     RPMPROB_FILTER_REPLACENEWFILES= (1 << 4),   /*!< from --replacefiles */
28     RPMPROB_FILTER_REPLACEOLDFILES= (1 << 5),   /*!< from --replacefiles */
29     RPMPROB_FILTER_OLDPACKAGE   = (1 << 6),     /*!< from --oldpackage */
30     RPMPROB_FILTER_DISKSPACE    = (1 << 7),     /*!< from --ignoresize */
31     RPMPROB_FILTER_DISKNODES    = (1 << 8)      /*!< from --ignoresize */
32 } rpmprobFilterFlags;
33
34 /**
35  * Raw data for an element of a problem set.
36  */
37 typedef struct rpmProblem_s * rpmProblem;
38
39 /** \ingroup rpmps
40  * Problem set iterator
41  */
42 typedef struct rpmpsi_s * rpmpsi;
43
44 /** \ingroup rpmps
45  * Enumerate transaction set problem types.
46  */
47 typedef enum rpmProblemType_e {
48     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
49     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
50     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
51     RPMPROB_BADRELOCATE,/*!< path ... is not relocatable for package ... */
52     RPMPROB_REQUIRES,   /*!< package ... has unsatisfied Requires: ... */
53     RPMPROB_CONFLICT,   /*!< package ... has unsatisfied Conflicts: ... */
54     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
55     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
56     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
57     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ... filesystem */
58     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ... filesystem */
59  } rpmProblemType;
60
61 /** \ingroup rpmps
62  * Create a problem item.
63  * @param type          type of problem
64  * @param pkgNEVR       package name
65  * @param key           filename or python object address
66  * @param dn            directory name
67  * @param bn            file base name
68  * @param altNEVR       related (e.g. through a dependency) package name
69  * @param number        generic number attribute
70  * @return              rpmProblem
71  */
72 rpmProblem rpmProblemCreate(rpmProblemType type,
73                             const char * pkgNEVR,
74                             fnpyKey key,
75                             const char * dn, const char * bn,
76                             const char * altNEVR,
77                             uint64_t number);
78
79 /** \ingroup rpmps
80  * Destroy a problem item.
81  * @param prob          rpm problem
82  * @return              rpm problem (NULL)
83  */
84 rpmProblem rpmProblemFree(rpmProblem prob);
85
86 /** \ingroup rpmps
87  * Reference an rpmProblem instance
88  * @param prob          rpm problem
89  * @return              rpm problem
90  */
91 rpmProblem rpmProblemLink(rpmProblem prob);
92
93 /** \ingroup rpmps
94  * Unreference an rpmProblem instance
95  * @param prob          rpm problem
96  * @return              rpm problem
97  */
98 rpmProblem rpmProblemUnlink(rpmProblem prob);
99
100 /** \ingroup rpmps
101  * Return package NEVR
102  * @param prob          rpm problem
103  * @return              package NEVR
104  */
105 const char * rpmProblemGetPkgNEVR(const rpmProblem prob);
106 /** \ingroup rpmps
107  * Return related (e.g. through a dependency) package NEVR
108  * @param prob          rpm problem
109  * @return              related (e.g. through a dependency) package NEVR
110  */
111 const char * rpmProblemGetAltNEVR(const rpmProblem prob);
112
113 /** \ingroup rpmps
114  * Return type of problem (dependency, diskpace etc)
115  * @param prob          rpm problem
116  * @return              type of problem
117  */
118
119 rpmProblemType rpmProblemGetType(const rpmProblem prob);
120
121 /** \ingroup rpmps
122  * Return filename or python object address of a problem
123  * @param prob          rpm problem
124  * @return              filename or python object address
125  */
126 fnpyKey rpmProblemGetKey(const rpmProblem prob);
127
128 /** \ingroup rpmps
129  * Return a generic data string from a problem
130  * @param prob          rpm problem
131  * @return              a generic data string
132  * @todo                needs a better name
133  */
134 const char * rpmProblemGetStr(const rpmProblem prob);
135
136 /** \ingroup rpmps
137  * Return disk requirement (needed disk space / number of inodes)
138  * depending on problem type. On problem types other than RPMPROB_DISKSPACE
139  * and RPMPROB_DISKNODES return value is undefined.
140  * @param prob          rpm problem
141  * @return              disk requirement
142  */
143 rpm_loff_t rpmProblemGetDiskNeed(const rpmProblem prob);
144
145 /** \ingroup rpmps
146  * Return formatted string representation of a problem.
147  * @param prob          rpm problem
148  * @return              formatted string (malloc'd)
149  */
150 char * rpmProblemString(const rpmProblem prob);
151
152 /** \ingroup rpmps
153  * Unreference a problem set instance.
154  * @param ps            problem set
155  * @param msg
156  * @return              problem set
157  */
158 rpmps rpmpsUnlink (rpmps ps,
159                 const char * msg);
160
161 /** \ingroup rpmps
162  * Reference a problem set instance.
163  * @param ps            transaction set
164  * @param msg
165  * @return              new transaction set reference
166  */
167 rpmps rpmpsLink (rpmps ps, const char * msg);
168
169 /** \ingroup rpmps
170  * Return number of problems in set.
171  * @param ps            problem set
172  * @return              number of problems
173  */
174 int rpmpsNumProblems(rpmps ps);
175
176 /** \ingroup rpmps
177  * Initialize problem set iterator.
178  * @param ps            problem set
179  * @return              problem set iterator
180  */
181 rpmpsi rpmpsInitIterator(rpmps ps);
182
183 /** \ingroup rpmps
184  * Destroy problem set iterator.
185  * @param psi           problem set iterator
186  * @return              problem set iterator (NULL)
187  */
188 rpmpsi rpmpsFreeIterator(rpmpsi psi);
189
190 /** \ingroup rpmps
191  * Return next problem set iterator index
192  * @param psi           problem set iterator
193  * @return              iterator index, -1 on termination
194  */
195 int rpmpsNextIterator(rpmpsi psi);
196
197 /** \ingroup rpmps
198  * Return current problem from problem set
199  * @param psi           problem set iterator
200  * @return              current rpmProblem 
201  */
202 rpmProblem rpmpsGetProblem(rpmpsi psi);
203
204 /** \ingroup rpmps
205  * Create a problem set.
206  * @return              new problem set
207  */
208 rpmps rpmpsCreate(void);
209
210 /** \ingroup rpmps
211  * Destroy a problem set.
212  * @param ps            problem set
213  * @return              NULL always
214  */
215 rpmps rpmpsFree(rpmps ps);
216
217 /** \ingroup rpmps
218  * Print problems to file handle.
219  * @param fp            file handle (NULL uses stderr)
220  * @param ps            problem set
221  */
222 void rpmpsPrint(FILE *fp, rpmps ps);
223
224 /** \ingroup rpmps
225  * Append a problem to current set of problems.
226  * @param ps            problem set
227  * @param prob          rpmProblem 
228  */
229 void rpmpsAppendProblem(rpmps ps, rpmProblem prob);
230
231 /** \ingroup rpmps
232  * Append a problem to current set of problems.
233  * @param ps            problem set
234  * @param type          type of problem
235  * @param pkgNEVR       package name
236  * @param key           filename or python object address
237  * @param dn            directory name
238  * @param bn            file base name
239  * @param altNEVR       related (e.g. through a dependency) package name
240  * @param number        generic number attribute
241  */
242 void rpmpsAppend(rpmps ps, rpmProblemType type,
243                 const char * pkgNEVR,
244                 fnpyKey key,
245                 const char * dn, const char * bn,
246                 const char * altNEVR,
247                 uint64_t number);
248
249 /** \ingroup rpmps
250  * Filter a problem set.
251  *
252  * As the problem sets are generated in an order solely dependent
253  * on the ordering of the packages in the transaction, and that
254  * ordering can't be changed, the problem sets must be parallel to
255  * one another. Additionally, the filter set must be a subset of the
256  * target set, given the operations available on transaction set.
257  * This is good, as it lets us perform this trim in linear time, rather
258  * then logarithmic or quadratic.
259  *
260  * @param ps            problem set
261  * @param filter        problem filter (or NULL)
262  * @return              0 no problems, 1 if problems remain
263  */
264 int rpmpsTrim(rpmps ps, rpmps filter);
265
266 #ifdef __cplusplus
267 }
268 #endif
269
270 #endif  /* H_RPMPS */