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