- fix: synthesize unpacking progress callbacks for packages w/o files.
[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 /**
10  * Raw data for an element of a problem set.
11  */
12 typedef /*@abstract@*/ struct rpmProblem_s * rpmProblem;
13
14 /**
15  * Transaction problems found while processing a transaction set/
16  */
17 typedef /*@abstract@*/ /*@refcounted@*/ struct rpmps_s * rpmps;
18
19 /**
20  * Enumerate transaction set problem types.
21  */
22 typedef enum rpmProblemType_e {
23     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
24     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
25     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
26     RPMPROB_BADRELOCATE,/*!< path ... is not relocateable for package ... */
27     RPMPROB_REQUIRES,   /*!< package ... has unsatisfied Requires: ... */
28     RPMPROB_CONFLICT,   /*!< package ... has unsatisfied Conflicts: ... */
29     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
30     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
31     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
32     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ... filesystem */
33     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ... filesystem */
34     RPMPROB_BADPRETRANS /*!< (unimplemented) */
35  } rpmProblemType;
36
37 /**
38  */
39 struct rpmProblem_s {
40 /*@only@*/ /*@null@*/
41     char * pkgNEVR;
42 /*@only@*/ /*@null@*/
43     char * altNEVR;
44 /*@exposed@*/ /*@null@*/
45     fnpyKey key;
46     rpmProblemType type;
47     int ignoreProblem;
48 /*@only@*/ /*@null@*/
49     char * str1;
50     unsigned long ulong1;
51 };
52
53 /**
54  */
55 struct rpmps_s {
56     int numProblems;            /*!< Current probs array size. */
57     int numProblemsAlloced;     /*!< Allocated probs array size. */
58     rpmProblem probs;           /*!< Array of specific problems. */
59 /*@refs@*/
60     int nrefs;                  /*!< Reference count. */
61 };
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66
67 /**
68  */
69 void printDepFlags(FILE *fp, const char *version, int flags)
70         /*@globals fileSystem @*/
71         /*@modifies *fp, fileSystem @*/;
72
73 /**
74  * Print a problem array.
75  * @param fp            output file
76  * @param ps            dependency problems
77  */
78 void printDepProblems(FILE * fp, /*@null@*/ const rpmps ps)
79         /*@globals fileSystem @*/
80         /*@modifies *fp, fileSystem @*/;
81
82 /**
83  * Return formatted string representation of a problem.
84  * @param prob          rpm problem
85  * @return              formatted string (malloc'd)
86  */
87 /*@-exportlocal@*/
88 /*@-redecl@*/   /* LCL: is confused. */
89 /*@only@*/ extern const char * rpmProblemString(const rpmProblem prob)
90         /*@*/;
91 /*@=redecl@*/
92 /*@=exportlocal@*/
93
94 /**
95  * Unreference a problem set instance.
96  * @param ps            problem set
97  * @param msg
98  * @return              problem set
99  */
100 /*@unused@*/
101 rpmps rpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmps ps,
102                 const char * msg)
103         /*@modifies ps @*/;
104
105 /** @todo Remove debugging entry from the ABI. */
106 /*@-exportlocal@*/
107 /*@null@*/
108 rpmps XrpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmps ps,
109                 const char * msg, const char * fn, unsigned ln)
110         /*@modifies ps @*/;
111 #define rpmpsUnlink(_ps, _msg)  XrpmpsUnlink(_ps, _msg, __FILE__, __LINE__)
112 /*@=exportlocal@*/
113
114 /**
115  * Reference a problem set instance.
116  * @param ps            transaction set
117  * @param msg
118  * @return              new transaction set reference
119  */
120 /*@unused@*/
121 rpmps rpmpsLink (rpmps ps, const char * msg)
122         /*@modifies ps @*/;
123
124 /** @todo Remove debugging entry from the ABI. */
125 rpmps XrpmpsLink (rpmps ps,
126                 const char * msg, const char * fn, unsigned ln)
127         /*@modifies ps @*/;
128 #define rpmpsLink(_ps, _msg)    XrpmpsLink(_ps, _msg, __FILE__, __LINE__)
129
130 /**
131  * Create a problem set.
132  */
133 rpmps rpmpsCreate(void)
134         /*@*/;
135
136 /**
137  * Destroy a problem set.
138  * @param ps            problem set
139  * @return              NULL always
140  */
141 /*@null@*/
142 rpmps rpmpsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmps ps)
143         /*@modifies ps @*/;
144
145 /**
146  * Output formatted string representation of a problem to file handle.
147  * @deprecated API: prob used to be passed by value, now passed by reference.
148  * @param fp            file handle
149  * @param prob          rpm problem
150  */
151 /*@-exportlocal@*/
152 void rpmProblemPrint(FILE *fp, rpmProblem prob)
153         /*@globals fileSystem @*/
154         /*@modifies prob, *fp, fileSystem @*/;
155 /*@=exportlocal@*/
156
157 /**
158  * Print problems to file handle.
159  * @param fp            file handle
160  * @param ps            problem set
161  */
162 void rpmpsPrint(FILE *fp, /*@null@*/ rpmps ps)
163         /*@globals fileSystem @*/
164         /*@modifies *fp, ps, fileSystem @*/;
165
166 /**
167  * Append a problem to set.
168  */
169 void rpmpsAppend(/*@null@*/ rpmps ps, rpmProblemType type,
170                 /*@null@*/ const char * pkgNEVR,
171                 /*@exposed@*/ /*@null@*/ fnpyKey key,
172                 /*@null@*/ const char * dn, /*@null@*/ const char * bn,
173                 /*@null@*/ const char * altNEVR,
174                 unsigned long ulong1)
175         /*@modifies ps @*/;
176
177 /**
178  * Filter a problem set.
179  *
180  * As the problem sets are generated in an order solely dependent
181  * on the ordering of the packages in the transaction, and that
182  * ordering can't be changed, the problem sets must be parallel to
183  * one another. Additionally, the filter set must be a subset of the
184  * target set, given the operations available on transaction set.
185  * This is good, as it lets us perform this trim in linear time, rather
186  * then logarithmic or quadratic.
187  *
188  * @param ps            problem set
189  * @param filter        problem filter (or NULL)
190  * @return              0 no problems, 1 if problems remain
191  */
192 int rpmpsTrim(/*@null@*/ rpmps ps, /*@null@*/ rpmps filter)
193         /*@modifies ps @*/;
194
195 #ifdef __cplusplus
196 }
197 #endif
198
199 #endif  /* H_RPMPS */