lib/rpmrc.c

Go to the documentation of this file.
00001 /*@-bounds@*/
00002 #include "system.h"
00003 
00004 #include <stdarg.h>
00005 #if defined(__linux__) && defined(__powerpc__)
00006 #include <setjmp.h>
00007 #endif
00008 
00009 #include <ctype.h>      /* XXX for /etc/rpm/platform contents */
00010 
00011 #if HAVE_SYS_SYSTEMCFG_H
00012 #include <sys/systemcfg.h>
00013 #else
00014 #define __power_pc() 0
00015 #endif
00016 
00017 #include <rpmlib.h>
00018 #include <rpmmacro.h>
00019 #include <rpmlua.h>
00020 
00021 #include "misc.h"
00022 #include "debug.h"
00023 
00024 /*@observer@*/ /*@unchecked@*/
00025 static const char *defrcfiles = LIBRPMRC_FILENAME ":" VENDORRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"; 
00026 
00027 /*@observer@*/ /*@checked@*/
00028 const char * macrofiles = MACROFILES;
00029 
00030 /*@observer@*/ /*@unchecked@*/
00031 static const char * platform = "/etc/rpm/platform";
00032 /*@only@*/ /*@relnull@*/ /*@unchecked@*/
00033 static const char ** platpat = NULL;
00034 /*@unchecked@*/
00035 static int nplatpat = 0;
00036 
00037 typedef /*@owned@*/ const char * cptr_t;
00038 
00039 typedef struct machCacheEntry_s {
00040     const char * name;
00041     int count;
00042     cptr_t * equivs;
00043     int visited;
00044 } * machCacheEntry;
00045 
00046 typedef struct machCache_s {
00047     machCacheEntry cache;
00048     int size;
00049 } * machCache;
00050 
00051 typedef struct machEquivInfo_s {
00052     const char * name;
00053     int score;
00054 } * machEquivInfo;
00055 
00056 typedef struct machEquivTable_s {
00057     int count;
00058     machEquivInfo list;
00059 } * machEquivTable;
00060 
00061 struct rpmvarValue {
00062     const char * value;
00063     /* eventually, this arch will be replaced with a generic condition */
00064     const char * arch;
00065 /*@only@*/ /*@null@*/ struct rpmvarValue * next;
00066 };
00067 
00068 struct rpmOption {
00069     const char * name;
00070     int var;
00071     int archSpecific;
00072 /*@unused@*/ int required;
00073     int macroize;
00074     int localize;
00075 /*@unused@*/ struct rpmOptionValue * value;
00076 };
00077 
00078 typedef struct defaultEntry_s {
00079 /*@owned@*/ /*@null@*/ const char * name;
00080 /*@owned@*/ /*@null@*/ const char * defName;
00081 } * defaultEntry;
00082 
00083 typedef struct canonEntry_s {
00084 /*@owned@*/ const char * name;
00085 /*@owned@*/ const char * short_name;
00086     short num;
00087 } * canonEntry;
00088 
00089 /* tags are 'key'canon, 'key'translate, 'key'compat
00090  *
00091  * for giggles, 'key'_canon, 'key'_compat, and 'key'_canon will also work
00092  */
00093 typedef struct tableType_s {
00094 /*@observer@*/ const char * const key;
00095     const int hasCanon;
00096     const int hasTranslate;
00097     struct machEquivTable_s equiv;
00098     struct machCache_s cache;
00099     defaultEntry defaults;
00100     canonEntry canons;
00101     int defaultsLength;
00102     int canonsLength;
00103 } * tableType;
00104 
00105 /*@-fullinitblock@*/
00106 /*@unchecked@*/
00107 static struct tableType_s tables[RPM_MACHTABLE_COUNT] = {
00108     { "arch", 1, 0 },
00109     { "os", 1, 0 },
00110     { "buildarch", 0, 1 },
00111     { "buildos", 0, 1 }
00112 };
00113 
00114 /* this *must* be kept in alphabetical order */
00115 /* The order of the flags is archSpecific, required, macroize, localize */
00116 
00117 /*@unchecked@*/
00118 static struct rpmOption optionTable[] = {
00119     { "include",                RPMVAR_INCLUDE,                 0, 1,   0, 2 },
00120     { "macrofiles",             RPMVAR_MACROFILES,              0, 0,   0, 1 },
00121     { "optflags",               RPMVAR_OPTFLAGS,                1, 0,   1, 0 },
00122     { "provides",               RPMVAR_PROVIDES,                0, 0,   0, 0 },
00123 };
00124 /*@=fullinitblock@*/
00125 
00126 /*@unchecked@*/
00127 static int optionTableSize = sizeof(optionTable) / sizeof(*optionTable);
00128 
00129 #define OS      0
00130 #define ARCH    1
00131 
00132 /*@unchecked@*/
00133 static cptr_t current[2];
00134 
00135 /*@unchecked@*/
00136 static int currTables[2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH };
00137 
00138 /*@unchecked@*/
00139 static struct rpmvarValue values[RPMVAR_NUM];
00140 
00141 /*@unchecked@*/
00142 static int defaultsInitialized = 0;
00143 
00144 /* prototypes */
00145 static int doReadRC( /*@killref@*/ FD_t fd, const char * urlfn)
00146         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00147         /*@modifies fd, rpmGlobalMacroContext, fileSystem, internalState @*/;
00148 
00149 static void rpmSetVarArch(int var, const char * val,
00150                 /*@null@*/ const char * arch)
00151         /*@globals values, internalState @*/
00152         /*@modifies values, internalState @*/;
00153 
00154 static void rebuildCompatTables(int type, const char * name)
00155         /*@globals internalState @*/
00156         /*@modifies internalState @*/;
00157 
00158 static void rpmRebuildTargetVars(/*@null@*/ const char **target, /*@null@*/ const char ** canontarget)
00159         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00160         /*@modifies *canontarget, rpmGlobalMacroContext,
00161                 fileSystem, internalState @*/;
00162 
00163 static int optionCompare(const void * a, const void * b)
00164         /*@*/
00165 {
00166     return xstrcasecmp(((struct rpmOption *) a)->name,
00167                       ((struct rpmOption *) b)->name);
00168 }
00169 
00170 static /*@observer@*/ /*@null@*/ machCacheEntry
00171 machCacheFindEntry(const machCache cache, const char * key)
00172         /*@*/
00173 {
00174     int i;
00175 
00176     for (i = 0; i < cache->size; i++)
00177         if (!strcmp(cache->cache[i].name, key)) return cache->cache + i;
00178 
00179     return NULL;
00180 }
00181 
00182 static int machCompatCacheAdd(char * name, const char * fn, int linenum,
00183                                 machCache cache)
00184         /*@globals internalState @*/
00185         /*@modifies *name, cache->cache, cache->size, internalState @*/
00186 {
00187     machCacheEntry entry = NULL;
00188     char * chptr;
00189     char * equivs;
00190     int delEntry = 0;
00191     int i;
00192 
00193     while (*name && xisspace(*name)) name++;
00194 
00195     chptr = name;
00196     while (*chptr && *chptr != ':') chptr++;
00197     if (!*chptr) {
00198         rpmError(RPMERR_RPMRC, _("missing second ':' at %s:%d\n"), fn, linenum);
00199         return 1;
00200     } else if (chptr == name) {
00201         rpmError(RPMERR_RPMRC, _("missing architecture name at %s:%d\n"), fn,
00202                              linenum);
00203         return 1;
00204     }
00205 
00206     while (*chptr == ':' || xisspace(*chptr)) chptr--;
00207     *(++chptr) = '\0';
00208     equivs = chptr + 1;
00209     while (*equivs && xisspace(*equivs)) equivs++;
00210     if (!*equivs) {
00211         delEntry = 1;
00212     }
00213 
00214     if (cache->size) {
00215         entry = machCacheFindEntry(cache, name);
00216         if (entry) {
00217             for (i = 0; i < entry->count; i++)
00218                 entry->equivs[i] = _free(entry->equivs[i]);
00219             entry->equivs = _free(entry->equivs);
00220             entry->count = 0;
00221         }
00222     }
00223 
00224     if (!entry) {
00225         cache->cache = xrealloc(cache->cache,
00226                                (cache->size + 1) * sizeof(*cache->cache));
00227         entry = cache->cache + cache->size++;
00228         entry->name = xstrdup(name);
00229         entry->count = 0;
00230         entry->visited = 0;
00231     }
00232 
00233     if (delEntry) return 0;
00234 
00235     while ((chptr = strtok(equivs, " ")) != NULL) {
00236         equivs = NULL;
00237         if (chptr[0] == '\0')   /* does strtok() return "" ever?? */
00238             continue;
00239         if (entry->count)
00240             entry->equivs = xrealloc(entry->equivs, sizeof(*entry->equivs)
00241                                         * (entry->count + 1));
00242         else
00243             entry->equivs = xmalloc(sizeof(*entry->equivs));
00244 
00245         entry->equivs[entry->count] = xstrdup(chptr);
00246         entry->count++;
00247     }
00248 
00249     return 0;
00250 }
00251 
00252 static /*@observer@*/ /*@null@*/ machEquivInfo
00253 machEquivSearch(const machEquivTable table, const char * name)
00254         /*@*/
00255 {
00256     int i;
00257 
00258     for (i = 0; i < table->count; i++)
00259         if (!xstrcasecmp(table->list[i].name, name))
00260             return table->list + i;
00261 
00262     return NULL;
00263 }
00264 
00265 static void machAddEquiv(machEquivTable table, const char * name,
00266                            int distance)
00267         /*@modifies table->list, table->count @*/
00268 {
00269     machEquivInfo equiv;
00270 
00271     equiv = machEquivSearch(table, name);
00272     if (!equiv) {
00273         if (table->count)
00274             table->list = xrealloc(table->list, (table->count + 1)
00275                                     * sizeof(*table->list));
00276         else
00277             table->list = xmalloc(sizeof(*table->list));
00278 
00279         table->list[table->count].name = xstrdup(name);
00280         table->list[table->count++].score = distance;
00281     }
00282 }
00283 
00284 static void machCacheEntryVisit(machCache cache,
00285                 machEquivTable table, const char * name, int distance)
00286         /*@modifies table->list, table->count @*/
00287 {
00288     machCacheEntry entry;
00289     int i;
00290 
00291     entry = machCacheFindEntry(cache, name);
00292     if (!entry || entry->visited) return;
00293 
00294     entry->visited = 1;
00295 
00296     for (i = 0; i < entry->count; i++) {
00297         machAddEquiv(table, entry->equivs[i], distance);
00298     }
00299 
00300     for (i = 0; i < entry->count; i++) {
00301         machCacheEntryVisit(cache, table, entry->equivs[i], distance + 1);
00302     }
00303 }
00304 
00305 static void machFindEquivs(machCache cache, machEquivTable table,
00306                 const char * key)
00307         /*@modifies cache->cache, table->list, table->count @*/
00308 {
00309     int i;
00310 
00311     for (i = 0; i < cache->size; i++)
00312         cache->cache[i].visited = 0;
00313 
00314     while (table->count > 0) {
00315         --table->count;
00316         table->list[table->count].name = _free(table->list[table->count].name);
00317     }
00318     table->count = 0;
00319     table->list = _free(table->list);
00320 
00321     /*
00322      *  We have a general graph built using strings instead of pointers.
00323      *  Yuck. We have to start at a point at traverse it, remembering how
00324      *  far away everything is.
00325      */
00326     /*@-nullstate@*/    /* FIX: table->list may be NULL. */
00327     machAddEquiv(table, key, 1);
00328     machCacheEntryVisit(cache, table, key, 2);
00329     return;
00330     /*@=nullstate@*/
00331 }
00332 
00333 static int addCanon(canonEntry * table, int * tableLen, char * line,
00334                     const char * fn, int lineNum)
00335         /*@globals internalState @*/
00336         /*@modifies *table, *tableLen, *line, internalState @*/
00337 {
00338     canonEntry t;
00339     char *s, *s1;
00340     const char * tname;
00341     const char * tshort_name;
00342     int tnum;
00343 
00344     (*tableLen) += 2;
00345     /*@-unqualifiedtrans@*/
00346     *table = xrealloc(*table, sizeof(**table) * (*tableLen));
00347     /*@=unqualifiedtrans@*/
00348 
00349     t = & ((*table)[*tableLen - 2]);
00350 
00351     tname = strtok(line, ": \t");
00352     tshort_name = strtok(NULL, " \t");
00353     s = strtok(NULL, " \t");
00354     if (! (tname && tshort_name && s)) {
00355         rpmError(RPMERR_RPMRC, _("Incomplete data line at %s:%d\n"),
00356                 fn, lineNum);
00357         return RPMERR_RPMRC;
00358     }
00359     if (strtok(NULL, " \t")) {
00360         rpmError(RPMERR_RPMRC, _("Too many args in data line at %s:%d\n"),
00361               fn, lineNum);
00362         return RPMERR_RPMRC;
00363     }
00364 
00365     /*@-nullpass@*/     /* LCL: s != NULL here. */
00366     tnum = strtoul(s, &s1, 10);
00367     if ((*s1) || (s1 == s) || (tnum == ULONG_MAX)) {
00368         rpmError(RPMERR_RPMRC, _("Bad arch/os number: %s (%s:%d)\n"), s,
00369               fn, lineNum);
00370         return(RPMERR_RPMRC);
00371     }
00372     /*@=nullpass@*/
00373 
00374     t[0].name = xstrdup(tname);
00375     t[0].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
00376     t[0].num = tnum;
00377 
00378     /* From A B C entry */
00379     /* Add  B B C entry */
00380     t[1].name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
00381     t[1].short_name = (tshort_name ? xstrdup(tshort_name) : xstrdup(""));
00382     t[1].num = tnum;
00383 
00384     return 0;
00385 }
00386 
00387 static int addDefault(defaultEntry * table, int * tableLen, char * line,
00388                         const char * fn, int lineNum)
00389         /*@globals internalState @*/
00390         /*@modifies *table, *tableLen, *line, internalState @*/
00391 {
00392     defaultEntry t;
00393 
00394     (*tableLen)++;
00395     /*@-unqualifiedtrans@*/
00396     *table = xrealloc(*table, sizeof(**table) * (*tableLen));
00397     /*@=unqualifiedtrans@*/
00398 
00399     t = & ((*table)[*tableLen - 1]);
00400 
00401     /*@-temptrans@*/
00402     t->name = strtok(line, ": \t");
00403     t->defName = strtok(NULL, " \t");
00404     if (! (t->name && t->defName)) {
00405         rpmError(RPMERR_RPMRC, _("Incomplete default line at %s:%d\n"),
00406                  fn, lineNum);
00407         return RPMERR_RPMRC;
00408     }
00409     if (strtok(NULL, " \t")) {
00410         rpmError(RPMERR_RPMRC, _("Too many args in default line at %s:%d\n"),
00411               fn, lineNum);
00412         return RPMERR_RPMRC;
00413     }
00414 
00415     t->name = xstrdup(t->name);
00416     t->defName = (t->defName ? xstrdup(t->defName) : NULL);
00417     /*@=temptrans@*/
00418 
00419     return 0;
00420 }
00421 
00422 static /*@null@*/ canonEntry lookupInCanonTable(const char * name,
00423                 const canonEntry table, int tableLen)
00424         /*@*/
00425 {
00426     while (tableLen) {
00427         tableLen--;
00428         if (strcmp(name, table[tableLen].name))
00429             continue;
00430         /*@-immediatetrans -retalias@*/
00431         return &(table[tableLen]);
00432         /*@=immediatetrans =retalias@*/
00433     }
00434 
00435     return NULL;
00436 }
00437 
00438 static /*@observer@*/ /*@null@*/
00439 const char * lookupInDefaultTable(const char * name,
00440                 const defaultEntry table, int tableLen)
00441         /*@*/
00442 {
00443     while (tableLen) {
00444         tableLen--;
00445         if (table[tableLen].name && !strcmp(name, table[tableLen].name))
00446             return table[tableLen].defName;
00447     }
00448 
00449     return name;
00450 }
00451 
00452 static void setVarDefault(int var, const char * macroname, const char * val,
00453                 /*@null@*/ const char * body)
00454         /*@globals rpmGlobalMacroContext, internalState @*/
00455         /*@modifies rpmGlobalMacroContext, internalState @*/
00456 {
00457     if (var >= 0) {     /* XXX Dying ... */
00458         if (rpmGetVar(var)) return;
00459         rpmSetVar(var, val);
00460     }
00461     if (body == NULL)
00462         body = val;
00463     addMacro(NULL, macroname, NULL, body, RMIL_DEFAULT);
00464 }
00465 
00466 static void setPathDefault(int var, const char * macroname, const char * subdir)
00467         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00468         /*@modifies rpmGlobalMacroContext, internalState @*/
00469 {
00470 
00471     if (var >= 0) {     /* XXX Dying ... */
00472         const char * topdir;
00473         char * fn;
00474 
00475         if (rpmGetVar(var)) return;
00476 
00477         topdir = rpmGetPath("%{_topdir}", NULL);
00478 
00479         fn = alloca(strlen(topdir) + strlen(subdir) + 2);
00480         strcpy(fn, topdir);
00481         if (fn[strlen(topdir) - 1] != '/')
00482             strcat(fn, "/");
00483         strcat(fn, subdir);
00484 
00485         rpmSetVar(var, fn);
00486         topdir = _free(topdir);
00487     }
00488 
00489     if (macroname != NULL) {
00490 #define _TOPDIRMACRO    "%{_topdir}/"
00491         char *body = alloca(sizeof(_TOPDIRMACRO) + strlen(subdir));
00492         strcpy(body, _TOPDIRMACRO);
00493         strcat(body, subdir);
00494         addMacro(NULL, macroname, NULL, body, RMIL_DEFAULT);
00495 #undef _TOPDIRMACRO
00496     }
00497 }
00498 
00499 /*@observer@*/ /*@unchecked@*/
00500 static const char * prescriptenviron = "\n\
00501 RPM_SOURCE_DIR=\"%{_sourcedir}\"\n\
00502 RPM_BUILD_DIR=\"%{_builddir}\"\n\
00503 RPM_OPT_FLAGS=\"%{optflags}\"\n\
00504 RPM_ARCH=\"%{_arch}\"\n\
00505 RPM_OS=\"%{_os}\"\n\
00506 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\n\
00507 RPM_DOC_DIR=\"%{_docdir}\"\n\
00508 export RPM_DOC_DIR\n\
00509 RPM_PACKAGE_NAME=\"%{name}\"\n\
00510 RPM_PACKAGE_VERSION=\"%{version}\"\n\
00511 RPM_PACKAGE_RELEASE=\"%{release}\"\n\
00512 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\n\
00513 %{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\n\
00514 export RPM_BUILD_ROOT\n}\
00515 ";
00516 
00517 static void setDefaults(void)
00518         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00519         /*@modifies rpmGlobalMacroContext, internalState @*/
00520 {
00521 
00522     addMacro(NULL, "_usr", NULL, "/usr", RMIL_DEFAULT);
00523     addMacro(NULL, "_var", NULL, "/var", RMIL_DEFAULT);
00524 
00525     addMacro(NULL, "_preScriptEnvironment",NULL, prescriptenviron,RMIL_DEFAULT);
00526 
00527     setVarDefault(-1,                   "_topdir",
00528                 "/usr/src/redhat",      "%{_usr}/src/redhat");
00529     setVarDefault(-1,                   "_tmppath",
00530                 "/var/tmp",             "%{_var}/tmp");
00531     setVarDefault(-1,                   "_dbpath",
00532                 "/var/lib/rpm",         "%{_var}/lib/rpm");
00533     setVarDefault(-1,                   "_defaultdocdir",
00534                 "/usr/doc",             "%{_usr}/doc");
00535 
00536     setVarDefault(-1,                   "_rpmfilename",
00537         "%%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm",NULL);
00538 
00539     setVarDefault(RPMVAR_OPTFLAGS,      "optflags",
00540                 "-O2",                  NULL);
00541     setVarDefault(-1,                   "sigtype",
00542                 "none",                 NULL);
00543     setVarDefault(-1,                   "_buildshell",
00544                 "/bin/sh",              NULL);
00545 
00546     setPathDefault(-1,                  "_builddir",    "BUILD");
00547     setPathDefault(-1,                  "_rpmdir",      "RPMS");
00548     setPathDefault(-1,                  "_srcrpmdir",   "SRPMS");
00549     setPathDefault(-1,                  "_sourcedir",   "SOURCES");
00550     setPathDefault(-1,                  "_specdir",     "SPECS");
00551 
00552 }
00553 
00554 /*@-usedef@*/   /*@ FIX: se usage inconsistent, W2DO? */
00555 static int doReadRC( /*@killref@*/ FD_t fd, const char * urlfn)
00556         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00557         /*@modifies fd, rpmGlobalMacroContext, fileSystem, internalState @*/
00558 {
00559     const char *s;
00560     char *se, *next;
00561     int linenum = 0;
00562     struct rpmOption searchOption, * option;
00563     int rc;
00564 
00565     /* XXX really need rc = Slurp(fd, const char * filename, char ** buf) */
00566   { off_t size = fdSize(fd);
00567     size_t nb = (size >= 0 ? size : (8*BUFSIZ - 2));
00568     if (nb == 0) {
00569         (void) Fclose(fd);
00570         return 0;
00571     }
00572     next = alloca(nb + 2);
00573     next[0] = '\0';
00574     rc = Fread(next, sizeof(*next), nb, fd);
00575     if (Ferror(fd) || (size > 0 && rc != nb)) { /* XXX Feof(fd) */
00576         rpmError(RPMERR_RPMRC, _("Failed to read %s: %s.\n"), urlfn,
00577                  Fstrerror(fd));
00578         rc = 1;
00579     } else
00580         rc = 0;
00581     (void) Fclose(fd);
00582     if (rc) return rc;
00583     next[nb] = '\n';
00584     next[nb + 1] = '\0';
00585   }
00586 
00587     /*@-branchstate@*/
00588     while (*next != '\0') {
00589         linenum++;
00590 
00591         s = se = next;
00592 
00593         /* Find end-of-line. */
00594         while (*se && *se != '\n') se++;
00595         if (*se != '\0') *se++ = '\0';
00596         next = se;
00597 
00598         /* Trim leading spaces */
00599         while (*s && xisspace(*s)) s++;
00600 
00601         /* We used to allow comments to begin anywhere, but not anymore. */
00602         if (*s == '#' || *s == '\0') continue;
00603 
00604         /* Find end-of-keyword. */
00605         se = (char *)s;
00606         while (*se && !xisspace(*se) && *se != ':') se++;
00607 
00608         if (xisspace(*se)) {
00609             *se++ = '\0';
00610             while (*se && xisspace(*se) && *se != ':') se++;
00611         }
00612 
00613         if (*se != ':') {
00614             rpmError(RPMERR_RPMRC, _("missing ':' (found 0x%02x) at %s:%d\n"),
00615                      (unsigned)(0xff & *se), urlfn, linenum);
00616             return 1;
00617         }
00618         *se++ = '\0';   /* terminate keyword or option, point to value */
00619         while (*se && xisspace(*se)) se++;
00620 
00621         /* Find keyword in table */
00622         searchOption.name = s;
00623         option = bsearch(&searchOption, optionTable, optionTableSize,
00624                          sizeof(optionTable[0]), optionCompare);
00625 
00626         if (option) {   /* For configuration variables  ... */
00627             const char *arch, *val, *fn;
00628 
00629             arch = val = fn = NULL;
00630             if (*se == '\0') {
00631                 rpmError(RPMERR_RPMRC, _("missing argument for %s at %s:%d\n"),
00632                       option->name, urlfn, linenum);
00633                 return 1;
00634             }
00635 
00636             switch (option->var) {
00637             case RPMVAR_INCLUDE:
00638               { FD_t fdinc;
00639 
00640                 s = se;
00641                 while (*se && !xisspace(*se)) se++;
00642                 if (*se != '\0') *se++ = '\0';
00643 
00644                 rpmRebuildTargetVars(NULL, NULL);
00645 
00646                 fn = rpmGetPath(s, NULL);
00647                 if (fn == NULL || *fn == '\0') {
00648                     rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\"\n"),
00649                         option->name, urlfn, linenum, s);
00650                     fn = _free(fn);
00651                     return 1;
00652                     /*@notreached@*/
00653                 }
00654 
00655                 fdinc = Fopen(fn, "r.fpio");
00656                 if (fdinc == NULL || Ferror(fdinc)) {
00657                     rpmError(RPMERR_RPMRC, _("cannot open %s at %s:%d: %s\n"),
00658                         fn, urlfn, linenum, Fstrerror(fdinc));
00659                     rc = 1;
00660                 } else {
00661                     rc = doReadRC(fdinc, fn);
00662                 }
00663                 fn = _free(fn);
00664                 if (rc) return rc;
00665                 continue;       /* XXX don't save include value as var/macro */
00666               } /*@notreached@*/ /*@switchbreak@*/ break;
00667             case RPMVAR_MACROFILES:
00668                 fn = rpmGetPath(se, NULL);
00669                 if (fn == NULL || *fn == '\0') {
00670                     rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\"\n"),
00671                         option->name, urlfn, linenum, fn);
00672                     fn = _free(fn);
00673                     return 1;
00674                 }
00675                 se = (char *)fn;
00676                 /*@switchbreak@*/ break;
00677             case RPMVAR_PROVIDES:
00678               { char *t;
00679                 s = rpmGetVar(RPMVAR_PROVIDES);
00680                 if (s == NULL) s = "";
00681                 fn = t = xmalloc(strlen(s) + strlen(se) + 2);
00682                 while (*s != '\0') *t++ = *s++;
00683                 *t++ = ' ';
00684                 while (*se != '\0') *t++ = *se++;
00685                 *t++ = '\0';
00686                 se = (char *)fn;
00687               } /*@switchbreak@*/ break;
00688             default:
00689                 /*@switchbreak@*/ break;
00690             }
00691 
00692             if (option->archSpecific) {
00693                 arch = se;
00694                 while (*se && !xisspace(*se)) se++;
00695                 if (*se == '\0') {
00696                     rpmError(RPMERR_RPMRC,
00697                                 _("missing architecture for %s at %s:%d\n"),
00698                                 option->name, urlfn, linenum);
00699                     return 1;
00700                 }
00701                 *se++ = '\0';
00702                 while (*se && xisspace(*se)) se++;
00703                 if (*se == '\0') {
00704                     rpmError(RPMERR_RPMRC,
00705                                 _("missing argument for %s at %s:%d\n"),
00706                                 option->name, urlfn, linenum);
00707                     return 1;
00708                 }
00709             }
00710         
00711             val = se;
00712 
00713             /* Only add macros if appropriate for this arch */
00714             if (option->macroize &&
00715               (arch == NULL || !strcmp(arch, current[ARCH]))) {
00716                 char *n, *name;
00717                 n = name = xmalloc(strlen(option->name)+2);
00718                 if (option->localize)
00719                     *n++ = '_';
00720                 strcpy(n, option->name);
00721                 addMacro(NULL, name, NULL, val, RMIL_RPMRC);
00722                 free(name);
00723             }
00724             rpmSetVarArch(option->var, val, arch);
00725             fn = _free(fn);
00726 
00727         } else {        /* For arch/os compatibilty tables ... */
00728             int gotit;
00729             int i;
00730 
00731             gotit = 0;
00732 
00733             for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
00734                 if (!strncmp(tables[i].key, s, strlen(tables[i].key)))
00735                     /*@innerbreak@*/ break;
00736             }
00737 
00738             if (i < RPM_MACHTABLE_COUNT) {
00739                 const char *rest = s + strlen(tables[i].key);
00740                 if (*rest == '_') rest++;
00741 
00742                 if (!strcmp(rest, "compat")) {
00743                     if (machCompatCacheAdd(se, urlfn, linenum,
00744                                                 &tables[i].cache))
00745                         return 1;
00746                     gotit = 1;
00747                 } else if (tables[i].hasTranslate &&
00748                            !strcmp(rest, "translate")) {
00749                     if (addDefault(&tables[i].defaults,
00750                                    &tables[i].defaultsLength,
00751                                    se, urlfn, linenum))
00752                         return 1;
00753                     gotit = 1;
00754                 } else if (tables[i].hasCanon &&
00755                            !strcmp(rest, "canon")) {
00756                     if (addCanon(&tables[i].canons, &tables[i].canonsLength,
00757                                  se, urlfn, linenum))
00758                         return 1;
00759                     gotit = 1;
00760                 }
00761             }
00762 
00763             if (!gotit) {
00764                 rpmError(RPMERR_RPMRC, _("bad option '%s' at %s:%d\n"),
00765                             s, urlfn, linenum);
00766             }
00767         }
00768     }
00769     /*@=branchstate@*/
00770 
00771     return 0;
00772 }
00773 /*@=usedef@*/
00774 
00775 
00778 /*@-bounds@*/
00779 static int rpmPlatform(const char * platform)
00780         /*@globals nplatpat, platpat,
00781                 rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00782         /*@modifies nplatpat, platpat,
00783                 rpmGlobalMacroContext, fileSystem, internalState @*/
00784 {
00785     char *cpu = NULL, *vendor = NULL, *os = NULL, *gnu = NULL;
00786     char * b = NULL;
00787     ssize_t blen = 0;
00788     int init_platform = 0;
00789     char * p, * pe;
00790     int rc;
00791 
00792     rc = rpmioSlurp(platform, &b, &blen);
00793 
00794     if (rc || b == NULL || blen <= 0) {
00795         rc = -1;
00796         goto exit;
00797     }
00798 
00799     p = b;
00800     for (pe = p; p && *p; p = pe) {
00801         pe = strchr(p, '\n');
00802         if (pe)
00803             *pe++ = '\0';
00804 
00805         while (*p && isspace(*p))
00806             p++;
00807         if (*p == '\0' || *p == '#')
00808             continue;
00809 
00810         if (init_platform) {
00811             char * t = p + strlen(p);
00812 
00813             while (--t > p && isspace(*t))
00814                 *t = '\0';
00815             if (t > p) {
00816                 platpat = xrealloc(platpat, (nplatpat + 2) * sizeof(*platpat));
00817 /*@-onlyunqglobaltrans@*/
00818                 platpat[nplatpat] = xstrdup(p);
00819                 nplatpat++;
00820                 platpat[nplatpat] = NULL;
00821 /*@=onlyunqglobaltrans@*/
00822             }
00823             continue;
00824         }
00825 
00826         cpu = p;
00827         vendor = "unknown";
00828         os = "unknown";
00829         gnu = NULL;
00830         while (*p && !(*p == '-' || isspace(*p)))
00831             p++;
00832         if (*p != '\0') *p++ = '\0';
00833 
00834         vendor = p;
00835         while (*p && !(*p == '-' || isspace(*p)))
00836             p++;
00837 /*@-branchstate@*/
00838         if (*p != '-') {
00839             if (*p != '\0') *p++ = '\0';
00840             os = vendor;
00841             vendor = "unknown";
00842         } else {
00843             if (*p != '\0') *p++ = '\0';
00844 
00845             os = p;
00846             while (*p && !(*p == '-' || isspace(*p)))
00847                 p++;
00848             if (*p == '-') {
00849                 *p++ = '\0';
00850 
00851                 gnu = p;
00852                 while (*p && !(*p == '-' || isspace(*p)))
00853                     p++;
00854             }
00855             if (*p != '\0') *p++ = '\0';
00856         }
00857 /*@=branchstate@*/
00858 
00859         addMacro(NULL, "_host_cpu", NULL, cpu, -1);
00860         addMacro(NULL, "_host_vendor", NULL, vendor, -1);
00861         addMacro(NULL, "_host_os", NULL, os, -1);
00862 
00863         platpat = xrealloc(platpat, (nplatpat + 2) * sizeof(*platpat));
00864 /*@-onlyunqglobaltrans@*/
00865         platpat[nplatpat] = rpmExpand("%{_host_cpu}-%{_host_vendor}-%{_host_os}", (gnu && *gnu ? "-" : NULL), gnu, NULL);
00866         nplatpat++;
00867         platpat[nplatpat] = NULL;
00868 /*@=onlyunqglobaltrans@*/
00869         
00870         init_platform++;
00871     }
00872     rc = (init_platform ? 0 : -1);
00873 
00874 exit:
00875 /*@-modobserver@*/
00876     b = _free(b);
00877 /*@=modobserver@*/
00878     return rc;
00879 }
00880 /*@=bounds@*/
00881 
00882 
00883 #       if defined(__linux__) && defined(__i386__)
00884 #include <setjmp.h>
00885 #include <signal.h>
00886 
00887 /*
00888  * Generic CPUID function
00889  */
00890 static inline void cpuid(unsigned int op, int *eax, int *ebx, int *ecx, int *edx)
00891         /*@modifies *eax, *ebx, *ecx, *edx @*/
00892 {
00893 #ifdef  __LCLINT__
00894     *eax = *ebx = *ecx = *edx = 0;
00895 #endif
00896     asm volatile (
00897         "pushl  %%ebx           \n"
00898         "cpuid                  \n"
00899         "movl   %%ebx,  %%esi   \n"
00900         "popl   %%ebx           \n"
00901     : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
00902     : "a" (op));
00903 }
00904 
00905 /*
00906  * CPUID functions returning a single datum
00907  */
00908 static inline unsigned int cpuid_eax(unsigned int op)
00909         /*@*/
00910 {
00911         unsigned int tmp, val;
00912         cpuid(op, &val, &tmp, &tmp, &tmp);
00913         return val;
00914 }
00915 
00916 static inline unsigned int cpuid_ebx(unsigned int op)
00917         /*@*/
00918 {
00919         unsigned int tmp, val;
00920         cpuid(op, &tmp, &val, &tmp, &tmp);
00921         return val;
00922 }
00923 
00924 static inline unsigned int cpuid_ecx(unsigned int op)
00925         /*@*/
00926 {
00927         unsigned int tmp, val;
00928         cpuid(op, &tmp, &tmp, &val, &tmp);
00929         return val;
00930 }
00931 
00932 static inline unsigned int cpuid_edx(unsigned int op)
00933         /*@*/
00934 {
00935         unsigned int tmp, val;
00936         cpuid(op, &tmp, &tmp, &tmp, &val);
00937         return val;
00938 }
00939 
00940 /*@unchecked@*/
00941 static sigjmp_buf jenv;
00942 
00943 static inline void model3(int _unused)
00944         /*@globals internalState @*/
00945         /*@modifies internalState @*/
00946 {
00947         siglongjmp(jenv, 1);
00948 }
00949 
00950 static inline int RPMClass(void)
00951         /*@globals internalState @*/
00952         /*@modifies internalState @*/
00953 {
00954         int cpu;
00955         unsigned int tfms, junk, cap, capamd;
00956         struct sigaction oldsa;
00957         
00958         sigaction(SIGILL, NULL, &oldsa);
00959         signal(SIGILL, model3);
00960         
00961         if (sigsetjmp(jenv, 1)) {
00962                 sigaction(SIGILL, &oldsa, NULL);
00963                 return 3;
00964         }
00965                 
00966         if (cpuid_eax(0x000000000)==0) {
00967                 sigaction(SIGILL, &oldsa, NULL);
00968                 return 4;
00969         }
00970 
00971         cpuid(0x00000001, &tfms, &junk, &junk, &cap);
00972         cpuid(0x80000001, &junk, &junk, &junk, &capamd);
00973         
00974         cpu = (tfms>>8)&15;
00975         
00976         sigaction(SIGILL, &oldsa, NULL);
00977 
00978         if (cpu < 6)
00979                 return cpu;
00980                 
00981         if (cap & (1<<15)) {
00982                 /* CMOV supported? */
00983                 if (capamd & (1<<30))
00984                         return 7;       /* 3DNOWEXT supported */
00985                 return 6;
00986         }
00987                 
00988         return 5;
00989 }
00990 
00991 /* should only be called for model 6 CPU's */
00992 static int is_athlon(void)
00993         /*@*/
00994 {
00995         unsigned int eax, ebx, ecx, edx;
00996         char vendor[16];
00997         int i;
00998         
00999         cpuid (0, &eax, &ebx, &ecx, &edx);
01000 
01001         /* If you care about space, you can just check ebx, ecx and edx directly
01002            instead of forming a string first and then doing a strcmp */
01003         memset(vendor, 0, sizeof(vendor));
01004         
01005         for (i=0; i<4; i++)
01006                 vendor[i] = (unsigned char) (ebx >>(8*i));
01007         for (i=0; i<4; i++)
01008                 vendor[4+i] = (unsigned char) (edx >>(8*i));
01009         for (i=0; i<4; i++)
01010                 vendor[8+i] = (unsigned char) (ecx >>(8*i));
01011                 
01012         if (strncmp(vendor, "AuthenticAMD", 12) != 0)  
01013                 return 0;
01014 
01015         return 1;
01016 }
01017 
01018 static int is_pentium3()
01019 {
01020     unsigned int eax, ebx, ecx, edx, family, model;
01021     char vendor[16];
01022     cpuid(0, &eax, &ebx, &ecx, &edx);
01023     memset(vendor, 0, sizeof(vendor));
01024     *((unsigned int *)&vendor[0]) = ebx;
01025     *((unsigned int *)&vendor[4]) = edx;
01026     *((unsigned int *)&vendor[8]) = ecx;
01027     if (strncmp(vendor, "GenuineIntel", 12) != 0)
01028         return 0;
01029     cpuid(1, &eax, &ebx, &ecx, &edx);
01030     family = (eax >> 8) & 0x0f;
01031     model = (eax >> 4) & 0x0f;
01032     if (family == 6)
01033         switch (model)
01034         {
01035             case 7:     // Pentium III, Pentium III Xeon (model 7)
01036             case 8:     // Pentium III, Pentium III Xeon, Celeron (model 8)
01037             case 9:     // Pentium M
01038                         /*
01039                             Intel recently announced its new technology for mobile platforms,
01040                             named Centrino, and presents it as a big advance in mobile PCs.
01041                             One of the main part of Centrino consists in a brand new CPU,
01042                             the Pentium M, codenamed Banias, that we'll study in this review.
01043                             A particularity of this CPU is that it was designed for mobile platform
01044                             exclusively, unlike previous mobile CPU (Pentium III-M, Pentium 4-M)
01045                             that share the same micro-architecture as their desktop counterparts.
01046                             The Pentium M introduces a new micro-architecture, adapted for mobility
01047                             constraints, and that is halfway between the Pentium III and the Pentium 4.
01048                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
01049                         */
01050             case 10:    // Pentium III Xeon (model A)
01051             case 11:    // Pentium III (model B)
01052                 return 1;
01053         }
01054     return 0;
01055 }
01056 
01057 static int is_pentium4()
01058 {
01059     unsigned int eax, ebx, ecx, edx, family, model;
01060     char vendor[16];
01061     cpuid(0, &eax, &ebx, &ecx, &edx);
01062     memset(vendor, 0, sizeof(vendor));
01063     *((unsigned int *)&vendor[0]) = ebx;
01064     *((unsigned int *)&vendor[4]) = edx;
01065     *((unsigned int *)&vendor[8]) = ecx;
01066     if (strncmp(vendor, "GenuineIntel", 12) != 0)
01067         return 0;
01068     cpuid(1, &eax, &ebx, &ecx, &edx);
01069     family = (eax >> 8) & 0x0f;
01070     model = (eax >> 4) & 0x0f;
01071     if (family == 15)
01072         switch (model)
01073         {
01074             case 0:     // Pentium 4, Pentium 4 Xeon                 (0.18um)
01075             case 1:     // Pentium 4, Pentium 4 Xeon MP, Celeron     (0.18um)
01076             case 2:     // Pentium 4, Mobile Pentium 4-M,
01077                         // Pentium 4 Xeon, Pentium 4 Xeon MP,
01078                         // Celeron, Mobile Celron                    (0.13um)
01079             case 3:     // Pentium 4, Celeron                        (0.09um)
01080                 return 1;
01081         }
01082     return 0;
01083 }
01084 
01085 #endif
01086 
01087 #if defined(__linux__) && defined(__powerpc__)
01088 static jmp_buf mfspr_jmpbuf;
01089 
01090 static void mfspr_ill(int notused)
01091 {
01092     longjmp(mfspr_jmpbuf, -1);
01093 }
01094 #endif
01095 
01098 static void defaultMachine(/*@out@*/ const char ** arch,
01099                 /*@out@*/ const char ** os)
01100         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
01101         /*@modifies *arch, *os, rpmGlobalMacroContext, fileSystem, internalState @*/
01102 {
01103     static struct utsname un;
01104     static int gotDefaults = 0;
01105     char * chptr;
01106     canonEntry canon;
01107     int rc;
01108 
01109     while (!gotDefaults) {
01110         if (!rpmPlatform(platform)) {
01111             const char * s;
01112             s = rpmExpand("%{_host_cpu}", NULL);
01113             if (s) {
01114                 strncpy(un.machine, s, sizeof(un.machine));
01115                 un.machine[sizeof(un.machine)-1] = '\0';
01116                 s = _free(s);
01117             }
01118             s = rpmExpand("%{_host_os}", NULL);
01119             if (s) {
01120                 strncpy(un.sysname, s, sizeof(un.sysname));
01121                 un.sysname[sizeof(un.sysname)-1] = '\0';
01122                 s = _free(s);
01123             }
01124             gotDefaults = 1;
01125             break;
01126         }
01127         rc = uname(&un);
01128         if (rc < 0) return;
01129 
01130 #if !defined(__linux__)
01131 #ifdef SNI
01132         /* USUALLY un.sysname on sinix does start with the word "SINIX"
01133          * let's be absolutely sure
01134          */
01135         strncpy(un.sysname, "SINIX", sizeof(un.sysname));
01136 #endif
01137         /*@-nullpass@*/
01138         if (!strcmp(un.sysname, "AIX")) {
01139             strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
01140             sprintf(un.sysname,"aix%s.%s", un.version, un.release);
01141         }
01142         else if(!strcmp(un.sysname, "Darwin")) { 
01143 #ifdef __ppc__
01144             strcpy(un.machine, "ppc");
01145 #else ifdef __i386__
01146             strcpy(un.machine, "i386");
01147 #endif 
01148         }
01149         else if (!strcmp(un.sysname, "SunOS")) {
01150             if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
01151                 int fd;
01152                 for (fd = 0;
01153                     (un.release[fd] != 0 && (fd < sizeof(un.release)));
01154                     fd++) {
01155                       if (!xisdigit(un.release[fd]) && (un.release[fd] != '.')) {
01156                         un.release[fd] = 0;
01157                         /*@innerbreak@*/ break;
01158                       }
01159                     }
01160                     sprintf(un.sysname,"sunos%s",un.release);
01161             }
01162 
01163             else /* Solaris 2.x: n.x.x becomes n-3.x.x */
01164                 sprintf(un.sysname, "solaris%1d%s", atoi(un.release)-3,
01165                         un.release+1+(atoi(un.release)/10));
01166 
01167             /* Solaris on Intel hardware reports i86pc instead of i386
01168              * (at least on 2.6 and 2.8)
01169              */
01170             if (!strcmp(un.machine, "i86pc"))
01171                 sprintf(un.machine, "i386");
01172         }
01173         else if (!strcmp(un.sysname, "HP-UX"))
01174             /*make un.sysname look like hpux9.05 for example*/
01175             sprintf(un.sysname, "hpux%s", strpbrk(un.release, "123456789"));
01176         else if (!strcmp(un.sysname, "OSF1"))
01177             /*make un.sysname look like osf3.2 for example*/
01178             sprintf(un.sysname, "osf%s", strpbrk(un.release, "123456789"));
01179         else if (!strncmp(un.sysname, "IP", 2))
01180             un.sysname[2] = '\0';
01181         else if (!strncmp(un.sysname, "SINIX", 5)) {
01182             sprintf(un.sysname, "sinix%s",un.release);
01183             if (!strncmp(un.machine, "RM", 2))
01184                 sprintf(un.machine, "mips");
01185         }
01186         else if ((!strncmp(un.machine, "34", 2) ||
01187                 !strncmp(un.machine, "33", 2)) && \
01188                 !strncmp(un.release, "4.0", 3))
01189         {
01190             /* we are on ncr-sysv4 */
01191             char * prelid = NULL;
01192             FD_t fd = Fopen("/etc/.relid", "r.fdio");
01193             int gotit = 0;
01194             /*@-branchstate@*/
01195             if (fd != NULL && !Ferror(fd)) {
01196                 chptr = xcalloc(1, 256);
01197                 {   int irelid = Fread(chptr, sizeof(*chptr), 256, fd);
01198                     (void) Fclose(fd);
01199                     /* example: "112393 RELEASE 020200 Version 01 OS" */
01200                     if (irelid > 0) {
01201                         if ((prelid = strstr(chptr, "RELEASE "))){
01202                             prelid += strlen("RELEASE ")+1;
01203                             sprintf(un.sysname,"ncr-sysv4.%.*s",1,prelid);
01204                             gotit = 1;
01205                         }
01206                     }
01207                 }
01208                 chptr = _free (chptr);
01209             }
01210             /*@=branchstate@*/
01211             if (!gotit) /* parsing /etc/.relid file failed? */
01212                 strcpy(un.sysname,"ncr-sysv4");
01213             /* wrong, just for now, find out how to look for i586 later*/
01214             strcpy(un.machine,"i486");
01215         }
01216         /*@=nullpass@*/
01217 #endif  /* __linux__ */
01218 
01219         /* get rid of the hyphens in the sysname */
01220         for (chptr = un.machine; *chptr != '\0'; chptr++)
01221             if (*chptr == '/') *chptr = '-';
01222 
01223 #       if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
01224             /* little endian */
01225             strcpy(un.machine, "mipsel");
01226 #       elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
01227            /* big endian */
01228                 strcpy(un.machine, "mips");
01229 #       endif
01230 
01231 #       if defined(__hpux) && defined(_SC_CPU_VERSION)
01232         {
01233 #           if !defined(CPU_PA_RISC1_2)
01234 #                define CPU_PA_RISC1_2  0x211 /* HP PA-RISC1.2 */
01235 #           endif
01236 #           if !defined(CPU_PA_RISC2_0)
01237 #               define CPU_PA_RISC2_0  0x214 /* HP PA-RISC2.0 */
01238 #           endif
01239             int cpu_version = sysconf(_SC_CPU_VERSION);
01240 
01241 #           if defined(CPU_HP_MC68020)
01242                 if (cpu_version == CPU_HP_MC68020)
01243                     strcpy(un.machine, "m68k");
01244 #           endif
01245 #           if defined(CPU_HP_MC68030)
01246                 if (cpu_version == CPU_HP_MC68030)
01247                     strcpy(un.machine, "m68k");
01248 #           endif
01249 #           if defined(CPU_HP_MC68040)
01250                 if (cpu_version == CPU_HP_MC68040)
01251                     strcpy(un.machine, "m68k");
01252 #           endif
01253 
01254 #           if defined(CPU_PA_RISC1_0)
01255                 if (cpu_version == CPU_PA_RISC1_0)
01256                     strcpy(un.machine, "hppa1.0");
01257 #           endif
01258 #           if defined(CPU_PA_RISC1_1)
01259                 if (cpu_version == CPU_PA_RISC1_1)
01260                     strcpy(un.machine, "hppa1.1");
01261 #           endif
01262 #           if defined(CPU_PA_RISC1_2)
01263                 if (cpu_version == CPU_PA_RISC1_2)
01264                     strcpy(un.machine, "hppa1.2");
01265 #           endif
01266 #           if defined(CPU_PA_RISC2_0)
01267                 if (cpu_version == CPU_PA_RISC2_0)
01268                     strcpy(un.machine, "hppa2.0");
01269 #           endif
01270         }
01271 #       endif   /* hpux */
01272 
01273 #       if defined(__linux__) && defined(__sparc__)
01274         if (!strcmp(un.machine, "sparc")) {
01275             #define PERS_LINUX          0x00000000
01276             #define PERS_LINUX_32BIT    0x00800000
01277             #define PERS_LINUX32        0x00000008
01278 
01279             extern int personality(unsigned long);
01280             int oldpers;
01281             
01282             oldpers = personality(PERS_LINUX_32BIT);
01283             if (oldpers != -1) {
01284                 if (personality(PERS_LINUX) != -1) {
01285                     uname(&un);
01286                     if (! strcmp(un.machine, "sparc64")) {
01287                         strcpy(un.machine, "sparcv9");
01288                         oldpers = PERS_LINUX32;
01289                     }
01290                 }
01291                 personality(oldpers);
01292             }
01293         }
01294 #       endif   /* sparc*-linux */
01295 
01296 #       if defined(__GNUC__) && defined(__alpha__)
01297         {
01298             unsigned long amask, implver;
01299             register long v0 __asm__("$0") = -1;
01300             __asm__ (".long 0x47e00c20" : "=r"(v0) : "0"(v0));
01301             amask = ~v0;
01302             __asm__ (".long 0x47e03d80" : "=r"(v0));
01303             implver = v0;
01304             switch (implver) {
01305             case 1:
01306                 switch (amask) {
01307                 case 0: strcpy(un.machine, "alphaev5"); break;
01308                 case 1: strcpy(un.machine, "alphaev56"); break;
01309                 case 0x101: strcpy(un.machine, "alphapca56"); break;
01310                 }
01311                 break;
01312             case 2:
01313                 switch (amask) {
01314                 case 0x303: strcpy(un.machine, "alphaev6"); break;
01315                 case 0x307: strcpy(un.machine, "alphaev67"); break;
01316                 }
01317                 break;
01318             }
01319         }
01320 #       endif
01321 
01322 #       if defined(__linux__) && defined(__i386__)
01323         {
01324             char class = (char) (RPMClass() | '0');
01325 
01326             if ((class == '6' && is_athlon()) || class == '7')
01327                 strcpy(un.machine, "athlon");
01328             else if (is_pentium4())
01329                 strcpy(un.machine, "pentium4");
01330             else if (is_pentium3())
01331                 strcpy(un.machine, "pentium3");
01332             else if (strchr("3456", un.machine[1]) && un.machine[1] != class)
01333                 un.machine[1] = class;
01334         }
01335 #       endif
01336 
01337         /* the uname() result goes through the arch_canon table */
01338         canon = lookupInCanonTable(un.machine,
01339                                    tables[RPM_MACHTABLE_INSTARCH].canons,
01340                                    tables[RPM_MACHTABLE_INSTARCH].canonsLength);
01341         if (canon)
01342             strcpy(un.machine, canon->short_name);
01343 
01344         canon = lookupInCanonTable(un.sysname,
01345                                    tables[RPM_MACHTABLE_INSTOS].canons,
01346                                    tables[RPM_MACHTABLE_INSTOS].canonsLength);
01347         if (canon)
01348             strcpy(un.sysname, canon->short_name);
01349         gotDefaults = 1;
01350         break;
01351     }
01352 
01353     if (arch) *arch = un.machine;
01354     if (os) *os = un.sysname;
01355 }
01356 
01357 static /*@observer@*/ /*@null@*/
01358 const char * rpmGetVarArch(int var, /*@null@*/ const char * arch)
01359         /*@*/
01360 {
01361     const struct rpmvarValue * next;
01362 
01363     if (arch == NULL) arch = current[ARCH];
01364 
01365     if (arch) {
01366         next = &values[var];
01367         while (next) {
01368             if (next->arch && !strcmp(next->arch, arch)) return next->value;
01369             next = next->next;
01370         }
01371     }
01372 
01373     next = values + var;
01374     while (next && next->arch) next = next->next;
01375 
01376     return next ? next->value : NULL;
01377 }
01378 
01379 const char *rpmGetVar(int var)
01380 {
01381     return rpmGetVarArch(var, NULL);
01382 }
01383 
01384 /* this doesn't free the passed pointer! */
01385 static void freeRpmVar(/*@only@*/ struct rpmvarValue * orig)
01386         /*@modifies *orig @*/
01387 {
01388     struct rpmvarValue * next, * var = orig;
01389 
01390     while (var) {
01391         next = var->next;
01392         var->arch = _free(var->arch);
01393         var->value = _free(var->value);
01394 
01395         /*@-branchstate@*/
01396         if (var != orig) var = _free(var);
01397         /*@=branchstate@*/
01398         var = next;
01399     }
01400 }
01401 
01402 void rpmSetVar(int var, const char * val)
01403         /*@globals values @*/
01404         /*@modifies values @*/
01405 {
01406     /*@-immediatetrans@*/
01407     freeRpmVar(&values[var]);
01408     /*@=immediatetrans@*/
01409     values[var].value = (val ? xstrdup(val) : NULL);
01410 }
01411 
01412 static void rpmSetVarArch(int var, const char * val, const char * arch)
01413 {
01414     struct rpmvarValue * next = values + var;
01415 
01416     if (next->value) {
01417         if (arch) {
01418             while (next->next) {
01419                 if (next->arch && !strcmp(next->arch, arch)) break;
01420                 next = next->next;
01421             }
01422         } else {
01423             while (next->next) {
01424                 if (!next->arch) break;
01425                 next = next->next;
01426             }
01427         }
01428 
01429         /*@-nullpass@*/ /* LCL: arch != NULL here. */
01430         if (next->arch && arch && !strcmp(next->arch, arch)) {
01431         /*@=nullpass@*/
01432             next->value = _free(next->value);
01433             next->arch = _free(next->arch);
01434         } else if (next->arch || arch) {
01435             next->next = xmalloc(sizeof(*next->next));
01436             next = next->next;
01437             next->value = NULL;
01438             next->arch = NULL;
01439             next->next = NULL;
01440         }
01441     }
01442 
01443     next->value = _free(next->value);
01444     next->value = xstrdup(val);
01445     next->arch = (arch ? xstrdup(arch) : NULL);
01446 }
01447 
01448 void rpmSetTables(int archTable, int osTable)
01449         /*@globals currTables @*/
01450         /*@modifies currTables @*/
01451 {
01452     const char * arch, * os;
01453 
01454     defaultMachine(&arch, &os);
01455 
01456     if (currTables[ARCH] != archTable) {
01457         currTables[ARCH] = archTable;
01458         rebuildCompatTables(ARCH, arch);
01459     }
01460 
01461     if (currTables[OS] != osTable) {
01462         currTables[OS] = osTable;
01463         rebuildCompatTables(OS, os);
01464     }
01465 }
01466 
01467 int rpmMachineScore(int type, const char * name)
01468 {
01469     machEquivInfo info = machEquivSearch(&tables[type].equiv, name);
01470     return (info != NULL ? info->score : 0);
01471 }
01472 
01473 void rpmGetMachine(const char ** arch, const char ** os)
01474 {
01475     if (arch)
01476         *arch = current[ARCH];
01477 
01478     if (os)
01479         *os = current[OS];
01480 }
01481 
01482 void rpmSetMachine(const char * arch, const char * os)
01483         /*@globals current @*/
01484         /*@modifies current @*/
01485 {
01486     const char * host_cpu, * host_os;
01487 
01488     defaultMachine(&host_cpu, &host_os);
01489 
01490     if (arch == NULL) {
01491         arch = host_cpu;
01492         if (tables[currTables[ARCH]].hasTranslate)
01493             arch = lookupInDefaultTable(arch,
01494                             tables[currTables[ARCH]].defaults,
01495                             tables[currTables[ARCH]].defaultsLength);
01496     }
01497     if (arch == NULL) return;   /* XXX can't happen */
01498 
01499     if (os == NULL) {
01500         os = host_os;
01501         if (tables[currTables[OS]].hasTranslate)
01502             os = lookupInDefaultTable(os,
01503                             tables[currTables[OS]].defaults,
01504                             tables[currTables[OS]].defaultsLength);
01505     }
01506     if (os == NULL) return;     /* XXX can't happen */
01507 
01508     if (!current[ARCH] || strcmp(arch, current[ARCH])) {
01509         current[ARCH] = _free(current[ARCH]);
01510         current[ARCH] = xstrdup(arch);
01511         rebuildCompatTables(ARCH, host_cpu);
01512     }
01513 
01514     if (!current[OS] || strcmp(os, current[OS])) {
01515         char * t = xstrdup(os);
01516         current[OS] = _free(current[OS]);
01517         /*
01518          * XXX Capitalizing the 'L' is needed to insure that old
01519          * XXX os-from-uname (e.g. "Linux") is compatible with the new
01520          * XXX os-from-platform (e.g "linux" from "sparc-*-linux").
01521          * XXX A copy of this string is embedded in headers and is
01522          * XXX used by rpmInstallPackage->{os,arch}Okay->rpmMachineScore->
01523          * XXX to verify correct arch/os from headers.
01524          */
01525         if (!strcmp(t, "linux"))
01526             *t = 'L';
01527         current[OS] = t;
01528         
01529         rebuildCompatTables(OS, host_os);
01530     }
01531 }
01532 
01533 static void rebuildCompatTables(int type, const char * name)
01534         /*@*/
01535 {
01536     machFindEquivs(&tables[currTables[type]].cache,
01537                    &tables[currTables[type]].equiv,
01538                    name);
01539 }
01540 
01541 static void getMachineInfo(int type, /*@null@*/ /*@out@*/ const char ** name,
01542                         /*@null@*/ /*@out@*/int * num)
01543         /*@modifies *name, *num @*/
01544 {
01545     canonEntry canon;
01546     int which = currTables[type];
01547 
01548     /* use the normal canon tables, even if we're looking up build stuff */
01549     if (which >= 2) which -= 2;
01550 
01551     canon = lookupInCanonTable(current[type],
01552                                tables[which].canons,
01553                                tables[which].canonsLength);
01554 
01555     if (canon) {
01556         if (num) *num = canon->num;
01557         if (name) *name = canon->short_name;
01558     } else {
01559         if (num) *num = 255;
01560         if (name) *name = current[type];
01561 
01562         if (tables[currTables[type]].hasCanon) {
01563             rpmMessage(RPMMESS_WARNING, _("Unknown system: %s\n"), current[type]);
01564             rpmMessage(RPMMESS_WARNING, _("Please contact rpm-maint@lists.rpm.org\n"));
01565         }
01566     }
01567 }
01568 
01569 void rpmGetArchInfo(const char ** name, int * num)
01570 {
01571     getMachineInfo(ARCH, name, num);
01572 }
01573 
01574 void rpmGetOsInfo(const char ** name, int * num)
01575 {
01576     getMachineInfo(OS, name, num);
01577 }
01578 
01579 static void rpmRebuildTargetVars(const char ** target, const char ** canontarget)
01580 {
01581 
01582     char *ca = NULL, *co = NULL, *ct = NULL;
01583     int x;
01584 
01585     /* Rebuild the compat table to recalculate the current target arch.  */
01586 
01587     rpmSetMachine(NULL, NULL);
01588     rpmSetTables(RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS);
01589     rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
01590 
01591     /*@-branchstate@*/
01592     if (target && *target) {
01593         char *c;
01594         /* Set arch and os from specified build target */
01595         ca = xstrdup(*target);
01596         if ((c = strchr(ca, '-')) != NULL) {
01597             *c++ = '\0';
01598             
01599             if ((co = strrchr(c, '-')) == NULL) {
01600                 co = c;
01601             } else {
01602                 if (!xstrcasecmp(co, "-gnu"))
01603                     *co = '\0';
01604                 if ((co = strrchr(c, '-')) == NULL)
01605                     co = c;
01606                 else
01607                     co++;
01608             }
01609             if (co != NULL) co = xstrdup(co);
01610         }
01611     } else {
01612         const char *a = NULL;
01613         const char *o = NULL;
01614         /* Set build target from rpm arch and os */
01615         rpmGetArchInfo(&a, NULL);
01616         ca = (a) ? xstrdup(a) : NULL;
01617         rpmGetOsInfo(&o, NULL);
01618         co = (o) ? xstrdup(o) : NULL;
01619     }
01620     /*@=branchstate@*/
01621 
01622     /* If still not set, Set target arch/os from default uname(2) values */
01623     if (ca == NULL) {
01624         const char *a = NULL;
01625         defaultMachine(&a, NULL);
01626         ca = (a) ? xstrdup(a) : NULL;
01627     }
01628     for (x = 0; ca[x] != '\0'; x++)
01629         ca[x] = xtolower(ca[x]);
01630 
01631     if (co == NULL) {
01632         const char *o = NULL;
01633         defaultMachine(NULL, &o);
01634         co = (o) ? xstrdup(o) : NULL;
01635     }
01636     for (x = 0; co[x] != '\0'; x++)
01637         co[x] = xtolower(co[x]);
01638 
01639     /* XXX For now, set canonical target to arch-os */
01640     if (ct == NULL) {
01641         ct = xmalloc(strlen(ca) + sizeof("-") + strlen(co));
01642         sprintf(ct, "%s-%s", ca, co);
01643     }
01644 
01645 /*
01646  * XXX All this macro pokery/jiggery could be achieved by doing a delayed
01647  *      rpmInitMacros(NULL, PER-PLATFORM-MACRO-FILE-NAMES);
01648  */
01649     delMacro(NULL, "_target");
01650     addMacro(NULL, "_target", NULL, ct, RMIL_RPMRC);
01651     delMacro(NULL, "_target_cpu");
01652     addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC);
01653     delMacro(NULL, "_target_os");
01654     addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
01655 /*
01656  * XXX Make sure that per-arch optflags is initialized correctly.
01657  */
01658   { const char *optflags = rpmGetVarArch(RPMVAR_OPTFLAGS, ca);
01659     if (optflags != NULL) {
01660         delMacro(NULL, "optflags");
01661         addMacro(NULL, "optflags", NULL, optflags, RMIL_RPMRC);
01662     }
01663   }
01664 
01665     /*@-branchstate@*/
01666     if (canontarget)
01667         *canontarget = ct;
01668     else
01669         ct = _free(ct);
01670     /*@=branchstate@*/
01671     ca = _free(ca);
01672     /*@-usereleased@*/
01673     co = _free(co);
01674     /*@=usereleased@*/
01675 }
01676 
01677 void rpmFreeRpmrc(void)
01678         /*@globals current, tables, values, defaultsInitialized,
01679                 platpat, nplatpat @*/
01680         /*@modifies current, tables, values, defaultsInitialized,
01681                 platpat, nplatpat @*/
01682 {
01683     int i, j, k;
01684 
01685 /*@-onlyunqglobaltrans -unqualifiedtrans @*/
01686     if (platpat)
01687     for (i = 0; i < nplatpat; i++)
01688         platpat[i] = _free(platpat[i]);
01689     platpat = _free(platpat);
01690 /*@-onlyunqglobaltrans =unqualifiedtrans @*/
01691     nplatpat = 0;
01692 
01693     for (i = 0; i < RPM_MACHTABLE_COUNT; i++) {
01694         tableType t;
01695         t = tables + i;
01696         if (t->equiv.list) {
01697             for (j = 0; j < t->equiv.count; j++)
01698                 t->equiv.list[j].name = _free(t->equiv.list[j].name);
01699             t->equiv.list = _free(t->equiv.list);
01700             t->equiv.count = 0;
01701         }
01702         if (t->cache.cache) {
01703             for (j = 0; j < t->cache.size; j++) {
01704                 machCacheEntry e;
01705                 e = t->cache.cache + j;
01706                 if (e == NULL)
01707                     /*@innercontinue@*/ continue;
01708                 e->name = _free(e->name);
01709                 if (e->equivs) {
01710                     for (k = 0; k < e->count; k++)
01711                         e->equivs[k] = _free(e->equivs[k]);
01712                     e->equivs = _free(e->equivs);
01713                 }
01714             }
01715             t->cache.cache = _free(t->cache.cache);
01716             t->cache.size = 0;
01717         }
01718         if (t->defaults) {
01719             for (j = 0; j < t->defaultsLength; j++) {
01720                 t->defaults[j].name = _free(t->defaults[j].name);
01721                 t->defaults[j].defName = _free(t->defaults[j].defName);
01722             }
01723             t->defaults = _free(t->defaults);
01724             t->defaultsLength = 0;
01725         }
01726         if (t->canons) {
01727             for (j = 0; j < t->canonsLength; j++) {
01728                 t->canons[j].name = _free(t->canons[j].name);
01729                 t->canons[j].short_name = _free(t->canons[j].short_name);
01730             }
01731             t->canons = _free(t->canons);
01732             t->canonsLength = 0;
01733         }
01734     }
01735 
01736     for (i = 0; i < RPMVAR_NUM; i++) {
01737         /*@only@*/ /*@null@*/ struct rpmvarValue * vp;
01738         while ((vp = values[i].next) != NULL) {
01739             values[i].next = vp->next;
01740             vp->value = _free(vp->value);
01741             vp->arch = _free(vp->arch);
01742             vp = _free(vp);
01743         }
01744         values[i].value = _free(values[i].value);
01745         values[i].arch = _free(values[i].arch);
01746     }
01747     current[OS] = _free(current[OS]);
01748     current[ARCH] = _free(current[ARCH]);
01749     defaultsInitialized = 0;
01750 /*@-globstate -nullstate@*/ /* FIX: platpat/current may be NULL */
01751     return;
01752 /*@=globstate =nullstate@*/
01753 }
01754 
01760 static int rpmReadRC(/*@null@*/ const char * rcfiles)
01761         /*@globals defaultsInitialized, rpmGlobalMacroContext,
01762                 rpmCLIMacroContext, h_errno, fileSystem, internalState @*/
01763         /*@modifies defaultsInitialized, rpmGlobalMacroContext,
01764                 fileSystem, internalState @*/
01765 {
01766     char *myrcfiles, *r, *re;
01767     int rc;
01768 
01769     if (!defaultsInitialized) {
01770         setDefaults();
01771         defaultsInitialized = 1;
01772     }
01773 
01774     if (rcfiles == NULL)
01775         rcfiles = defrcfiles;
01776 
01777     /* Read each file in rcfiles. */
01778     rc = 0;
01779     for (r = myrcfiles = xstrdup(rcfiles); r && *r != '\0'; r = re) {
01780         char fn[4096];
01781         FD_t fd;
01782 
01783         /* Get pointer to rest of files */
01784         for (re = r; (re = strchr(re, ':')) != NULL; re++) {
01785             if (!(re[1] == '/' && re[2] == '/'))
01786                 /*@innerbreak@*/ break;
01787         }
01788         if (re && *re == ':')
01789             *re++ = '\0';
01790         else
01791             re = r + strlen(r);
01792 
01793         /* Expand ~/ to $HOME/ */
01794         fn[0] = '\0';
01795         if (r[0] == '~' && r[1] == '/') {
01796             const char * home = getenv("HOME");
01797             if (home == NULL) {
01798             /* XXX Only /usr/lib/rpm/rpmrc must exist in default rcfiles list */
01799                 if (rcfiles == defrcfiles && myrcfiles != r)
01800                     continue;
01801                 rpmError(RPMERR_RPMRC, _("Cannot expand %s\n"), r);
01802                 rc = 1;
01803                 break;
01804             }
01805             if (strlen(home) > (sizeof(fn) - strlen(r))) {
01806                 rpmError(RPMERR_RPMRC, _("Cannot read %s, HOME is too large.\n"),
01807                                 r);
01808                 rc = 1;
01809                 break;
01810             }
01811             strcpy(fn, home);
01812             r++;
01813         }
01814         strncat(fn, r, sizeof(fn) - (strlen(fn) + 1));
01815         fn[sizeof(fn)-1] = '\0';
01816 
01817         /* Read another rcfile */
01818         fd = Fopen(fn, "r.fpio");
01819         if (fd == NULL || Ferror(fd)) {
01820             /* XXX Only /usr/lib/rpm/rpmrc must exist in default rcfiles list */
01821             if (rcfiles == defrcfiles && myrcfiles != r)
01822                 continue;
01823             rpmError(RPMERR_RPMRC, _("Unable to open %s for reading: %s.\n"),
01824                  fn, Fstrerror(fd));
01825             rc = 1;
01826             break;
01827         } else {
01828             rc = doReadRC(fd, fn);
01829         }
01830         if (rc) break;
01831     }
01832     myrcfiles = _free(myrcfiles);
01833     if (rc)
01834         return rc;
01835 
01836     rpmSetMachine(NULL, NULL);  /* XXX WTFO? Why bother? */
01837 
01838     {   const char *mfpath;
01839         /*@-branchstate@*/
01840         if ((mfpath = rpmGetVar(RPMVAR_MACROFILES)) != NULL) {
01841             mfpath = xstrdup(mfpath);
01842             rpmInitMacros(NULL, mfpath);
01843             mfpath = _free(mfpath);
01844         }
01845         /*@=branchstate@*/
01846     }
01847 
01848     return rc;
01849 }
01850 
01851 int rpmReadConfigFiles(const char * file, const char * target)
01852 {
01853 
01854     /* Preset target macros */
01855     /*@-nullstate@*/    /* FIX: target can be NULL */
01856     rpmRebuildTargetVars(&target, NULL);
01857 
01858     /* Read the files */
01859     if (rpmReadRC(file)) return -1;
01860 
01861     /* Reset target macros */
01862     rpmRebuildTargetVars(&target, NULL);
01863     /*@=nullstate@*/
01864 
01865     /* Finally set target platform */
01866     {   const char *cpu = rpmExpand("%{_target_cpu}", NULL);
01867         const char *os = rpmExpand("%{_target_os}", NULL);
01868         rpmSetMachine(cpu, os);
01869         cpu = _free(cpu);
01870         os = _free(os);
01871     }
01872 
01873     /* Force Lua state initialization */
01874 #ifdef WITH_LUA
01875     (void)rpmluaGetPrintBuffer(NULL);
01876 #endif
01877 
01878     return 0;
01879 }
01880 
01881 int rpmShowRC(FILE * fp)
01882 {
01883     struct rpmOption *opt;
01884     int i;
01885     machEquivTable equivTable;
01886 
01887     /* the caller may set the build arch which should be printed here */
01888     fprintf(fp, "ARCHITECTURE AND OS:\n");
01889     fprintf(fp, "build arch            : %s\n", current[ARCH]);
01890 
01891     fprintf(fp, "compatible build archs:");
01892     equivTable = &tables[RPM_MACHTABLE_BUILDARCH].equiv;
01893     for (i = 0; i < equivTable->count; i++)
01894         fprintf(fp," %s", equivTable->list[i].name);
01895     fprintf(fp, "\n");
01896 
01897     fprintf(fp, "build os              : %s\n", current[OS]);
01898 
01899     fprintf(fp, "compatible build os's :");
01900     equivTable = &tables[RPM_MACHTABLE_BUILDOS].equiv;
01901     for (i = 0; i < equivTable->count; i++)
01902         fprintf(fp," %s", equivTable->list[i].name);
01903     fprintf(fp, "\n");
01904 
01905     rpmSetTables(RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS);
01906     rpmSetMachine(NULL, NULL);  /* XXX WTFO? Why bother? */
01907 
01908     fprintf(fp, "install arch          : %s\n", current[ARCH]);
01909     fprintf(fp, "install os            : %s\n", current[OS]);
01910 
01911     fprintf(fp, "compatible archs      :");
01912     equivTable = &tables[RPM_MACHTABLE_INSTARCH].equiv;
01913     for (i = 0; i < equivTable->count; i++)
01914         fprintf(fp," %s", equivTable->list[i].name);
01915     fprintf(fp, "\n");
01916 
01917     fprintf(fp, "compatible os's       :");
01918     equivTable = &tables[RPM_MACHTABLE_INSTOS].equiv;
01919     for (i = 0; i < equivTable->count; i++)
01920         fprintf(fp," %s", equivTable->list[i].name);
01921     fprintf(fp, "\n");
01922 
01923     fprintf(fp, "\nRPMRC VALUES:\n");
01924     for (i = 0, opt = optionTable; i < optionTableSize; i++, opt++) {
01925         const char *s = rpmGetVar(opt->var);
01926         if (s != NULL || rpmIsVerbose())
01927             fprintf(fp, "%-21s : %s\n", opt->name, s ? s : "(not set)");
01928     }
01929     fprintf(fp, "\n");
01930 
01931     fprintf(fp, "Features supported by rpmlib:\n");
01932     rpmShowRpmlibProvides(fp);
01933     fprintf(fp, "\n");
01934 
01935     rpmDumpMacroTable(NULL, fp);
01936 
01937     return 0;
01938 }
01939 /*@=bounds@*/

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