rpm  4.5
rpmte.h
Go to the documentation of this file.
1 #ifndef H_RPMTE
2 #define H_RPMTE
3 
8 #include <argv.h>
9 
12 /*@-exportlocal@*/
13 /*@unchecked@*/
14 extern int _rpmte_debug;
15 /*@=exportlocal@*/
16 
20 typedef /*@abstract@*/ struct tsortInfo_s * tsortInfo;
21 
25 typedef /*@abstract@*/ struct rpmtsi_s * rpmtsi;
26 
30 typedef enum rpmElementType_e {
31  TR_ADDED = (1 << 0),
32  TR_REMOVED = (1 << 1)
34 
35 #if defined(_RPMTE_INTERNAL)
36 
39 /*@-fielduse@*/ /* LCL: confused by union? */
40 struct tsortInfo_s {
41  union {
42  int count;
43  /*@exposed@*/ /*@dependent@*/ /*@null@*/
44  rpmte suc;
45  } tsi_u;
46 #define tsi_count tsi_u.count
47 #define tsi_suc tsi_u.suc
48 /*@owned@*/ /*@null@*/
49  tsortInfo tsi_next;
50 /*@exposed@*/ /*@dependent@*/ /*@null@*/
51  rpmte tsi_chain;
52  int tsi_tagn;
53  int tsi_reqx;
54  int tsi_queued;
55  int tsi_qcnt;
56 };
57 /*@=fielduse@*/
58 
62 struct rpmChainLink_s {
63 /*@only@*/ /*@null@*/
64  ARGV_t Pkgid;
65 /*@only@*/ /*@null@*/
66  ARGV_t Hdrid;
67 /*@only@*/ /*@null@*/
68  ARGV_t NEVRA;
69 };
70 
74 struct rpmte_s {
75  rpmElementType type;
77 /*@refcounted@*/ /*@relnull@*/
78  Header h;
79 /*@only@*/
80  const char * NEVR;
81 /*@only@*/
82  const char * NEVRA;
83 /*@only@*/ /*@relnull@*/
84  const char * pkgid;
85 /*@only@*/ /*@relnull@*/
86  const char * hdrid;
87 /*@owned@*/
88  const char * name;
89 /*@only@*/ /*@null@*/
90  char * epoch;
91 /*@dependent@*/ /*@null@*/
92  char * version;
93 /*@dependent@*/ /*@null@*/
94  char * release;
95 /*@only@*/ /*@null@*/
96  const char * arch;
97 /*@only@*/ /*@null@*/
98  const char * os;
99  int isSource;
101  rpmte parent;
102  int degree;
103  int npreds;
104  int tree;
105  int depth;
106  int breadth;
107  unsigned int db_instance;
108 /*@owned@*/
109  tsortInfo tsi;
111 /*@null@*/
112  rpmPRCO PRCO;
114 /*@refcounted@*/ /*@null@*/
115  rpmfi fi;
117  uint_32 color;
118  uint_32 pkgFileSize;
120 /*@exposed@*/ /*@dependent@*/ /*@null@*/
121  fnpyKey key;
122 /*@owned@*/ /*@null@*/
123  rpmRelocation relocs;
124  int nrelocs;
125  int autorelocatex;
126 /*@refcounted@*/ /*@null@*/
127  FD_t fd;
129  struct rpmChainLink_s blink;
130  struct rpmChainLink_s flink;
131  int linkFailed;
132  int done;
134  int installed;
135  int downgrade;
137  struct {
138 /*@exposed@*/ /*@dependent@*/ /*@null@*/
139  alKey addedKey;
140  struct {
141 /*@exposed@*/ /*@dependent@*/ /*@null@*/
142  alKey dependsOnKey;
143  int dboffset;
144  } removed;
145  } u;
146 
147 };
148 
152 struct rpmtsi_s {
153 /*@refcounted@*/
154  rpmts ts;
155  int reverse;
156  int ocsave;
157  int oc;
158 };
159 
160 #endif /* _RPMTE_INTERNAL */
161 
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165 
171 /*@null@*/
172 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
173  /*@globals fileSystem @*/
174  /*@modifies te, fileSystem @*/;
175 
187 /*@only@*/ /*@null@*/
188 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
189  /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
190  /*@null@*/ rpmRelocation relocs,
191  int dboffset,
192  /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
193  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
194  /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
195 
201 extern Header rpmteHeader(rpmte te)
202  /*@modifies te @*/;
203 
210 extern Header rpmteSetHeader(rpmte te, Header h)
211  /*@modifies te, h @*/;
212 
219  /*@*/;
220 
226 /*@observer@*/
227 extern const char * rpmteN(rpmte te)
228  /*@*/;
229 
235 /*@observer@*/ /*@null@*/
236 extern const char * rpmteE(rpmte te)
237  /*@*/;
238 
244 /*@observer@*/ /*@null@*/
245 extern const char * rpmteV(rpmte te)
246  /*@*/;
247 
253 /*@observer@*/ /*@null@*/
254 extern const char * rpmteR(rpmte te)
255  /*@*/;
256 
262 /*@observer@*/ /*@null@*/
263 extern const char * rpmteA(rpmte te)
264  /*@*/;
265 
271 /*@observer@*/ /*@null@*/
272 extern const char * rpmteO(rpmte te)
273  /*@*/;
274 
280 extern int rpmteIsSource(rpmte te)
281  /*@*/;
282 
289  /*@*/;
290 
298  /*@modifies te @*/;
299 
305 unsigned int rpmteDBInstance(rpmte te)
306  /*@*/;
307 
314 void rpmteSetDBInstance(rpmte te, unsigned int instance)
315  /*@modifies te @*/;
316 
324  /*@*/;
325 
331 int rpmteDepth(rpmte te)
332  /*@*/;
333 
340 int rpmteSetDepth(rpmte te, int ndepth)
341  /*@modifies te @*/;
342 
348 int rpmteBreadth(rpmte te)
349  /*@*/;
350 
357 int rpmteSetBreadth(rpmte te, int nbreadth)
358  /*@modifies te @*/;
359 
365 int rpmteNpreds(rpmte te)
366  /*@*/;
367 
374 int rpmteSetNpreds(rpmte te, int npreds)
375  /*@modifies te @*/;
376 
382 int rpmteTree(rpmte te)
383  /*@*/;
384 
391 int rpmteSetTree(rpmte te, int ntree)
392  /*@modifies te @*/;
393 
399 /*@observer@*/ /*@unused@*/
401  /*@*/;
402 
409 /*@null@*/
411  /*@modifies te @*/;
412 
418 int rpmteDegree(rpmte te)
419  /*@*/;
420 
427 int rpmteSetDegree(rpmte te, int ndegree)
428  /*@modifies te @*/;
429 
436  /*@*/;
437 
442 void rpmteFreeTSI(rpmte te)
443  /*@modifies te @*/;
444 
449 void rpmteNewTSI(rpmte te)
450  /*@modifies te @*/;
451 
456 /*@unused@*/
457 void rpmteCleanDS(rpmte te)
458  /*@modifies te @*/;
459 
465 /*@exposed@*/ /*@dependent@*/ /*@null@*/
467  /*@*/;
468 
475 /*@exposed@*/ /*@dependent@*/ /*@null@*/
477  /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
478  /*@modifies te @*/;
479 
485 int rpmteDBOffset(rpmte te)
486  /*@*/;
487 
493 /*@observer@*/
494 extern const char * rpmteNEVR(rpmte te)
495  /*@*/;
496 
502 /*@-exportlocal@*/
503 /*@observer@*/
504 extern const char * rpmteNEVRA(rpmte te)
505  /*@*/;
506 /*@=exportlocal@*/
507 
513 /*@-exportlocal@*/
514 /*@observer@*/ /*@null@*/
515 extern const char * rpmtePkgid(rpmte te)
516  /*@*/;
517 /*@=exportlocal@*/
518 
524 /*@-exportlocal@*/
525 /*@observer@*/ /*@null@*/
526 extern const char * rpmteHdrid(rpmte te)
527  /*@*/;
528 /*@=exportlocal@*/
529 
535 FD_t rpmteFd(rpmte te)
536  /*@*/;
537 
543 /*@exposed@*/
545  /*@*/;
546 
553 rpmds rpmteDS(rpmte te, rpmTag tag)
554  /*@*/;
555 
562 rpmfi rpmteFI(rpmte te, rpmTag tag)
563  /*@*/;
564 
570 /*@-exportlocal@*/
571 void rpmteColorDS(rpmte te, rpmTag tag)
572  /*@modifies te @*/;
573 /*@=exportlocal@*/
574 
583 int rpmteChain(rpmte p, rpmte q, Header oh, /*@null@*/ const char * msg)
584  /*@modifies p, q, oh @*/;
585 
586 #define RPMTE_CHAIN_END "CHAIN END"
593 int rpmtsiOc(rpmtsi tsi)
594  /*@*/;
595 
601 /*@unused@*/ /*@null@*/
602 rpmtsi rpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi)
603  /*@globals fileSystem @*/
604  /*@modifies fileSystem @*/;
605 
613 /*@null@*/
614 rpmtsi XrpmtsiFree(/*@only@*//*@null@*/ rpmtsi tsi,
615  const char * fn, unsigned int ln)
616  /*@globals fileSystem @*/
617  /*@modifies fileSystem @*/;
618 #define rpmtsiFree(_tsi) XrpmtsiFree(_tsi, __FILE__, __LINE__)
619 
625 /*@unused@*/ /*@only@*/
627  /*@modifies ts @*/;
628 
636 /*@unused@*/ /*@only@*/
638  const char * fn, unsigned int ln)
639  /*@modifies ts @*/;
640 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
641 
648 /*@dependent@*/ /*@null@*/
650  /*@modifies tsi @*/;
651 
652 #if !defined(SWIG)
653 #if defined(_RPMTE_INTERNAL)
654 static inline void rpmtePrintID(rpmte p)
655  /*@globals fileSystem @*/
656  /*@modifies fileSystem @*/
657 {
658  if (p != NULL) {
659  if (p->blink.Pkgid) argvPrint("blink.Pkgid", p->blink.Pkgid, NULL);
660  if (p->blink.Hdrid) argvPrint("blink.Hdrid", p->blink.Hdrid, NULL);
661  if (p->blink.NEVRA) argvPrint("blink.NEVRA", p->blink.NEVRA, NULL);
662  if (p->flink.Pkgid) argvPrint("flink.Pkgid", p->flink.Pkgid, NULL);
663  if (p->flink.Hdrid) argvPrint("flink.Hdrid", p->flink.Hdrid, NULL);
664  if (p->flink.NEVRA) argvPrint("flink.NEVRA", p->flink.NEVRA, NULL);
665  }
666 };
667 #endif
668 
669 static inline void hdrPrintInstalled(Header h)
670  /*@globals fileSystem @*/
671  /*@modifies fileSystem @*/
672 {
673  const char * qfmt = "[%{erasednevra} O:%{packageorigin} P:%{erasedpkgid} H:%{erasedhdrid}\n]";
674  const char * errstr = "(unknown error)";
675 /*@-modobserver@*/
676  const char * str = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errstr);
677 /*@=modobserver@*/
678 
679  if (str == NULL)
680  fprintf(stderr, "error: %s\n", errstr);
681  else {
682  fprintf(stderr, "%s", str);
683  str = _free(str);
684  }
685 }
686 
687 static inline void hdrPrintErased(Header h)
688  /*@globals fileSystem @*/
689  /*@modifies fileSystem @*/
690 {
691  const char * qfmt = "[%{installednevra} O:%{packageorigin} P:%{installedpkgid} H:%{installedhdrid}\n]";
692  const char * errstr = "(unknown error)";
693 /*@-modobserver@*/
694  const char * str = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errstr);
695 /*@=modobserver@*/
696  if (str == NULL)
697  fprintf(stderr, "error: %s\n", errstr);
698  else {
699  fprintf(stderr, "%s", str);
700  str = _free(str);
701  }
702 }
703 #endif
704 
705 #ifdef __cplusplus
706 }
707 #endif
708 
709 #endif /* H_RPMTE */