'Adjust extern C {} blocks.'
[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 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 extern int _rpmps_debug;
14
15 /**
16  * Raw data for an element of a problem set.
17  */
18 typedef struct rpmProblem_s * rpmProblem;
19
20 /**
21  * Transaction problems found while processing a transaction set/
22  */
23 typedef struct rpmps_s * rpmps;
24
25 /**
26  * Enumerate transaction set problem types.
27  */
28 typedef enum rpmProblemType_e {
29     RPMPROB_BADARCH,    /*!< package ... is for a different architecture */
30     RPMPROB_BADOS,      /*!< package ... is for a different operating system */
31     RPMPROB_PKG_INSTALLED, /*!< package ... is already installed */
32     RPMPROB_BADRELOCATE,/*!< path ... is not relocatable for package ... */
33     RPMPROB_REQUIRES,   /*!< package ... has unsatisfied Requires: ... */
34     RPMPROB_CONFLICT,   /*!< package ... has unsatisfied Conflicts: ... */
35     RPMPROB_NEW_FILE_CONFLICT, /*!< file ... conflicts between attemped installs of ... */
36     RPMPROB_FILE_CONFLICT,/*!< file ... from install of ... conflicts with file from package ... */
37     RPMPROB_OLDPACKAGE, /*!< package ... (which is newer than ...) is already installed */
38     RPMPROB_DISKSPACE,  /*!< installing package ... needs ... on the ... filesystem */
39     RPMPROB_DISKNODES,  /*!< installing package ... needs ... on the ... filesystem */
40     RPMPROB_BADPRETRANS /*!< (unimplemented) */
41  } rpmProblemType;
42
43 /**
44  */
45 struct rpmProblem_s {
46     char * pkgNEVR;
47     char * altNEVR;
48     fnpyKey key;
49     rpmProblemType type;
50     int ignoreProblem;
51     char * str1;
52     unsigned long ulong1;
53 };
54
55 /**
56  */
57 struct rpmps_s {
58     int numProblems;            /*!< Current probs array size. */
59     int numProblemsAlloced;     /*!< Allocated probs array size. */
60     rpmProblem probs;           /*!< Array of specific problems. */
61     int nrefs;                  /*!< Reference count. */
62 };
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 */