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