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