- no-brainer refcounts for rpmDepSet and rpmFNSet objects.
[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  * A package filename set.
11  */
12 struct rpmFNSet_s {
13     int i;                      /*!< File index. */
14
15 /*@observer@*/
16     const char * Type;          /*!< Tag name. */
17
18     rpmTag tagN;                /*!< Header tag. */
19 /*@refcounted@*/ /*@null@*/
20     Header h;                   /*!< Header for file name set (or NULL) */
21
22 /*@only@*/ /*@null@*/
23     const char ** bnl;          /*!< Base name(s) (from header) */
24 /*@only@*/ /*@null@*/
25     const char ** dnl;          /*!< Directory name(s) (from header) */
26
27 /*@only@*/ /*@null@*/
28     const char ** fmd5s;        /*!< File MD5 sum(s) (from header) */
29 /*@only@*/ /*@null@*/
30     const char ** flinks;       /*!< File link(s) (from header) */
31 /*@only@*/ /*@null@*/
32     const char ** flangs;       /*!< File lang(s) */
33
34 /*@only@*/ /*@null@*/
35     const uint_32 * dil;        /*!< Directory indice(s) (from header) */
36 /*@only@*/ /*@null@*/
37     const uint_32 * fflags;     /*!< File flag(s) (from header) */
38 /*@only@*/ /*@null@*/
39     const uint_32 * fsizes;     /*!< File size(s) (from header) */
40 /*@only@*/ /*@null@*/
41     const uint_32 * fmtimes;    /*!< File modification time(s) (from header) */
42 /*@only@*/ /*@null@*/
43     const uint_16 * fmodes;     /*!< File mode(s) (from header) */
44 /*@only@*/ /*@null@*/
45     const uint_16 * frdevs;     /*!< File rdev(s) (from header) */
46
47 /*@only@*/ /*@null@*/
48     char * fstates;             /*!< File state(s) (from header) */
49
50     int_32 dc;                  /*!< No. of directories. */
51     int_32 fc;                  /*!< No. of files. */
52 /*@refs@*/ int nrefs;           /*!< Reference count. */
53 };
54
55 /**
56  * A package dependency set.
57  */
58 struct rpmDepSet_s {
59     int i;                      /*!< Element index. */
60
61 /*@observer@*/
62     const char * Type;          /*!< Tag name. */
63 /*@only@*/ /*@null@*/
64     const char * DNEVR;         /*!< Formatted dependency string. */
65
66     rpmTag tagN;                /*!< Header tag. */
67 /*@refcounted@*/ /*@null@*/
68     Header h;                   /*!< Header for dependency set (or NULL) */
69
70 /*@only@*/
71     const char ** N;            /*!< Name. */
72 /*@only@*/
73     const char ** EVR;          /*!< Epoch-Version-Release. */
74 /*@only@*/
75     const int_32 * Flags;       /*!< Flags identifying context/comparison. */
76     rpmTagType Nt, EVRt, Ft;    /*!< Tag data types. */
77     int_32 Count;               /*!< No. of elements */
78 /*@refs@*/ int nrefs;           /*!< Reference count. */
79 };
80
81 #ifdef __cplusplus
82 extern "C" {
83 #endif
84
85 /**
86  * Unreference a file info set instance.
87  * @param fns           file info set
88  * @return              NULL always
89  */
90 /*@unused@*/ /*@null@*/
91 rpmFNSet rpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
92                 const char * msg)
93         /*@modifies fns @*/;
94
95 /** @todo Remove debugging entry from the ABI. */
96 /*@-exportlocal@*/
97 /*@null@*/
98 rpmFNSet XrpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
99                 const char * msg, const char * fn, unsigned ln)
100         /*@modifies fns @*/;
101 /*@=exportlocal@*/
102 #define rpmfnsUnlink(_fns, _msg) XrpmfnsUnlink(_fns, _msg, __FILE__, __LINE__)
103
104 /**
105  * Reference a file info set instance.
106  * @param fns           file info set
107  * @return              new file info set reference
108  */
109 /*@unused@*/
110 rpmFNSet rpmfnsLink (/*@null@*/ rpmFNSet fns, const char * msg)
111         /*@modifies fns @*/;
112
113 /** @todo Remove debugging entry from the ABI. */
114 rpmFNSet XrpmfnsLink (/*@null@*/ rpmFNSet fns, const char * msg,
115                 const char * fn, unsigned ln)
116         /*@modifies fns @*/;
117 #define rpmfnsLink(_fns, _msg)  XrpmfnsLink(_fns, _msg, __FILE__, __LINE__)
118
119 /**
120  * Destroy a file name set.
121  * @param ds            file name set
122  * @return              NULL always
123  */
124 /*@null@*/
125 rpmFNSet fnsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns)
126         /*@modifies fns@*/;
127
128 /**
129  * Create and load a file name set.
130  * @param h             header
131  * @param tagN          RPMTAG_BASENAMES
132  * @param scareMem      Use pointers to refcounted header memory?
133  * @return              new file name set
134  */
135 /*@null@*/
136 rpmFNSet fnsNew(Header h, rpmTag tagN, int scareMem)
137         /*@modifies h @*/;
138
139 /**
140  * Unreference a dependency set instance.
141  * @param ds            dependency set
142  * @return              NULL always
143  */
144 /*@unused@*/ /*@null@*/
145 rpmDepSet rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
146                 const char * msg)
147         /*@modifies ds @*/;
148
149 /** @todo Remove debugging entry from the ABI. */
150 /*@-exportlocal@*/
151 /*@null@*/
152 rpmDepSet XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
153                 const char * msg, const char * fn, unsigned ln)
154         /*@modifies ds @*/;
155 /*@=exportlocal@*/
156 #define rpmdsUnlink(_ds, _msg)  XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
157
158 /**
159  * Reference a dependency set instance.
160  * @param ds            dependency set
161  * @return              new dependency set reference
162  */
163 /*@unused@*/
164 rpmDepSet rpmdsLink (/*@null@*/ rpmDepSet ds, const char * msg)
165         /*@modifies ds @*/;
166
167 /** @todo Remove debugging entry from the ABI. */
168 rpmDepSet XrpmdsLink (/*@null@*/ rpmDepSet ds, const char * msg,
169                 const char * fn, unsigned ln)
170         /*@modifies ds @*/;
171 #define rpmdsLink(_ds, _msg)    XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
172
173 /**
174  * Destroy a dependency set.
175  * @param ds            dependency set
176  * @return              NULL always
177  */
178 /*@null@*/
179 rpmDepSet dsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds)
180         /*@modifies ds@*/;
181 /**
182  * Create and load a dependency set.
183  * @param h             header
184  * @param tagN          type of dependency
185  * @param scareMem      Use pointers to refcounted header memory?
186  * @return              new dependency set
187  */
188 /*@null@*/
189 rpmDepSet dsNew(Header h, rpmTag tagN, int scareMem)
190         /*@modifies h @*/;
191
192 /**
193  * Return new formatted dependency string.
194  * @param dspfx         formatted dependency string prefix
195  * @param ds            dependency set
196  * @return              new formatted dependency (malloc'ed)
197  */
198 /*@only@*/
199 char * dsDNEVR(const char * dspfx, const rpmDepSet ds)
200         /*@*/;
201
202 /**
203  * Return dependency set count.
204  * @param ds            dependency set
205  * @return              current count
206  */
207 int dsiGetCount(/*@null@*/ rpmDepSet ds)
208         /*@*/;
209
210 /**
211  * Return dependency set index.
212  * @param ds            dependency set
213  * @return              current index
214  */
215 int dsiGetIx(/*@null@*/ rpmDepSet ds)
216         /*@*/;
217
218 /**
219  * Set dependency set index.
220  * @param ds            dependency set
221  * @param ix            new index
222  * @return              current index
223  */
224 int dsiSetIx(/*@null@*/ rpmDepSet ds, int ix)
225         /*@modifies ds @*/;
226
227 /**
228  * Return current formatted dependency string.
229  * @param ds            dependency set
230  * @return              current dependency DNEVR, NULL on invalid
231  */
232 /*@null@*/
233 const char * dsiGetDNEVR(/*@null@*/ rpmDepSet ds)
234         /*@*/;
235
236 /**
237  * Return current dependency name.
238  * @param ds            dependency set
239  * @return              current dependency name, NULL on invalid
240  */
241 /*@null@*/
242 const char * dsiGetN(/*@null@*/ rpmDepSet ds)
243         /*@*/;
244
245 /**
246  * Return current dependency epoch-version-release.
247  * @param ds            dependency set
248  * @return              current dependency EVR, NULL on invalid
249  */
250 /*@null@*/
251 const char * dsiGetEVR(/*@null@*/ rpmDepSet ds)
252         /*@*/;
253
254 /**
255  * Return current dependency Flags.
256  * @param ds            dependency set
257  * @return              current dependency EVR, 0 on invalid
258  */
259 int_32 dsiGetFlags(/*@null@*/ rpmDepSet ds)
260         /*@*/;
261
262 /**
263  * Notify of results of dependency match;
264  * @param ds            dependency set
265  * @param where         where dependency was resolved (or NULL)
266  * @param rc            0 == YES, otherwise NO
267  */
268 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
269 void dsiNotify(/*@null@*/ rpmDepSet ds, /*@null@*/ const char * where, int rc)
270         /*@globals fileSystem @*/
271         /*@modifies fileSystem @*/;
272 /*@=globuse@*/
273
274 /**
275  * Return next dependency set iterator index.
276  * @param ds            dependency set
277  * @return              dependency set iterator index, -1 on termination
278  */
279 int dsiNext(/*@null@*/ rpmDepSet ds)
280         /*@modifies ds @*/;
281
282 /**
283  * Initialize dependency set iterator.
284  * @param ds            dependency set
285  * @return              dependency set
286  */
287 /*@null@*/
288 rpmDepSet dsiInit(/*@returned@*/ /*@null@*/ rpmDepSet ds)
289         /*@modifies ds @*/;
290
291 /**
292  * Compare two versioned dependency ranges, looking for overlap.
293  * @param A             1st dependency
294  * @param B             2nd dependency
295  * @return              1 if dependencies overlap, 0 otherwise
296  */
297 int dsCompare(const rpmDepSet A, const rpmDepSet B)
298         /*@*/;
299
300 /**
301  * Report a Requires: or Conflicts: dependency problem.
302  */
303 void dsProblem(/*@null@*/ rpmProblemSet tsprobs, Header h, const rpmDepSet ds,
304                 /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys)
305         /*@modifies tsprobs, h @*/;
306
307 /**
308  * Compare package provides dependencies from header with a single dependency.
309  * @param h             header
310  * @param ds            dependency set
311  */
312 int rangeMatchesDepFlags (Header h, const rpmDepSet req)
313         /*@modifies h @*/;
314
315 /**
316  * Compare package name-version-release from header with a single dependency.
317  * @deprecated Remove from API when obsoletes is correctly implemented.
318  * @param h             header
319  * @param req           dependency
320  * @return              1 if dependency overlaps, 0 otherwise
321  */
322 int headerMatchesDepFlags(Header h, const rpmDepSet req)
323         /*@*/;
324
325 #ifdef __cplusplus
326 }
327 #endif
328
329 #endif  /* H_RPMDS */