Add a saner rpmps iteration interface
[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 #include <rpm/rpmprob.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /** \ingroup rpmps
18  * Problem set iterator
19  */
20 typedef struct rpmpsi_s * rpmpsi;
21
22 /** \ingroup rpmps
23  * Unreference a problem set instance.
24  * @param ps            problem set
25  * @return              problem set
26  */
27 rpmps rpmpsUnlink (rpmps ps);
28
29 /** \ingroup rpmps
30  * Reference a problem set instance.
31  * @param ps            transaction set
32  * @return              new transaction set reference
33  */
34 rpmps rpmpsLink (rpmps ps);
35
36 /** \ingroup rpmps
37  * Return number of problems in set.
38  * @param ps            problem set
39  * @return              number of problems
40  */
41 int rpmpsNumProblems(rpmps ps);
42
43 /** \ingroup rpmps
44  * Initialize problem set iterator.
45  * @param ps            problem set
46  * @return              problem set iterator
47  */
48 rpmpsi rpmpsInitIterator(rpmps ps);
49
50 /** \ingroup rpmps
51  * Destroy problem set iterator.
52  * @param psi           problem set iterator
53  * @return              problem set iterator (NULL)
54  */
55 rpmpsi rpmpsFreeIterator(rpmpsi psi);
56
57 /** \ingroup rpmps
58  * Return next problem from iterator
59  * @param psi           problem set iterator
60  * @return              next problem (weak ref), NULL on termination
61  */
62 rpmProblem rpmpsiNext(rpmpsi psi);
63
64 /** \ingroup rpmps
65  * Return next problem set iterator index
66  * @param psi           problem set iterator
67  * @return              iterator index, -1 on termination
68  */
69 int rpmpsNextIterator(rpmpsi psi);
70
71 /** \ingroup rpmps
72  * Return current problem from problem set
73  * @param psi           problem set iterator
74  * @return              current rpmProblem 
75  */
76 rpmProblem rpmpsGetProblem(rpmpsi psi);
77
78 /** \ingroup rpmps
79  * Create a problem set.
80  * @return              new problem set
81  */
82 rpmps rpmpsCreate(void);
83
84 /** \ingroup rpmps
85  * Destroy a problem set.
86  * @param ps            problem set
87  * @return              NULL always
88  */
89 rpmps rpmpsFree(rpmps ps);
90
91 /** \ingroup rpmps
92  * Print problems to file handle.
93  * @param fp            file handle (NULL uses stderr)
94  * @param ps            problem set
95  */
96 void rpmpsPrint(FILE *fp, rpmps ps);
97
98 /** \ingroup rpmps
99  * Append a problem to current set of problems.
100  * @param ps            problem set
101  * @param prob          rpmProblem 
102  */
103 void rpmpsAppendProblem(rpmps ps, rpmProblem prob);
104
105 /** \ingroup rpmps
106  * Append a problem to current set of problems.
107  * @param ps            problem set
108  * @param type          type of problem
109  * @param pkgNEVR       package name
110  * @param key           filename or python object address
111  * @param dn            directory name
112  * @param bn            file base name
113  * @param altNEVR       related (e.g. through a dependency) package name
114  * @param number        generic number attribute
115  */
116 void rpmpsAppend(rpmps ps, rpmProblemType type,
117                 const char * pkgNEVR,
118                 fnpyKey key,
119                 const char * dn, const char * bn,
120                 const char * altNEVR,
121                 uint64_t number);
122
123 /** \ingroup rpmps
124  * Filter a problem set.
125  *
126  * As the problem sets are generated in an order solely dependent
127  * on the ordering of the packages in the transaction, and that
128  * ordering can't be changed, the problem sets must be parallel to
129  * one another. Additionally, the filter set must be a subset of the
130  * target set, given the operations available on transaction set.
131  * This is good, as it lets us perform this trim in linear time, rather
132  * then logarithmic or quadratic.
133  *
134  * @param ps            problem set
135  * @param filter        problem filter (or NULL)
136  * @return              0 no problems, 1 if problems remain
137  */
138 int rpmpsTrim(rpmps ps, rpmps filter);
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif  /* H_RPMPS */