- commit to using rpmDepSet and TFI_t, not header.
[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 struct sharedFileInfo_s *               sharedFileInfo;
12
13 /**
14  */
15 struct sharedFileInfo_s {
16     int pkgFileNum;
17     int otherFileNum;
18     int otherPkg;
19     int isRemoved;
20 };
21
22 /**
23  * A package filename set.
24  */
25 struct TFI_s {
26     int i;                      /*!< File index. */
27
28 /*@observer@*/
29     const char * Type;          /*!< Tag name. */
30
31     rpmTag tagN;                /*!< Header tag. */
32 /*@refcounted@*/ /*@null@*/
33     Header h;                   /*!< Header for file set (or NULL) */
34
35 /*@only@*/ /*?null?*/
36     const char ** bnl;          /*!< Base name(s) (from header) */
37 /*@only@*/ /*?null?*/
38     const char ** dnl;          /*!< Directory name(s) (from header) */
39
40 /*@only@*/ /*?null?*/
41     const char ** fmd5s;        /*!< File MD5 sum(s) (from header) */
42 /*@only@*/ /*?null?*/
43     const char ** flinks;       /*!< File link(s) (from header) */
44 /*@only@*/ /*?null?*/
45     const char ** flangs;       /*!< File lang(s) */
46
47 /*@only@*/ /*?null?*/
48           uint_32 * dil;        /*!< Directory indice(s) (from header) */
49 /*@only@*/ /*?null?*/
50     const uint_32 * fflags;     /*!< File flag(s) (from header) */
51 /*@only@*/ /*?null?*/
52     const uint_32 * fsizes;     /*!< File size(s) (from header) */
53 /*@only@*/ /*?null?*/
54     const uint_32 * fmtimes;    /*!< File modification time(s) (from header) */
55 /*@only@*/ /*?null?*/
56           uint_16 * fmodes;     /*!< File mode(s) (from header) */
57 /*@only@*/ /*?null?*/
58     const uint_16 * frdevs;     /*!< File rdev(s) (from header) */
59
60 /*@only@*/ /*@null@*/
61     const char ** fuser;        /*!< File owner(s) */
62 /*@only@*/ /*@null@*/
63     const char ** fgroup;       /*!< File group(s) */
64 /*@only@*/ /*@null@*/
65     uid_t * fuids;              /*!< File uid(s) */
66 /*@only@*/ /*@null@*/
67     gid_t * fgids;              /*!< File gid(s) */
68
69 /*@only@*/ /*@null@*/
70     char * fstates;             /*!< File state(s) (from header) */
71
72     int_32 dc;                  /*!< No. of directories. */
73     int_32 fc;                  /*!< No. of files. */
74
75 /*=============================*/
76 /*@dependent@*/
77     transactionElement te;
78
79     HGE_t hge;                  /*!< Vector to headerGetEntry() */
80     HAE_t hae;                  /*!< Vector to headerAddEntry() */
81     HME_t hme;                  /*!< Vector to headerModifyEntry() */
82     HRE_t hre;                  /*!< Vector to headerRemoveEntry() */
83     HFD_t hfd;                  /*!< Vector to headerFreeData() */
84 /*-----------------------------*/
85     uid_t uid;                  /*!< File uid (default). */
86     gid_t gid;                  /*!< File gid (default). */
87     uint_32 flags;              /*!< File flags (default). */
88     fileAction action;          /*!< File disposition (default). */
89 /*@owned@*/
90     fileAction * actions;       /*!< File disposition(s). */
91 /*@owned@*/
92     struct fingerPrint_s * fps; /*!< File fingerprint(s). */
93 /*@owned@*/
94     const char ** obnl;         /*!< Original basename(s) (from header) */
95 /*@owned@*/
96     const char ** odnl;         /*!< Original dirname(s) (from header) */
97 /*@unused@*/
98     int_32 * odil;              /*!< Original dirindex(s) (from header) */
99     int bnlmax;                 /*!< Length (in bytes) of longest basename. */
100     int dnlmax;                 /*!< Length (in bytes) of longest dirname. */
101     int astriplen;
102     int striplen;
103     unsigned int archiveSize;
104     mode_t dperms;              /*!< Directory perms (0755) if not mapped. */
105     mode_t fperms;              /*!< File perms (0644) if not mapped. */
106 /*@only@*/ /*@null@*/
107     const char ** apath;
108     int mapflags;
109 /*@owned@*/ /*@null@*/
110     int * fmapflags;
111 /*@owned@*/
112     FSM_t fsm;                  /*!< File state machine data. */
113     int keep_header;            /*!< Keep header? */
114 /*@owned@*/
115     sharedFileInfo replaced;    /*!< (TR_ADDED) */
116 /*@owned@*/
117     uint_32 * replacedSizes;    /*!< (TR_ADDED) */
118     unsigned int record;        /*!< (TR_REMOVED) */
119     int magic;
120 #define TFIMAGIC        0x09697923
121 /*=============================*/
122
123 /*@refs@*/ int nrefs;           /*!< Reference count. */
124 };
125
126 /**
127  * A package dependency set.
128  */
129 struct rpmDepSet_s {
130     int i;                      /*!< Element index. */
131
132 /*@observer@*/
133     const char * Type;          /*!< Tag name. */
134 /*@only@*/ /*@null@*/
135     const char * DNEVR;         /*!< Formatted dependency string. */
136
137     rpmTag tagN;                /*!< Header tag. */
138 /*@refcounted@*/ /*@null@*/
139     Header h;                   /*!< Header for dependency set (or NULL) */
140
141 /*@only@*/
142     const char ** N;            /*!< Name. */
143 /*@only@*/
144     const char ** EVR;          /*!< Epoch-Version-Release. */
145 /*@only@*/
146     int_32 * Flags;             /*!< Flags identifying context/comparison. */
147     rpmTagType Nt, EVRt, Ft;    /*!< Tag data types. */
148     int_32 Count;               /*!< No. of elements */
149 /*@refs@*/ int nrefs;           /*!< Reference count. */
150 };
151
152 #ifdef __cplusplus
153 extern "C" {
154 #endif
155
156 /**
157  * Unreference a file info set instance.
158  * @param fi            file info set
159  * @return              NULL always
160  */
161 /*@unused@*/ /*@null@*/
162 TFI_t rpmfiUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ TFI_t fi,
163                 /*@null@*/ const char * msg)
164         /*@modifies fi @*/;
165
166 /** @todo Remove debugging entry from the ABI. */
167 /*@-exportlocal@*/
168 /*@null@*/
169 TFI_t XrpmfiUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ TFI_t fi,
170                 /*@null@*/ const char * msg, const char * fn, unsigned ln)
171         /*@modifies fi @*/;
172 /*@=exportlocal@*/
173 #define rpmfiUnlink(_fi, _msg) XrpmfiUnlink(_fi, _msg, __FILE__, __LINE__)
174
175 /**
176  * Reference a file info set instance.
177  * @param fi            file info set
178  * @return              new file info set reference
179  */
180 /*@unused@*/
181 TFI_t rpmfiLink (/*@null@*/ TFI_t fi, /*@null@*/ const char * msg)
182         /*@modifies fi @*/;
183
184 /** @todo Remove debugging entry from the ABI. */
185 TFI_t XrpmfiLink (/*@null@*/ TFI_t fi, /*@null@*/ const char * msg,
186                 const char * fn, unsigned ln)
187         /*@modifies fi @*/;
188 #define rpmfiLink(_fi, _msg)    XrpmfiLink(_fi, _msg, __FILE__, __LINE__)
189
190 /**
191  * Retrieve key from transaction element file info
192  * @param fi            transaction element file info
193  * @return              transaction element file info key
194  */
195 /*@exposed@*/ /*@dependent@*/ /*@null@*/
196 fnpyKey rpmfiGetKey(TFI_t fi)
197         /*@*/;
198
199 /**
200  * Destroy a file set.
201  * @param fi            file set
202  * @param freefimem     free fi memory too?
203  * @return              NULL always
204  */
205 /*@null@*/
206 TFI_t fiFree(/*@killref@*/ /*@only@*/ /*@null@*/ TFI_t fi, int freefimem)
207         /*@modifies fi@*/;
208
209 /**
210  * Create and load a file set.
211  * @param ts            transaction set
212  * @param fi            file set (NULL if creating)
213  * @param h             header
214  * @param tagN          RPMTAG_BASENAMES
215  * @param scareMem      Use pointers to refcounted header memory?
216  * @return              new file set
217  */
218 /*@null@*/
219 TFI_t fiNew(rpmTransactionSet ts, /*@null@*/ TFI_t fi,
220                 Header h, rpmTag tagN, int scareMem)
221         /*@modifies ts, fi, h @*/;
222
223 /**
224  * Unreference a dependency set instance.
225  * @param ds            dependency set
226  * @return              NULL always
227  */
228 /*@unused@*/ /*@null@*/
229 rpmDepSet rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
230                 /*@null@*/ const char * msg)
231         /*@modifies ds @*/;
232
233 /** @todo Remove debugging entry from the ABI. */
234 /*@-exportlocal@*/
235 /*@null@*/
236 rpmDepSet XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
237                 /*@null@*/ const char * msg, const char * fn, unsigned ln)
238         /*@modifies ds @*/;
239 /*@=exportlocal@*/
240 #define rpmdsUnlink(_ds, _msg)  XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
241
242 /**
243  * Reference a dependency set instance.
244  * @param ds            dependency set
245  * @return              new dependency set reference
246  */
247 /*@unused@*/
248 rpmDepSet rpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg)
249         /*@modifies ds @*/;
250
251 /** @todo Remove debugging entry from the ABI. */
252 rpmDepSet XrpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg,
253                 const char * fn, unsigned ln)
254         /*@modifies ds @*/;
255 #define rpmdsLink(_ds, _msg)    XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
256
257 /**
258  * Destroy a dependency set.
259  * @param ds            dependency set
260  * @return              NULL always
261  */
262 /*@null@*/
263 rpmDepSet dsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds)
264         /*@modifies ds@*/;
265 /**
266  * Create and load a dependency set.
267  * @param h             header
268  * @param tagN          type of dependency
269  * @param scareMem      Use pointers to refcounted header memory?
270  * @return              new dependency set
271  */
272 /*@null@*/
273 rpmDepSet dsNew(Header h, rpmTag tagN, int scareMem)
274         /*@modifies h @*/;
275
276 /**
277  * Return new formatted dependency string.
278  * @param dspfx         formatted dependency string prefix
279  * @param ds            dependency set
280  * @return              new formatted dependency (malloc'ed)
281  */
282 /*@only@*/
283 char * dsDNEVR(const char * dspfx, const rpmDepSet ds)
284         /*@*/;
285
286 /**
287  * Create, load and initialize a dependency for this header. 
288  * @param h             header
289  * @param tagN          type of dependency
290  * @param Flags         comparison flags
291  * @return              new dependency set
292  */
293 /*@null@*/
294 rpmDepSet dsThis(Header h, rpmTag tagN, int_32 Flags)
295         /*@*/;
296
297 /**
298  * Create, load and initialize a dependency set of size 1.
299  * @param tagN          type of dependency
300  * @param N             name
301  * @param EVR           epoch:version-release
302  * @param Flags         comparison flags
303  * @return              new dependency set
304  */
305 /*@null@*/
306 rpmDepSet dsSingle(rpmTag tagN, const char * N, const char * EVR, int_32 Flags)
307         /*@*/;
308
309 /**
310  * Return dependency set count.
311  * @param ds            dependency set
312  * @return              current count
313  */
314 int dsiGetCount(/*@null@*/ rpmDepSet ds)
315         /*@*/;
316
317 /**
318  * Return dependency set index.
319  * @param ds            dependency set
320  * @return              current index
321  */
322 int dsiGetIx(/*@null@*/ rpmDepSet ds)
323         /*@*/;
324
325 /**
326  * Set dependency set index.
327  * @param ds            dependency set
328  * @param ix            new index
329  * @return              current index
330  */
331 int dsiSetIx(/*@null@*/ rpmDepSet ds, int ix)
332         /*@modifies ds @*/;
333
334 /**
335  * Return current formatted dependency string.
336  * @param ds            dependency set
337  * @return              current dependency DNEVR, NULL on invalid
338  */
339 /*@null@*/
340 const char * dsiGetDNEVR(/*@null@*/ rpmDepSet ds)
341         /*@*/;
342
343 /**
344  * Return current dependency name.
345  * @param ds            dependency set
346  * @return              current dependency name, NULL on invalid
347  */
348 /*@null@*/
349 const char * dsiGetN(/*@null@*/ rpmDepSet ds)
350         /*@*/;
351
352 /**
353  * Return current dependency epoch-version-release.
354  * @param ds            dependency set
355  * @return              current dependency EVR, NULL on invalid
356  */
357 /*@null@*/
358 const char * dsiGetEVR(/*@null@*/ rpmDepSet ds)
359         /*@*/;
360
361 /**
362  * Return current dependency Flags.
363  * @param ds            dependency set
364  * @return              current dependency EVR, 0 on invalid
365  */
366 int_32 dsiGetFlags(/*@null@*/ rpmDepSet ds)
367         /*@*/;
368
369 /**
370  * Notify of results of dependency match;
371  * @param ds            dependency set
372  * @param where         where dependency was resolved (or NULL)
373  * @param rc            0 == YES, otherwise NO
374  */
375 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
376 void dsiNotify(/*@null@*/ rpmDepSet ds, /*@null@*/ const char * where, int rc)
377         /*@globals fileSystem @*/
378         /*@modifies fileSystem @*/;
379 /*@=globuse@*/
380
381 /**
382  * Return next dependency set iterator index.
383  * @param ds            dependency set
384  * @return              dependency set iterator index, -1 on termination
385  */
386 int dsiNext(/*@null@*/ rpmDepSet ds)
387         /*@modifies ds @*/;
388
389 /**
390  * Initialize dependency set iterator.
391  * @param ds            dependency set
392  * @return              dependency set
393  */
394 /*@null@*/
395 rpmDepSet dsiInit(/*@returned@*/ /*@null@*/ rpmDepSet ds)
396         /*@modifies ds @*/;
397
398 /**
399  * Compare two versioned dependency ranges, looking for overlap.
400  * @param A             1st dependency
401  * @param B             2nd dependency
402  * @return              1 if dependencies overlap, 0 otherwise
403  */
404 int dsCompare(const rpmDepSet A, const rpmDepSet B)
405         /*@*/;
406
407 /**
408  * Report a Requires: or Conflicts: dependency problem.
409  */
410 void dsProblem(/*@null@*/ rpmProblemSet tsprobs,
411                 const char * pkgNEVR, const rpmDepSet ds,
412                 /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys)
413         /*@modifies tsprobs @*/;
414
415 /**
416  * Compare package provides dependencies from header with a single dependency.
417  * @param h             header
418  * @param ds            dependency set
419  */
420 int rangeMatchesDepFlags (Header h, const rpmDepSet req)
421         /*@modifies h @*/;
422
423 /**
424  * Compare package name-version-release from header with a single dependency.
425  * @deprecated Remove from API when obsoletes is correctly implemented.
426  * @param h             header
427  * @param req           dependency
428  * @return              1 if dependency overlaps, 0 otherwise
429  */
430 int headerMatchesDepFlags(const Header h, const rpmDepSet req)
431         /*@*/;
432
433 #ifdef __cplusplus
434 }
435 #endif
436
437 #endif  /* H_RPMDS */