More missing system includes for size_t & friends
[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/rpmcallback.h>    /* for fnpyKey */
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  * Transaction problems found while processing a transaction set/
41  */
42 typedef struct rpmps_s * rpmps;
43
44 typedef struct rpmpsi_s * rpmpsi;
45
46 /** \ingroup rpmps
47  * Enumerate transaction set problem types.
48  */
49 typedef enum rpmProblemType_e {
50     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
51     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
52     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
53     RPMPROB_BADRELOCATE,/*!< path ... is not relocatable for package ... */
54     RPMPROB_REQUIRES,   /*!< package ... has unsatisfied Requires: ... */
55     RPMPROB_CONFLICT,   /*!< package ... has unsatisfied Conflicts: ... */
56     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
57     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
58     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
59     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ... filesystem */
60     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ... filesystem */
61  } rpmProblemType;
62
63 /** \ingroup rpmps
64  * Create a problem item.
65  * @param type          type of problem
66  * @param pkgNEVR       package name
67  * @param key           filename or python object address
68  * @param dn            directory name
69  * @param bn            file base name
70  * @param altNEVR       related (e.g. through a dependency) package name
71  * @param ulong1        generic pointer/long attribute
72  * @return              rpmProblem
73  */
74 rpmProblem rpmProblemCreate(rpmProblemType type,
75                             const char * pkgNEVR,
76                             fnpyKey key,
77                             const char * dn, const char * bn,
78                             const char * altNEVR,
79                             unsigned long ulong1);
80
81 /** \ingroup rpmps
82  * Destroy a problem item.
83  * @param prob          rpm problem
84  * @return              rpm problem (NULL)
85  */
86 rpmProblem rpmProblemFree(rpmProblem prob);
87
88 /** \ingroup rpmps
89  * Return package NEVR
90  * @param prob          rpm problem
91  * @return              package NEVR
92  */
93 const char * rpmProblemGetPkgNEVR(const rpmProblem prob);
94 /** \ingroup rpmps
95  * Return related (e.g. through a dependency) package NEVR
96  * @param prob          rpm problem
97  * @return              related (e.g. through a dependency) package NEVR
98  */
99 const char * rpmProblemGetAltNEVR(const rpmProblem prob);
100
101 /** \ingroup rpmps
102  * Return type of problem (dependency, diskpace etc)
103  * @param prob          rpm problem
104  * @return              type of problem
105  */
106
107 rpmProblemType rpmProblemGetType(const rpmProblem prob);
108
109 /** \ingroup rpmps
110  * Return filename or python object address of a problem
111  * @param prob          rpm problem
112  * @return              filename or python object address
113  */
114 fnpyKey rpmProblemGetKey(const rpmProblem prob);
115
116 /** \ingroup rpmps
117  * Return a generic data string from a problem
118  * @param prob          rpm problem
119  * @return              a generic data string
120  * @todo                needs a better name
121  */
122 const char * rpmProblemGetStr(const rpmProblem prob);
123 /** \ingroup rpmps
124  * Return generic pointer/long attribute from a problem
125  * @param prob          rpm problem
126  * @return              a generic pointer/long attribute
127  * @todo                needs a better name
128  */
129 unsigned long rpmProblemGetLong(const rpmProblem prob);
130
131 /** \ingroup rpmps
132  * Return formatted string representation of a problem.
133  * @param prob          rpm problem
134  * @return              formatted string (malloc'd)
135  */
136 extern char * rpmProblemString(const rpmProblem prob);
137
138 /** \ingroup rpmps
139  * Unreference a problem set instance.
140  * @param ps            problem set
141  * @param msg
142  * @return              problem set
143  */
144 rpmps rpmpsUnlink (rpmps ps,
145                 const char * msg);
146
147 /** \ingroup rpmps
148  * Reference a problem set instance.
149  * @param ps            transaction set
150  * @param msg
151  * @return              new transaction set reference
152  */
153 rpmps rpmpsLink (rpmps ps, const char * msg);
154
155 /** \ingroup rpmps
156  * Return number of problems in set.
157  * @param ps            problem set
158  * @return              number of problems
159  */
160 int rpmpsNumProblems(rpmps ps);
161
162 /** \ingroup rpmps
163  * Initialize problem set iterator.
164  * @param ps            problem set
165  * @return              problem set iterator
166  */
167 rpmpsi rpmpsInitIterator(rpmps ps);
168
169 /** \ingroup rpmps
170  * Destroy problem set iterator.
171  * @param psi           problem set iterator
172  * @return              problem set iterator (NULL)
173  */
174 rpmpsi rpmpsFreeIterator(rpmpsi psi);
175
176 /** \ingroup rpmps
177  * Return next problem set iterator index
178  * @param psi           problem set iterator
179  * @return              iterator index, -1 on termination
180  */
181 int rpmpsNextIterator(rpmpsi psi);
182
183 /** \ingroup rpmps
184  * Return current problem from problem set
185  * @param psi           problem set iterator
186  * @return              current rpmProblem 
187  */
188 rpmProblem rpmpsGetProblem(rpmpsi psi);
189
190 /** \ingroup rpmps
191  * Create a problem set.
192  * @return              new problem set
193  */
194 rpmps rpmpsCreate(void);
195
196 /** \ingroup rpmps
197  * Destroy a problem set.
198  * @param ps            problem set
199  * @return              NULL always
200  */
201 rpmps rpmpsFree(rpmps ps);
202
203 /** \ingroup rpmps
204  * Print problems to file handle.
205  * @param fp            file handle (NULL uses stderr)
206  * @param ps            problem set
207  */
208 void rpmpsPrint(FILE *fp, rpmps ps);
209
210 /** \ingroup rpmps
211  * Append a problem to current set of problems.
212  * @param ps            problem set
213  * @param prob          rpmProblem 
214  */
215 void rpmpsAppendProblem(rpmps ps, rpmProblem prob);
216
217 /** \ingroup rpmps
218  * Append a problem to current set of problems.
219  * @param ps            problem set
220  * @param type          type of problem
221  * @param pkgNEVR       package name
222  * @param key           filename or python object address
223  * @param dn            directory name
224  * @param bn            file base name
225  * @param altNEVR       related (e.g. through a dependency) package name
226  * @param ulong1        generic pointer/long attribute
227  */
228 void rpmpsAppend(rpmps ps, rpmProblemType type,
229                 const char * pkgNEVR,
230                 fnpyKey key,
231                 const char * dn, const char * bn,
232                 const char * altNEVR,
233                 unsigned long ulong1);
234
235 /** \ingroup rpmps
236  * Filter a problem set.
237  *
238  * As the problem sets are generated in an order solely dependent
239  * on the ordering of the packages in the transaction, and that
240  * ordering can't be changed, the problem sets must be parallel to
241  * one another. Additionally, the filter set must be a subset of the
242  * target set, given the operations available on transaction set.
243  * This is good, as it lets us perform this trim in linear time, rather
244  * then logarithmic or quadratic.
245  *
246  * @param ps            problem set
247  * @param filter        problem filter (or NULL)
248  * @return              0 no problems, 1 if problems remain
249  */
250 int rpmpsTrim(rpmps ps, rpmps filter);
251
252 #ifdef __cplusplus
253 }
254 #endif
255
256 #endif  /* H_RPMPS */