rpm  5.2.1
Defines | Typedefs | Enumerations | Functions | Variables
rpmio/rpmmacro.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define RMIL_DEFAULT   -15
 Markers for sources of macros added throughout rpm.
#define RMIL_MACROFILES   -13
#define RMIL_RPMRC   -11
#define RMIL_CMDLINE   -7
#define RMIL_TARBALL   -5
#define RMIL_SPEC   -3
#define RMIL_OLDSPEC   -1
#define RMIL_GLOBAL   0

Typedefs

typedef struct MacroEntry_s * MacroEntry
typedef struct MacroContext_s * MacroContext
typedef enum rpmCompressedMagic_e rpmCompressedMagic

Enumerations

enum  rpmCompressedMagic_e {
  COMPRESSED_NOT = 0, COMPRESSED_OTHER = 1, COMPRESSED_BZIP2 = 2, COMPRESSED_ZIP = 3,
  COMPRESSED_LZOP = 4, COMPRESSED_LZMA = 5, COMPRESSED_XZ = 6
}

Functions

void rpmDumpMacroTable (MacroContext mc, FILE *fp)
 Print macros to file stream.
int rpmGetMacroEntries (MacroContext mc, void *_mire, int used, const char ***avp)
 Return macro entries as string array.
int rpmSecuritySaneFile (const char *filename)
 Check whether configuration file is moderately secure to load.
int rpmGlob (const char *patterns, int *argcPtr, const char ***argvPtr)
 Return URL path(s) from a (URL prefixed) pattern glob.
int expandMacros (void *spec, MacroContext mc, char *sbuf, size_t slen)
 Expand macro into buffer.
void addMacro (MacroContext mc, const char *n, const char *o, const char *b, int level)
 Add macro to context.
void delMacro (MacroContext mc, const char *n)
 Delete macro from context.
int rpmDefineMacro (MacroContext mc, const char *macro, int level)
 Define macro in context.
int rpmUndefineMacro (MacroContext mc, const char *macro)
 Undefine macro in context.
void rpmLoadMacros (MacroContext mc, int level)
 Load macros from specific context into global context.
int rpmLoadMacroFile (MacroContext mc, const char *fn)
 Load macro context from a macro file.
void rpmInitMacros (MacroContext mc, const char *macrofiles)
 Initialize macro context from set of macrofile(s).
void rpmFreeMacros (MacroContext mc)
 Destroy macro context.
int isCompressed (const char *file, rpmCompressedMagic *compressed)
 Return type of compression used in file.
char * rpmExpand (const char *arg,...)
 Return (malloc'ed) concatenated macro expansion(s).
char * rpmMCExpand (MacroContext mc, const char *arg,...)
 Return (malloc'ed) concatenated macro expansion(s) in a context.
char * rpmCleanPath (char *path)
 Canonicalize file path.
const char * rpmGetPath (const char *path,...)
 Return (malloc'ed) expanded, canonicalized, file path.
const char * rpmGenPath (const char *urlroot, const char *urlmdir, const char *urlfile)
 Merge 3 args into path, any or all of which may be a url.
int rpmExpandNumeric (const char *arg)
 Return macro expansion as a numeric value.

Variables

MacroContext rpmGlobalMacroContext
MacroContext rpmCLIMacroContext
const char * rpmMacrofiles
 List of macro files to read when configuring rpm.

Detailed Description

Definition in file rpmmacro.h.


Define Documentation

#define RMIL_CMDLINE   -7
#define RMIL_DEFAULT   -15

Markers for sources of macros added throughout rpm.

Definition at line 50 of file rpmmacro.h.

Referenced by addMacroDefault(), rpmtsOpenSDB(), setDefaults(), and setPathDefault().

#define RMIL_GLOBAL   0

Definition at line 58 of file rpmmacro.h.

Referenced by expandMacro(), and rpmcliInstall().

#define RMIL_MACROFILES   -13

Definition at line 51 of file rpmmacro.h.

Referenced by rpmLoadMacroFile().

#define RMIL_OLDSPEC   -1

Definition at line 57 of file rpmmacro.h.

Referenced by handlePreambleTag().

#define RMIL_RPMRC   -11

Definition at line 52 of file rpmmacro.h.

Referenced by parseSpec(), and rpmRebuildTargetVars().

#define RMIL_SPEC   -3

Definition at line 56 of file rpmmacro.h.

Referenced by addSource(), doSetupMacro(), handlePreambleTag(), parsePreamble(), and parseSpec().

#define RMIL_TARBALL   -5

Definition at line 55 of file rpmmacro.h.


Typedef Documentation

typedef struct MacroContext_s* MacroContext

Definition at line 8 of file rpmmacro.h.

typedef struct MacroEntry_s* MacroEntry

Definition at line 7 of file rpmmacro.h.


Enumeration Type Documentation

Enumerator:
COMPRESSED_NOT 

not compressed

COMPRESSED_OTHER 

gzip can handle

COMPRESSED_BZIP2 

bzip2 can handle

COMPRESSED_ZIP 

unzip can handle

COMPRESSED_LZOP 

lzop can handle

COMPRESSED_LZMA 

lzma can handle

COMPRESSED_XZ 

xz can handle

Definition at line 203 of file rpmmacro.h.


Function Documentation

void addMacro ( MacroContext  mc,
const char *  n,
const char *  o,
const char *  b,
int  level 
)

Add macro to context.

Deprecated:
Use rpmDefineMacro().
Parameters:
mcmacro context (NULL uses global context).
nmacro name
omacro paramaters
bmacro body
levelmacro recursion level (0 is entry API)

Definition at line 2399 of file macro.c.

References _, expandMacroTable(), findEntry(), pushMacro(), rpmGlobalMacroContext, rpmlog(), RPMLOG_ERR, and sortMacroTable().

Referenced by addMacroDefault(), addSource(), doDefine(), doSetupMacro(), expandMacro(), grabArgs(), handlePreambleTag(), headerMacrosLoad(), makeGPGSignature(), parsePreamble(), parseSpec(), rpmcliInstall(), rpmLoadMacros(), rpmPlatform(), rpmRebuildTargetVars(), rpmtsOpenSDB(), setDefaults(), and setPathDefault().

void delMacro ( MacroContext  mc,
const char *  n 
)

Delete macro from context.

Parameters:
mcmacro context (NULL uses global context).
nmacro name

Definition at line 2438 of file macro.c.

References findEntry(), popMacro(), rpmGlobalMacroContext, and sortMacroTable().

Referenced by doUndefine(), handlePreambleTag(), headerMacrosUnload(), makeGPGSignature(), parseSpec(), rpmcliInstall(), rpmRebuildTargetVars(), and rpmtsOpenSDB().

int expandMacros ( void *  spec,
MacroContext  mc,
char *  sbuf,
size_t  slen 
)

Expand macro into buffer.

Deprecated:
Use rpmExpand().
Todo:
Eliminate from API.
Parameters:
speccookie (unused)
mcmacro context (NULL uses global context).
Return values:
sbufinput macro to expand, output expansion
Parameters:
slensize of buffer
Returns:
0 on success

Definition at line 2364 of file macro.c.

References _, alloca(), MacroBuf_s::depth, MacroBuf_s::expand_trace, expandMacro(), MacroBuf_s::macro_trace, MacroBuf_s::mc, MacroBuf_s::nb, print_expand_trace, print_macro_trace, rpmGlobalMacroContext, rpmlog(), RPMLOG_ERR, MacroBuf_s::s, MacroBuf_s::spec, and MacroBuf_s::t.

Referenced by addFileToTagAux(), copyNextLineFromOFI(), processPackageFiles(), rpmExpand(), rpmGetPath(), and rpmMCExpand().

int isCompressed ( const char *  file,
rpmCompressedMagic compressed 
)

Return type of compression used in file.

Parameters:
filename of file
Return values:
compressedaddress of compression type
Returns:
0 on success, 1 on I/O error

Definition at line 2668 of file macro.c.

References _, COMPRESSED_BZIP2, COMPRESSED_LZMA, COMPRESSED_LZOP, COMPRESSED_NOT, COMPRESSED_OTHER, COMPRESSED_XZ, COMPRESSED_ZIP, Fclose(), Ferror(), Fopen(), Fread(), Fstrerror(), rpmlog(), and RPMLOG_ERR.

Referenced by doFoo(), doPatch(), and doUntar().

char* rpmCleanPath ( char *  path)

Canonicalize file path.

Parameters:
pathpath to canonicalize (in-place)
Returns:
pointer to path

Definition at line 2881 of file macro.c.

Referenced by db3open(), doLookup(), relocateFileList(), rpmGetPath(), rpmioAccess(), and rpmQueryVerify().

int rpmDefineMacro ( MacroContext  mc,
const char *  macro,
int  level 
)

Define macro in context.

Parameters:
mcmacro context (NULL uses global context).
macromacro name, options, body
levelmacro recursion level (0 is entry API)
Returns:
Todo:
Document.

Definition at line 2454 of file macro.c.

References alloca(), doDefine(), MacroBuf_s::mc, and rpmGlobalMacroContext.

Referenced by ftsCacheUpdate(), main(), rpmcliAllArgCallback(), rpmdbRebuild(), rpmioAllArgCallback(), and rpmLoadMacroFile().

void rpmDumpMacroTable ( MacroContext  mc,
FILE *  fp 
)

Print macros to file stream.

Parameters:
mcmacro context (NULL uses global context).
fpfile stream (NULL uses stderr).

Definition at line 268 of file macro.c.

References _, and rpmGlobalMacroContext.

Referenced by expandMacro(), and rpmShowRC().

char* rpmExpand ( const char *  arg,
  ... 
)

Return (malloc'ed) concatenated macro expansion(s).

Parameters:
argmacro(s) to expand (NULL terminates list)
Returns:
macro expansion (malloc'ed)

Definition at line 2780 of file macro.c.

References _macro_BUFSIZ, expandMacros(), stpcpy(), xmalloc(), xrealloc(), and xstrdup().

Referenced by _GetPass(), addChangelog(), archScore(), checkForValidArchitectures(), checkUnpackagedFiles(), cpio_doio(), dbiTagsInit(), debevrfmtTag(), debmd5sumsTag(), defaultMachine(), doPatch(), doPrimary(), doSetupMacro(), fillOutMainPackage(), Fopen(), formatValue(), getMachineInfo(), handlePreambleTag(), headerMacrosLoad(), headerMacrosUnload(), i18nTag(), ignoreDep(), initGlobs(), initSourceHeader(), lookupPackage(), main(), makeGPGSignature(), open_dso(), packageBinaries(), parseBuildInstallClean(), parseForRegexLang(), parseForSimple(), parsePreamble(), parseSpec(), prepFetch(), processSourceFiles(), rdToken(), readLine(), Realpath(), repoDoRepoMetadata(), repoMDExpand(), rpmCheckPassPhrase(), rpmcliEvalSlurp(), rpmcliImportPubkeys(), rpmcliInstallElementPath(), rpmcliQuery(), rpmdbNew(), rpmdcParseZeroInstall(), rpmdsCpuinfo(), rpmdsEVRorder(), rpmdsGetconf(), rpmdsLdconfig(), rpmdsPipe(), rpmdsSysinfo(), rpmEVRmire(), rpmEVRorder(), rpmExpandNumeric(), rpmfcClassify(), rpmfcExec(), rpmfcExpandAppend(), rpmfcExpandRegexps(), rpmfcGenerateDependsHelper(), rpmgiNext(), rpmgiOpen(), rpmInstallSourcePackage(), rpmioAllArgCallback(), rpmmiAddPattern(), rpmnsArch(), rpmnsParse(), rpmnsProbeSignature(), rpmPlatform(), rpmReadConfigFiles(), rpmReadRC(), rpmRollback(), rpmShowProgress(), rpmShowRC(), rpmts_IDTXglob(), rpmtsAddInstallElement(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), rpmtsRollback(), rpmtsSolve(), runImmedTriggers(), runInstScript(), runScript(), runTriggers(), skipFiles(), spec_get_buildroot(), statFormat(), strsubFormat(), tagLoadATags(), tagValidate(), unsatisfiedDepend(), urlFind(), urlGetFile(), and writeRPM().

int rpmExpandNumeric ( const char *  arg)

Return macro expansion as a numeric value.

Boolean values ('Y' or 'y' returns 1, 'N' or 'n' returns 0) are permitted as well. An undefined macro returns 0.

Parameters:
argmacro to expand
Returns:
numeric value

Definition at line 2854 of file macro.c.

References _free(), and rpmExpand().

Referenced by checkPackageDeps(), checkUnpackagedFiles(), dbiOpen(), doIcon(), doPatchMacro(), getDigestAlgo(), main(), newSpec(), parseScript(), parseSpec(), processPackageFiles(), relocateFileList(), rpmcliInstall(), rpmcliQuery(), rpmcliVerify(), rpmdbInit(), rpmdbNew(), rpmdbOpen(), rpmdbRebuild(), rpmdbVerify(), rpmdsELF(), rpmErase(), rpmfcGenerateDepends(), rpmRollback(), rpmts_new(), rpmtsCreate(), rpmtsOpenSDB(), rpmtsOrder(), rpmtsRollback(), rpmtsRun(), skipFiles(), unsatisfiedDepend(), and urlGetFile().

Destroy macro context.

Parameters:
mcmacro context (NULL uses global context).

Definition at line 2641 of file macro.c.

References _free(), and rpmGlobalMacroContext.

Referenced by main(), rpmcliFini(), rpmioFini(), and rpmspecQuery().

const char* rpmGenPath ( const char *  urlroot,
const char *  urlmdir,
const char *  urlfile 
)

Merge 3 args into path, any or all of which may be a url.

The leading part of the first URL encountered is used for the result, other URL prefixes are discarded, permitting a primitive form of URL inheiritance.

Parameters:
urlrootroot URL (often path to chroot, or NULL)
urlmdirdirectory URL (often a directory, or NULL)
urlfilefile URL (often a file, or NULL)
Returns:
expanded, merged, canonicalized path (malloc'ed)

Definition at line 3005 of file macro.c.

References _free(), alloca(), rpmGetPath(), URL_IS_DASH, and urlPath().

Referenced by addSource(), createDir(), db3close(), db3open(), db_init(), doIcon(), doPatch(), doScript(), doSetupMacro(), doUntar(), handlePreambleTag(), isSpecFile(), main(), prepFetch(), processBinaryFile(), processMetadataFile(), processPackageFiles(), rpmdsNew(), rpmfcGenerateDepends(), rpmfiNew(), rpmpsmStage(), rpmTempFile(), sql_close(), sql_initDB(), and sql_open().

int rpmGetMacroEntries ( MacroContext  mc,
void *  _mire,
int  used,
const char ***  avp 
)

Return macro entries as string array.

Parameters:
mcmacro context (NULL uses global context)
_mirepattern to match (NULL disables)
usedmacro usage (<0 all, =0 unused, >=1 used count)
Return values:
*avpmacro definitions
Returns:
no. of entries

Definition at line 302 of file macro.c.

References dupMacroEntry(), mireRegexec(), rpmGlobalMacroContext, xcalloc(), and xrealloc().

Referenced by packageSources(), and rpmtsFini().

const char* rpmGetPath ( const char *  path,
  ... 
)
int rpmGlob ( const char *  patterns,
int *  argcPtr,
const char ***  argvPtr 
)

Return URL path(s) from a (URL prefixed) pattern glob.

Parameters:
patternsglob pattern
Return values:
*argcPtrno. of paths
*argvPtrarray of paths (malloc'd contiguous blob)
Returns:
0 on success

Definition at line 2225 of file macro.c.

References _free(), glob_t::gl_pathc, glob_t::gl_pathv, Glob(), Glob_error(), Glob_pattern_p(), GLOB_TILDE, Globfree(), setlocale, URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), xmalloc(), XpoptParseArgvString(), xrealloc(), and xstrdup().

Referenced by IDTXglob(), processBinaryFile(), rpmcliInit(), rpmcliInstallElementPath(), rpmgiGlobArgv(), rpmInitMacros(), rpmioInit(), and rpmReadPackageManifest().

void rpmInitMacros ( MacroContext  mc,
const char *  macrofiles 
)

Initialize macro context from set of macrofile(s).

Parameters:
mcmacro context
macrofilescolon separated list of macro files (NULL does nothing)

Definition at line 2555 of file macro.c.

References _free(), _suffix, RMIL_CMDLINE, rpmCLIMacroContext, rpmGlob(), rpmGlobalMacroContext, rpmLoadMacroFile(), rpmLoadMacros(), rpmlog(), RPMLOG_WARNING, rpmSecuritySaneFile(), xmalloc(), and xstrdup().

Referenced by rpmReadRC().

int rpmLoadMacroFile ( MacroContext  mc,
const char *  fn 
)

Load macro context from a macro file.

Parameters:
mc(unused)
fnmacro file name

Definition at line 2516 of file macro.c.

References _macro_BUFSIZ, _MAX_MACRO_DEPTH, alloca(), Fclose(), Ferror(), Fopen(), max_macro_depth, rdcl(), RMIL_MACROFILES, rpmDefineMacro(), and SKIPBLANK.

Referenced by expandMacro(), and rpmInitMacros().

void rpmLoadMacros ( MacroContext  mc,
int  level 
)

Load macros from specific context into global context.

Parameters:
mcmacro context (NULL does nothing).
levelmacro recursion level (0 is entry API)

Definition at line 2476 of file macro.c.

References addMacro(), and rpmGlobalMacroContext.

Referenced by rpmInitMacros().

char* rpmMCExpand ( MacroContext  mc,
const char *  arg,
  ... 
)

Return (malloc'ed) concatenated macro expansion(s) in a context.

Parameters:
mcmacro context
argmacro(s) to expand (NULL terminates list)
Returns:
macro expansion (malloc'ed)

Definition at line 2817 of file macro.c.

References _macro_BUFSIZ, expandMacros(), stpcpy(), xmalloc(), xrealloc(), and xstrdup().

int rpmSecuritySaneFile ( const char *  filename)

Check whether configuration file is moderately secure to load.

Parameters:
filenamefilename to check
Returns:
1 on success, 0 on failure

Definition at line 2202 of file macro.c.

Referenced by rpmcliInit(), rpmInitMacros(), and rpmioInit().

int rpmUndefineMacro ( MacroContext  mc,
const char *  macro 
)

Undefine macro in context.

Parameters:
mcmacro context (NULL uses global context).
macromacro name
Returns:
Todo:
Document.

Definition at line 2468 of file macro.c.

References doUndefine(), and rpmGlobalMacroContext.

Referenced by rpmcliAllArgCallback(), and rpmioAllArgCallback().


Variable Documentation