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