Remove unimplemented, unused RPMPROB_BADPRETRANS
[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 /**
28  * Enumerate transaction set problem types.
29  */
30 typedef enum rpmProblemType_e {
31     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
32     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
33     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
34     RPMPROB_BADRELOCATE,/*!< path ... is not relocatable for package ... */
35     RPMPROB_REQUIRES,   /*!< package ... has unsatisfied Requires: ... */
36     RPMPROB_CONFLICT,   /*!< package ... has unsatisfied Conflicts: ... */
37     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
38     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
39     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
40     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ... filesystem */
41     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ... filesystem */
42  } rpmProblemType;
43
44 /**
45  */
46 struct rpmProblem_s {
47     char * pkgNEVR;
48     char * altNEVR;
49     fnpyKey key;
50     rpmProblemType type;
51     int ignoreProblem;
52     char * str1;
53     unsigned long ulong1;
54 };
55
56 /**
57  */
58 struct rpmps_s {
59     int numProblems;            /*!< Current probs array size. */
60     int numProblemsAlloced;     /*!< Allocated probs array size. */
61     rpmProblem probs;           /*!< Array of specific problems. */
62     int nrefs;                  /*!< Reference count. */
63 };
64
65 /**
66  * Return formatted string representation of a problem.
67  * @param prob          rpm problem
68  * @return              formatted string (malloc'd)
69  */
70 extern const char * rpmProblemString(const rpmProblem prob);
71
72 /**
73  * Unreference a problem set instance.
74  * @param ps            problem set
75  * @param msg
76  * @return              problem set
77  */
78 rpmps rpmpsUnlink (rpmps ps,
79                 const char * msg);
80
81 /** @todo Remove debugging entry from the ABI. */
82 rpmps XrpmpsUnlink (rpmps ps,
83                 const char * msg, const char * fn, unsigned ln);
84 #define rpmpsUnlink(_ps, _msg)  XrpmpsUnlink(_ps, _msg, __FILE__, __LINE__)
85
86 /**
87  * Reference a problem set instance.
88  * @param ps            transaction set
89  * @param msg
90  * @return              new transaction set reference
91  */
92 rpmps rpmpsLink (rpmps ps, const char * msg);
93
94 /** @todo Remove debugging entry from the ABI. */
95 rpmps XrpmpsLink (rpmps ps,
96                 const char * msg, const char * fn, unsigned ln);
97 #define rpmpsLink(_ps, _msg)    XrpmpsLink(_ps, _msg, __FILE__, __LINE__)
98
99 /**
100  * Return number of problems in set.
101  * @param ps            problem set
102  * @return              number of problems
103  */
104 int rpmpsNumProblems(rpmps ps);
105
106 /**
107  * Create a problem set.
108  * @return              new problem set
109  */
110 rpmps rpmpsCreate(void);
111
112 /**
113  * Destroy a problem set.
114  * @param ps            problem set
115  * @return              NULL always
116  */
117 rpmps rpmpsFree(rpmps ps);
118
119 /**
120  * Print problems to file handle.
121  * @param fp            file handle (NULL uses stderr)
122  * @param ps            problem set
123  */
124 void rpmpsPrint(FILE *fp, rpmps ps);
125
126 /**
127  * Append a problem to current set of problems.
128  * @param ps            problem set
129  * @param type          type of problem
130  * @param pkgNEVR       package name
131  * @param key           filename or python object address
132  * @param dn            directory name
133  * @param bn            file base name
134  * @param altNEVR       related (e.g. through a dependency) package name
135  * @param ulong1        generic pointer/long attribute
136  */
137 void rpmpsAppend(rpmps ps, rpmProblemType type,
138                 const char * pkgNEVR,
139                 fnpyKey key,
140                 const char * dn, const char * bn,
141                 const char * altNEVR,
142                 unsigned long ulong1);
143
144 /**
145  * Filter a problem set.
146  *
147  * As the problem sets are generated in an order solely dependent
148  * on the ordering of the packages in the transaction, and that
149  * ordering can't be changed, the problem sets must be parallel to
150  * one another. Additionally, the filter set must be a subset of the
151  * target set, given the operations available on transaction set.
152  * This is good, as it lets us perform this trim in linear time, rather
153  * then logarithmic or quadratic.
154  *
155  * @param ps            problem set
156  * @param filter        problem filter (or NULL)
157  * @return              0 no problems, 1 if problems remain
158  */
159 int rpmpsTrim(rpmps ps, rpmps filter);
160
161 #ifdef __cplusplus
162 }
163 #endif
164
165 #endif  /* H_RPMPS */