rpm
5.4.14
|
#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 59 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 55 of file rpmmacro.h.
Referenced by addMacroDefault(), rpmtsOpenSDB(), setDefaults(), and setPathDefault().
#define RMIL_GLOBAL 0 |
Definition at line 63 of file rpmmacro.h.
Referenced by rpmcliInstall(), and while().
#define RMIL_MACROFILES -13 |
Definition at line 56 of file rpmmacro.h.
Referenced by rpmLoadMacroFile().
#define RMIL_OLDSPEC -1 |
Definition at line 62 of file rpmmacro.h.
Referenced by handlePreambleTag().
#define RMIL_RPMRC -11 |
Definition at line 57 of file rpmmacro.h.
Referenced by parseSpec(), and rpmRebuildTargetVars().
#define RMIL_SPEC -3 |
Definition at line 61 of file rpmmacro.h.
Referenced by addSource(), doSetupMacro(), handlePreambleTag(), parsePreamble(), and parseSpec().
#define RMIL_TARBALL -5 |
Definition at line 60 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 211 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 2722 of file macro.c.
References _, findEntry(), n, NULL, pushMacro(), rpmGlobalMacroContext, rpmlog(), RPMLOG_ERR, sortMacroTable(), and strcmp().
Referenced by addMacroDefault(), addSource(), doSetupMacro(), grabArgs(), handlePreambleTag(), headerMacrosLoad(), makeGPGSignature(), parsePreamble(), parseSpec(), rpmcliInstall(), rpmLoadMacros(), rpmPlatform(), rpmRebuildTargetVars(), rpmtsOpenSDB(), setDefaults(), setPathDefault(), and while().
void delMacro | ( | MacroContext | mc, |
const char * | n | ||
) |
Delete macro from context.
mc | macro context (NULL uses global context). |
n | macro name |
Definition at line 2761 of file macro.c.
References findEntry(), NULL, rpmGlobalMacroContext, and sortMacroTable().
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 2687 of file macro.c.
References _, alloca(), MacroBuf_s::depth, MacroBuf_s::expand_trace, expandMacro(), MacroBuf_s::macro_trace, MacroBuf_s::mc, MacroBuf_s::nb, NULL, print_expand_trace, print_macro_trace, rc, rpmGlobalMacroContext, rpmlog(), RPMLOG_ERR, MacroBuf_s::s, sbuf, spec, MacroBuf_s::spec, strncpy(), MacroBuf_s::t, and tbuf.
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 3045 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(), fd, Ferror(), Fopen(), Fread(), Fstrerror(), nb, NULL, rc, rpmlog(), RPMLOG_ERR, and void.
char* rpmCleanPath | ( | char * | path | ) |
Canonicalize file path.
path | path to canonicalize (in-place) |
Definition at line 3279 of file macro.c.
References NULL, path, s, se, t, and te.
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 2789 of file macro.c.
References alloca(), MacroBuf_s::mc, memset(), rpmGlobalMacroContext, and void.
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 _, fprintf(), i, me, NULL, and rpmGlobalMacroContext.
Referenced by rpmShowRC(), and while().
char* rpmExpand | ( | const char * | arg, |
... | |||
) |
Return (malloc'ed) concatenated macro expansion(s).
arg | macro(s) to expand (NULL terminates list) |
Definition at line 3178 of file macro.c.
References _macro_BUFSIZ, bufn, expandMacros(), NULL, s, stpcpy(), t, te, void, xmalloc, xrealloc, and xstrdup().
Referenced by _GetPass(), addChangelog(), archScore(), checkForValidArchitectures(), checkUnpackagedFiles(), cpio_doio(), dbiTagsInit(), debevrfmtTag(), debmd5sumsTag(), defaultMachine(), doPatch(), doPrimary(), doSetupMacro(), fillOutMainPackage(), Fopen(), for(), formatValue(), getMachineInfo(), headerMacrosLoad(), headerMacrosUnload(), headerSprintf(), i18nTag(), if(), 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(), 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(), rpmtsAddInstallElement(), rpmtsAddObsoletes(), rpmtsAddUpgrades(), rpmtsEraseDebuginfo(), rpmtsFindPubkey(), rpmtsOpenSDB(), rpmtsRollback(), rpmtsSkipFiles(), rpmtsSolve(), rpmvtNew(), runImmedTriggers(), runInstScript(), runScript(), runTriggers(), 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 3252 of file macro.c.
References _free(), NULL, rc, rpmExpand(), and val.
Referenced by _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(), unsatisfiedDepend(), and urlGetFile().
void rpmFreeMacros | ( | MacroContext | mc | ) |
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 3417 of file macro.c.
References _free(), alloca(), file, fprintf(), NULL, result, rpmGetPath(), strncpy(), t, URL_IS_DASH, and urlPath().
Referenced by addSource(), createDir(), db3close(), db3open(), db_init(), doIcon(), doPatch(), doScript(), doSetupMacro(), doUntar(), for(), handlePreambleTag(), 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 ac, av, dupMacroEntry(), i, me, mireRegexec(), NULL, 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 3371 of file macro.c.
References _macro_BUFSIZ, alloca(), buf, DRD_xstrdup, expandMacros(), nb, NULL, rpmCleanPath(), s, stpcpy(), t, te, void, and xstrdup().
Referenced by addFileToTagAux(), buildSpec(), Chroot(), db3open(), db_init(), defaultMachine(), doPatch(), doUntar(), for(), fpLookupSubdir(), getSourceDir(), initSourceHeader(), packageBinaries(), packageSources(), parseFiles(), parseForSimple(), parseSpec(), processPackageFiles(), Realpath(), repoWriteMetadataDocs(), 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().
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 2547 of file macro.c.
References _free(), ac, argv, av, exit, fprintf(), glob_t::gl_pathc, glob_t::gl_pathv, Glob(), Glob_error(), Glob_pattern_p(), GLOB_TILDE, Globfree(), i, j, nb, NULL, path, rc, setlocale, strncpy(), t, 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(), void, xmalloc, XpoptParseArgvString(), xrealloc, and xstrdup().
Referenced by for(), IDTXglob(), processBinaryFile(), 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 2930 of file macro.c.
References _free(), _max_load_depth, _suffix, ac, av, i, m, me, NULL, RMIL_CMDLINE, rpmCLIMacroContext, rpmGlob(), rpmGlobalMacroContext, rpmLoadMacroFile(), rpmLoadMacros(), rpmlog(), RPMLOG_WARNING, rpmSecuritySaneFile(), void, 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 2851 of file macro.c.
References _, _free(), _macro_BUFSIZ, _MAX_MACRO_DEPTH, alloca(), argv, buf, c, exit, Fclose(), fd, Ferror(), Fopen(), i, max_macro_depth, NULL, rc, RMIL_MACROFILES, rpmDefineMacro(), rpmGlob(), rpmLoadMacroFile(), rpmlog(), RPMLOG_WARNING, rpmMCExpand(), s, SKIPBLANK, void, and xx.
Referenced by rpmInitMacros(), rpmLoadMacroFile(), rpmmc_load_macro_file(), and while().
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 2811 of file macro.c.
References addMacro(), i, me, NULL, 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 3215 of file macro.c.
References _macro_BUFSIZ, bufn, expandMacros(), NULL, s, stpcpy(), t, te, void, 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 2524 of file macro.c.
Referenced by for(), 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 2803 of file macro.c.
References rpmGlobalMacroContext, and void.
Referenced by rpmcliAllArgCallback(), rpmioAllArgCallback(), and rpmmc_del().
MacroContext rpmCLIMacroContext |
Definition at line 127 of file macro.c.
Referenced by _rpmmc_free(), rpmcliAllArgCallback(), rpmInitMacros(), rpmioAllArgCallback(), rpmioFini(), and rpmmc_get_cli_mc().
MacroContext rpmGlobalMacroContext |
Definition at line 122 of file macro.c.
Referenced by _rpmmc_free(), addMacro(), delMacro(), delMacroAll(), expandMacros(), newSpec(), rpmDefineMacro(), rpmDumpMacroTable(), rpmFreeMacros(), rpmGetMacroEntries(), rpmInitMacros(), rpmLoadMacros(), rpmmc_get_global_mc(), and rpmUndefineMacro().