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

lib/rpmrc.c File Reference

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

Go to the source code of this file.

Data Structures

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

Defines

#define __power_pc()   0
#define OS   0
#define ARCH   1

Typedefs

typedef const char * cptr_t
typedef machCacheEntry_smachCacheEntry
typedef machCache_smachCache
typedef machEquivInfo_smachEquivInfo
typedef machEquivTable_smachEquivTable
typedef defaultEntry_sdefaultEntry
typedef canonEntry_scanonEntry
typedef tableType_stableType

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)
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 setVar (const char *macroname, const char *body)
void rpmSetDefaults (void)
int rpmPlatform (const char *platform)
const char * checkAMD (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 ":" VENDORRPMRC_FILENAME ":/etc/rpmrc:~/.rpmrc"
const char * macrofiles = MACROFILES
const char * platform = "/etc/rpm/platform"
const char ** platpat = NULL
int nplatpat = 0
tableType_s tables [4]
rpmOption optionTable []
int optionTableSize = sizeof(optionTable) / sizeof(*optionTable)
cptr_t current [2]
int currTables [2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH }
rpmvarValue values [55]
int defaultsInitialized = 0
const char * prescriptenviron


Define Documentation

 
#define __power_pc      0
 

Definition at line 14 of file rpmrc.c.

Referenced by defaultMachine().

#define ARCH   1
 

Definition at line 131 of file rpmrc.c.

Referenced by doReadRC(), rpmFreeRpmrc(), rpmGetArchInfo(), rpmGetMachine(), rpmGetVarArch(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().

#define OS   0
 

Definition at line 130 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), rpmGetMachine(), rpmGetOsInfo(), rpmSetMachine(), rpmSetTables(), and rpmShowRC().


Typedef Documentation

typedef struct canonEntry_s * canonEntry
 

typedef const char* cptr_t
 

Definition at line 38 of file rpmrc.c.

typedef struct defaultEntry_s * defaultEntry
 

typedef struct machCache_s * machCache
 

typedef struct machCacheEntry_s * machCacheEntry
 

typedef struct machEquivInfo_s * machEquivInfo
 

typedef struct machEquivTable_s * machEquivTable
 

typedef struct tableType_s * tableType
 


Function Documentation

int addCanon canonEntry   table,
int *    tableLen,
char *    line,
const char *    fn,
int    lineNum
[static]
 

Definition at line 335 of file rpmrc.c.

References _, 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 389 of file rpmrc.c.

References _, defaultEntry_s::defName, defaultEntry_s::name, RPMERR_RPMRC, rpmError, xrealloc(), and xstrdup().

Referenced by doReadRC().

const char* checkAMD void    [static]
 

Definition at line 1023 of file rpmrc.c.

Referenced by defaultMachine().

void defaultMachine const char **    arch,
const char **    os
[static]
 

Definition at line 1051 of file rpmrc.c.

References __power_pc, _free(), checkAMD(), Fclose(), Ferror(), Fopen(), Fread(), lookupInCanonTable(), platform, RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS, rpmExpand(), rpmPlatform(), canonEntry_s::short_name, xcalloc(), and xisdigit().

Referenced by rpmRebuildTargetVars(), rpmSetMachine(), and rpmSetTables().

int doReadRC FD_t    fd,
const char *    urlfn
[static]
 

Definition at line 533 of file rpmrc.c.

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

Referenced by rpmReadRC().

void freeRpmVar struct rpmvarValue   orig [static]
 

Definition at line 1358 of file rpmrc.c.

References _free(), rpmvarValue::arch, rpmvarValue::next, and rpmvarValue::value.

Referenced by rpmSetVar().

void getMachineInfo int    type,
const char **    name,
int *    num
[static]
 

Definition at line 1508 of file rpmrc.c.

References _, current, currTables, lookupInCanonTable(), canonEntry_s::num, RPMMESS_WARNING, rpmMessage, and canonEntry_s::short_name.

Referenced by rpmGetArchInfo(), and rpmGetOsInfo().

canonEntry lookupInCanonTable const char *    name,
const canonEntry    table,
int    tableLen
[static]
 

Definition at line 424 of file rpmrc.c.

Referenced by defaultMachine(), and getMachineInfo().

const char* lookupInDefaultTable const char *    name,
const defaultEntry    table,
int    tableLen
[static]
 

Definition at line 441 of file rpmrc.c.

References defaultEntry_s::defName, and defaultEntry_s::name.

Referenced by rpmSetMachine().

void machAddEquiv machEquivTable    table,
const char *    name,
int    distance
[static]
 

Definition at line 267 of file rpmrc.c.

References machEquivTable_s::count, machEquivTable_s::list, machEquivSearch(), xmalloc(), xrealloc(), and xstrdup().

Referenced by machCacheEntryVisit(), and machFindEquivs().

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

Definition at line 286 of file rpmrc.c.

References machCacheEntry_s::count, machCacheEntry_s::equivs, machAddEquiv(), machCacheFindEntry(), and machCacheEntry_s::visited.

Referenced by machFindEquivs().

machCacheEntry machCacheFindEntry const machCache    cache,
const char *    key
[static]
 

Definition at line 173 of file rpmrc.c.

References machCache_s::cache, 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 184 of file rpmrc.c.

References _, _free(), machCache_s::cache, machCacheEntry_s::count, machCacheEntry_s::equivs, 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 255 of file rpmrc.c.

References machEquivTable_s::count, machEquivTable_s::list, machEquivInfo_s::name, and xstrcasecmp().

Referenced by machAddEquiv(), and rpmMachineScore().

void machFindEquivs machCache    cache,
machEquivTable    table,
const char *    key
[static]
 

Definition at line 307 of file rpmrc.c.

References _free(), machCache_s::cache, machEquivTable_s::count, machEquivTable_s::list, machAddEquiv(), machCacheEntryVisit(), machCache_s::size, and machCacheEntry_s::visited.

Referenced by rebuildCompatTables().

int optionCompare const void *    a,
const void *    b
[static]
 

Definition at line 165 of file rpmrc.c.

References xstrcasecmp().

Referenced by doReadRC().

void rebuildCompatTables int    type,
const char *    name
[static]
 

Definition at line 1500 of file rpmrc.c.

References currTables, and machFindEquivs().

Referenced by rpmSetMachine(), and rpmSetTables().

void rpmFreeRpmrc void   
 

Destroy rpmrc arch/os compatibility tables.

Todo:
Eliminate from API.

Definition at line 1644 of file rpmrc.c.

References _free(), ARCH, rpmvarValue::arch, machCache_s::cache, tableType_s::cache, tableType_s::canons, tableType_s::canonsLength, machCacheEntry_s::count, machEquivTable_s::count, current, tableType_s::defaults, defaultsInitialized, tableType_s::defaultsLength, defaultEntry_s::defName, tableType_s::equiv, machCacheEntry_s::equivs, machEquivTable_s::list, canonEntry_s::name, defaultEntry_s::name, machCacheEntry_s::name, machEquivInfo_s::name, rpmvarValue::next, OS, canonEntry_s::short_name, machCache_s::size, and rpmvarValue::value.

Referenced by main().

void rpmGetArchInfo const char **    name,
int *    num
 

Return current arch name and/or number.

Todo:
Generalize to extract arch component from target_platform macro.
Return values:
name  address of arch name (or NULL)
num  address of arch number (or NULL)

Definition at line 1536 of file rpmrc.c.

References ARCH, and getMachineInfo().

Referenced by archOkay(), checkForValidArchitectures(), parseSpec(), psmStage(), readLine(), rpmRebuildTargetVars(), and writeRPM().

void rpmGetMachine const char **    arch,
const char **    os
 

Return current arch/os names.

Deprecated:
Use rpmExpand on _target_* macros.
Todo:
Eliminate from API.
Return values:
arch  address of arch name (or NULL)
os  address of os name (or NULL)

Definition at line 1442 of file rpmrc.c.

References ARCH, current, and OS.

Referenced by parseSpec().

void rpmGetOsInfo const char **    name,
int *    num
 

Return current os name and/or number.

Todo:
Generalize to extract os component from target_platform macro.
Return values:
name  address of os name (or NULL)
num  address of os number (or NULL)

Definition at line 1541 of file rpmrc.c.

References getMachineInfo(), and OS.

Referenced by checkForValidArchitectures(), parseSpec(), psmStage(), readLine(), rpmRebuildTargetVars(), and writeRPM().

const char* rpmGetVar int    var
 

Return value of an rpmrc variable.

Deprecated:
Use rpmExpand() with appropriate macro expression.
Todo:
Eliminate from API.

Definition at line 1352 of file rpmrc.c.

References rpmGetVarArch().

Referenced by doReadRC(), rpmReadRC(), rpmShowRC(), setVarDefault(), and unsatisfiedDepend().

const char* rpmGetVarArch int    var,
const char *    arch
[static]
 

Definition at line 1331 of file rpmrc.c.

References rpmvarValue::arch, ARCH, current, rpmvarValue::next, and rpmvarValue::value.

Referenced by rpmGetVar(), and rpmRebuildTargetVars().

int rpmMachineScore int    type,
const char *    name
 

Return arch/os score of a name. An arch/os score measures the "nearness" of a name to the currently running (or defined) platform arch/os. For example, the score of arch "i586" on an i686 platform is (usually) 2. The arch/os score is used to select one of several otherwise identical packages using the arch/os tags from the header as hints of the intended platform for the package.

Todo:
Rewrite to use RE's against config.guess target platform output.
Parameters:
type  any of the RPM_MACHTABLE_* constants
name  name
Returns:
arch score (0 is no match, lower is preferred)

Definition at line 1436 of file rpmrc.c.

References machEquivSearch(), and machEquivInfo_s::score.

Referenced by archOkay(), archScore(), osOkay(), parseSpec(), and psGetArchScore().

int rpmPlatform const char *    platform [static]
 

Definition at line 757 of file rpmrc.c.

References _free(), addMacro(), nplatpat, platform, platpat, rpmExpand(), rpmioSlurp(), xrealloc(), and xstrdup().

Referenced by defaultMachine().

int rpmReadConfigFiles const char *    file,
const char *    target
 

Read macro configuration file(s) for a target.

Parameters:
file  colon separated files to read (NULL uses default)
target  target platform (NULL uses default)
Returns:
0 on success, -1 on error

Definition at line 1803 of file rpmrc.c.

References _free(), rpmExpand(), rpmReadRC(), rpmRebuildTargetVars(), and rpmSetMachine().

Referenced by build(), initrpm(), and main().

void rpmRebuildTargetVars const char **    target,
const char **    canontarget
[static]
 

Definition at line 1546 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 rpmSetDefaults void    [static]
 

Definition at line 496 of file rpmrc.c.

References defaultsInitialized, prescriptenviron, RPMVAR_OPTFLAGS, setVar(), and setVarDefault().

Referenced by rpmReadRC().

void rpmSetMachine const char *    arch,
const char *    os
 

Set current arch/os names. NULL as argument is set to the default value (munged uname()) pushed through a translation table (if appropriate).

Deprecated:
Use addMacro to set _target_* macros.
Todo:
Eliminate from API.
Parameters:
arch  arch name (or NULL)
os  os name (or NULL)

Definition at line 1451 of file rpmrc.c.

References _free(), ARCH, current, currTables, defaultMachine(), lookupInDefaultTable(), OS, rebuildCompatTables(), and xstrdup().

Referenced by parseSpec(), rpmReadConfigFiles(), rpmReadRC(), rpmRebuildTargetVars(), and rpmShowRC().

void rpmSetTables int    archTable,
int    osTable
 

Deprecated:
Use addMacro to set _target_* macros.
Todo:
Eliminate from API. #
Note:
Only used by build code.
Parameters:
archTable 
osTable 

Definition at line 1419 of file rpmrc.c.

References ARCH, currTables, defaultMachine(), OS, and rebuildCompatTables().

Referenced by buildForTarget(), rpmRebuildTargetVars(), and rpmShowRC().

void rpmSetVar int    var,
const char *    val
 

Set value of an rpmrc variable.

Deprecated:
Use rpmDefineMacro() to change appropriate macro instead.
Todo:
Eliminate from API.

Definition at line 1375 of file rpmrc.c.

References freeRpmVar(), rpmvarValue::value, and xstrdup().

Referenced by setVarDefault().

void rpmSetVarArch int    var,
const char *    val,
const char *    arch
[static]
 

Definition at line 1383 of file rpmrc.c.

References _free(), rpmvarValue::arch, rpmvarValue::next, rpmvarValue::value, xmalloc(), and xstrdup().

Referenced by doReadRC().

int rpmShowRC FILE *    fp
 

Display current rpmrc (and macro) configuration.

Parameters:
fp  output file handle
Returns:
0 always

Definition at line 1828 of file rpmrc.c.

References ARCH, machEquivTable_s::count, current, machEquivTable_s::list, rpmOption::name, machEquivInfo_s::name, optionTableSize, OS, RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS, RPM_MACHTABLE_INSTARCH, RPM_MACHTABLE_INSTOS, rpmDumpMacroTable(), rpmGetVar(), rpmIsVerbose, rpmSetMachine(), rpmSetTables(), rpmShowRpmlibProvides(), and rpmOption::var.

Referenced by main().

void setVar const char *    macroname,
const char *    body
[static]
 

Definition at line 469 of file rpmrc.c.

References addMacro(), and RMIL_DEFAULT.

Referenced by rpmSetDefaults().

void setVarDefault int    var,
const char *    macroname,
const char *    val,
const char *    body
[static]
 

Definition at line 454 of file rpmrc.c.

References addMacro(), RMIL_DEFAULT, rpmGetVar(), and rpmSetVar().

Referenced by rpmSetDefaults().


Variable Documentation

cptr_t current[2] [static]
 

Definition at line 134 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 137 of file rpmrc.c.

Referenced by getMachineInfo(), rebuildCompatTables(), rpmSetMachine(), and rpmSetTables().

int defaultsInitialized = 0 [static]
 

Definition at line 143 of file rpmrc.c.

Referenced by rpmFreeRpmrc(), and rpmSetDefaults().

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

Definition at line 26 of file rpmrc.c.

Referenced by rpmReadRC().

int nplatpat = 0 [static]
 

Definition at line 36 of file rpmrc.c.

Referenced by rpmPlatform().

struct rpmOption optionTable[] [static]
 

Initial value:

 {
    { "include",                 43 ,                   0, 1,   0, 2 },
    { "macrofiles",              49 ,           0, 0,   0, 1 },
    { "optflags",                3 ,            1, 0,   1, 0 },
    { "provides",                38 ,                0, 0,      0, 0 },
}

Definition at line 119 of file rpmrc.c.

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

Definition at line 128 of file rpmrc.c.

Referenced by doReadRC(), and rpmShowRC().

const char* platform = "/etc/rpm/platform" [static]
 

Definition at line 32 of file rpmrc.c.

Referenced by defaultMachine(), and rpmPlatform().

const char** platpat = NULL [static]
 

Definition at line 34 of file rpmrc.c.

Referenced by rpmPlatform().

const char* prescriptenviron [static]
 

Initial value:

 "\n\
RPM_SOURCE_DIR=\"%{_sourcedir}\"\n\
RPM_BUILD_DIR=\"%{_builddir}\"\n\
RPM_DOC_DIR=\"%{_docdir}\"\n\
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_DOC_DIR\n\
RPM_OPT_FLAGS=\"%{optflags}\"\n\
RPM_ARCH=\"%{_arch}\"\n\
RPM_OS=\"%{_os}\"\n\
export RPM_OPT_FLAGS RPM_ARCH RPM_OS\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 479 of file rpmrc.c.

Referenced by rpmSetDefaults().

struct tableType_s tables[ 4 ] [static]
 

Initial value:

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

Definition at line 108 of file rpmrc.c.

struct rpmvarValue values[ 55 ] [static]
 

Definition at line 140 of file rpmrc.c.


Generated on Sun Feb 2 23:32:10 2003 for rpm by doxygen1.2.18