rpm
5.4.15
|
#include <stdio.h>
#include <sys/types.h>
Go to the source code of this file.
Macros | |
#define | RMIL_DEFAULT -15 |
Markers for sources of macros added throughout rpm. More... | |
#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, COMPRESSED_LRZIP = 7, COMPRESSED_LZIP = 8, COMPRESSED_7ZIP = 9 } |
Functions | |
void | rpmDumpMacroTable (MacroContext mc, FILE *fp) |
Print macros to file stream. More... | |
int | rpmGetMacroEntries (MacroContext mc, void *_mire, int used, const char ***avp) |
Return macro entries as string array. More... | |
int | rpmSecuritySaneFile (const char *filename) |
Check whether configuration file is moderately secure to load. More... | |
int | rpmGlob (const char *patterns, int *argcPtr, const char ***argvPtr) |
Return URL path(s) from a (URL prefixed) pattern glob. More... | |
int | expandMacros (void *spec, MacroContext mc, char *sbuf, size_t slen) |
Expand macro into buffer. More... | |
void | addMacro (MacroContext mc, const char *n, const char *o, const char *b, int level) |
Add macro to context. More... | |
void | delMacro (MacroContext mc, const char *n) |
Delete macro from context. More... | |
int | rpmDefineMacro (MacroContext mc, const char *macro, int level) |
Define macro in context. More... | |
int | rpmUndefineMacro (MacroContext mc, const char *macro) |
Undefine macro in context. More... | |
void | rpmLoadMacros (MacroContext mc, int level) |
Load macros from specific context into global context. More... | |
int | rpmLoadMacroFile (MacroContext mc, const char *fn, int nesting) |
Load macro context from a macro file. More... | |
void | rpmInitMacros (MacroContext mc, const char *macrofiles) |
Initialize macro context from set of macrofile(s). More... | |
void | rpmFreeMacros (MacroContext mc) |
Destroy macro context. More... | |
int | isCompressed (const char *file, rpmCompressedMagic *compressed) |
Return type of compression used in file. More... | |
char * | rpmExpand (const char *arg,...) |
Return (malloc'ed) concatenated macro expansion(s). More... | |
char * | rpmMCExpand (MacroContext mc, const char *arg,...) |
Return (malloc'ed) concatenated macro expansion(s) in a context. More... | |
char * | rpmCleanPath (char *path) |
Canonicalize file path. More... | |
char * | rpmGetPath (const char *path,...) |
Return (malloc'ed) expanded, canonicalized, file path. More... | |
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. More... | |
int | rpmExpandNumeric (const char *arg) |
Return macro expansion as a numeric value. More... | |
Variables | |
MacroContext | rpmGlobalMacroContext |
MacroContext | rpmCLIMacroContext |
const char * | rpmMacrofiles |
List of macro files to read when configuring rpm. More... | |
#define RMIL_CMDLINE -7 |
Definition at line 66 of file rpmmacro.h.
Referenced by ftsCacheUpdate(), main(), rpmcliAllArgCallback(), rpmInitMacros(), and rpmioAllArgCallback().
#define RMIL_DEFAULT -15 |
Markers for sources of macros added throughout rpm.
Definition at line 62 of file rpmmacro.h.
Referenced by addMacroDefault(), rpmtsOpenSDB(), setDefaults(), and setPathDefault().
#define RMIL_GLOBAL 0 |
Definition at line 70 of file rpmmacro.h.
Referenced by expandMacro(), and rpmcliInstall().
#define RMIL_MACROFILES -13 |
Definition at line 63 of file rpmmacro.h.
Referenced by rpmLoadMacroFile().
#define RMIL_OLDSPEC -1 |
Definition at line 69 of file rpmmacro.h.
Referenced by handlePreambleTag().
#define RMIL_RPMRC -11 |
Definition at line 64 of file rpmmacro.h.
Referenced by parseSpec(), and rpmRebuildTargetVars().
#define RMIL_SPEC -3 |
Definition at line 68 of file rpmmacro.h.
Referenced by addSource(), doSetupMacro(), handlePreambleTag(), parsePreamble(), and parseSpec().
#define RMIL_TARBALL -5 |
Definition at line 67 of file rpmmacro.h.
typedef struct MacroContext_s* MacroContext |
Definition at line 13 of file rpmmacro.h.
typedef struct MacroEntry_s* MacroEntry |
Definition at line 12 of file rpmmacro.h.
typedef enum rpmCompressedMagic_e rpmCompressedMagic |
enum rpmCompressedMagic_e |
Definition at line 218 of file rpmmacro.h.
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 2784 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().
void delMacro | ( | MacroContext | mc, |
const char * | n | ||
) |
Delete macro from context.
mc | macro context (NULL uses global context). |
n | macro name |
Definition at line 2823 of file macro.c.
References findEntry(), popMacro(), rpmGlobalMacroContext, and sortMacroTable().
Referenced by delMacroAll(), doUndefine(), handlePreambleTag(), headerMacrosUnload(), makeGPGSignature(), parseSpec(), rpmcliInstall(), rpmRebuildTargetVars(), and rpmtsOpenSDB().
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 2749 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.
file | name of file |
compressed | address of compression type |
Definition at line 3117 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.
char* rpmCleanPath | ( | char * | path | ) |
Canonicalize file path.
path | path to canonicalize (in-place) |
Definition at line 3351 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 2851 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 287 of file macro.c.
References _, i, 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 3250 of file macro.c.
References _macro_BUFSIZ, expandMacros(), stpcpy(), xmalloc, xrealloc, and xstrdup().
Referenced by _GetPass(), _rpmvtAppendCols(), addChangelog(), archScore(), checkForValidArchitectures(), checkUnpackagedFiles(), cpio_doio(), dbiTagsInit(), debevrfmtTag(), debmd5sumsTag(), defaultMachine(), doPatch(), doPrimary(), doSetupMacro(), fillOutMainPackage(), Fopen(), formatValue(), getMachineInfo(), headerMacrosLoad(), headerMacrosUnload(), headerSprintf(), i18nTag(), ignoreDep(), initGlobs(), initSourceHeader(), lookupPackage(), main(), makeGPGSignature(), odbcConnect(), odbcNew(), Open(), open_dso(), packageBinaries(), packageSources(), parseBuildInstallClean(), parseForRegexLang(), parseForSimple(), parsePreamble(), parseSpec(), pgpDigSetAlgos(), prepFetch(), processBinaryFiles(), processSourceFiles(), rdToken(), readLine(), Realpath(), rpmCheckPassPhrase(), rpmcliEvalSlurp(), rpmcliImportPubkeys(), rpmcliInstallElementPath(), rpmcliQuery(), rpmdbNew(), rpmdcParseZeroInstall(), rpmdsCpuinfo(), rpmdsEVRorder(), rpmdsGetconf(), rpmdsLdconfig(), rpmdsPipe(), rpmdsSysinfo(), rpmEVRmire(), rpmEVRorder(), rpmExpandNumeric(), rpmfcClassify(), rpmfcExec(), rpmfcExpandAppend(), rpmfcExpandRegexps(), rpmfcGenerateDependsHelper(), rpmfcSCRIPT(), rpmgiNext(), rpmgiOpen(), rpmgitNew(), rpmhkpFindKey(), rpmhkpLookup(), rpmInstallSourcePackage(), rpmioAllArgCallback(), rpmlock_new(), rpmmiAddPattern(), rpmnsArch(), rpmnsParse(), rpmnsProbeSignature(), rpmperlNew(), rpmPlatform(), rpmpsmStage(), rpmpythonNew(), rpmrbLoadClasses(), rpmrbLoadFile(), rpmReadConfigFiles(), rpmReadRC(), rpmrepoDoRepoMetadata(), rpmrepoInitPopt(), rpmrepoMDExpand(), rpmRollback(), rpmShowProgress(), rpmShowRC(), rpmsmList(), rpmsqlNew(), rpmsqlRun(), rpmts_IDTXglob(), rpmtsAddInstallElement(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), rpmtsOpenSDB(), rpmtsRollback(), rpmtsSkipFiles(), rpmtsSolve(), rpmvtNew(), runImmedTriggers(), runInstScript(), runScript(), runTriggers(), spec_get_buildroot(), statFormat(), strsubFormat(), tagAppendCols(), tagLoadArgv(), 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 3324 of file macro.c.
References _free(), and rpmExpand().
Referenced by _rpmtsOrder(), _rpmtsRun(), addChangelog(), checkPackageDeps(), checkPackages(), checkUnpackagedFiles(), doIcon(), doPatchMacro(), genCpioListAndHeader(), getDigestAlgo(), main(), newSpec(), parseScript(), parseSpec(), processBinaryFiles(), processPackageFiles(), relocateFileList(), rpmcliInstall(), rpmcliQuery(), rpmcliVerify(), rpmdbNew(), rpmdbOpen(), rpmdsELF(), rpmErase(), rpmfcGenerateDepends(), rpmfcSCRIPT(), rpmRollback(), rpmts_new(), rpmtsAddInstallElement(), rpmtsCreate(), rpmtsOpenSDB(), rpmtsPrepare(), rpmtsRollback(), rpmtsSkipFiles(), spec_Parse(), unsatisfiedDepend(), and urlGetFile().
void rpmFreeMacros | ( | MacroContext | mc | ) |
Destroy macro context.
mc | macro context (NULL uses global context). |
Definition at line 3088 of file macro.c.
References _free(), i, 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 3489 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(), rpmlock_new(), 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 321 of file macro.c.
References dupMacroEntry(), i, 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 3443 of file macro.c.
References _macro_BUFSIZ, alloca(), DRD_xstrdup, expandMacros(), rpmCleanPath(), stpcpy(), and xstrdup().
Referenced by addFileToTagAux(), buildSpec(), Chroot(), compressedFN(), db3open(), db_init(), defaultMachine(), doPatch(), doUntar(), fpLookupSubdir(), getSourceDir(), initSourceHeader(), main(), packageBinaries(), packageSources(), parseFiles(), parseForSimple(), parseSpec(), processPackageFiles(), Realpath(), repoWriteMetadataDocs(), rpmcliInit(), rpmcliInstallElementPath(), rpmdbExportHR_MIB(), 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 2609 of file macro.c.
References _free(), glob_t::gl_pathc, glob_t::gl_pathv, Glob(), Glob_error(), Glob_pattern_p(), GLOB_TILDE, Globfree(), i, j, 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 3002 of file macro.c.
References _free(), _max_load_depth, _suffix, i, 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 2913 of file macro.c.
References _, _free(), _macro_BUFSIZ, _MAX_MACRO_DEPTH, _suffix, Access(), alloca(), Fclose(), Ferror(), Fopen(), i, matchchar(), max_macro_depth, R_OK, 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 2873 of file macro.c.
References addMacro(), i, 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 3287 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 2586 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 2865 of file macro.c.
References doUndefine(), and rpmGlobalMacroContext.
Referenced by rpmcliAllArgCallback(), rpmioAllArgCallback(), and rpmmc_del().
MacroContext rpmCLIMacroContext |
Definition at line 129 of file macro.c.
Referenced by _rpmmc_free(), rpmcliAllArgCallback(), rpmcliFini(), rpmInitMacros(), rpmioAllArgCallback(), rpmioFini(), and rpmmc_get_cli_mc().
MacroContext rpmGlobalMacroContext |
Definition at line 124 of file macro.c.
Referenced by _rpmmc_free(), addMacro(), delMacro(), delMacroAll(), expandMacros(), findEntry(), newSpec(), rpmDefineMacro(), rpmDumpMacroTable(), rpmFreeMacros(), rpmGetMacroEntries(), rpmInitMacros(), rpmLoadMacros(), rpmmc_get_global_mc(), and rpmUndefineMacro().
const char* rpmMacrofiles |
List of macro files to read when configuring rpm.
This is a colon separated list of files. URI's are permitted as well, identified by the token '://', so file paths must not begin with '//'.
Definition at line 62 of file macro.c.
Referenced by rpmReadConfigFiles(), and rpmShowRC().