Main Page Modules Data Structures File List Data Fields Globals Related Pages

# 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 is 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     { NULL,                             NULL, 0,        NULL }
    00052 };
    00053
    00054 void rpmShowRpmlibProvides(FILE * fp)
    00055 {
    00056     const struct rpmlibProvides_s * rlp;
    00057
    00058     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
    00059 /*@-nullpass@*/ /* FIX: rlp->featureEVR not NULL */
    00060         rpmds pro = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName,
    00061                         rlp->featureEVR, rlp->featureFlags);
    00062 /*@=nullpass@*/
    00063         const char * DNEVR = rpmdsDNEVR(pro);
    00064
    00065         if (pro != NULL && DNEVR != NULL) {
    00066             fprintf(fp, "    %s\n", DNEVR+2);
    00067             if (rlp->featureDescription)
    00068                 fprintf(fp, "\t%s\n", rlp->featureDescription);
    00069         }
    00070         pro = rpmdsFree(pro);
    00071     }
    00072 }
    00073
    00074 int rpmCheckRpmlibProvides(const rpmds key)
    00075 {
    00076     const struct rpmlibProvides_s * rlp;
    00077     int rc = 0;
    00078
    00079     for (rlp = rpmlibProvides; rlp->featureName != NULL; rlp++) {
    00080         if (rlp->featureEVR && rlp->featureFlags) {
    00081             rpmds pro;
    00082             pro = rpmdsSingle(RPMTAG_PROVIDENAME, rlp->featureName,
    00083                         rlp->featureEVR, rlp->featureFlags);
    00084             rc = rpmdsCompare(pro, key);
    00085             pro = rpmdsFree(pro);
    00086         }
    00087         if (rc)
    00088             break;
    00089     }
    00090     return rc;
    00091 }
    00092
    00093 int rpmGetRpmlibProvides(const char *** provNames, int ** provFlags,
    00094                          const char *** provVersions)
    00095 {
    00096     const char ** names, ** versions;
    00097     int * flags;
    00098     int n = 0;
    00099
    00100 /*@-boundswrite@*/
    00101     while (rpmlibProvides[n].featureName != NULL)
    00102         n++;
    00103 /*@=boundswrite@*/
    00104
    00105     names = xcalloc((n+1), sizeof(*names));
    00106     versions = xcalloc((n+1), sizeof(*versions));
    00107     flags = xcalloc((n+1), sizeof(*flags));
    00108
    00109 /*@-boundswrite@*/
    00110     for (n = 0; rpmlibProvides[n].featureName != NULL; n++) {
    00111         names[n] = rpmlibProvides[n].featureName;
    00112         flags[n] = rpmlibProvides[n].featureFlags;
    00113         versions[n] = rpmlibProvides[n].featureEVR;
    00114     }
    00115
    00116     /*@-branchstate@*/
    00117     if (provNames)
    00118         *provNames = names;
    00119     else
    00120         names = _free(names);
    00121     /*@=branchstate@*/
    00122
    00123     /*@-branchstate@*/
    00124     if (provFlags)
    00125         *provFlags = flags;
    00126     else
    00127         flags = _free(flags);
    00128     /*@=branchstate@*/
    00129
    00130     /*@-branchstate@*/
    00131     if (provVersions)
    00132         *provVersions = versions;
    00133     else
    00134         versions = _free(versions);
    00135     /*@=branchstate@*/
    00136 /*@=boundswrite@*/
    00137
    00138     /*@-compmempass@*/ /* FIX: rpmlibProvides[] reachable */
    00139     return n;
    00140     /*@=compmempass@*/
    00141 }