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