- no-brainer refcounts for rpmProblemSet object.
[platform/upstream/rpm.git] / lib / rpmds.h
1 #ifndef H_RPMDS
2 #define H_RPMDS
3
4 /** \ingroup rpmdep rpmtrans
5  * \file lib/rpmds.h
6  * Structure used for handling a dependency set.
7  */
8
9 /**
10  */
11 typedef /*@abstract@*/ struct rpmFNSet_s *              rpmFNSet;
12
13 /**
14  * A package filename set.
15  */
16 struct rpmFNSet_s {
17     int i;                      /*!< File index. */
18
19 /*@observer@*/
20     const char * Type;          /*!< Tag name. */
21
22     rpmTag tagN;                /*!< Header tag. */
23 /*@refcounted@*/ /*@null@*/
24     Header h;                   /*!< Header for file name set (or NULL) */
25
26 /*@only@*/
27     const char ** BN;           /*!< File base name(s). */
28 /*@only@*/
29     const int_32 * DI;          /*!< File directory index. */
30 /*@only@*/
31     const uint_32 * Flags;      /*!< File flags. */
32 /*@only@*/
33     const char ** DN;           /*!< Directory name(s). */
34     int_32 DCount;              /*!< No. of directories. */
35     rpmTagType BNt, DIt, Ft, DNt;       /*!< Tag data types. */
36     int_32 Count;               /*!< No. of files. */
37 };
38
39 /**
40  * A package dependency set.
41  */
42 struct rpmDepSet_s {
43     int i;                      /*!< Element index. */
44
45 /*@observer@*/
46     const char * Type;          /*!< Tag name. */
47 /*@only@*/ /*@null@*/
48     const char * DNEVR;         /*!< Formatted dependency string. */
49
50     rpmTag tagN;                /*!< Header tag. */
51 /*@refcounted@*/ /*@null@*/
52     Header h;                   /*!< Header for dependency set (or NULL) */
53
54 /*@only@*/
55     const char ** N;            /*!< Name. */
56 /*@only@*/
57     const char ** EVR;          /*!< Epoch-Version-Release. */
58 /*@only@*/
59     const int_32 * Flags;       /*!< Flags identifying context/comparison. */
60     rpmTagType Nt, EVRt, Ft;    /*!< Tag data types. */
61     int_32 Count;               /*!< No. of elements */
62 };
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67
68 /**
69  * Destroy a file name set.
70  * @param ds            file name set
71  * @return              NULL always
72  */
73 /*@only@*/ /*@null@*/
74 rpmFNSet fnsFree(/*@only@*/ /*@null@*/ rpmFNSet fns)
75         /*@modifies fns@*/;
76 /**
77  * Create and load a file name set.
78  * @param h             header
79  * @param tagN          RPMTAG_BASENAMES
80  * @param scareMem      Use pointers to refcounted header memory?
81  * @return              new file name set
82  */
83 /*@only@*/ /*@null@*/
84 rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem)
85         /*@modifies h @*/;
86
87 /**
88  * Destroy a dependency set.
89  * @param ds            dependency set
90  * @return              NULL always
91  */
92 /*@only@*/ /*@null@*/
93 rpmDepSet dsFree(/*@only@*/ /*@null@*/ rpmDepSet ds)
94         /*@modifies ds@*/;
95 /**
96  * Create and load a dependency set.
97  * @param h             header
98  * @param tagN          type of dependency
99  * @param scareMem      Use pointers to refcounted header memory?
100  * @return              new dependency set
101  */
102 /*@only@*/ /*@null@*/
103 rpmDepSet dsNew(Header h, rpmTag tagN, int scareMem)
104         /*@modifies h @*/;
105
106 /**
107  * Return new formatted dependency string.
108  * @param dspfx         formatted dependency string prefix
109  * @param ds            dependency set
110  * @return              new formatted dependency (malloc'ed)
111  */
112 /*@only@*/
113 char * dsDNEVR(const char * dspfx, const rpmDepSet ds)
114         /*@*/;
115
116 /**
117  * Return dependency set count.
118  * @param ds            dependency set
119  * @return              current count
120  */
121 int dsiGetCount(/*@null@*/ rpmDepSet ds)
122         /*@*/;
123
124 /**
125  * Return dependency set index.
126  * @param ds            dependency set
127  * @return              current index
128  */
129 int dsiGetIx(/*@null@*/ rpmDepSet ds)
130         /*@*/;
131
132 /**
133  * Set dependency set index.
134  * @param ds            dependency set
135  * @param ix            new index
136  * @return              current index
137  */
138 int dsiSetIx(/*@null@*/ rpmDepSet ds, int ix)
139         /*@modifies ds @*/;
140
141 /**
142  * Return current formatted dependency string.
143  * @param ds            dependency set
144  * @return              current dependency DNEVR, NULL on invalid
145  */
146 /*@null@*/
147 const char * dsiGetDNEVR(/*@null@*/ rpmDepSet ds)
148         /*@*/;
149
150 /**
151  * Return current dependency name.
152  * @param ds            dependency set
153  * @return              current dependency name, NULL on invalid
154  */
155 /*@null@*/
156 const char * dsiGetN(/*@null@*/ rpmDepSet ds)
157         /*@*/;
158
159 /**
160  * Return current dependency epoch-version-release.
161  * @param ds            dependency set
162  * @return              current dependency EVR, NULL on invalid
163  */
164 /*@null@*/
165 const char * dsiGetEVR(/*@null@*/ rpmDepSet ds)
166         /*@*/;
167
168 /**
169  * Return current dependency Flags.
170  * @param ds            dependency set
171  * @return              current dependency EVR, 0 on invalid
172  */
173 int_32 dsiGetFlags(/*@null@*/ rpmDepSet ds)
174         /*@*/;
175
176 /**
177  * Notify of results of dependency match;
178  * @param ds            dependency set
179  * @param where         where dependency was resolved (or NULL)
180  * @param rc            0 == YES, otherwise NO
181  */
182 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
183 void dsiNotify(/*@null@*/ rpmDepSet ds, /*@null@*/ const char * where, int rc)
184         /*@globals fileSystem @*/
185         /*@modifies fileSystem @*/;
186 /*@=globuse@*/
187
188 /**
189  * Return next dependency set iterator index.
190  * @param ds            dependency set
191  * @return              dependency set iterator index, -1 on termination
192  */
193 int dsiNext(/*@null@*/ rpmDepSet ds)
194         /*@modifies ds @*/;
195
196 /**
197  * Initialize dependency set iterator.
198  * @param ds            dependency set
199  * @return              dependency set
200  */
201 /*@null@*/
202 rpmDepSet dsiInit(/*@returned@*/ /*@null@*/ rpmDepSet ds)
203         /*@modifies ds @*/;
204
205 /**
206  * Compare two versioned dependency ranges, looking for overlap.
207  * @param A             1st dependency
208  * @param B             2nd dependency
209  * @return              1 if dependencies overlap, 0 otherwise
210  */
211 int dsCompare(const rpmDepSet A, const rpmDepSet B)
212         /*@*/;
213
214 /**
215  * Report a Requires: or Conflicts: dependency problem.
216  */
217 void dsProblem(/*@null@*/ rpmProblemSet tsprobs, Header h, const rpmDepSet ds,
218                 /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys)
219         /*@modifies tsprobs, h @*/;
220
221 /**
222  * Compare package provides dependencies from header with a single dependency.
223  * @param h             header
224  * @param ds            dependency set
225  */
226 int rangeMatchesDepFlags (Header h, const rpmDepSet req)
227         /*@modifies h @*/;
228
229 /**
230  * Compare package name-version-release from header with a single dependency.
231  * @deprecated Remove from API when obsoletes is correctly implemented.
232  * @param h             header
233  * @param req           dependency
234  * @return              1 if dependency overlaps, 0 otherwise
235  */
236 int headerMatchesDepFlags(Header h, const rpmDepSet req)
237         /*@*/;
238
239 #ifdef __cplusplus
240 }
241 #endif
242
243 #endif  /* H_RPMDS */