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