- disambiguate added/installed dependency failures (#50388).
[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  * Return formatted string representation of a problem.
69  * @param prob          rpm problem
70  * @return              formatted string (malloc'd)
71  */
72 /*@-exportlocal@*/
73 /*@-redecl@*/   /* LCL: is confused. */
74 /*@only@*/ extern const char * rpmProblemString(const rpmProblem prob)
75         /*@*/;
76 /*@=redecl@*/
77 /*@=exportlocal@*/
78
79 /**
80  * Unreference a problem set instance.
81  * @param ps            problem set
82  * @param msg
83  * @return              problem set
84  */
85 /*@unused@*/
86 rpmps rpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmps ps,
87                 const char * msg)
88         /*@modifies ps @*/;
89
90 /** @todo Remove debugging entry from the ABI. */
91 /*@-exportlocal@*/
92 /*@null@*/
93 rpmps XrpmpsUnlink (/*@killref@*/ /*@returned@*/ rpmps ps,
94                 const char * msg, const char * fn, unsigned ln)
95         /*@modifies ps @*/;
96 #define rpmpsUnlink(_ps, _msg)  XrpmpsUnlink(_ps, _msg, __FILE__, __LINE__)
97 /*@=exportlocal@*/
98
99 /**
100  * Reference a problem set instance.
101  * @param ps            transaction set
102  * @param msg
103  * @return              new transaction set reference
104  */
105 /*@unused@*/
106 rpmps rpmpsLink (rpmps ps, const char * msg)
107         /*@modifies ps @*/;
108
109 /** @todo Remove debugging entry from the ABI. */
110 rpmps XrpmpsLink (rpmps ps,
111                 const char * msg, const char * fn, unsigned ln)
112         /*@modifies ps @*/;
113 #define rpmpsLink(_ps, _msg)    XrpmpsLink(_ps, _msg, __FILE__, __LINE__)
114
115 /**
116  * Return number of problems in set.
117  * @param ps            problem set
118  * @return              number of problems
119  */
120 int rpmpsNumProblems(/*@null@*/ rpmps ps)
121         /*@*/;
122
123 /**
124  * Create a problem set.
125  * @return              new problem set
126  */
127 rpmps rpmpsCreate(void)
128         /*@*/;
129
130 /**
131  * Destroy a problem set.
132  * @param ps            problem set
133  * @return              NULL always
134  */
135 /*@null@*/
136 rpmps rpmpsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmps ps)
137         /*@modifies ps @*/;
138
139 /**
140  * Print problems to file handle.
141  * @param fp            file handle (NULL uses stderr)
142  * @param ps            problem set
143  */
144 void rpmpsPrint(/*@null@*/ FILE *fp, /*@null@*/ rpmps ps)
145         /*@globals fileSystem @*/
146         /*@modifies *fp, ps, fileSystem @*/;
147
148 /**
149  * Append a problem to set.
150  * @param ps            problem set
151  * @param type          type of problem
152  * @param pkgNEVR       package name
153  * @param key           filename or python object address
154  * @param dn            directory name
155  * @param bn            file base name
156  * @param ulong1        generic pointer/long attribute
157  */
158 void rpmpsAppend(/*@null@*/ rpmps ps, rpmProblemType type,
159                 /*@null@*/ const char * pkgNEVR,
160                 /*@exposed@*/ /*@null@*/ fnpyKey key,
161                 /*@null@*/ const char * dn, /*@null@*/ const char * bn,
162                 /*@null@*/ const char * altNEVR,
163                 unsigned long ulong1)
164         /*@modifies ps @*/;
165
166 /**
167  * Filter a problem set.
168  *
169  * As the problem sets are generated in an order solely dependent
170  * on the ordering of the packages in the transaction, and that
171  * ordering can't be changed, the problem sets must be parallel to
172  * one another. Additionally, the filter set must be a subset of the
173  * target set, given the operations available on transaction set.
174  * This is good, as it lets us perform this trim in linear time, rather
175  * then logarithmic or quadratic.
176  *
177  * @param ps            problem set
178  * @param filter        problem filter (or NULL)
179  * @return              0 no problems, 1 if problems remain
180  */
181 int rpmpsTrim(/*@null@*/ rpmps ps, /*@null@*/ rpmps filter)
182         /*@modifies ps @*/;
183
184 #ifdef __cplusplus
185 }
186 #endif
187
188 #endif  /* H_RPMPS */