rpm  5.4.10
rpmte.h
Go to the documentation of this file.
1 #ifndef H_RPMTE
2 #define H_RPMTE
3 
8 #include <rpmfi.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@*/ /*@refcounted@*/ 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 #include <argv.h>
37 #include <rpmtxn.h>
38 #include <rpmal.h>
39 
40 typedef struct relation_s * relation;
41 
42 #if defined(_RPMTS_ORDER_INTERNAL)
43 struct relation_s {
44  rpmte rel_suc; // pkg requiring this package
45  rpmsenseFlags rel_flags; // accumulated flags of the requirements
46  struct relation_s * rel_next;
47 };
48 #endif
49 
53 /*@-fielduse@*/ /* LCL: confused by union? */
54 struct tsortInfo_s {
55 /*@owned@*/ /*@null@*/
56  tsortInfo tsi_next;
57 /*@exposed@*/ /*@dependent@*/ /*@null@*/
58  rpmte tsi_chain;
59  int tsi_tagn;
60  int tsi_queued;
61 
62  int tsi_count;
63  int tsi_qcnt;
64  int tsi_reqx;
65  relation tsi_relations;
66  relation tsi_forward_relations;
67  rpmte tsi_suc;
68  int tsi_SccIdx;
69  int tsi_SccLowlink;
70 };
71 /*@=fielduse@*/
72 
76 struct rpmChainLink_s {
77 /*@only@*/ /*@null@*/
78  ARGV_t Pkgid;
79 /*@only@*/ /*@null@*/
80  ARGV_t Hdrid;
81 /*@only@*/ /*@null@*/
82  ARGV_t NEVRA;
83 };
84 
87 typedef struct sharedFileInfo_s * sharedFileInfo;
88 
92 struct sharedFileInfo_s {
93  rpmuint32_t pkgFileNum;
94  rpmuint32_t otherFileNum;
95  rpmuint32_t otherPkg;
96  rpmuint32_t isRemoved;
97 };
98 
102 struct rpmte_s {
103  struct rpmioItem_s _item;
104  rpmElementType type;
106 /*@refcounted@*/ /*@relnull@*/
107  Header h;
108 /*@only@*/
109  const char * NEVR;
110 /*@only@*/
111  const char * NEVRA;
112 /*@only@*/ /*@relnull@*/
113  const char * pkgid;
114 /*@only@*/ /*@relnull@*/
115  const char * hdrid;
116 /*@only@*/ /*@null@*/
117  const char * sourcerpm;
118 /*@only@*/
119  const char * name;
120 /*@only@*/ /*@null@*/
121  char * epoch;
122 /*@only@*/ /*@null@*/
123  char * version;
124 /*@only@*/ /*@null@*/
125  char * release;
126 #ifdef RPM_VENDOR_MANDRIVA
127 /*@only@*/ /*@null@*/
128  char * distepoch;
129 #endif
130 /*@only@*/ /*@null@*/
131  const char * arch;
132 /*@only@*/ /*@null@*/
133  const char * os;
134  int isSource;
136  rpmte parent;
137  int degree;
138  int npreds;
139  int tree;
140  int depth;
141  int breadth;
142  uint32_t db_instance;
143 /*@owned@*/
144  tsortInfo tsi;
146 /*@null@*/
147  rpmPRCO PRCO;
149 /*@null@*/
150  rpmtxn txn;
151 /*@refcounted@*/ /*@null@*/
152  rpmfi fi;
153 #ifdef REFERENCE
154  rpmpol pol;
155 #endif
156 
157  rpmuint32_t depFlags;
158  rpmuint32_t transFlags;
159  rpmuint32_t color;
160  rpmuint32_t pkgFileSize;
162 /*@exposed@*/ /*@dependent@*/ /*@null@*/
163  fnpyKey key;
164 /*@owned@*/ /*@null@*/
165  rpmRelocation relocs;
166  int nrelocs;
167  int autorelocatex;
168 /*@refcounted@*/ /*@null@*/
169  FD_t fd;
171 /*@owned@*/ /*@null@*/
172  sharedFileInfo replaced;
173  int nreplaced;
175  struct rpmChainLink_s blink;
176  struct rpmChainLink_s flink;
177  int linkFailed;
178  int done;
179  rpmuint32_t originTid[2];
180  rpmuint32_t originTime[2];
182  int installed;
183  int downgrade;
185  struct {
186 /*@exposed@*/ /*@dependent@*/ /*@null@*/
187  alKey addedKey;
188  struct {
189 /*@exposed@*/ /*@dependent@*/ /*@null@*/
190  alKey dependsOnKey;
191  uint32_t dboffset;
192  } removed;
193  } u;
194 #if defined(__LCLINT__)
195 /*@refs@*/
196  int nrefs;
197 #endif
198 };
199 
203 struct rpmtsi_s {
204  struct rpmioItem_s _item;
205 /*@refcounted@*/
206  rpmts ts;
207  int reverse;
208  int ocsave;
209  int oc;
210 #if defined(__LCLINT__)
211 /*@refs@*/
212  int nrefs;
213 #endif
214 };
215 
216 #ifdef __cplusplus
217 extern "C" {
218 #endif
219 
220 int rpmteClose(rpmte te, rpmts ts, int reset_fi)
221  /*@modifies te, ts @*/;
222 Header rpmteDBHeader(rpmts ts, uint32_t rec)
223  /*@modifies ts @*/;
225  /*@modifies ts, te @*/;
226 int rpmteOpen(rpmte te, rpmts ts, int reload_fi)
227  /*@modifies te, ts @*/;
228 
234 int rpmteFailed(rpmte te)
235  /*@*/;
236 
237 int rpmteHaveTransScript(rpmte te, rpmTag tag)
238  /*@*/;
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif /* _RPMTE_INTERNAL */
245 
246 #ifdef __cplusplus
247 extern "C" {
248 #endif
249 
255 /*@unused@*/ /*@null@*/
256 rpmte rpmteFree(/*@only@*/ /*@null@*/ rpmte te)
257  /*@globals fileSystem @*/
258  /*@modifies te, fileSystem @*/;
259 #define rpmteFree(_te) \
260  ((rpmte) rpmioFreePoolItem((rpmioItem)(_te), __FUNCTION__, __FILE__, __LINE__))
261 
273 /*@only@*/ /*@null@*/
274 rpmte rpmteNew(const rpmts ts, Header h, rpmElementType type,
275  /*@exposed@*/ /*@dependent@*/ /*@null@*/ fnpyKey key,
276  /*@null@*/ rpmRelocation relocs,
277  uint32_t dboffset,
278  /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey pkgKey)
279  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
280  /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
281 
287 extern Header rpmteHeader(rpmte te)
288  /*@modifies te @*/;
289 
296 extern Header rpmteSetHeader(rpmte te, Header h)
297  /*@modifies te, h @*/;
298 
305  /*@*/;
306 
312 /*@observer@*/
313 extern const char * rpmteN(rpmte te)
314  /*@*/;
315 
321 /*@observer@*/ /*@null@*/
322 extern const char * rpmteE(rpmte te)
323  /*@*/;
324 
330 /*@observer@*/ /*@null@*/
331 extern const char * rpmteV(rpmte te)
332  /*@*/;
333 
339 /*@observer@*/ /*@null@*/
340 extern const char * rpmteR(rpmte te)
341  /*@*/;
342 
348 /*@observer@*/ /*@null@*/
349 extern const char * rpmteD(rpmte te)
350  /*@*/;
351 
357 /*@observer@*/ /*@null@*/
358 extern const char * rpmteA(rpmte te)
359  /*@*/;
360 
366 /*@observer@*/ /*@null@*/
367 extern const char * rpmteO(rpmte te)
368  /*@*/;
369 
375 extern int rpmteIsSource(rpmte te)
376  /*@*/;
377 
384  /*@*/;
385 
393  /*@modifies te @*/;
394 
400 uint32_t rpmteDBInstance(rpmte te)
401  /*@*/;
402 
409 void rpmteSetDBInstance(rpmte te, unsigned int instance)
410  /*@modifies te @*/;
411 
419  /*@*/;
420 
426 /*@observer@*/
428  /*@*/;
429 
435 /*@observer@*/
437  /*@*/;
438 
444 int rpmteDepth(rpmte te)
445  /*@*/;
446 
453 int rpmteSetDepth(rpmte te, int ndepth)
454  /*@modifies te @*/;
455 
461 int rpmteBreadth(rpmte te)
462  /*@*/;
463 
470 int rpmteSetBreadth(rpmte te, int nbreadth)
471  /*@modifies te @*/;
472 
478 int rpmteNpreds(rpmte te)
479  /*@*/;
480 
487 int rpmteSetNpreds(rpmte te, int npreds)
488  /*@modifies te @*/;
489 
495 int rpmteTree(rpmte te)
496  /*@*/;
497 
504 int rpmteSetTree(rpmte te, int ntree)
505  /*@modifies te @*/;
506 
512 /*@observer@*/ /*@unused@*/
514  /*@*/;
515 
522 /*@null@*/
524  /*@modifies te @*/;
525 
531 int rpmteDegree(rpmte te)
532  /*@*/;
533 
540 int rpmteSetDegree(rpmte te, int ndegree)
541  /*@modifies te @*/;
542 
549  /*@*/;
550 
555 void rpmteFreeTSI(rpmte te)
556  /*@modifies te @*/;
557 
562 void rpmteNewTSI(rpmte te)
563  /*@modifies te @*/;
564 
569 /*@unused@*/
570 void rpmteCleanDS(rpmte te)
571  /*@modifies te @*/;
572 
573 #if defined(_RPMTE_INTERNAL)
574 
579 /*@exposed@*/ /*@dependent@*/ /*@null@*/
581  /*@*/;
582 
589 /*@exposed@*/ /*@dependent@*/ /*@null@*/
591  /*@exposed@*/ /*@dependent@*/ /*@null@*/ alKey npkgKey)
592  /*@modifies te @*/;
593 #endif /* _RPMTE_INTERNAL */
594 
600 int rpmteDBOffset(rpmte te)
601  /*@*/;
602 
608 /*@observer@*/
609 extern const char * rpmteNEVR(rpmte te)
610  /*@*/;
611 
617 /*@-exportlocal@*/
618 /*@observer@*/
619 extern const char * rpmteNEVRA(rpmte te)
620  /*@*/;
621 /*@=exportlocal@*/
622 
628 /*@-exportlocal@*/
629 /*@observer@*/ /*@null@*/
630 extern const char * rpmtePkgid(rpmte te)
631  /*@*/;
632 /*@=exportlocal@*/
633 
639 /*@-exportlocal@*/
640 /*@observer@*/ /*@null@*/
641 extern const char * rpmteHdrid(rpmte te)
642  /*@*/;
643 /*@=exportlocal@*/
644 
650 /*@-exportlocal@*/
651 /*@observer@*/ /*@null@*/
652 extern const char * rpmteSourcerpm(rpmte te)
653  /*@*/;
654 /*@=exportlocal@*/
655 
661 FD_t rpmteFd(rpmte te)
662  /*@*/;
663 
669 /*@exposed@*/
671  /*@*/;
672 
679 rpmds rpmteDS(rpmte te, rpmTag tag)
680  /*@*/;
681 
688 rpmfi rpmteFI(rpmte te, rpmTag tag)
689  /*@*/;
690 /*@null@*/
691 rpmfi rpmteSetFI(rpmte te, rpmfi fi)
692  /*@modifies te, fi @*/;
693 
699 /*@-exportlocal@*/
700 void rpmteColorDS(rpmte te, rpmTag tag)
701  /*@modifies te @*/;
702 /*@=exportlocal@*/
703 
712 int rpmteChain(rpmte p, rpmte q, Header oh, /*@null@*/ const char * msg)
713  /*@globals internalState @*/
714  /*@modifies p, q, oh, internalState @*/;
715 
716 #define RPMTE_CHAIN_END "CHAIN END"
723 int rpmtsiOc(rpmtsi tsi)
724  /*@*/;
725 
731 /*@unused@*/ /*@null@*/
732 rpmtsi rpmtsiFree(/*@killref@*//*@null@*/ rpmtsi tsi)
733  /*@globals fileSystem @*/
734  /*@modifies fileSystem @*/;
735 #define rpmtsiFree(_tsi) \
736  ((rpmtsi)rpmioFreePoolItem((rpmioItem)(_tsi), __FUNCTION__, __FILE__, __LINE__))
737 
743 /*@unused@*/ /*@only@*/
745  /*@modifies ts @*/;
746 
754 /*@unused@*/ /*@only@*/
756  const char * fn, unsigned int ln)
757  /*@modifies ts @*/;
758 #define rpmtsiInit(_ts) XrpmtsiInit(_ts, __FILE__, __LINE__)
759 
766 /*@dependent@*/ /*@null@*/
768  /*@modifies tsi @*/;
769 
770 #if defined(DYING)
771 #if !defined(SWIG)
772 
774 static inline void rpmtePrintID(rpmte p)
775  /*@globals fileSystem @*/
776  /*@modifies fileSystem @*/
777 {
778  if (p != NULL) {
779  if (p->blink.Pkgid) argvPrint("blink.Pkgid", p->blink.Pkgid, NULL);
780  if (p->blink.Hdrid) argvPrint("blink.Hdrid", p->blink.Hdrid, NULL);
781  if (p->blink.NEVRA) argvPrint("blink.NEVRA", p->blink.NEVRA, NULL);
782  if (p->flink.Pkgid) argvPrint("flink.Pkgid", p->flink.Pkgid, NULL);
783  if (p->flink.Hdrid) argvPrint("flink.Hdrid", p->flink.Hdrid, NULL);
784  if (p->flink.NEVRA) argvPrint("flink.NEVRA", p->flink.NEVRA, NULL);
785  }
786 };
787 
790 static inline void hdrPrintInstalled(Header h)
791  /*@globals fileSystem @*/
792  /*@modifies h, fileSystem @*/
793 {
794  const char * qfmt = "[%{erasednevra} O:%{packageorigin} P:%{erasedpkgid} H:%{erasedhdrid}\n]";
795  const char * errstr = "(unknown error)";
796 /*@-modobserver@*/
797  const char * str = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errstr);
798 /*@=modobserver@*/
799 
800  if (str == NULL)
801  fprintf(stderr, "error: %s\n", errstr);
802  else {
803  fprintf(stderr, "%s", str);
804  str = _free(str);
805  }
806 }
807 
810 static inline void hdrPrintErased(Header h)
811  /*@globals fileSystem @*/
812  /*@modifies h, fileSystem @*/
813 {
814  const char * qfmt = "[%{installednevra} O:%{packageorigin} P:%{installedpkgid} H:%{installedhdrid}\n]";
815  const char * errstr = "(unknown error)";
816 /*@-modobserver@*/
817  const char * str = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errstr);
818 /*@=modobserver@*/
819  if (str == NULL)
820  fprintf(stderr, "error: %s\n", errstr);
821  else {
822  fprintf(stderr, "%s", str);
823  str = _free(str);
824  }
825 }
826 #endif
827 #endif
828 
829 #ifdef REFERENCE
830 
833 typedef struct rpmfs_s * rpmfs;
834 
837 struct sharedFileInfo_s {
838  int pkgFileNum;
839  int otherPkg;
840  int otherFileNum;
841 };
842 
843 typedef char rpm_fstate_t;
844 
845 struct rpmfs_s {
846  unsigned int fc;
847 
848  rpm_fstate_t * states;
849  rpmFileAction * actions;
851  sharedFileInfo replaced;
852  int numReplaced;
853  int allocatedReplaced;
854 };
855 
856 int rpmteMarkFailed(rpmte te, rpmts ts);
857 
858 rpmps rpmteProblems(rpmte te);
859 rpmfs rpmteGetFileStates(rpmte te);
860 rpmfs rpmfsNew(unsigned int fc, rpmElementType type);
861 rpmfs rpmfsFree(rpmfs fs);
862 rpm_count_t rpmfsFC(rpmfs fs);
863 void rpmfsAddReplaced(rpmfs fs, int pkgFileNum, int otherPkg, int otherFileNum);
864 sharedFileInfo rpmfsGetReplaced(rpmfs fs);
865 sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced);
866 void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state);
867 rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix);
868 /*@null@*/
869 rpm_fstate_t * rpmfsGetStates(rpmfs fs);
870 void rpmfsSetAction(rpmfs fs, unsigned int ix, rpmFileAction action);
871 #endif /* REFERENCE */
872 
873 #ifdef __cplusplus
874 }
875 #endif
876 
877 #endif /* H_RPMTE */