# lib/rpmrc.c File Reference

`#include "system.h"`
`#include <stdarg.h>`
`#include <rpmlib.h>`
`#include <rpmmacro.h>`
`#include "misc.h"`
`#include "debug.h"`

Go to the source code of this file.

## Data Structures

struct | machCacheEntry_s
struct | machCache_s
struct | machEquivInfo_s
struct | machEquivTable_s
struct | rpmvarValue
struct | rpmOption
struct | defaultEntry_s
struct | canonEntry_s
struct | tableType_s

## Defines

#define | __power_pc() 0
#define | OS 0
#define | ARCH 1
#define | _TOPDIRMACRO "%{_topdir}/"

## Typedefs

typedef const char * | cptr_t
typedef machCacheEntry_s * | machCacheEntry
typedef machCache_s * | machCache
typedef machEquivInfo_s * | machEquivInfo
typedef machEquivTable_s * | machEquivTable
typedef defaultEntry_s * | defaultEntry
typedef canonEntry_s * | canonEntry
typedef tableType_s * | tableType

## Functions

int | doReadRC (FD_t fd, const char *urlfn)
void | rpmSetVarArch (int var, const char *val, const char *arch)
void | rebuildCompatTables (int type, const char *name)
void | rpmRebuildTargetVars (const char **target, const char **canontarget)
int | optionCompare (const void *a, const void *b)
machCacheEntry | machCacheFindEntry (const machCache cache, const char *key)
int | machCompatCacheAdd (char *name, const char *fn, int linenum, machCache cache)
machEquivInfo | machEquivSearch (const machEquivTable table, const char *name)
void | machAddEquiv (machEquivTable table, const char *name, int distance)
void | machCacheEntryVisit (machCache cache, machEquivTable table, const char *name, int distance)
void | machFindEquivs (machCache cache, machEquivTable table, const char *key)
int | addCanon (canonEntry *table, int *tableLen, char *line, const char *fn, int lineNum)
int | addDefault (defaultEntry *table, int *tableLen, char *line, const char *fn, int lineNum)
const canonEntry | lookupInCanonTable (const char *name, const canonEntry table, int tableLen)
const char * | lookupInDefaultTable (const char *name, const defaultEntry table, int tableLen)
void | setVarDefault (int var, const char *macroname, const char *val, const char *body)
void | setPathDefault (int var, const char *macroname, const char *subdir)
void | setDefaults (void)
void | defaultMachine (const char **arch, const char **os)
const char * | rpmGetVarArch (int var, const char *arch)
const char * | rpmGetVar (int var)
void | freeRpmVar (struct rpmvarValue *orig)
void | rpmSetVar (int var, const char *val)
void | rpmSetTables (int archTable, int osTable)
int | rpmMachineScore (int type, const char *name)
void | rpmGetMachine (const char **arch, const char **os)
void | rpmSetMachine (const char *arch, const char *os)
void | getMachineInfo (int type, const char **name, int *num)
void | rpmGetArchInfo (const char **name, int *num)
void | rpmGetOsInfo (const char **name, int *num)
void | rpmFreeRpmrc (void)
int | rpmReadRC (const char *rcfiles)
int | rpmReadConfigFiles (const char *file, const char *target)
int | rpmShowRC (FILE *fp)

## Variables

const char * | defrcfiles = LIBRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"
const char * | macrofiles = MACROFILES
tableType_s | tables [RPM_MACHTABLE_COUNT]
rpmOption | optionTable []
int | optionTableSize = sizeof(optionTable) / sizeof(*optionTable)
cptr_t | current [2]
int | currTables [2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }
rpmvarValue | values [RPMVAR_NUM]
int | defaultsInitialized = 0
const char * | prescriptenviron

## Define Documentation

#define __power_pc | (

)

0

| Definition at line 13 of file rpmrc.c. Referenced by defaultMachine().

#define _TOPDIRMACRO "%{_topdir}/"

| Referenced by setPathDefault().

#define ARCH 1

| Definition at line 123 of file rpmrc.c. Referenced by doReadRC(), rpmFreeRpmrc(), rpmGetArchInfo(), rpmGetMachine(), rpmGetVarArch(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().

#define OS 0

| Definition at line 122 of file rpmrc.c. Referenced by rpmFreeRpmrc(), rpmGetMachine(), rpmGetOsInfo(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().

## Typedef Documentation

typedef struct canonEntry_s * canonEntry

| Referenced by addCanon(), defaultMachine(), getMachineInfo(), and lookupInCanonTable().

typedef const char* cptr_t

| Definition at line 30 of file rpmrc.c.

typedef struct defaultEntry_s * defaultEntry

| Referenced by addDefault(), and lookupInDefaultTable().

typedef struct machCache_s * machCache

| Referenced by machCacheEntryVisit(), machCacheFindEntry(), machCompatCacheAdd(), and machFindEquivs().

typedef struct machCacheEntry_s * machCacheEntry

| Referenced by machCacheEntryVisit(), machCompatCacheAdd(), and rpmFreeRpmrc().

typedef struct machEquivInfo_s * machEquivInfo

| Referenced by machAddEquiv(), and rpmMachineScore().

typedef struct machEquivTable_s * machEquivTable

| Referenced by machAddEquiv(), machCacheEntryVisit(), machEquivSearch(), machFindEquivs(), and rpmShowRC().

typedef struct tableType_s * tableType

| Referenced by rpmFreeRpmrc().

## Function Documentation

int addCanon | ( | canonEntry * | table,
|  | int * | tableLen,
|  | char * | line,
|  | const char * | fn,
|  | int | lineNum
| ) | `[static]`

| Definition at line 327 of file rpmrc.c. References _, canonEntry, canonEntry_s::name, canonEntry_s::num, RPMERR_RPMRC, rpmError, canonEntry_s::short_name, xrealloc(), and xstrdup(). Referenced by doReadRC().

int addDefault | ( | defaultEntry * | table,
|  | int * | tableLen,
|  | char * | line,
|  | const char * | fn,
|  | int | lineNum
| ) | `[static]`

| Definition at line 381 of file rpmrc.c. References _, defaultEntry, defaultEntry_s::defName, defaultEntry_s::name, RPMERR_RPMRC, rpmError, xrealloc(), and xstrdup(). Referenced by doReadRC().

void defaultMachine | ( | const char ** | arch,
|  | const char ** | os
| ) | `[static]`

| Definition at line 936 of file rpmrc.c. References __power_pc, _free(), canonEntry, Fclose(), FD_t, Ferror(), Fopen(), Fread(), lookupInCanonTable(), RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS, canonEntry_s::short_name, tables, xcalloc(), and xisdigit(). Referenced by rpmRebuildTargetVars(), rpmSetMachine(), and rpmSetTables().

int doReadRC | ( | FD_t | fd,
|  | const char * | urlfn
| ) | `[static]`

Definition at line 552 of file rpmrc.c.

References _, _free(), addCanon(), addDefault(), addMacro(), alloca(), ARCH, current, Fclose(), FD_t, fdSize(), Ferror(), Fopen(), Fread(), Fstrerror(), tableType_s::hasCanon, tableType_s::hasTranslate, machCompatCacheAdd(), rpmOption::name, optionCompare(), optionTable, optionTableSize, RMIL_RPMRC, RPM_MACHTABLE_COUNT, RPMERR_RPMRC, rpmError, rpmGetPath(), rpmGetVar(), rpmRebuildTargetVars(), rpmSetVarArch(), RPMVAR_INCLUDE, RPMVAR_MACROFILES, RPMVAR_PROVIDES, tables, xisspace(), and xmalloc().

Referenced by rpmReadRC().

void freeRpmVar | ( | struct rpmvarValue * | orig | ) | `[static]`

| Definition at line 1215 of file rpmrc.c. References _free(), rpmvarValue::arch, and rpmvarValue::next. Referenced by rpmSetVar().

void getMachineInfo | ( | int | type,
|  | const char ** | name,
|  | int * | num
| ) | `[static]`

| Definition at line 1365 of file rpmrc.c. References _, canonEntry, current, currTables, tableType_s::hasCanon, lookupInCanonTable(), canonEntry_s::num, RPMMESS_WARNING, rpmMessage, canonEntry_s::short_name, and tables. Referenced by rpmGetArchInfo(), and rpmGetOsInfo().

const canonEntry lookupInCanonTable | ( | const char * | name,
|  | const canonEntry | table,
|  | int | tableLen
| ) | `[static]`

| Definition at line 416 of file rpmrc.c. References canonEntry. Referenced by defaultMachine(), and getMachineInfo().

const char* lookupInDefaultTable | ( | const char * | name,
|  | const defaultEntry | table,
|  | int | tableLen
| ) | `[static]`

| Definition at line 433 of file rpmrc.c. References defaultEntry, defaultEntry_s::defName, and defaultEntry_s::name. Referenced by rpmSetMachine().

void machAddEquiv | ( | machEquivTable | table,
|  | const char * | name,
|  | int | distance
| ) | `[static]`

| Definition at line 259 of file rpmrc.c. References machEquivTable_s::count, machEquivTable_s::list, machEquivInfo, machEquivSearch(), machEquivTable, machEquivInfo_s::name, machEquivInfo_s::score, xmalloc(), xrealloc(), and xstrdup(). Referenced by machCacheEntryVisit(), and machFindEquivs().

void machCacheEntryVisit | ( | machCache | cache,
|  | machEquivTable | table,
|  | const char * | name,
|  | int | distance
| ) | `[static]`

| Definition at line 278 of file rpmrc.c. References machCacheEntry_s::count, machCacheEntry_s::equivs, machAddEquiv(), machCache, machCacheEntry, machCacheFindEntry(), machEquivTable, and machCacheEntry_s::visited. Referenced by machFindEquivs().

machCacheEntry machCacheFindEntry | ( | const machCache | cache,
|  | const char * | key
| ) | `[static]`

| Definition at line 165 of file rpmrc.c. References machCache_s::cache, machCache, machCacheEntry_s::name, and machCache_s::size. Referenced by machCacheEntryVisit(), and machCompatCacheAdd().

int machCompatCacheAdd | ( | char * | name,
|  | const char * | fn,
|  | int | linenum,
|  | machCache | cache
| ) | `[static]`

| Definition at line 176 of file rpmrc.c. References _, _free(), machCache_s::cache, machCacheEntry_s::count, machCacheEntry_s::equivs, machCache, machCacheEntry, machCacheFindEntry(), machCacheEntry_s::name, RPMERR_RPMRC, rpmError, machCache_s::size, machCacheEntry_s::visited, xisspace(), xmalloc(), xrealloc(), and xstrdup(). Referenced by doReadRC().

machEquivInfo machEquivSearch | ( | const machEquivTable | table,
|  | const char * | name
| ) | `[static]`

| Definition at line 247 of file rpmrc.c. References machEquivTable_s::count, machEquivTable_s::list, machEquivTable, machEquivInfo_s::name, and xstrcasecmp(). Referenced by machAddEquiv(), and rpmMachineScore().

void machFindEquivs | ( | machCache | cache,
|  | machEquivTable | table,
|  | const char * | key
| ) | `[static]`

| Definition at line 299 of file rpmrc.c. References _free(), machCache_s::cache, machEquivTable_s::count, machEquivTable_s::list, machAddEquiv(), machCache, machCacheEntryVisit(), machEquivTable, machEquivInfo_s::name, machCache_s::size, and machCacheEntry_s::visited. Referenced by rebuildCompatTables().

int optionCompare | ( | const void * | a,
|  | const void * | b
| ) | `[static]`

| Definition at line 157 of file rpmrc.c. References xstrcasecmp(). Referenced by doReadRC().

void rebuildCompatTables | ( | int | type,
|  | const char * | name
| ) | `[static]`

| Definition at line 1357 of file rpmrc.c. References currTables, machFindEquivs(), and tables. Referenced by rpmSetMachine(), and rpmSetTables().

const char* rpmGetVarArch | ( | int | var,
|  | const char * | arch
| ) | `[static]`

| Definition at line 1188 of file rpmrc.c. References ARCH, current, rpmvarValue::next, rpmvarValue::value, and values. Referenced by rpmGetVar(), and rpmRebuildTargetVars().

void rpmRebuildTargetVars | ( | const char ** | target,
|  | const char ** | canontarget
| ) | `[static]`

Definition at line 1403 of file rpmrc.c.

References _free(), addMacro(), defaultMachine(), delMacro(), RMIL_RPMRC, RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS, RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS, rpmGetArchInfo(), rpmGetOsInfo(), rpmGetVarArch(), rpmSetMachine(), rpmSetTables(), RPMVAR_OPTFLAGS, xmalloc(), xstrcasecmp(), xstrdup(), and xtolower().

Referenced by doReadRC(), and rpmReadConfigFiles().

void rpmSetVarArch | ( | int | var,
|  | const char * | val,
|  | const char * | arch
| ) | `[static]`

| Definition at line 1240 of file rpmrc.c. References _free(), rpmvarValue::next, rpmvarValue::value, values, xmalloc(), and xstrdup(). Referenced by doReadRC().

void setDefaults | ( | void |  | ) | `[static]`

| Definition at line 513 of file rpmrc.c. References addMacro(), prescriptenviron, RMIL_DEFAULT, RPMVAR_OPTFLAGS, setPathDefault(), and setVarDefault(). Referenced by rpmReadRC().

void setPathDefault | ( | int | var,
|  | const char * | macroname,
|  | const char * | subdir
| ) | `[static]`

| Definition at line 461 of file rpmrc.c. References _free(), _TOPDIRMACRO, addMacro(), alloca(), RMIL_DEFAULT, rpmGetPath(), rpmGetVar(), and rpmSetVar(). Referenced by setDefaults().

void setVarDefault | ( | int | var,
|  | const char * | macroname,
|  | const char * | val,
|  | const char * | body
| ) | `[static]`

| Definition at line 446 of file rpmrc.c. References addMacro(), RMIL_DEFAULT, rpmGetVar(), and rpmSetVar(). Referenced by setDefaults().

## Variable Documentation

cptr_t current[2]`[static]`

| Definition at line 126 of file rpmrc.c. Referenced by doReadRC(), getMachineInfo(), rpmFreeRpmrc(), rpmGetMachine(), rpmGetVarArch(), rpmSetMachine(), and rpmShowRC().

int currTables[2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }`[static]`

| Definition at line 129 of file rpmrc.c. Referenced by getMachineInfo(), rebuildCompatTables(), rpmSetMachine(), and rpmSetTables().

int defaultsInitialized = 0`[static]`

| Definition at line 135 of file rpmrc.c. Referenced by rpmFreeRpmrc(), and rpmReadRC().

const char* defrcfiles = LIBRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"`[static]`

| Definition at line 25 of file rpmrc.c. Referenced by rpmReadRC().

struct rpmOption optionTable[]`[static]`

Initial value:

     {
        { "include",                RPMVAR_INCLUDE,                 0, 1,   0, 2 },
        { "macrofiles",             RPMVAR_MACROFILES,              0, 0,   0, 1 },
        { "optflags",               RPMVAR_OPTFLAGS,                1, 0,   1, 0 },
        { "provides",               RPMVAR_PROVIDES,                0, 0,   0, 0 },
    }

Definition at line 111 of file rpmrc.c.

Referenced by doReadRC(), and rpmShowRC().

int optionTableSize = sizeof(optionTable) / sizeof(*optionTable)`[static]`

| Definition at line 120 of file rpmrc.c. Referenced by doReadRC(), and rpmShowRC().

const char* prescriptenviron`[static]`

Initial value:

     "\n\
    RPM_SOURCE_DIR=\"%{_sourcedir}\"\n\
    RPM_BUILD_DIR=\"%{_builddir}\"\n\
    RPM_OPT_FLAGS=\"%{optflags}\"\n\
    RPM_ARCH=\"%{_arch}\"\n\
    RPM_OS=\"%{_os}\"\n\
    export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\n\
    RPM_DOC_DIR=\"%{_docdir}\"\n\
    export RPM_DOC_DIR\n\
    RPM_PACKAGE_NAME=\"%{name}\"\n\
    RPM_PACKAGE_VERSION=\"%{version}\"\n\
    RPM_PACKAGE_RELEASE=\"%{release}\"\n\
    export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE\n\
    %{?buildroot:RPM_BUILD_ROOT=\"%{buildroot}\"\n\
    export RPM_BUILD_ROOT\n}\
    "

Definition at line 496 of file rpmrc.c.

Referenced by setDefaults().

struct tableType_s tables[RPM_MACHTABLE_COUNT]`[static]`

Initial value:

     {
        { "arch", 1, 0 },
        { "os", 1, 0 },
        { "buildarch", 0, 1 },
        { "buildos", 0, 1 }
    }

Definition at line 100 of file rpmrc.c.

Referenced by defaultMachine(), doReadRC(), getMachineInfo(), rebuildCompatTables(), rpmFreeRpmrc(), rpmMachineScore(), rpmSetMachine(), and rpmShowRC().

struct rpmvarValue values[RPMVAR_NUM]`[static]`

| Definition at line 132 of file rpmrc.c. Referenced by rpmFreeRpmrc(), rpmGetVarArch(), rpmSetVar(), and rpmSetVarArch().