- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# lib/rpmds.h

Go to the documentation of this file.

    00001 #ifndef H_RPMDS
    00002 #define H_RPMDS
    00003
    00009 #include "rpmevr.h"
    00010 #define _RPMNS_INTERNAL
    00011 #include "rpmns.h"
    00012 #include "rpmps.h"
    00013
    00016 /*@-exportlocal@*/
    00017 /*@unchecked@*/
    00018 extern int _rpmds_debug;
    00019 /*@=exportlocal@*/
    00020
    00023 /*@unchecked@*/ /*@observer@*/ /*@owned@*/ /*@relnull@*/
    00024 extern const char *_sysinfo_path;
    00025
    00028 /*@-exportlocal@*/
    00029 /*@unchecked@*/
    00030 extern int _rpmds_nopromote;
    00031 /*@=exportlocal@*/
    00032
    00033 #if defined(_RPMDS_INTERNAL)
    00034
    00037 struct rpmds_s {
    00038 /*@observer@*/
    00039     const char * Type;
    00040 /*@only@*/ /*@null@*/
    00041     const char * DNEVR;
    00042 /*@refcounted@*/ /*@null@*/
    00043     Header h;
    00044 /*@only@*/ /*@relnull@*/
    00045     const char ** N;
    00046 /*@only@*/ /*@relnull@*/
    00047     const char ** EVR;
    00048 /*@only@*/ /*@relnull@*/
    00049     evrFlags * Flags;
    00050 /*@only@*/ /*@null@*/
    00051     uint32_t * Color;
    00052 /*@only@*/ /*@null@*/
    00053     uint32_t * Refs;
    00054 /*@only@*/ /*@null@*/
    00055     int32_t * Result;
    00056 /*@null@*/
    00057     int (*EVRparse) (const char *evrstr, EVR_t evr);     /* EVR parsing. */
    00058     int (*EVRcmp) (const char *a, const char *b);        /* EVR comparison. */
    00059     struct rpmns_s ns;
    00060 /*@only@*/ /*@null@*/
    00061     const char * A;
    00062     uint32_t BT;
    00063     rpmTag tagN;
    00064     uint32_t Count;
    00065     int i;
    00066     unsigned l;
    00067     unsigned u;
    00068     int nopromote;
    00069 /*@refs@*/
    00070     int nrefs;
    00071 };
    00072 #endif  /* _RPMDS_INTERNAL */
    00073
    00074 #if defined(_RPMPRCO_INTERNAL)
    00075
    00078 struct rpmPRCO_s {
    00079 /*@dependent@*/ /*@relnull@*/
    00080     rpmds * Pdsp;
    00081 /*@dependent@*/ /*@relnull@*/
    00082     rpmds * Rdsp;
    00083 /*@dependent@*/ /*@relnull@*/
    00084     rpmds * Cdsp;
    00085 /*@dependent@*/ /*@relnull@*/
    00086     rpmds * Odsp;
    00087 /*@dependent@*/ /*@relnull@*/
    00088     rpmds * Tdsp;
    00089 /*@dependent@*/ /*@relnull@*/
    00090     rpmds * Ddsp;
    00091 /*@dependent@*/ /*@relnull@*/
    00092     rpmds * Ldsp;
    00093 /*@refcounted@*/ /*@null@*/
    00094     rpmds this;
    00095 /*@refcounted@*/ /*@null@*/
    00096     rpmds P;
    00097 /*@refcounted@*/ /*@null@*/
    00098     rpmds R;
    00099 /*@refcounted@*/ /*@null@*/
    00100     rpmds C;
    00101 /*@refcounted@*/ /*@null@*/
    00102     rpmds O;
    00103 /*@refcounted@*/ /*@null@*/
    00104     rpmds T;
    00105 /*@refcounted@*/ /*@null@*/
    00106     rpmds D;
    00107 /*@refcounted@*/ /*@null@*/
    00108     rpmds L;
    00109 };
    00110 #endif  /* _RPMPRCO_INTERNAL */
    00111
    00112 #ifdef __cplusplus
    00113 extern "C" {
    00114 #endif
    00115
    00124 /*@unused@*/ /*@null@*/
    00125 rpmds rpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds,
    00126                 /*@null@*/ const char * msg)
    00127         /*@modifies ds @*/;
    00128
    00130 /*@-exportlocal@*/
    00131 /*@null@*/
    00132 rpmds XrpmdsUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds,
    00133                 /*@null@*/ const char * msg, const char * fn, unsigned ln)
    00134         /*@modifies ds @*/;
    00135 /*@=exportlocal@*/
    00136 #define rpmdsUnlink(_ds, _msg)  XrpmdsUnlink(_ds, _msg, __FILE__, __LINE__)
    00137
    00144 /*@unused@*/ /*@newref@*/ /*@null@*/
    00145 rpmds rpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg)
    00146         /*@modifies ds @*/;
    00147
    00149 /*@newref@*/ /*@null@*/
    00150 rpmds XrpmdsLink (/*@null@*/ rpmds ds, /*@null@*/ const char * msg,
    00151                 const char * fn, unsigned ln)
    00152         /*@modifies ds @*/;
    00153 #define rpmdsLink(_ds, _msg)    XrpmdsLink(_ds, _msg, __FILE__, __LINE__)
    00154
    00160 /*@null@*/
    00161 rpmds rpmdsFree(/*@killref@*/ /*@only@*/ /*@null@*/ rpmds ds)
    00162         /*@modifies ds @*/;
    00170 /*@null@*/
    00171 rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
    00172         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00173         /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00174
    00180 /*@dependent@*/ /*@observer@*/ /*@null@*/
    00181 const char * rpmdsNewN(rpmds ds)
    00182         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
    00183         /*@modifies ds, rpmGlobalMacroContext, internalState @*/;
    00184
    00191 char * rpmdsNewDNEVR(const char * dspfx, rpmds ds)
    00192         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
    00193         /*@modifies ds, rpmGlobalMacroContext, internalState @*/;
    00194
    00202 /*@null@*/
    00203 rpmds rpmdsThis(Header h, rpmTag tagN, evrFlags Flags)
    00204         /*@*/;
    00205
    00214 /*@null@*/
    00215 rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, evrFlags Flags)
    00216         /*@*/;
    00217
    00223 int rpmdsCount(/*@null@*/ const rpmds ds)
    00224         /*@*/;
    00225
    00231 int rpmdsIx(/*@null@*/ const rpmds ds)
    00232         /*@*/;
    00233
    00240 int rpmdsSetIx(/*@null@*/ rpmds ds, int ix)
    00241         /*@modifies ds @*/;
    00242
    00248 /*@observer@*/ /*@relnull@*/
    00249 extern const char * rpmdsDNEVR(/*@null@*/ const rpmds ds)
    00250         /*@*/;
    00251
    00257 /*@observer@*/ /*@null@*/
    00258 extern const char * rpmdsN(/*@null@*/ rpmds ds)
    00259         /*@globals internalState @*/
    00260         /*@modifies internalState @*/;
    00261
    00267 /*@observer@*/ /*@relnull@*/
    00268 extern const char * rpmdsEVR(/*@null@*/ const rpmds ds)
    00269         /*@*/;
    00270
    00276 evrFlags rpmdsFlags(/*@null@*/ const rpmds ds)
    00277         /*@*/;
    00278
    00284 rpmTag rpmdsTagN(/*@null@*/ const rpmds ds)
    00285         /*@*/;
    00286
    00292 /*@observer@*/ /*@relnull@*/
    00293 extern const char * rpmdsA(/*@null@*/ const rpmds ds)
    00294         /*@*/;
    00295
    00301 time_t rpmdsBT(/*@null@*/ const rpmds ds)
    00302         /*@*/;
    00303
    00310 time_t rpmdsSetBT(/*@null@*/ const rpmds ds, time_t BT)
    00311         /*@modifies ds @*/;
    00312
    00318 nsType rpmdsNSType(/*@null@*/ const rpmds ds)
    00319         /*@*/;
    00320
    00334 int rpmdsNoPromote(/*@null@*/ const rpmds ds)
    00335         /*@*/;
    00336
    00343 int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
    00344         /*@modifies ds @*/;
    00345
    00352 /*@null@*/
    00353 void * rpmdsSetEVRparse(/*@null@*/ rpmds ds,
    00354                 /*@null@*/ int (*EVRparse)(const char *everstr, EVR_t evr))
    00355         /*@modifies ds @*/;
    00356
    00363 /*@null@*/
    00364 void * rpmdsSetEVRcmp(/*@null@*/ rpmds ds,
    00365                 /*@null@*/ int (*EVRcmp)(const char *a, const char *b))
    00366         /*@modifies ds @*/;
    00367
    00373 uint32_t rpmdsColor(/*@null@*/ const rpmds ds)
    00374         /*@*/;
    00375
    00382 uint32_t rpmdsSetColor(/*@null@*/ const rpmds ds, uint32_t color)
    00383         /*@modifies ds @*/;
    00384
    00390 uint32_t rpmdsRefs(/*@null@*/ const rpmds ds)
    00391         /*@*/;
    00392
    00399 uint32_t rpmdsSetRefs(/*@null@*/ const rpmds ds, uint32_t refs)
    00400         /*@modifies ds @*/;
    00401
    00407 int32_t rpmdsResult(/*@null@*/ const rpmds ds)
    00408         /*@*/;
    00409
    00416 int32_t rpmdsSetResult(/*@null@*/ const rpmds ds, int32_t result)
    00417         /*@modifies ds @*/;
    00418
    00425 /*@-globuse@*/ /* FIX: rpmMessage annotation is a lie */
    00426 void rpmdsNotify(/*@null@*/ rpmds ds, /*@null@*/ const char * where, int rc)
    00427         /*@globals fileSystem @*/
    00428         /*@modifies fileSystem @*/;
    00429 /*@=globuse@*/
    00430
    00436 int rpmdsNext(/*@null@*/ rpmds ds)
    00437         /*@modifies ds @*/;
    00438
    00444 /*@null@*/
    00445 rpmds rpmdsInit(/*@null@*/ rpmds ds)
    00446         /*@modifies ds @*/;
    00447
    00454 int rpmdsFind(rpmds ds, /*@null@*/ const rpmds ods)
    00455         /*@modifies ds @*/;
    00456
    00463 int rpmdsMerge(/*@null@*/ /*@out@*/ rpmds * dsp, /*@null@*/ rpmds ods)
    00464         /*@modifies *dsp, ods @*/;
    00465
    00474 int rpmdsSearch(/*@null@*/ rpmds ds, /*@null@*/ rpmds ods)
    00475         /*@modifies ds, ods @*/;
    00476
    00483 int rpmdsCpuinfo(/*@out@*/ rpmds * dsp, /*@null@*/ const char * fn)
    00484         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00485         /*@modifies *dsp, rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/;
    00486
    00493 int rpmdsRpmlib(rpmds * dsp, /*@null@*/ void * tblp)
    00494         /*@modifies *dsp @*/;
    00495
    00502 int rpmdsSysinfo(rpmPRCO PRCO, /*@null@*/ const char * fn)
    00503         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00504         /*@modifies PRCO, rpmGlobalMacroContext, h_errno,
    00505                 fileSystem, internalState @*/;
    00506
    00513 int rpmdsGetconf(rpmds * dsp, /*@null@*/ const char * path)
    00514         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00515         /*@modifies *dsp, rpmGlobalMacroContext, h_errno,
    00516                 fileSystem, internalState @*/;
    00517
    00524 int rpmdsMergePRCO(void * context, rpmds ds)
    00525         /*@modifies context, ds @*/;
    00526
    00532 /*@null@*/
    00533 rpmPRCO rpmdsFreePRCO(/*@only@*/ /*@null@*/ rpmPRCO PRCO)
    00534         /*@modifies PRCO @*/;
    00535
    00541 rpmPRCO rpmdsNewPRCO(/*@null@*/ Header h)
    00542         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00543         /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00544
    00551 /*@null@*/
    00552 rpmds rpmdsFromPRCO(/*@null@*/ rpmPRCO PRCO, rpmTag tagN)
    00553         /*@*/;
    00554
    00563 int rpmdsELF(const char * fn, int flags,
    00564                 int (*add) (void * context, rpmds ds), void * context)
    00565         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00566         /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
    00567 #define RPMELF_FLAG_SKIPPROVIDES        0x1     /*<! rpmdsELF: skip provides */
    00568 #define RPMELF_FLAG_SKIPREQUIRES        0x2     /*<! rpmdsELF: skip requires */
    00569
    00577 int rpmdsLdconfig(rpmPRCO PRCO, /*@null@*/ const char * fn)
    00578         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00579         /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00580
    00581 #if defined(__sun)
    00582
    00591 int rpmdsRldpath(rpmPRCO PRCO, /*@null@*/ const char * rldp)
    00592         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00593         /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00594
    00603 int rpmdsCrle(rpmPRCO PRCO, /*@null@*/ const char * fn)
    00604         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00605         /*@modifies *PRCO, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00606 #endif
    00607
    00614 struct utsname;
    00615 int rpmdsUname(rpmds * dsp, /*@null@*/ const struct utsname * un)
    00616         /*@globals internalState @*/
    00617         /*@modifies *dsp, internalState @*/;
    00618
    00626 int rpmdsPipe(rpmds * dsp, rpmTag tagN, /*@null@*/ const char * cmd)
    00627         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00628         /*@modifies *dsp, rpmGlobalMacroContext, h_errno,
    00629                 fileSystem, internalState @*/;
    00630
    00637 int rpmdsCompare(const rpmds A, const rpmds B)
    00638         /*@*/;
    00639
    00648 void rpmdsProblem(/*@null@*/ rpmps ps, const char * pkgNEVR, const rpmds ds,
    00649                 /*@only@*/ /*@null@*/ const fnpyKey * suggestedKeys,
    00650                 int adding)
    00651         /*@globals internalState @*/
    00652         /*@modifies ps, internalState @*/;
    00653
    00661 int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote)
    00662         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
    00663         /*@modifies h, rpmGlobalMacroContext, fileSystem, internalState @*/;
    00664
    00672 int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote)
    00673         /*@*/;
    00674
    00681 int rpmdsNegateRC(const rpmds ds, int rc)
    00682         /*@*/;
    00683
    00684 #if !defined(SWIG)
    00685
    00690 /*@unused@*/ static inline /*@observer@*/
    00691 const char * rpmdsTagName(/*@null@*/ const rpmds ds)
    00692         /*@*/
    00693 {
    00694     rpmTag tagN = rpmdsTagN(ds);
    00695
    00696     switch (tagN) {
    00697     case RPMTAG_PROVIDENAME:    return "Provides";      /*@notreached@*/ break;
    00698     case RPMTAG_REQUIRENAME:    return "Requires";      /*@notreached@*/ break;
    00699     case RPMTAG_CONFLICTNAME:   return "Conflicts";     /*@notreached@*/ break;
    00700     case RPMTAG_OBSOLETENAME:   return "Obsoletes";     /*@notreached@*/ break;
    00701     case RPMTAG_TRIGGERNAME:    return "Triggers";      /*@notreached@*/ break;
    00702     case RPMTAG_DIRNAMES:       return "Dirnames";      /*@notreached@*/ break;
    00703     }
    00704     return tagName(tagN);
    00705 }
    00706
    00713 /*@unused@*/ static inline
    00714 int rpmdsPrint(/*@null@*/ rpmds ds, /*@null@*/ FILE * fp)
    00715         /*@globals fileSystem @*/
    00716         /*@modifies ds, *fp, fileSystem @*/
    00717 {
    00718     if (fp == NULL)
    00719         fp = stderr;
    00720     ds = rpmdsInit(ds);
    00721     while (rpmdsNext(ds) >= 0)
    00722         fprintf(fp, "%6d\t%s: %s\n", rpmdsIx(ds), rpmdsTagName(ds), rpmdsDNEVR(ds)+2);
    00723     return 0;
    00724 }
    00725
    00732 /*@unused@*/ static inline
    00733 int rpmdsPrintResults(/*@null@*/ rpmds ds, /*@null@*/ FILE * fp)
    00734         /*@globals fileSystem @*/
    00735         /*@modifies ds, *fp, fileSystem @*/
    00736 {
    00737     if (fp == NULL)
    00738         fp = stderr;
    00739     ds = rpmdsInit(ds);
    00740     while (rpmdsNext(ds) >= 0) {
    00741         int rc = rpmdsResult(ds);
    00742         if (rc > 0)
    00743             continue;
    00744         fprintf(fp, "%6d\t%s: %s\n", rpmdsIx(ds), rpmdsTagName(ds), rpmdsDNEVR(ds)+2);
    00745     }
    00746     return 0;
    00747 }
    00748
    00756 /*@-mods@*/     /* XXX LCL wonky */
    00757 /*@unused@*/ static inline
    00758 int rpmdsPrintClosure(/*@null@*/ rpmds P, /*@null@*/ rpmds R,
    00759                 /*@null@*/ FILE * fp)
    00760         /*@globals fileSystem @*/
    00761         /*@modifies P, R, *fp, fileSystem @*/
    00762 {
    00763     int rc;
    00764
    00765     /* Allocate the R results array (to be filled in by rpmdsSearch). */
    00766     (void) rpmdsSetResult(R, 0);        /* allocate result array. */
    00767
    00768     /* Collect the rpmdsSearch results (in the R dependency set). */
    00769     R = rpmdsInit(R);
    00770     while (rpmdsNext(R) >= 0)
    00771         rc = rpmdsSearch(P, R);
    00772
    00773     return rpmdsPrintResults(R, fp);
    00774 }
    00775 /*@=mods@*/
    00776 #endif
    00777
    00779 #ifdef __cplusplus
    00780 }
    00781 #endif
    00782
    00783 #endif  /* H_RPMDS */