rpm  4.5
rpmds.h
Go to the documentation of this file.
1 #ifndef H_RPMDS
2 #define H_RPMDS
3 
9 #include "rpmevr.h"
10 #define _RPMNS_INTERNAL
11 #include "rpmns.h"
12 #include "rpmps.h"
13 
16 /*@-exportlocal@*/
17 /*@unchecked@*/
18 extern int _rpmds_debug;
19 /*@=exportlocal@*/
20 
23 /*@-exportlocal@*/
24 /*@unchecked@*/
25 extern int _rpmds_nopromote;
26 /*@=exportlocal@*/
27 
28 #if defined(_RPMDS_INTERNAL)
29 
32 struct rpmds_s {
33 /*@observer@*/
34  const char * Type;
35 /*@only@*/ /*@null@*/
36  const char * DNEVR;
37 /*@refcounted@*/ /*@null@*/
38  Header h;
39 /*@only@*/ /*@relnull@*/
40  const char ** N;
41 /*@only@*/ /*@relnull@*/
42  const char ** EVR;
43 /*@only@*/ /*@relnull@*/
44  int_32 * Flags;
45 /*@only@*/ /*@null@*/
46  uint_32 * Color;
47 /*@only@*/ /*@null@*/
48  int_32 * Refs;
49 /*@only@*/ /*@null@*/
50  int_32 * Result;
51 /*@null@*/
52  int (*EVRparse) (const char *evrstr, EVR_t evr); /* EVR parsing. */
53  int (*EVRcmp) (const char *a, const char *b); /* EVR comparison. */
54  struct rpmns_s ns;
55 /*@only@*/ /*@null@*/
56  const char * A;
57  int_32 BT;
58  rpmTag tagN;
59  rpmTagType Nt, EVRt, Ft;
60  int_32 Count;
61  int i;
62  unsigned l;
63  unsigned u;
64  int nopromote;
65 /*@refs@*/
66  int nrefs;
67 };
68 #endif /* _RPMDS_INTERNAL */
69 
70 #if defined(_RPMPRCO_INTERNAL)
71 
74 struct rpmPRCO_s {
75 /*@dependent@*/ /*@relnull@*/
76  rpmds * Pdsp;
77 /*@dependent@*/ /*@relnull@*/
78  rpmds * Rdsp;
79 /*@dependent@*/ /*@relnull@*/
80  rpmds * Cdsp;
81 /*@dependent@*/ /*@relnull@*/
82  rpmds * Odsp;
83 /*@dependent@*/ /*@relnull@*/
84  rpmds * Tdsp;
85 /*@dependent@*/ /*@relnull@*/
86  rpmds * Ddsp;
87 /*@dependent@*/ /*@relnull@*/
88  rpmds * Ldsp;
89 /*@refcounted@*/ /*@null@*/
90  rpmds this;
91 /*@refcounted@*/ /*@null@*/
92  rpmds P;
93 /*@refcounted@*/ /*@null@*/
94  rpmds R;
95 /*@refcounted@*/ /*@null@*/
96  rpmds C;
97 /*@refcounted@*/ /*@null@*/
98  rpmds O;
99 /*@refcounted@*/ /*@null@*/
100  rpmds T;
101 /*@refcounted@*/ /*@null@*/
102  rpmds D;
103 /*@refcounted@*/ /*@null@*/
104  rpmds L;
105 };
106 #endif /* _RPMPRCO_INTERNAL */
107 
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111 
120 /*@unused@*/ /*@null@*/
121 rpmds rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds,
122  /*@null@*/ const char * msg)
123  /*@modifies ds @*/;
124 
126 /*@-exportlocal@*/
127 /*@null@*/
128 rpmds XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds,
129  /*@null@*/ const char * msg, const char * fn, unsigned ln)
130  /*@modifies ds @*/;
131 /*@=exportlocal@*/
132 #define rpmdsUnlink(_ds, _msg) XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
133 
140 /*@unused@*/ /*@newref@*/ /*@null@*/
141 rpmds rpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg)
142  /*@modifies ds @*/;
143 
145 /*@newref@*/ /*@null@*/
146 rpmds XrpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg,
147  const char * fn, unsigned ln)
148  /*@modifies ds @*/;
149 #define rpmdsLink(_ds, _msg) XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
150 
156 /*@null@*/
157 rpmds rpmdsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds)
158  /*@modifies ds @*/;
166 /*@null@*/
167 rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
168  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
169  /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
170 
176 const char * rpmdsNewN(rpmds ds)
177  /*@globals rpmGlobalMacroContext, h_errno @*/
178  /*@modifies ds, rpmGlobalMacroContext @*/;
179 
186 char * rpmdsNewDNEVR(const char * dspfx, rpmds ds)
187  /*@globals rpmGlobalMacroContext, h_errno @*/
188  /*@modifies ds, rpmGlobalMacroContext @*/;
189 
197 /*@null@*/
198 rpmds rpmdsThis(Header h, rpmTag tagN, int_32 Flags)
199  /*@*/;
200 
209 /*@null@*/
210 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, int_32 Flags)
211  /*@*/;
212 
218 int rpmdsCount(/*@null@*/ const rpmds ds)
219  /*@*/;
220 
226 int rpmdsIx(/*@null@*/ const rpmds ds)
227  /*@*/;
228 
235 int rpmdsSetIx(/*@null@*/ rpmds ds, int ix)
236  /*@modifies ds @*/;
237 
243 /*@observer@*/ /*@relnull@*/
244 extern const char * rpmdsDNEVR(/*@null@*/ const rpmds ds)
245  /*@*/;
246 
252 /*@observer@*/ /*@null@*/
253 extern const char * rpmdsN(/*@null@*/ rpmds ds)
254  /*@*/;
255 
261 /*@observer@*/ /*@relnull@*/
262 extern const char * rpmdsEVR(/*@null@*/ const rpmds ds)
263  /*@*/;
264 
270 int_32 rpmdsFlags(/*@null@*/ const rpmds ds)
271  /*@*/;
272 
278 rpmTag rpmdsTagN(/*@null@*/ const rpmds ds)
279  /*@*/;
280 
286 /*@observer@*/ /*@relnull@*/
287 extern const char * rpmdsA(/*@null@*/ const rpmds ds)
288  /*@*/;
289 
295 time_t rpmdsBT(/*@null@*/ const rpmds ds)
296  /*@*/;
297 
304 time_t rpmdsSetBT(/*@null@*/ const rpmds ds, time_t BT)
305  /*@modifies ds @*/;
306 
312 nsType rpmdsNSType(/*@null@*/ const rpmds ds)
313  /*@*/;
314 
328 int rpmdsNoPromote(/*@null@*/ const rpmds ds)
329  /*@*/;
330 
337 int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
338  /*@modifies ds @*/;
339 
346 /*@null@*/
347 void * rpmdsSetEVRparse(/*@null@*/ rpmds ds,
348  /*@null@*/ int (*EVRparse)(const char *everstr, EVR_t evr))
349  /*@modifies ds @*/;
350 
357 /*@null@*/
358 void * rpmdsSetEVRcmp(/*@null@*/ rpmds ds,
359  /*@null@*/ int (*EVRcmp)(const char *a, const char *b))
360  /*@modifies ds @*/;
361 
367 uint_32 rpmdsColor(/*@null@*/ const rpmds ds)
368  /*@*/;
369 
376 uint_32 rpmdsSetColor(/*@null@*/ const rpmds ds, uint_32 color)
377  /*@modifies ds @*/;
378 
384 int_32 rpmdsRefs(/*@null@*/ const rpmds ds)
385  /*@*/;
386 
393 int_32 rpmdsSetRefs(/*@null@*/ const rpmds ds, int_32 refs)
394  /*@modifies ds @*/;
395 
401 int_32 rpmdsResult(/*@null@*/ const rpmds ds)
402  /*@*/;
403 
410 int_32 rpmdsSetResult(/*@null@*/ const rpmds ds, int_32 result)
411  /*@modifies ds @*/;
412 
419 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
420 void rpmdsNotify(/*@null@*/ rpmds ds, /*@null@*/ const char * where, int rc)
421  /*@globals fileSystem @*/
422  /*@modifies fileSystem @*/;
423 /*@=globuse@*/
424 
430 int rpmdsNext(/*@null@*/ rpmds ds)
431  /*@modifies ds @*/;
432 
438 /*@null@*/
439 rpmds rpmdsInit(/*@null@*/ rpmds ds)
440  /*@modifies ds @*/;
441 
448 int rpmdsFind(rpmds ds, /*@null@*/ const rpmds ods)
449  /*@modifies ds @*/;
450 
457 int rpmdsMerge(/*@null@*/ /*@out@*/ rpmds * dsp, /*@null@*/ rpmds ods)
458  /*@modifies *dsp, ods @*/;
459 
468 int rpmdsSearch(/*@null@*/ rpmds ds, /*@null@*/ rpmds ods)
469  /*@modifies ds, ods @*/;
470 
477 int rpmdsCpuinfo(/*@out@*/ rpmds * dsp, /*@null@*/ const char * fn)
478  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
479  /*@modifies *dsp, rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/;
480 
487 int rpmdsRpmlib(rpmds * dsp, /*@null@*/ void * tblp)
488  /*@modifies *dsp @*/;
489 
496 int rpmdsSysinfo(rpmPRCO PRCO, /*@null@*/ const char * fn)
497  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
498  /*@modifies PRCO, rpmGlobalMacroContext, h_errno,
499  fileSystem, internalState @*/;
500 
507 int rpmdsGetconf(rpmds * dsp, /*@null@*/ const char * path)
508  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
509  /*@modifies *dsp, rpmGlobalMacroContext, h_errno,
510  fileSystem, internalState @*/;
511 
518 int rpmdsMergePRCO(void * context, rpmds ds)
519  /*@modifies context, ds @*/;
520 
526 /*@null@*/
527 rpmPRCO rpmdsFreePRCO(/*@only@*/ /*@null@*/ rpmPRCO PRCO)
528  /*@modifies PRCO @*/;
529 
535 rpmPRCO rpmdsNewPRCO(/*@null@*/ Header h)
536  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
537  /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
538 
545 /*@null@*/
546 rpmds rpmdsFromPRCO(/*@null@*/ rpmPRCO PRCO, rpmTag tagN)
547  /*@*/;
548 
557 int rpmdsELF(const char * fn, int flags,
558  int (*add) (void * context, rpmds ds), void * context)
559  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
560  /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
561 #define RPMELF_FLAG_SKIPPROVIDES 0x1 /*<! rpmdsELF: skip provides */
562 #define RPMELF_FLAG_SKIPREQUIRES 0x2 /*<! rpmdsELF: skip requires */
563 
571 int rpmdsLdconfig(rpmPRCO PRCO, /*@null@*/ const char * fn)
572  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
573  /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
574 
575 #if defined(__sun)
576 
585 int rpmdsRldpath(rpmPRCO PRCO, /*@null@*/ const char * rldp)
586  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
587  /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
588 
597 int rpmdsCrle(rpmPRCO PRCO, /*@null@*/ const char * fn)
598  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
599  /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
600 #endif
601 
608 int rpmdsUname(rpmds * dsp, /*@null@*/ const struct utsname * un)
609  /*@globals internalState @*/
610  /*@modifies *dsp, internalState @*/;
611 
619 int rpmdsPipe(rpmds * dsp, int_32 tagN, /*@null@*/ const char * cmd)
620  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
621  /*@modifies *dsp, rpmGlobalMacroContext, h_errno,
622  fileSystem, internalState @*/;
623 
630 int rpmdsCompare(const rpmds A, const rpmds B)
631  /*@*/;
632 
641 void rpmdsProblem(/*@null@*/ rpmps ps, const char * pkgNEVR, const rpmds ds,
642  /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys,
643  int adding)
644  /*@modifies ps @*/;
645 
653 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote)
654  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
655  /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
656 
664 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote)
665  /*@*/;
666 
673 int rpmdsNegateRC(const rpmds ds, int rc)
674  /*@*/;
675 
676 #if !defined(SWIG)
677 
682 /*@unused@*/ static inline /*@observer@*/
683 const char * rpmdsTagName(/*@null@*/ const rpmds ds)
684  /*@*/
685 {
686  int tagN = rpmdsTagN(ds);
687 
688  switch (tagN) {
689  case RPMTAG_PROVIDENAME: return "Provides"; /*@notreached@*/ break;
690  case RPMTAG_REQUIRENAME: return "Requires"; /*@notreached@*/ break;
691  case RPMTAG_CONFLICTNAME: return "Conflicts"; /*@notreached@*/ break;
692  case RPMTAG_OBSOLETENAME: return "Obsoletes"; /*@notreached@*/ break;
693  case RPMTAG_TRIGGERNAME: return "Triggers"; /*@notreached@*/ break;
694  case RPMTAG_DIRNAMES: return "Dirnames"; /*@notreached@*/ break;
695  }
696  return tagName(tagN);
697 }
698 
705 /*@unused@*/ static inline
706 int rpmdsPrint(/*@null@*/ rpmds ds, /*@null@*/ FILE * fp)
707  /*@globals fileSystem @*/
708  /*@modifies ds, *fp, fileSystem @*/
709 {
710  if (fp == NULL)
711  fp = stderr;
712  ds = rpmdsInit(ds);
713  while (rpmdsNext(ds) >= 0)
714  fprintf(fp, "%6d\t%s: %s\n", rpmdsIx(ds), rpmdsTagName(ds), rpmdsDNEVR(ds)+2);
715  return 0;
716 }
717 
724 /*@unused@*/ static inline
725 int rpmdsPrintResults(/*@null@*/ rpmds ds, /*@null@*/ FILE * fp)
726  /*@globals fileSystem @*/
727  /*@modifies ds, *fp, fileSystem @*/
728 {
729  if (fp == NULL)
730  fp = stderr;
731  ds = rpmdsInit(ds);
732  while (rpmdsNext(ds) >= 0) {
733  int rc = rpmdsResult(ds);
734  if (rc > 0)
735  continue;
736  fprintf(fp, "%6d\t%s: %s\n", rpmdsIx(ds), rpmdsTagName(ds), rpmdsDNEVR(ds)+2);
737  }
738  return 0;
739 }
740 
748 /*@-mods@*/ /* XXX LCL wonky */
749 /*@unused@*/ static inline
750 int rpmdsPrintClosure(/*@null@*/ rpmds P, /*@null@*/ rpmds R,
751  /*@null@*/ FILE * fp)
752  /*@globals fileSystem @*/
753  /*@modifies P, R, *fp, fileSystem @*/
754 {
755  int rc;
756 
757  /* Allocate the R results array (to be filled in by rpmdsSearch). */
758  (void) rpmdsSetResult(R, 0); /* allocate result array. */
759 
760  /* Collect the rpmdsSearch results (in the R dependency set). */
761  R = rpmdsInit(R);
762  while (rpmdsNext(R) >= 0)
763  rc = rpmdsSearch(P, R);
764 
765  return rpmdsPrintResults(R, fp);
766 }
767 /*@=mods@*/
768 #endif
769 
771 #ifdef __cplusplus
772 }
773 #endif
774 
775 #endif /* H_RPMDS */