#include "system.h"
#include <stdarg.h>
#include <rpmio_internal.h>
#include <rpmmessages.h>
#include <rpmerr.h>
#include <rpmmacro.h>
#include "debug.h"
Go to the source code of this file.
Compounds | |
struct | MacroBuf |
Defines | |
#define | isblank(_c) ((_c) == ' ' || (_c) == '\t') |
#define | iseol(_c) ((_c) == '\n' || (_c) == '\r') |
#define | STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn))) |
#define | FREE(_x) { if (_x) free((void *)_x); (_x) = NULL; } |
#define | SAVECHAR(_mb, _c) { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; } |
#define | MAX_MACRO_DEPTH 16 |
#define | MACRO_CHUNK_SIZE 16 |
#define | SKIPBLANK(_s, _c) |
#define | SKIPNONBLANK(_s, _c) |
#define | COPYNAME(_ne, _s, _c) |
#define | COPYOPTS(_oe, _s, _c) |
#define | COPYBODY(_be, _s, _c) |
Typedefs | |
typedef struct MacroBuf | MacroBuf |
Macro expansion state. | |
Functions | |
int | expandMacro (MacroBuf *mb) |
The main macro recursion loop. More... | |
int | compareMacroName (const void *ap, const void *bp) |
Compare macro entries by name (qsort/bsearch). More... | |
void | expandMacroTable (MacroContext *mc) |
Enlarge macro table. More... | |
void | sortMacroTable (MacroContext *mc) |
Sort entries in macro table. More... | |
void | rpmDumpMacroTable (MacroContext * mc, FILE * fp) |
Print macros to file stream. More... | |
MacroEntry** | findEntry (MacroContext *mc, const char *name, size_t namelen) |
Find entry in macro table. More... | |
char* | rdcl (char *buf, size_t size, FD_t fd, int escapes) |
fgets(3) analogue that reads \ continuations. More... | |
const char* | matchchar (const char *p, char pl, char pr) |
Return text between pl and matching pr characters. More... | |
void | printMacro (MacroBuf *mb, const char *s, const char *se) |
Pre-print macro expression to be expanded. More... | |
void | printExpansion (MacroBuf *mb, const char *t, const char *te) |
Post-print expanded macro expression. More... | |
int | expandT (MacroBuf *mb, const char *f, size_t flen) |
Save source and expand field into target. More... | |
int | expandU (MacroBuf *mb, char *u, size_t ulen) |
Save source/target and expand macro in u. More... | |
int | doShellEscape (MacroBuf *mb, const char *cmd, size_t clen) |
Expand output of shell command into target buffer. More... | |
const char* | doDefine (MacroBuf *mb, const char *se, int level, int expandbody) |
Parse (and execute) new macro definition. More... | |
const char* | doUndefine (MacroContext *mc, const char *se) |
Parse (and execute) macro undefinition. More... | |
void | pushMacro (MacroEntry **mep, const char *n, const char *o, const char *b, int level) |
Push new macro definition onto macro entry stack. More... | |
void | popMacro (MacroEntry **mep) |
Pop macro definition from macro entry stack. More... | |
void | freeArgs (MacroBuf *mb) |
Free parsed arguments for parameterized macro. More... | |
const char* | grabArgs (MacroBuf *mb, const MacroEntry *me, const char *se, char lastc) |
Parse arguments (to next new line) for parameterized macro. More... | |
void | doOutput (MacroBuf *mb, int waserror, const char *msg, size_t msglen) |
Perform macro message output. More... | |
void | doFoo (MacroBuf *mb, int negate, const char *f, size_t fn, const char *g, size_t glen) |
Execute macro primitives. More... | |
int | expandMacros (void *spec, MacroContext *mc, char *s, 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... | |
void | rpmLoadMacros (MacroContext * mc, int level) |
Load macros from context into global context. 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... | |
int | rpmExpandNumeric (const char *arg) |
Return macro expansion as a numeric value. More... | |
char* | rpmCleanPath (char * path) |
Canonicalize file path. More... | |
const 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... | |
Variables | |
int | max_macro_depth = 16 |
int | print_macro_trace = 0 |
int | print_expand_trace = 0 |
Definition in file macro.c.
|
Initializer: \ { while(((_c) = *(_s)) && !iseol(_c)) { \ if ((_c) == '\\') \ (_s)++; \ *(_be)++ = *(_s)++; \ } \ *(_be) = '\0'; \ } Definition at line 392 of file macro.c. Referenced by doDefine(). |
|
Initializer: \ { SKIPBLANK(_s,_c); \ while(((_c) = *(_s)) && (isalnum(_c) || (_c) == '_')) \ *(_ne)++ = *(_s)++; \ *(_ne) = '\0'; \ } Definition at line 379 of file macro.c. Referenced by doDefine(), and doUndefine(). |
|
Initializer: \ { while(((_c) = *(_s)) && (_c) != ')') \ *(_oe)++ = *(_s)++; \ *(_oe) = '\0'; \ } Definition at line 386 of file macro.c. Referenced by doDefine(). |
|
|
|
|
|
|
|
Definition at line 76 of file macro.c. Referenced by doShellEscape(), and expandMacro(). |
|
Initializer: \ while (((_c) = *(_s)) && isblank(_c)) \ (_s)++; Definition at line 371 of file macro.c. Referenced by doDefine(), and rpmInitMacros(). |
|
Initializer: |
|
Definition at line 15 of file macro.c. Referenced by doFoo(), and expandMacro(). |
|
Definition at line 11 of file macro.c. Referenced by doDefine(), doFoo(), expandMacro(), and grabArgs(). |
|
Definition at line 13 of file macro.c. Referenced by doDefine(), doShellEscape(), doUndefine(), expandMacro(), printExpansion(), printMacro(), and rdcl(). |
|
Macro expansion state.
|
|
Add macro to context.
Definition at line 1331 of file macro.c. Referenced by RMIL_GLOBAL(), addSource(), buildForTarget(), doAddMacro(), doDefine(), doReadRC(), doScript(), doSetupMacro(), expandMacro(), grabArgs(), handlePreambleTag(), main(), parseSpec(), rpmInstallLoadMacros(), rpmLoadMacros(), rpmRebuildTargetVars(), setDefaults(), setPathDefault(), and setVarDefault(). |
|
Compare macro entries by name (qsort/bsearch).
|
|
Delete macro from context.
Definition at line 1354 of file macro.c. Referenced by RMIL_GLOBAL(), doDelMacro(), doScript(), doUndefine(), handlePreambleTag(), parseSpec(), and rpmRebuildTargetVars(). |
|
Parse (and execute) new macro definition.
Definition at line 529 of file macro.c. Referenced by expandMacro(), and rpmDefineMacro(). |
|
Execute macro primitives.
Definition at line 889 of file macro.c. Referenced by expandMacro(). |
|
Perform macro message output.
Definition at line 866 of file macro.c. Referenced by expandMacro(). |
|
Expand output of shell command into target buffer.
Definition at line 493 of file macro.c. Referenced by expandMacro(). |
|
Parse (and execute) macro undefinition.
Definition at line 616 of file macro.c. Referenced by expandMacro(). |
|
The main macro recursion loop.
Definition at line 982 of file macro.c. Referenced by expandMacros(), expandT(), and expandU(). |
|
Enlarge macro table.
Definition at line 121 of file macro.c. Referenced by addMacro(). |
|
Expand macro into buffer.
Definition at line 1295 of file macro.c. Referenced by RMIL_GLOBAL(), addFileToTagAux(), copyNextLine(), processPackageFiles(), rpmExpand(), and rpmGetPath(). |
|
Save source and expand field into target.
Definition at line 409 of file macro.c. Referenced by doFoo(), and expandMacro(). |
|
Save source/target and expand macro in u.
Definition at line 458 of file macro.c. Referenced by doDefine(), doFoo(), doOutput(), doShellEscape(), and grabArgs(). |
|
Find entry in macro table.
Definition at line 199 of file macro.c. Referenced by addMacro(), delMacro(), expandMacro(), headerAddI18NString(), headerAddOrAppendEntry(), headerAppendEntry(), headerFindI18NString(), headerGetRawEntry(), headerIsEntry(), headerModifyEntry(), headerRemoveEntry(), htGetEntry(), htHasEntry(), and intGetEntry(). |
|
Free parsed arguments for parameterized macro.
Definition at line 702 of file macro.c. Referenced by expandMacro(). |
|
Parse arguments (to next new line) for parameterized macro.
Definition at line 749 of file macro.c. Referenced by expandMacro(). |
|
Return type of compression used in file.
Definition at line 1490 of file macro.c. Referenced by buildForTarget(), doFoo(), doPatch(), and doUntar(). |
|
Return text between pl and matching pr characters.
Definition at line 269 of file macro.c. Referenced by doDefine(), and expandMacro(). |
|
Pop macro definition from macro entry stack.
|
|
Post-print expanded macro expression.
Definition at line 336 of file macro.c. Referenced by expandMacro(). |
|
Pre-print macro expression to be expanded.
Definition at line 294 of file macro.c. Referenced by expandMacro(). |
|
Push new macro definition onto macro entry stack.
Definition at line 664 of file macro.c. Referenced by addMacro(). |
|
fgets(3) analogue that reads \ continuations. Last newline always trimmed. Definition at line 230 of file macro.c. Referenced by rpmInitMacros(). |
|
Canonicalize file path.
Definition at line 1590 of file macro.c. Referenced by doLookup(), removeBinaryPackage(), rpmGetPath(), rpmQueryVerify(), rpmdbMoveDatabase(), and rpmdbRemoveDatabase(). |
|
Define macro in context.
Definition at line 1370 of file macro.c. Referenced by RMIL_GLOBAL(), main(), and rpmInitMacros(). |
|
Print macros to file stream.
Definition at line 159 of file macro.c. Referenced by RMIL_GLOBAL(), and expandMacro(). |
|
Return (malloc'ed) concatenated macro expansion(s).
Definition at line 1541 of file macro.c. Referenced by checkForValidArchitectures(), checkPassPhrase(), cpio_doio(), dbiTagsInit(), doPrimary(), doScript(), doSetupMacro(), fillOutMainPackage(), generateDepends(), i18nTag(), main(), makeGPGSignature(), makePGPSignature(), packageBinaries(), parseForRegexLang(), parseForRegexMultiLib(), parseSpec(), rdToken(), readLine(), rpmExpandNumeric(), rpmGetPassPhrase(), rpmLookupSignatureType(), rpmReadConfigFiles(), runScript(), skipFiles(), verifyGPGSignature(), verifyPGPSignature(), and writeRPM(). |
|
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.
Definition at line 1563 of file macro.c. Referenced by dbiOpen(), genCpioListAndHeader(), main(), newRpmdb(), parseRCPOT(), parseSpec(), processPackageFiles(), rpmdbInit(), rpmdbOpen(), rpmdbRebuild(), and skipFiles(). |
|
Destroy macro context.
Definition at line 1467 of file macro.c. Referenced by RMIL_GLOBAL(), build(), and main(). |
|
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's are discarded, permitting a primitive form of inheiritance.
Definition at line 1699 of file macro.c. Referenced by buildForTarget(), db1close(), db1open(), doScript(), doSetupMacro(), handlePreambleTag(), installSources(), makeTempFile(), processBinaryFile(), processPackageFiles(), and rpmInstall(). |
|
Return (malloc'ed) expanded, canonicalized, file path.
Definition at line 1670 of file macro.c. Referenced by addFileToTagAux(), addSource(), buildForTarget(), checkSpec(), doPatch(), doReadRC(), doRmSource(), doUntar(), newRpmdb(), packageBinaries(), parseFiles(), parseForSimple(), parseSpec(), processPackageFiles(), processSourceFiles(), readIcon(), rpmDetectPGPVersion(), rpmErase(), rpmGenPath(), rpmGetFilesystemUsage(), rpmInstall(), rpmdbRebuild(), setPathDefault(), verifyGPGSignature(), and verifyPGPSignature(). |
|
Initialize macro context from set of macrofile(s).
Definition at line 1401 of file macro.c. Referenced by RMIL_GLOBAL(), and rpmReadRC(). |
|
Load macros from context into global context.
Definition at line 1382 of file macro.c. Referenced by RMIL_GLOBAL(), and rpmInitMacros(). |
|
Sort entries in macro table.
|
|
|
|
|
|
|