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

Generated on Fri Oct 12 08:44:53 2007 for rpm by  doxygen 1.5.2