Eliminate rpmps and rpmProblem structure details from the API
[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 "rpmmessages.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 /**
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 /**
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 /**
47  * Return package NEVR
48  * @param prob          rpm problem
49  * @return              package NEVR
50  */
51 const char * rpmProblemGetPkgNEVR(const rpmProblem prob);
52 /**
53  * Return related (e.g. through a dependency) package NEVR
54  * @param prob          rpm problem
55  * @return              related (e.g. through a dependency) package NEVR
56  */
57 const char * rpmProblemGetAltNEVR(const rpmProblem prob);
58
59 /**
60  * Return type of problem (dependency, diskpace etc)
61  * @param prob          rpm problem
62  * @return              type of problem
63  */
64
65 rpmProblemType rpmProblemGetType(const rpmProblem prob);
66
67 /**
68  * Return filename or python object address of a problem
69  * @param prob          rpm problem
70  * @return              filename or python object address
71  */
72 fnpyKey rpmProblemGetKey(const rpmProblem prob);
73
74 /**
75  * Return a generic data string from a problem
76  * @param prob          rpm problem
77  * @return              a generic data string
78  * @todo                needs a better name
79  */
80 const char * rpmProblemGetStr(const rpmProblem prob);
81 /**
82  * Return generic pointer/long attribute from a problem
83  * @param prob          rpm problem
84  * @return              a generic pointer/long attribute
85  * @todo                needs a better name
86  */
87 unsigned long rpmProblemGetLong(const rpmProblem prob);
88
89 /**
90  * Return formatted string representation of a problem.
91  * @param prob          rpm problem
92  * @return              formatted string (malloc'd)
93  */
94 extern const char * rpmProblemString(const rpmProblem prob);
95
96 /**
97  * Unreference a problem set instance.
98  * @param ps            problem set
99  * @param msg
100  * @return              problem set
101  */
102 rpmps rpmpsUnlink (rpmps ps,
103                 const char * msg);
104
105 /** @todo Remove debugging entry from the ABI. */
106 rpmps XrpmpsUnlink (rpmps ps,
107                 const char * msg, const char * fn, unsigned ln);
108 #define rpmpsUnlink(_ps, _msg)  XrpmpsUnlink(_ps, _msg, __FILE__, __LINE__)
109
110 /**
111  * Reference a problem set instance.
112  * @param ps            transaction set
113  * @param msg
114  * @return              new transaction set reference
115  */
116 rpmps rpmpsLink (rpmps ps, const char * msg);
117
118 /** @todo Remove debugging entry from the ABI. */
119 rpmps XrpmpsLink (rpmps ps,
120                 const char * msg, const char * fn, unsigned ln);
121 #define rpmpsLink(_ps, _msg)    XrpmpsLink(_ps, _msg, __FILE__, __LINE__)
122
123 /**
124  * Return number of problems in set.
125  * @param ps            problem set
126  * @return              number of problems
127  */
128 int rpmpsNumProblems(rpmps ps);
129
130 /**
131  * Initialize problem set iterator.
132  * @param ps            problem set
133  * @return              problem set iterator
134  */
135 rpmpsi rpmpsInitIterator(rpmps ps);
136
137 /**
138  * Destroy problem set iterator.
139  * @param psi           problem set iterator
140  * @return              problem set iterator (NULL)
141  */
142 rpmpsi rpmpsFreeIterator(rpmpsi psi);
143
144 /**
145  * Return next problem set iterator index
146  * @param psi           problem set iterator
147  * @return              iterator index, -1 on termination
148  */
149 int rpmpsNextIterator(rpmpsi psi);
150
151 /**
152  * Return current problem from problem set
153  * @param psi           problem set iterator
154  * @return              current rpmProblem 
155  */
156 rpmProblem rpmpsProblem(rpmpsi psi);
157
158 /**
159  * Create a problem set.
160  * @return              new problem set
161  */
162 rpmps rpmpsCreate(void);
163
164 /**
165  * Destroy a problem set.
166  * @param ps            problem set
167  * @return              NULL always
168  */
169 rpmps rpmpsFree(rpmps ps);
170
171 /**
172  * Print problems to file handle.
173  * @param fp            file handle (NULL uses stderr)
174  * @param ps            problem set
175  */
176 void rpmpsPrint(FILE *fp, rpmps ps);
177
178 /**
179  * Append a problem to current set of problems.
180  * @param ps            problem set
181  * @param type          type of problem
182  * @param pkgNEVR       package name
183  * @param key           filename or python object address
184  * @param dn            directory name
185  * @param bn            file base name
186  * @param altNEVR       related (e.g. through a dependency) package name
187  * @param ulong1        generic pointer/long attribute
188  */
189 void rpmpsAppend(rpmps ps, rpmProblemType type,
190                 const char * pkgNEVR,
191                 fnpyKey key,
192                 const char * dn, const char * bn,
193                 const char * altNEVR,
194                 unsigned long ulong1);
195
196 /**
197  * Filter a problem set.
198  *
199  * As the problem sets are generated in an order solely dependent
200  * on the ordering of the packages in the transaction, and that
201  * ordering can't be changed, the problem sets must be parallel to
202  * one another. Additionally, the filter set must be a subset of the
203  * target set, given the operations available on transaction set.
204  * This is good, as it lets us perform this trim in linear time, rather
205  * then logarithmic or quadratic.
206  *
207  * @param ps            problem set
208  * @param filter        problem filter (or NULL)
209  * @return              0 no problems, 1 if problems remain
210  */
211 int rpmpsTrim(rpmps ps, rpmps filter);
212
213 #ifdef __cplusplus
214 }
215 #endif
216
217 #endif  /* H_RPMPS */