rpm
5.4.10
|
#include "system.h"
#include <stdarg.h>
#include <rpmio_internal.h>
#include <rpmlog.h>
#include <mire.h>
#include <rpmaug.h>
#include <rpmficl.h>
#include <rpmgit.h>
#include <rpmjs.h>
#include <rpmperl.h>
#include <rpmpython.h>
#include <rpmruby.h>
#include <rpmsm.h>
#include <rpmsquirrel.h>
#include <rpmsql.h>
#include <rpmtcl.h>
#include <rpmuuid.h>
#include <rpmmacro.h>
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | MacroBuf_s |
Macro expansion state. More... |
Macros | |
#define | isblank(_c) ((char)(_c) == ' ' || (char)(_c) == '\t') |
#define | iseol(_c) ((char)(_c) == '\n' || (char)(_c) == '\r') |
#define | STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn))) |
#define | _RPMAUG_INTERNAL /* XXX for _rpmaugFoo globals */ |
#define | _MACRO_INTERNAL |
#define | SAVECHAR(_mb, _c) { *(_mb)->t = (char) (_c), (_mb)->t++, (_mb)->nb--; } |
#define | _MAX_MACRO_DEPTH 16 |
#define | _PRINT_MACRO_TRACE 0 |
#define | _PRINT_EXPAND_TRACE 0 |
#define | _MAX_LOAD_DEPTH 2 |
#define | MACRO_CHUNK_SIZE 16 |
#define | SKIPBLANK(_s, _c) |
#define | SKIPNONBLANK(_s, _c) |
#define | COPYNAME(_ne, _s, _c) |
#define | COPYOPTS(_oe, _s, _c) |
#define | POPT_ERROR_NOARG -10 |
#define | POPT_ERROR_BADQUOTE -15 |
#define | POPT_ERROR_MALLOC -21 |
#define | POPT_ARGV_ARRAY_GROW_DELTA 5 |
#define | _suffix(_s, _x) (slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x))) |
Typedefs | |
typedef struct MacroBuf_s * | MacroBuf |
Functions | |
static int | expandMacro (MacroBuf mb) |
Parse args and string for PHP like %{foo <args> : <string> } syntax. | |
static int | compareMacroName (const void *ap, const void *bp) |
Compare macro entries by name (qsort/bsearch). | |
static void | expandMacroTable (MacroContext mc) |
Enlarge macro table. | |
static void | sortMacroTable (MacroContext mc) |
Sort entries in macro table. | |
static char * | dupMacroEntry (MacroEntry me) |
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. | |
static MacroEntry * | findEntry (MacroContext mc, const char *name, size_t namelen) |
Find entry in macro table. | |
static char * | rdcl (char *buf, size_t size, FD_t fd) |
fgets(3) analogue that reads \ continuations. | |
static const char * | matchchar (const char *p, char pl, char pr) |
Return text between pl and matching pr characters. | |
static void | printMacro (MacroBuf mb, const char *s, const char *se) |
Pre-print macro expression to be expanded. | |
static void | printExpansion (MacroBuf mb, const char *t, const char *te) |
Post-print expanded macro expression. | |
static int | expandT (MacroBuf mb, const char *f, size_t flen) |
Save source and expand field into target. | |
static int | expandU (MacroBuf mb, char *u, size_t ulen) |
Save source/target and expand macro in u. | |
static int | doShellEscape (MacroBuf mb, const char *cmd, size_t clen) |
Expand output of shell command into target buffer. | |
static const char * | doDefine (MacroBuf mb, const char *se, int level, int expandbody) |
Parse (and execute) new macro definition. | |
static const char * | doUndefine (MacroContext mc, const char *se) |
Parse (and execute) macro undefinition. | |
static void | pushMacro (MacroEntry *mep, const char *n, const char *o, const char *b, int level) |
Push new macro definition onto macro entry stack. | |
static void | popMacro (MacroEntry *mep) |
Pop macro definition from macro entry stack. | |
static void | freeArgs (MacroBuf mb) |
Free parsed arguments for parameterized macro. | |
static const char * | grabArgs (MacroBuf mb, const MacroEntry me, const char *se, const char *lastc) |
Parse arguments (to next new line) for parameterized macro. | |
static void | doOutput (MacroBuf mb, int waserror, const char *msg, size_t msglen) |
Perform macro message output. | |
static void | doFoo (MacroBuf mb, int negate, const char *f, size_t fn, const char *g, size_t gn) |
Execute macro primitives. | |
static int | expandFIFO (MacroBuf mb, MacroEntry me, const char *g, size_t gn) |
static int | XpoptDupArgv (int argc, char **argv, int *argcPtr, char ***argvPtr) |
static int | XpoptParseArgvString (const char *s, int *argcPtr, char ***argvPtr) |
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, int nesting) |
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. | |
int | rpmExpandNumeric (const char *arg) |
Return macro expansion as a numeric value. | |
char * | rpmCleanPath (char *path) |
Canonicalize file path. | |
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. |
Variables | |
const char * | rpmMacrofiles = MACROFILES |
List of macro files to read when configuring rpm. | |
static struct MacroContext_s | rpmGlobalMacroContext_s |
MacroContext | rpmGlobalMacroContext = &rpmGlobalMacroContext_s |
static struct MacroContext_s | rpmCLIMacroContext_s |
MacroContext | rpmCLIMacroContext = &rpmCLIMacroContext_s |
int | max_macro_depth = 16 |
int | print_macro_trace = 0 |
int | print_expand_trace = 0 |
int | _max_load_depth = 2 |
static size_t | _macro_BUFSIZ = 16 * 1024 |
static int | _debug = 0 |
Definition in file macro.c.
#define _MAX_MACRO_DEPTH 16 |
Definition at line 152 of file macro.c.
Referenced by rpmLoadMacroFile().
#define _suffix | ( | _s, | |
_x | |||
) | (slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x))) |
#define COPYNAME | ( | _ne, | |
_s, | |||
_c | |||
) |
Definition at line 587 of file macro.c.
Referenced by doDefine(), and doUndefine().
#define COPYOPTS | ( | _oe, | |
_s, | |||
_c | |||
) |
Definition at line 594 of file macro.c.
Referenced by doDefine().
#define isblank | ( | _c | ) | ((char)(_c) == ' ' || (char)(_c) == '\t') |
Definition at line 9 of file macro.c.
Referenced by doDefine(), doFoo(), expandMacro(), and grabArgs().
#define iseol | ( | _c | ) | ((char)(_c) == '\n' || (char)(_c) == '\r') |
Definition at line 11 of file macro.c.
Referenced by doDefine(), doShellEscape(), doUndefine(), expandMacro(), printExpansion(), printMacro(), and rdcl().
#define MACRO_CHUNK_SIZE 16 |
Definition at line 169 of file macro.c.
Referenced by expandMacroTable().
#define POPT_ARGV_ARRAY_GROW_DELTA 5 |
Definition at line 1490 of file macro.c.
Referenced by XpoptParseArgvString().
#define POPT_ERROR_BADQUOTE -15 |
error in paramter quoting
Definition at line 1487 of file macro.c.
Referenced by XpoptParseArgvString().
#define POPT_ERROR_MALLOC -21 |
memory allocation failed
Definition at line 1488 of file macro.c.
Referenced by XpoptDupArgv(), and XpoptParseArgvString().
#define POPT_ERROR_NOARG -10 |
#define SAVECHAR | ( | _mb, | |
_c | |||
) | { *(_mb)->t = (char) (_c), (_mb)->t++, (_mb)->nb--; } |
Definition at line 148 of file macro.c.
Referenced by doShellEscape(), and expandMacro().
#define SKIPBLANK | ( | _s, | |
_c | |||
) |
Definition at line 575 of file macro.c.
Referenced by doDefine(), and rpmLoadMacroFile().
#define SKIPNONBLANK | ( | _s, | |
_c | |||
) |
#define STREQ | ( | _t, | |
_f, | |||
_fn | |||
) | ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn))) |
Definition at line 13 of file macro.c.
Referenced by doFoo(), and expandMacro().
typedef struct MacroBuf_s * MacroBuf |
void addMacro | ( | MacroContext | mc, |
const char * | n, | ||
const char * | o, | ||
const char * | b, | ||
int | level | ||
) |
Add macro to context.
mc | macro context (NULL uses global context). |
n | macro name |
o | macro paramaters |
b | macro body |
level | macro recursion level (0 is entry API) |
Definition at line 2684 of file macro.c.
References _, expandMacroTable(), findEntry(), name, 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().
|
static |
Compare macro entries by name (qsort/bsearch).
ap | 1st macro entry |
bp | 2nd macro entry |
Definition at line 193 of file macro.c.
Referenced by findEntry(), and sortMacroTable().
void delMacro | ( | MacroContext | mc, |
const char * | n | ||
) |
Delete macro from context.
mc | macro context (NULL uses global context). |
n | macro name |
Definition at line 2723 of file macro.c.
References findEntry(), popMacro(), rpmGlobalMacroContext, and sortMacroTable().
Referenced by doUndefine(), handlePreambleTag(), headerMacrosUnload(), makeGPGSignature(), parseSpec(), rpmcliInstall(), rpmRebuildTargetVars(), and rpmtsOpenSDB().
|
static |
Parse (and execute) new macro definition.
mb | macro expansion state |
se | macro definition to parse |
level | macro recursion level |
expandbody | should body be expanded? |
Definition at line 737 of file macro.c.
References _, _macro_BUFSIZ, addMacro(), alloca(), COPYNAME, COPYOPTS, expandU(), isblank, iseol, matchchar(), MacroBuf_s::mc, rpmlog(), RPMLOG_ERR, SKIPBLANK, and xisalpha().
Referenced by expandMacro(), and rpmDefineMacro().
|
static |
Execute macro primitives.
mb | macro expansion state |
negate | should logic be inverted? |
f | beginning of field f |
fn | length of field f |
g | beginning of field g |
gn | length of field g |
Definition at line 1236 of file macro.c.
References _macro_BUFSIZ, alloca(), COMPRESSED_OTHER, expandT(), expandU(), getenv(), isblank, isCompressed(), PATH_MAX, realpath(), rpmlog(), RPMLOG_ERR, RPMLOG_INFO, RPMLOG_MASK, rpmlogSetMask(), rpmuuidMake(), stpcpy(), stpncpy(), STREQ, urlPath(), uuid_ns, uuid_version, xisdigit(), and xisspace().
Referenced by expandMacro().
|
static |
Perform macro message output.
mb | macro expansion state |
waserror | use rpmError()? |
msg | message to ouput |
msglen | no. of bytes in message |
Definition at line 1210 of file macro.c.
References _macro_BUFSIZ, alloca(), expandU(), rpmlog(), and RPMLOG_ERR.
Referenced by expandMacro().
|
static |
Expand output of shell command into target buffer.
mb | macro expansion state |
cmd | shell command |
clen | no. bytes in shell command |
Definition at line 698 of file macro.c.
References _macro_BUFSIZ, alloca(), expandU(), iseol, MacroBuf_s::nb, SAVECHAR, and MacroBuf_s::t.
Referenced by expandMacro().
|
static |
Parse (and execute) macro undefinition.
mc | macro context |
se | macro name to undefine |
Definition at line 872 of file macro.c.
References _, _macro_BUFSIZ, alloca(), COPYNAME, delMacro(), iseol, rpmlog(), RPMLOG_ERR, and xisalpha().
Referenced by expandMacro(), and rpmUndefineMacro().
|
static |
Definition at line 257 of file macro.c.
References stpcpy(), and xmalloc.
Referenced by rpmGetMacroEntries().
|
static |
|
static |
Parse args and string for PHP like %{foo <args> : <string> } syntax.
s | "{ ... }" construct to parse |
nb | no. of bytes |
*avp | invocation args |
mb | macro expansion state |
Definition at line 1650 of file macro.c.
References _, _free(), _max_load_depth, addMacro(), alloca(), MacroBuf_s::depth, doDefine(), doFoo(), doOutput(), doShellEscape(), doUndefine(), MacroBuf_s::expand_trace, expandFIFO(), expandT(), findEntry(), freeArgs(), grabArgs(), isblank, iseol, MacroBuf_s::macro_trace, matchchar(), max_macro_depth, MacroBuf_s::mc, MacroBuf_s::nb, print_expand_trace, print_macro_trace, printExpansion(), printMacro(), RMIL_GLOBAL, rpmDumpMacroTable(), rpmjsFree(), rpmjsNew(), rpmjsRun(), rpmLoadMacroFile(), rpmlog(), RPMLOG_ERR, rpmluaGetGlobalState(), rpmluaGetPrintBuffer(), rpmluaRunScript(), rpmperlFree(), rpmperlNew(), rpmperlRun(), rpmpythonFree(), rpmpythonNew(), rpmpythonRun(), RPMRC_OK, rpmrubyFree(), rpmrubyNew(), rpmrubyRun(), rpmsqlFree(), rpmsqlNew(), rpmsqlRun(), rpmsquirrelFree(), rpmsquirrelNew(), rpmsquirrelRun(), rpmtclFree(), rpmtclNew(), rpmtclRun(), MacroBuf_s::s, SAVECHAR, STREQ, MacroBuf_s::t, xisalnum(), xisdigit(), xmalloc, and xstrdup().
Referenced by expandMacros(), expandT(), and expandU().
int expandMacros | ( | void * | spec, |
MacroContext | mc, | ||
char * | sbuf, | ||
size_t | slen | ||
) |
Expand macro into buffer.
spec | cookie (unused) |
mc | macro context (NULL uses global context). |
sbuf | input macro to expand, output expansion |
slen | size of buffer |
Definition at line 2649 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().
|
static |
Enlarge macro table.
mc | macro context |
Definition at line 213 of file macro.c.
References MACRO_CHUNK_SIZE, xmalloc, and xrealloc.
Referenced by addMacro().
|
static |
Save source and expand field into target.
mb | macro expansion state |
f | field |
flen | no. bytes in field |
Definition at line 608 of file macro.c.
References alloca(), expandMacro(), and MacroBuf_s::s.
Referenced by doFoo(), expandFIFO(), and expandMacro().
|
static |
Save source/target and expand macro in u.
mb | macro expansion state |
u | input macro, output expansion |
ulen | no. bytes in u buffer |
Definition at line 661 of file macro.c.
References alloca(), expandMacro(), MacroBuf_s::nb, MacroBuf_s::s, and MacroBuf_s::t.
Referenced by doDefine(), doFoo(), doOutput(), doShellEscape(), and grabArgs().
|
static |
Find entry in macro table.
mc | macro context |
name | macro name |
namelen | no. of bytes |
Definition at line 366 of file macro.c.
References alloca(), compareMacroName(), and rpmGlobalMacroContext.
Referenced by addMacro(), delMacro(), and expandMacro().
|
static |
Free parsed arguments for parameterized macro.
mb | macro expansion state |
Definition at line 983 of file macro.c.
References _, MacroBuf_s::depth, MacroBuf_s::mc, popMacro(), rpmlog(), RPMLOG_ERR, and sortMacroTable().
Referenced by expandMacro().
|
static |
Parse arguments (to next new line) for parameterized macro.
mb | macro expansion state |
me | macro entry slot |
se | arguments to parse |
lastc | stop parsing at lastc |
Definition at line 1034 of file macro.c.
References _, _free(), _macro_BUFSIZ, addMacro(), alloca(), MacroBuf_s::depth, expandU(), isblank, MacroBuf_s::mc, rpmlog(), RPMLOG_ERR, stpcpy(), and xcalloc().
Referenced by expandMacro().
int isCompressed | ( | const char * | file, |
rpmCompressedMagic * | compressed | ||
) |
Return type of compression used in file.
file | name of file |
compressed | address of compression type |
Definition at line 2995 of file macro.c.
References _, COMPRESSED_7ZIP, COMPRESSED_BZIP2, COMPRESSED_LRZIP, COMPRESSED_LZIP, COMPRESSED_LZMA, COMPRESSED_LZOP, COMPRESSED_NOT, COMPRESSED_OTHER, COMPRESSED_XZ, COMPRESSED_ZIP, Fclose(), Ferror(), Fopen(), Fread(), Fstrerror(), rpmlog(), and RPMLOG_ERR.
|
static |
Return text between pl and matching pr characters.
p | start of text |
pl | left char, i.e. '[', '(', '{', etc. |
pr | right char, i.e. ']', ')', '}', etc. |
Definition at line 468 of file macro.c.
Referenced by doDefine(), expandMacro(), and rpmLoadMacroFile().
|
static |
Pop macro definition from macro entry stack.
mep | address of macro entry slot |
Definition at line 960 of file macro.c.
References _free().
Referenced by delMacro(), and freeArgs().
|
static |
Post-print expanded macro expression.
mb | macro expansion state |
t | current expansion string result |
te | end of string |
Definition at line 538 of file macro.c.
References _, MacroBuf_s::depth, and iseol.
Referenced by expandMacro().
|
static |
Pre-print macro expression to be expanded.
mb | macro expansion state |
s | current expansion string |
se | end of string |
Definition at line 494 of file macro.c.
References _, MacroBuf_s::depth, and iseol.
Referenced by expandMacro().
|
static |
Push new macro definition onto macro entry stack.
mep | address of macro entry slot |
n | macro name |
o | macro parameters (NULL if none) |
b | macro body (NULL becomes "") |
level | macro recursion level |
Definition at line 925 of file macro.c.
References name, xmalloc, and xstrdup().
Referenced by addMacro().
|
static |
fgets(3) analogue that reads \ continuations.
Last newline always trimmed.
buf | input buffer |
size | inbut buffer size (bytes) |
fd | file handle |
Definition at line 404 of file macro.c.
References fdGetFILE, and iseol.
Referenced by rpmLoadMacroFile().
char* rpmCleanPath | ( | char * | path | ) |
Canonicalize file path.
path | path to canonicalize (in-place) |
Definition at line 3218 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.
mc | macro context (NULL uses global context). |
macro | macro name, options, body |
level | macro recursion level (0 is entry API) |
Definition at line 2739 of file macro.c.
References alloca(), doDefine(), MacroBuf_s::mc, and rpmGlobalMacroContext.
Referenced by ftsCacheUpdate(), main(), rpmcliAllArgCallback(), rpmioAllArgCallback(), rpmLoadMacroFile(), and rpmmc_add().
void rpmDumpMacroTable | ( | MacroContext | mc, |
FILE * | fp | ||
) |
Print macros to file stream.
mc | macro context (NULL uses global context). |
fp | file stream (NULL uses stderr). |
Definition at line 285 of file macro.c.
References _, and rpmGlobalMacroContext.
Referenced by expandMacro(), and rpmShowRC().
char* rpmExpand | ( | const char * | arg, |
... | |||
) |
Return (malloc'ed) concatenated macro expansion(s).
arg | macro(s) to expand (NULL terminates list) |
Definition at line 3117 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(), headerMacrosLoad(), headerMacrosUnload(), headerSprintf(), i18nTag(), initGlobs(), initSourceHeader(), lookupPackage(), main(), makeGPGSignature(), Open(), open_dso(), packageBinaries(), packageSources(), parseBuildInstallClean(), parseForRegexLang(), parseForSimple(), parsePreamble(), parseSpec(), prepFetch(), processBinaryFiles(), processSourceFiles(), rdToken(), readLine(), Realpath(), rpmCheckPassPhrase(), rpmcliEvalSlurp(), rpmcliImportPubkeys(), rpmcliInstallElementPath(), rpmcliQuery(), rpmdbExportL10N_SQL(), rpmdbNew(), rpmdcParseZeroInstall(), rpmdsCpuinfo(), rpmdsEVRorder(), rpmdsGetconf(), rpmdsLdconfig(), rpmdsPipe(), rpmdsSysinfo(), rpmEVRmire(), rpmEVRorder(), rpmExpandNumeric(), rpmfcClassify(), rpmfcExec(), rpmfcExpandAppend(), rpmfcExpandRegexps(), rpmfcGenerateDependsHelper(), rpmfcSCRIPT(), rpmgiNext(), rpmgiOpen(), rpmInstallSourcePackage(), rpmioAllArgCallback(), rpmmiAddPattern(), rpmnsArch(), rpmnsParse(), rpmnsProbeSignature(), rpmperlNew(), rpmPlatform(), rpmpsmStage(), rpmpythonNew(), rpmrbLoadClasses(), rpmrbLoadFile(), rpmReadConfigFiles(), rpmReadRC(), rpmrepoDoRepoMetadata(), rpmrepoInitPopt(), rpmrepoMDExpand(), rpmRollback(), rpmShowProgress(), rpmShowRC(), rpmsqlNew(), rpmsqlRun(), rpmts_IDTXglob(), rpmtsAddInstallElement(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), rpmtsOpenSDB(), rpmtsRollback(), rpmtsSkipFiles(), rpmtsSolve(), rpmvtNew(), runImmedTriggers(), runInstScript(), runScript(), runTriggers(), 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.
arg | macro to expand |
Definition at line 3191 of file macro.c.
References _free(), and rpmExpand().
Referenced by _rpmtsRun(), checkPackageDeps(), checkPackages(), checkUnpackagedFiles(), doIcon(), doPatchMacro(), genCpioListAndHeader(), getDigestAlgo(), handleInstInstalledFile(), handleOverlappedFiles(), main(), newSpec(), parseScript(), parseSpec(), processBinaryFiles(), processPackageFiles(), relocateFileList(), rpmcliInstall(), rpmcliQuery(), rpmcliVerify(), rpmdbNew(), rpmdbOpen(), rpmdsELF(), rpmErase(), rpmfcGenerateDepends(), rpmfcSCRIPT(), rpmpsmStage(), rpmRollback(), rpmts_new(), rpmtsAddInstallElement(), rpmtsCreate(), rpmtsOpenSDB(), rpmtsPrepare(), rpmtsRollback(), rpmtsSkipFiles(), unsatisfiedDepend(), and urlGetFile().
void rpmFreeMacros | ( | MacroContext | mc | ) |
Destroy macro context.
mc | macro context (NULL uses global context). |
Definition at line 2966 of file macro.c.
References _free(), and rpmGlobalMacroContext.
Referenced by _rpmmc_free(), 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.
urlroot | root URL (often path to chroot, or NULL) |
urlmdir | directory URL (often a directory, or NULL) |
urlfile | file URL (often a file, or NULL) |
Definition at line 3356 of file macro.c.
References _free(), alloca(), file, rpmGetPath(), URL_IS_DASH, and urlPath().
Referenced by addSource(), createDir(), db3close(), db3open(), db_init(), doIcon(), doPatch(), doScript(), doSetupMacro(), doUntar(), handlePreambleTag(), main(), prepFetch(), processBinaryFile(), processMetadataFile(), processPackageFiles(), rpmdsNew(), rpmfcGenerateDepends(), rpmfiNew(), rpmpsmStage(), rpmrepoInitPopt(), 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.
mc | macro context (NULL uses global context) |
_mire | pattern to match (NULL disables) |
used | macro usage (<0 all, =0 unused, >=1 used count) |
*avp | macro definitions |
Definition at line 319 of file macro.c.
References dupMacroEntry(), mireRegexec(), rpmGlobalMacroContext, xcalloc(), and xrealloc.
Referenced by packageSources(), rpmmc_list(), and rpmtsFini().
char* rpmGetPath | ( | const char * | path, |
... | |||
) |
Return (malloc'ed) expanded, canonicalized, file path.
path | macro(s) to expand (NULL terminates list) |
Definition at line 3310 of file macro.c.
References _macro_BUFSIZ, alloca(), DRD_xstrdup, expandMacros(), rpmCleanPath(), stpcpy(), and xstrdup().
Referenced by addFileToTagAux(), buildSpec(), Chroot(), db3open(), db_init(), defaultMachine(), doPatch(), doUntar(), fpLookupSubdir(), getSourceDir(), initSourceHeader(), main(), packageBinaries(), packageSources(), parseFiles(), parseForSimple(), parseSpec(), processPackageFiles(), Realpath(), repoWriteMetadataDocs(), rpmcliInit(), rpmcliInstallElementPath(), rpmdbExportHR_MIB(), rpmdbExportL10N_SQL(), rpmdbURIPath(), rpmdsSysinfo(), rpmfiNew(), rpmGenPath(), rpmGetFilesystemUsage(), rpmpsmStage(), rpmQueryVerify(), rpmrbLoadClasses(), rpmrepoCloseMDFile(), rpmrepoDoFinalMove(), rpmrepoDoPkgMetadata(), rpmrepoDoRepoMetadata(), rpmrepoGetPath(), rpmrepoInitPopt(), rpmrepoMkdir(), rpmrepoOpenMDFile(), rpmrepoTestSetupDirs(), rpmsqlNew(), rpmsxNew(), rpmtsFindPubkey(), rpmtsOpenDB(), rpmtsOpenSDB(), rpmtsPRCO(), rpmtsRebuildDB(), rpmvfNew(), str2uuid(), and unsatisfiedDepend().
int rpmGlob | ( | const char * | patterns, |
int * | argcPtr, | ||
const char *** | argvPtr | ||
) |
Return URL path(s) from a (URL prefixed) pattern glob.
patterns | glob pattern |
*argcPtr | no. of paths |
*argvPtr | array of paths (malloc'd contiguous blob) |
Definition at line 2509 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_MONGO, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), xmalloc, XpoptParseArgvString(), xrealloc, and xstrdup().
Referenced by IDTXglob(), processBinaryFile(), rpmcliInit(), rpmcliInstallElementPath(), rpmgiGlobArgv(), rpmInitMacros(), rpmioInit(), rpmLoadMacroFile(), and rpmReadPackageManifest().
void rpmInitMacros | ( | MacroContext | mc, |
const char * | macrofiles | ||
) |
Initialize macro context from set of macrofile(s).
mc | macro context |
macrofiles | colon separated list of macro files (NULL does nothing) |
Definition at line 2880 of file macro.c.
References _free(), _max_load_depth, _suffix, RMIL_CMDLINE, rpmCLIMacroContext, rpmGlob(), rpmGlobalMacroContext, rpmLoadMacroFile(), rpmLoadMacros(), rpmlog(), RPMLOG_WARNING, rpmSecuritySaneFile(), xmalloc, and xstrdup().
Referenced by rpmmc_init_macros(), and rpmReadRC().
int rpmLoadMacroFile | ( | MacroContext | mc, |
const char * | fn, | ||
int | nesting | ||
) |
Load macro context from a macro file.
mc | (unused) |
fn | macro file name |
nesting | max load recursion depth, 0 disables. |
Definition at line 2801 of file macro.c.
References _, _free(), _macro_BUFSIZ, _MAX_MACRO_DEPTH, alloca(), Fclose(), Ferror(), Fopen(), matchchar(), max_macro_depth, rdcl(), RMIL_MACROFILES, rpmDefineMacro(), rpmGlob(), rpmLoadMacroFile(), rpmlog(), RPMLOG_WARNING, rpmMCExpand(), and SKIPBLANK.
Referenced by expandMacro(), rpmInitMacros(), rpmLoadMacroFile(), and rpmmc_load_macro_file().
void rpmLoadMacros | ( | MacroContext | mc, |
int | level | ||
) |
Load macros from specific context into global context.
mc | macro context (NULL does nothing). |
level | macro recursion level (0 is entry API) |
Definition at line 2761 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.
mc | macro context |
arg | macro(s) to expand (NULL terminates list) |
Definition at line 3154 of file macro.c.
References _macro_BUFSIZ, expandMacros(), stpcpy(), xmalloc, xrealloc, and xstrdup().
Referenced by rpmLoadMacroFile(), and rpmmc_expand().
int rpmSecuritySaneFile | ( | const char * | filename | ) |
Check whether configuration file is moderately secure to load.
filename | filename to check |
Definition at line 2486 of file macro.c.
Referenced by rpmcliInit(), rpmInitMacros(), and rpmioInit().
int rpmUndefineMacro | ( | MacroContext | mc, |
const char * | macro | ||
) |
Undefine macro in context.
mc | macro context (NULL uses global context). |
macro | macro name |
Definition at line 2753 of file macro.c.
References doUndefine(), and rpmGlobalMacroContext.
Referenced by rpmcliAllArgCallback(), rpmioAllArgCallback(), and rpmmc_del().
|
static |
Sort entries in macro table.
mc | macro context |
Definition at line 235 of file macro.c.
References compareMacroName().
Referenced by addMacro(), delMacro(), and freeArgs().
|
static |
< missing argument
< missing argument
< memory allocation failed
Definition at line 1492 of file macro.c.
References POPT_ERROR_MALLOC, POPT_ERROR_NOARG, and xmalloc.
Referenced by XpoptParseArgvString().
|
static |
< memory allocation failed
< error in paramter quoting
< error in paramter quoting
Definition at line 1532 of file macro.c.
References alloca(), POPT_ARGV_ARRAY_GROW_DELTA, POPT_ERROR_BADQUOTE, POPT_ERROR_MALLOC, xmalloc, and XpoptDupArgv().
Referenced by rpmGlob().
|
static |
Definition at line 173 of file macro.c.
Referenced by doDefine(), doFoo(), doOutput(), doShellEscape(), doUndefine(), grabArgs(), rpmExpand(), rpmGetPath(), rpmLoadMacroFile(), and rpmMCExpand().
int _max_load_depth = 2 |
Definition at line 166 of file macro.c.
Referenced by expandMacro(), and rpmInitMacros().
int max_macro_depth = 16 |
Definition at line 154 of file macro.c.
Referenced by expandMacro(), and rpmLoadMacroFile().
int print_expand_trace = 0 |
Definition at line 162 of file macro.c.
Referenced by expandMacro(), and expandMacros().
int print_macro_trace = 0 |
Definition at line 158 of file macro.c.
Referenced by expandMacro(), and expandMacros().
MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s |
Definition at line 127 of file macro.c.
Referenced by _rpmmc_free(), rpmcliAllArgCallback(), rpmcliFini(), rpmInitMacros(), rpmioAllArgCallback(), rpmioFini(), and rpmmc_get_cli_mc().
MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s |
Definition at line 122 of file macro.c.
Referenced by _rpmmc_free(), addMacro(), delMacro(), expandMacros(), findEntry(), newSpec(), rpmDefineMacro(), rpmDumpMacroTable(), rpmFreeMacros(), rpmGetMacroEntries(), rpmInitMacros(), rpmLoadMacros(), rpmmc_get_global_mc(), and rpmUndefineMacro().