Replace loadFi with fiNew, freeFi with fiFree.
[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 rpmFNSet_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 fns           file info set
159  * @return              NULL always
160  */
161 /*@unused@*/ /*@null@*/
162 rpmFNSet rpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
163                 /*@null@*/ const char * msg)
164         /*@modifies fns @*/;
165
166 /** @todo Remove debugging entry from the ABI. */
167 /*@-exportlocal@*/
168 /*@null@*/
169 rpmFNSet XrpmfnsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fns,
170                 /*@null@*/ const char * msg, const char * fn, unsigned ln)
171         /*@modifies fns @*/;
172 /*@=exportlocal@*/
173 #define rpmfnsUnlink(_fns, _msg) XrpmfnsUnlink(_fns, _msg, __FILE__, __LINE__)
174
175 /**
176  * Reference a file info set instance.
177  * @param fns           file info set
178  * @return              new file info set reference
179  */
180 /*@unused@*/
181 rpmFNSet rpmfnsLink (/*@null@*/ rpmFNSet fns, /*@null@*/ const char * msg)
182         /*@modifies fns @*/;
183
184 /** @todo Remove debugging entry from the ABI. */
185 rpmFNSet XrpmfnsLink (/*@null@*/ rpmFNSet fns, /*@null@*/ const char * msg,
186                 const char * fn, unsigned ln)
187         /*@modifies fns @*/;
188 #define rpmfnsLink(_fns, _msg)  XrpmfnsLink(_fns, _msg, __FILE__, __LINE__)
189
190 /**
191  * Destroy a file set.
192  * @param fi            file set
193  * @param freefimem     free fi memory too?
194  * @return              NULL always
195  */
196 /*@null@*/
197 rpmFNSet fiFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmFNSet fi, int freefimem)
198         /*@modifies fi@*/;
199
200 /**
201  * Create and load a file set.
202  * @param ts            transaction set
203  * @param fi            file set (NULL if creating)
204  * @param h             header
205  * @param tagN          RPMTAG_BASENAMES
206  * @param scareMem      Use pointers to refcounted header memory?
207  * @return              new file set
208  */
209 /*@null@*/
210 rpmFNSet fiNew(rpmTransactionSet ts, /*@null@*/ rpmFNSet fi,
211                 Header h, rpmTag tagN, int scareMem)
212         /*@modifies ts, fi, h @*/;
213
214 /**
215  * Unreference a dependency set instance.
216  * @param ds            dependency set
217  * @return              NULL always
218  */
219 /*@unused@*/ /*@null@*/
220 rpmDepSet rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
221                 /*@null@*/ const char * msg)
222         /*@modifies ds @*/;
223
224 /** @todo Remove debugging entry from the ABI. */
225 /*@-exportlocal@*/
226 /*@null@*/
227 rpmDepSet XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds,
228                 /*@null@*/ const char * msg, const char * fn, unsigned ln)
229         /*@modifies ds @*/;
230 /*@=exportlocal@*/
231 #define rpmdsUnlink(_ds, _msg)  XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
232
233 /**
234  * Reference a dependency set instance.
235  * @param ds            dependency set
236  * @return              new dependency set reference
237  */
238 /*@unused@*/
239 rpmDepSet rpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg)
240         /*@modifies ds @*/;
241
242 /** @todo Remove debugging entry from the ABI. */
243 rpmDepSet XrpmdsLink (/*@null@*/ rpmDepSet ds, /*@null@*/ const char * msg,
244                 const char * fn, unsigned ln)
245         /*@modifies ds @*/;
246 #define rpmdsLink(_ds, _msg)    XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
247
248 /**
249  * Destroy a dependency set.
250  * @param ds            dependency set
251  * @return              NULL always
252  */
253 /*@null@*/
254 rpmDepSet dsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmDepSet ds)
255         /*@modifies ds@*/;
256 /**
257  * Create and load a dependency set.
258  * @param h             header
259  * @param tagN          type of dependency
260  * @param scareMem      Use pointers to refcounted header memory?
261  * @return              new dependency set
262  */
263 /*@null@*/
264 rpmDepSet dsNew(Header h, rpmTag tagN, int scareMem)
265         /*@modifies h @*/;
266
267 /**
268  * Return new formatted dependency string.
269  * @param dspfx         formatted dependency string prefix
270  * @param ds            dependency set
271  * @return              new formatted dependency (malloc'ed)
272  */
273 /*@only@*/
274 char * dsDNEVR(const char * dspfx, const rpmDepSet ds)
275         /*@*/;
276
277 /**
278  * Create, load and initialize a dependency for this header. 
279  * @param h             header
280  * @param tagN          type of dependency
281  * @param Flags         comparison flags
282  * @return              new dependency set
283  */
284 /*@null@*/
285 rpmDepSet dsThis(Header h, rpmTag tagN, int_32 Flags)
286         /*@*/;
287
288 /**
289  * Create, load and initialize a dependency set of size 1.
290  * @param tagN          type of dependency
291  * @param N             name
292  * @param EVR           epoch:version-release
293  * @param Flags         comparison flags
294  * @return              new dependency set
295  */
296 /*@null@*/
297 rpmDepSet dsSingle(rpmTag tagN, const char * N, const char * EVR, int_32 Flags)
298         /*@*/;
299
300 /**
301  * Return dependency set count.
302  * @param ds            dependency set
303  * @return              current count
304  */
305 int dsiGetCount(/*@null@*/ rpmDepSet ds)
306         /*@*/;
307
308 /**
309  * Return dependency set index.
310  * @param ds            dependency set
311  * @return              current index
312  */
313 int dsiGetIx(/*@null@*/ rpmDepSet ds)
314         /*@*/;
315
316 /**
317  * Set dependency set index.
318  * @param ds            dependency set
319  * @param ix            new index
320  * @return              current index
321  */
322 int dsiSetIx(/*@null@*/ rpmDepSet ds, int ix)
323         /*@modifies ds @*/;
324
325 /**
326  * Return current formatted dependency string.
327  * @param ds            dependency set
328  * @return              current dependency DNEVR, NULL on invalid
329  */
330 /*@null@*/
331 const char * dsiGetDNEVR(/*@null@*/ rpmDepSet ds)
332         /*@*/;
333
334 /**
335  * Return current dependency name.
336  * @param ds            dependency set
337  * @return              current dependency name, NULL on invalid
338  */
339 /*@null@*/
340 const char * dsiGetN(/*@null@*/ rpmDepSet ds)
341         /*@*/;
342
343 /**
344  * Return current dependency epoch-version-release.
345  * @param ds            dependency set
346  * @return              current dependency EVR, NULL on invalid
347  */
348 /*@null@*/
349 const char * dsiGetEVR(/*@null@*/ rpmDepSet ds)
350         /*@*/;
351
352 /**
353  * Return current dependency Flags.
354  * @param ds            dependency set
355  * @return              current dependency EVR, 0 on invalid
356  */
357 int_32 dsiGetFlags(/*@null@*/ rpmDepSet ds)
358         /*@*/;
359
360 /**
361  * Notify of results of dependency match;
362  * @param ds            dependency set
363  * @param where         where dependency was resolved (or NULL)
364  * @param rc            0 == YES, otherwise NO
365  */
366 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
367 void dsiNotify(/*@null@*/ rpmDepSet ds, /*@null@*/ const char * where, int rc)
368         /*@globals fileSystem @*/
369         /*@modifies fileSystem @*/;
370 /*@=globuse@*/
371
372 /**
373  * Return next dependency set iterator index.
374  * @param ds            dependency set
375  * @return              dependency set iterator index, -1 on termination
376  */
377 int dsiNext(/*@null@*/ rpmDepSet ds)
378         /*@modifies ds @*/;
379
380 /**
381  * Initialize dependency set iterator.
382  * @param ds            dependency set
383  * @return              dependency set
384  */
385 /*@null@*/
386 rpmDepSet dsiInit(/*@returned@*/ /*@null@*/ rpmDepSet ds)
387         /*@modifies ds @*/;
388
389 /**
390  * Compare two versioned dependency ranges, looking for overlap.
391  * @param A             1st dependency
392  * @param B             2nd dependency
393  * @return              1 if dependencies overlap, 0 otherwise
394  */
395 int dsCompare(const rpmDepSet A, const rpmDepSet B)
396         /*@*/;
397
398 /**
399  * Report a Requires: or Conflicts: dependency problem.
400  */
401 void dsProblem(/*@null@*/ rpmProblemSet tsprobs,
402                 const char * pkgNEVR, const rpmDepSet ds,
403                 /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys)
404         /*@modifies tsprobs @*/;
405
406 /**
407  * Compare package provides dependencies from header with a single dependency.
408  * @param h             header
409  * @param ds            dependency set
410  */
411 int rangeMatchesDepFlags (Header h, const rpmDepSet req)
412         /*@modifies h @*/;
413
414 /**
415  * Compare package name-version-release from header with a single dependency.
416  * @deprecated Remove from API when obsoletes is correctly implemented.
417  * @param h             header
418  * @param req           dependency
419  * @return              1 if dependency overlaps, 0 otherwise
420  */
421 int headerMatchesDepFlags(const Header h, const rpmDepSet req)
422         /*@*/;
423
424 #ifdef __cplusplus
425 }
426 #endif
427
428 #endif  /* H_RPMDS */