lib/rpmlibprov.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #include <rpmlib.h>
00008 
00009 #include "rpmds.h"
00010 
00011 #include "debug.h"
00012 
00015 struct rpmlibProvides_s {
00016 /*@observer@*/ /*@null@*/
00017     const char * featureName;
00018 /*@observer@*/ /*@null@*/
00019     const char * featureEVR;
00020     int featureFlags;
00021 /*@observer@*/ /*@null@*/
00022     const char * featureDescription;
00023 };
00024 
00025 /*@observer@*/ /*@unchecked@*/
00026 static struct rpmlibProvides_s rpmlibProvides[] = {
00027     { "rpmlib(VersionedDependencies)",  "3.0.3-1",
00028         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00029     N_("PreReq:, Provides:, and Obsoletes: dependencies support versions.") },
00030     { "rpmlib(CompressedFileNames)",    "3.0.4-1",
00031         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00032     N_("file name(s) stored as (dirName,baseName,dirIndex) tuple, not as path.")},
00033     { "rpmlib(PayloadIsBzip2)",         "3.0.5-1",
00034         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00035     N_("package payload can be compressed using bzip2.") },
00036     { "rpmlib(PayloadFilesHavePrefix)", "4.0-1",
00037         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00038     N_("package payload file(s) have \"./\" prefix.") },
00039     { "rpmlib(ExplicitPackageProvide)", "4.0-1",
00040         (RPMSENSE_RPMLIB|RPMSENSE_EQUAL),
00041     N_("package name-version-release is not implicitly provided.") },
00042     { "rpmlib(HeaderLoadSortsTags)",    "4.0.1-1",
00043         (                RPMSENSE_EQUAL),
00044     N_("header tags are always sorted after being loaded.") },
00045     { "rpmlib(ScriptletInterpreterArgs)",    "4.0.3-1",
00046         (                RPMSENSE_EQUAL),
00047     N_("the scriptlet interpreter can use arguments from header.") },
00048     { "rpmlib(PartialHardlinkSets)",    "4.0.4-1",
00049         (                RPMSENSE_EQUAL),
00050     N_("a hardlink file set may be installed without being complete.") },
00051     { "rpmlib(ConcurrentAccess)",    "4.1-1",
00052         (                RPMSENSE_EQUAL),
00053     N_("package scriptlets may access the rpm database while installing.") },
00054     { "rpmlib(BuiltinLuaScripts)",    "4.2.2-1",
00055         (                RPMSENSE_EQUAL),
00056     N_("internal support for lua scripts.") },
00057     { NULL,                             NULL, 0,        NULL }
00058 };
00059 
00060 void rpmShowRpmlibProvides(FILE * fp)
00061 {
00062     const struct rpmlibProvides_s * rlp;
00063 
00064     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
00065 /*@-nullpass@*/ /* FIX: rlp->featureEVR not NULL */
00066         rpmds pro = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName,
00067                         rlp->featureEVR, rlp->featureFlags);
00068 /*@=nullpass@*/
00069         const char * DNEVR = rpmdsDNEVR(pro);
00070 
00071         if (pro != NULL && DNEVR != NULL) {
00072             fprintf(fp, "    %s\n", DNEVR+2);
00073             if (rlp->featureDescription)
00074                 fprintf(fp, "\t%s\n", rlp->featureDescription);
00075         }
00076         pro = rpmdsFree(pro);
00077     }
00078 }
00079 
00080 int rpmCheckRpmlibProvides(const rpmds key)
00081 {
00082     const struct rpmlibProvides_s * rlp;
00083     int rc = 0;
00084 
00085     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
00086         if (rlp->featureEVR && rlp->featureFlags) {
00087             rpmds pro;
00088             pro = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName,
00089                         rlp->featureEVR, rlp->featureFlags);
00090             rc = rpmdsCompare(pro, key);
00091             pro = rpmdsFree(pro);
00092         }
00093         if (rc)
00094             break;
00095     }
00096     return rc;
00097 }
00098 
00099 int rpmGetRpmlibProvides(const char *** provNames, int ** provFlags,
00100                          const char *** provVersions)
00101 {
00102     const char ** names, ** versions;
00103     int * flags;
00104     int n = 0;
00105     
00106 /*@-boundswrite@*/
00107     while (rpmlibProvides[n].featureName != NULL)
00108         n++;
00109 /*@=boundswrite@*/
00110 
00111     names = xcalloc((n+1), sizeof(*names));
00112     versions = xcalloc((n+1), sizeof(*versions));
00113     flags = xcalloc((n+1), sizeof(*flags));
00114     
00115 /*@-boundswrite@*/
00116     for (n = 0; rpmlibProvides[n].featureName != NULL; n++) {
00117         names[n] = rpmlibProvides[n].featureName;
00118         flags[n] = rpmlibProvides[n].featureFlags;
00119         versions[n] = rpmlibProvides[n].featureEVR;
00120     }
00121     
00122     /*@-branchstate@*/
00123     if (provNames)
00124         *provNames = names;
00125     else
00126         names = _free(names);
00127     /*@=branchstate@*/
00128 
00129     /*@-branchstate@*/
00130     if (provFlags)
00131         *provFlags = flags;
00132     else
00133         flags = _free(flags);
00134     /*@=branchstate@*/
00135 
00136     /*@-branchstate@*/
00137     if (provVersions)
00138         *provVersions = versions;
00139     else
00140         versions = _free(versions);
00141     /*@=branchstate@*/
00142 /*@=boundswrite@*/
00143 
00144     /*@-compmempass@*/ /* FIX: rpmlibProvides[] reachable */
00145     return n;
00146     /*@=compmempass@*/
00147 }

Generated on Wed Jan 28 12:45:24 2009 for rpm by  doxygen 1.4.7