Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

rpmio/macro.c File Reference

More...

#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.

Data Structures

struct  MacroBuf_s
 Macro expansion state. More...


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 SAVECHAR(_mb, _c)   { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
#define _MAX_MACRO_DEPTH   16
#define _PRINT_MACRO_TRACE   0
#define _PRINT_EXPAND_TRACE   0
#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)
#define POPT_ERROR_NOARG   -10 /*!< missing argument */
#define POPT_ERROR_BADQUOTE   -15 /*!< error in paramter quoting */
#define POPT_ERROR_MALLOC   -21 /*!< memory allocation failed */
#define POPT_ARGV_ARRAY_GROW_DELTA   5

Typedefs

typedef MacroBuf_sMacroBuf
 Macro expansion state.


Functions

int expandMacro (MacroBuf mb)
 The main macro recursion loop.

void * _free (const void *p)
 Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.

int compareMacroName (const void *ap, const void *bp)
 Compare macro entries by name (qsort/bsearch).

void expandMacroTable (MacroContext mc)
 Enlarge macro table.

void sortMacroTable (MacroContext mc)
 Sort entries in macro table.

void rpmDumpMacroTable (MacroContext mc, FILE *fp)
 Print macros to file stream.

MacroEntryfindEntry (MacroContext mc, const char *name, size_t namelen)
 Find entry in macro table.

char * rdcl (char *buf, size_t size, FD_t fd, int escapes)
 fgets(3) analogue that reads \ continuations.

const char * matchchar (const char *p, char pl, char pr)
 Return text between pl and matching pr characters.

void printMacro (MacroBuf mb, const char *s, const char *se)
 Pre-print macro expression to be expanded.

void printExpansion (MacroBuf mb, const char *t, const char *te)
 Post-print expanded macro expression.

int expandT (MacroBuf mb, const char *f, size_t flen)
 Save source and expand field into target.

int expandU (MacroBuf mb, char *u, size_t ulen)
 Save source/target and expand macro in u.

int doShellEscape (MacroBuf mb, const char *cmd, size_t clen)
 Expand output of shell command into target buffer.

const char * doDefine (MacroBuf mb, const char *se, int level, int expandbody)
 Parse (and execute) new macro definition.

const char * doUndefine (MacroContext mc, const char *se)
 Parse (and execute) macro undefinition.

void pushMacro (MacroEntry *mep, const char *n, const char *o, const char *b, int level)
 Push new macro definition onto macro entry stack.

void popMacro (MacroEntry *mep)
 Pop macro definition from macro entry stack.

void freeArgs (MacroBuf mb)
 Free parsed arguments for parameterized macro.

const char * grabArgs (MacroBuf mb, const MacroEntry me, const char *se, const char *lastc)
 Parse arguments (to next new line) for parameterized macro.

void doOutput (MacroBuf mb, int waserror, const char *msg, size_t msglen)
 Perform macro message output.

void doFoo (MacroBuf mb, int negate, const char *f, size_t fn, const char *g, size_t gn)
 Execute macro primitives.

int poptDupArgv (int argc, const char **argv, int *argcPtr, const char ***argvPtr)
int poptParseArgvString (const char *s, int *argcPtr, const char ***argvPtr)
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.

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).

int rpmExpandNumeric (const char *arg)
 Return macro expansion as a numeric value.

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.


Variables

MacroContext_s rpmGlobalMacroContext_s
MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s
MacroContext_s rpmCLIMacroContext_s
MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s
int max_macro_depth = 16
int print_macro_trace = 0
int print_expand_trace = 0
int _debug = 0


Detailed Description

Definition in file macro.c.


Define Documentation

#define _MAX_MACRO_DEPTH   16
 

Definition at line 95 of file macro.c.

#define _PRINT_EXPAND_TRACE   0
 

Definition at line 103 of file macro.c.

#define _PRINT_MACRO_TRACE   0
 

Definition at line 99 of file macro.c.

#define COPYBODY _be,
_s,
_c   ) 
 

Value:

{       /*@-boundswrite@*/      \
        while(((_c) = *(_s)) && !iseol(_c)) { \
                if ((_c) == '\\') \
                        (_s)++; \
                *(_be)++ = *(_s)++; \
        }                       \
        *(_be) = '\0';          \
        /*@=boundswrite@*/      \
    }

Definition at line 473 of file macro.c.

Referenced by doDefine().

#define COPYNAME _ne,
_s,
_c   ) 
 

Value:

{       SKIPBLANK(_s,_c);       \
        /*@-boundswrite@*/      \
        while(((_c) = *(_s)) && (xisalnum(_c) || (_c) == '_')) \
                *(_ne)++ = *(_s)++; \
        *(_ne) = '\0';          \
        /*@=boundswrite@*/      \
    }

Definition at line 456 of file macro.c.

Referenced by doDefine(), and doUndefine().

#define COPYOPTS _oe,
_s,
_c   ) 
 

Value:

{       /*@-boundswrite@*/      \
        while(((_c) = *(_s)) && (_c) != ')') \
                *(_oe)++ = *(_s)++; \
        *(_oe) = '\0';          \
        /*@=boundswrite@*/      \
    }

Definition at line 465 of file macro.c.

Referenced by doDefine().

#define isblank _c   )     ((_c) == ' ' || (_c) == '\t')
 

Definition at line 10 of file macro.c.

Referenced by doDefine(), doFoo(), expandMacro(), and grabArgs().

#define iseol _c   )     ((_c) == '\n' || (_c) == '\r')
 

Definition at line 12 of file macro.c.

Referenced by doDefine(), doShellEscape(), doUndefine(), expandMacro(), printExpansion(), printMacro(), and rdcl().

#define MACRO_CHUNK_SIZE   16
 

Definition at line 108 of file macro.c.

Referenced by expandMacroTable().

#define POPT_ARGV_ARRAY_GROW_DELTA   5
 

Definition at line 1493 of file macro.c.

Referenced by poptParseArgvString().

#define POPT_ERROR_BADQUOTE   -15 /*!< error in paramter quoting */
 

error in paramter quoting

Definition at line 1488 of file macro.c.

Referenced by poptParseArgvString(), and poptStrerror().

#define POPT_ERROR_MALLOC   -21 /*!< memory allocation failed */
 

memory allocation failed

Definition at line 1490 of file macro.c.

Referenced by execCommand(), poptConfigFileToString(), poptDupArgv(), poptParseArgvString(), and poptStrerror().

#define POPT_ERROR_NOARG   -10 /*!< missing argument */
 

missing argument

Definition at line 1486 of file macro.c.

Referenced by execCommand(), poptDupArgv(), poptGetNextOpt(), and poptStrerror().

#define SAVECHAR _mb,
_c   )     { *(_mb)->t = (_c), (_mb)->t++, (_mb)->nb--; }
 

Definition at line 91 of file macro.c.

Referenced by doShellEscape(), and expandMacro().

#define SKIPBLANK _s,
_c   ) 
 

Value:

/*@-globs@*/    /* FIX: __ctype_b */ \
        while (((_c) = *(_s)) && isblank(_c)) \
                (_s)++;         \
        /*@=globs@*/

Definition at line 442 of file macro.c.

Referenced by doDefine().

#define SKIPNONBLANK _s,
_c   ) 
 

Value:

/*@-globs@*/    /* FIX: __ctype_b */ \
        while (((_c) = *(_s)) && !(isblank(_c) || iseol(_c))) \
                (_s)++;         \
        /*@=globs@*/

Definition at line 449 of file macro.c.

#define STREQ _t,
_f,
_fn   )     ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
 

Definition at line 14 of file macro.c.

Referenced by doFoo(), and expandMacro().


Typedef Documentation

typedef struct MacroBuf_s * MacroBuf
 

Macro expansion state.

Referenced by printExpansion(), and printMacro().


Function Documentation

void* _free const void *  p  )  [inline, static]
 

Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.

Parameters:
p memory to free
Return values:
NULL always

Definition at line 123 of file macro.c.

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

Add macro to context.

Deprecated:
Use rpmDefineMacro().
Parameters:
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 1753 of file macro.c.

References expandMacroTable(), MacroContext_s::firstFree, MacroContext_s::macrosAllocated, MacroContext_s::macroTable, and rpmGlobalMacroContext.

Referenced by addSource(), buildForTarget(), doDefine(), doReadRC(), doScript(), doSetupMacro(), expandMacro(), grabArgs(), handlePreambleTag(), main(), makeGPGSignature(), makePGPSignature(), parseSpec(), rpmInstallLoadMacros(), rpmLoadMacros(), rpmPlatform(), rpmrc_AddMacro(), rpmRebuildTargetVars(), rpmtsOpenSDB(), setDefaults(), setPathDefault(), and setVarDefault().

int compareMacroName const void *  ap,
const void *  bp
[static]
 

Compare macro entries by name (qsort/bsearch).

Parameters:
ap 1st macro entry
bp 2nd macro entry
Returns:
result of comparison

Definition at line 139 of file macro.c.

References MacroEntry, and MacroEntry_s::name.

Referenced by findEntry(), and sortMacroTable().

void delMacro MacroContext  mc,
const char *  n
 

Delete macro from context.

Parameters:
mc macro context (NULL uses global context).
n macro name

Definition at line 1779 of file macro.c.

References popMacro(), and sortMacroTable().

Referenced by doScript(), doUndefine(), handlePreambleTag(), makeGPGSignature(), makePGPSignature(), parseSpec(), rpmrc_DelMacro(), rpmRebuildTargetVars(), and rpmtsOpenSDB().

const char* doDefine MacroBuf  mb,
const char *  se,
int  level,
int  expandbody
[static]
 

Parse (and execute) new macro definition.

Parameters:
mb macro expansion state
se macro definition to parse
level macro recursion level
expandbody should body be expanded?
Returns:
address to continue parsing

Definition at line 624 of file macro.c.

References _, addMacro(), COPYBODY, COPYNAME, COPYOPTS, expandU(), isblank, iseol, matchchar(), MacroBuf_s::mc, RPMERR_BADSPEC, rpmError, SKIPBLANK, and xisalpha().

Referenced by expandMacro().

void doFoo MacroBuf  mb,
int  negate,
const char *  f,
size_t  fn,
const char *  g,
size_t  gn
[static]
 

Execute macro primitives.

Parameters:
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 1060 of file macro.c.

References COMPRESSED_OTHER, expandT(), expandU(), isblank, isCompressed(), rpmCompressedMagic, rpmIsVerbose, STREQ, urlPath(), and xisdigit().

Referenced by expandMacro().

void doOutput MacroBuf  mb,
int  waserror,
const char *  msg,
size_t  msglen
[static]
 

Perform macro message output.

Parameters:
mb macro expansion state
waserror use rpmError()?
msg message to ouput
msglen no. of bytes in message

Definition at line 1035 of file macro.c.

References expandU(), RPMERR_BADSPEC, and rpmError.

Referenced by expandMacro().

int doShellEscape MacroBuf  mb,
const char *  cmd,
size_t  clen
[static]
 

Expand output of shell command into target buffer.

Parameters:
mb macro expansion state
cmd shell command
clen no. bytes in shell command
Returns:
result of expansion

Definition at line 585 of file macro.c.

References expandU(), iseol, MacroBuf_s::nb, SAVECHAR, and MacroBuf_s::t.

Referenced by expandMacro().

const char* doUndefine MacroContext  mc,
const char *  se
[static]
 

Parse (and execute) macro undefinition.

Parameters:
mc macro context
se macro name to undefine
Returns:
address to continue parsing

Definition at line 720 of file macro.c.

References _, COPYNAME, delMacro(), iseol, RPMERR_BADSPEC, rpmError, and xisalpha().

Referenced by expandMacro().

int expandMacro MacroBuf  mb  )  [static]
 

The main macro recursion loop.

Todo:
Dynamically reallocate target buffer.
Parameters:
mb macro expansion state
Returns:
0 on success, 1 on failure

Definition at line 1162 of file macro.c.

References _, addMacro(), MacroEntry_s::body, MacroBuf_s::depth, doDefine(), doFoo(), doOutput(), doShellEscape(), doUndefine(), MacroBuf_s::expand_trace, expandT(), findEntry(), freeArgs(), grabArgs(), isblank, iseol, MacroBuf_s::macro_trace, MacroEntry, matchchar(), max_macro_depth, MacroBuf_s::mc, MacroEntry_s::name, MacroBuf_s::nb, MacroEntry_s::opts, print_expand_trace, print_macro_trace, printExpansion(), printMacro(), RMIL_GLOBAL, rpmDumpMacroTable(), RPMERR_BADSPEC, rpmError, MacroBuf_s::s, SAVECHAR, STREQ, MacroBuf_s::t, MacroEntry_s::used, and xisalnum().

Referenced by expandT(), and expandU().

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

Expand macro into buffer.

Deprecated:
Use rpmExpand().

Todo:
Eliminate from API.
Parameters:
spec cookie (unused)
mc macro context (NULL uses global context).
Return values:
sbuf input macro to expand, output expansion
Parameters:
slen size of buffer
Returns:
0 on success

Definition at line 1718 of file macro.c.

References print_expand_trace, print_macro_trace, and rpmGlobalMacroContext.

Referenced by addFileToTagAux(), copyNextLine(), and processPackageFiles().

void expandMacroTable MacroContext  mc  )  [static]
 

Enlarge macro table.

Parameters:
mc macro context

Definition at line 160 of file macro.c.

References MacroContext_s::firstFree, MACRO_CHUNK_SIZE, MacroContext, MacroEntry, MacroContext_s::macrosAllocated, MacroContext_s::macroTable, xmalloc(), and xrealloc().

Referenced by addMacro().

int expandT MacroBuf  mb,
const char *  f,
size_t  flen
[static]
 

Save source and expand field into target.

Parameters:
mb macro expansion state
f field
flen no. bytes in field
Returns:
result of expansion

Definition at line 492 of file macro.c.

References alloca(), expandMacro(), and MacroBuf_s::s.

Referenced by doFoo(), and expandMacro().

int expandU MacroBuf  mb,
char *  u,
size_t  ulen
[static]
 

Save source/target and expand macro in u.

Parameters:
mb macro expansion state
u input macro, output expansion
ulen no. bytes in u buffer
Returns:
result of expansion

Definition at line 546 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().

MacroEntry* findEntry MacroContext  mc,
const char *  name,
size_t  namelen
[static]
 

Find entry in macro table.

Parameters:
mc macro context
name macro name
namelen no. of bytes
Returns:
address of slot in macro table with name (or NULL)

Definition at line 246 of file macro.c.

References compareMacroName(), MacroContext_s::firstFree, MacroContext, MacroEntry, MacroContext_s::macroTable, and rpmGlobalMacroContext.

Referenced by expandMacro(), headerFindI18NString(), headerGetRawEntry(), htGetEntry(), htHasEntry(), and intGetEntry().

void freeArgs MacroBuf  mb  )  [static]
 

Free parsed arguments for parameterized macro.

Parameters:
mb macro expansion state

Definition at line 829 of file macro.c.

References _, MacroEntry_s::body, MacroBuf_s::depth, MacroContext_s::firstFree, MacroEntry_s::level, MacroContext, MacroEntry, MacroContext_s::macroTable, MacroBuf_s::mc, MacroEntry_s::name, popMacro(), RPMERR_BADSPEC, rpmError, sortMacroTable(), and MacroEntry_s::used.

Referenced by expandMacro().

const char* grabArgs MacroBuf  mb,
const MacroEntry  me,
const char *  se,
const char *  lastc
[static]
 

Parse arguments (to next new line) for parameterized macro.

Todo:
Use popt rather than getopt to parse args.
Parameters:
mb macro expansion state
me macro entry slot
se arguments to parse
lastc stop parsing at lastc
Returns:
address to continue parsing

Definition at line 881 of file macro.c.

References _, addMacro(), alloca(), MacroBuf_s::depth, expandU(), isblank, MacroBuf_s::mc, MacroEntry_s::name, MacroEntry_s::opts, RPMERR_BADSPEC, rpmError, and stpcpy().

Referenced by expandMacro().

int isCompressed const char *  file,
rpmCompressedMagic compressed
 

Return type of compression used in file.

Parameters:
file name of file
Return values:
compressed address of compression type
Returns:
0 on success, 1 on I/O error

Definition at line 1937 of file macro.c.

References COMPRESSED_NOT.

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

const char* matchchar const char *  p,
char  pl,
char  pr
[static]
 

Return text between pl and matching pr characters.

Parameters:
p start of text
pl left char, i.e. '[', '(', '{', etc.
pr right char, i.e. ']', ')', '}', etc.
Returns:
address of last char before pr (or NULL)

Definition at line 335 of file macro.c.

Referenced by doDefine(), and expandMacro().

void popMacro MacroEntry mep  )  [static]
 

Pop macro definition from macro entry stack.

Parameters:
mep address of macro entry slot

Definition at line 803 of file macro.c.

References _free(), MacroEntry_s::body, MacroEntry, MacroEntry_s::name, MacroEntry_s::opts, and MacroEntry_s::prev.

Referenced by delMacro(), and freeArgs().

int poptDupArgv int  argc,
const char **  argv,
int *  argcPtr,
const char ***  argvPtr
[static]
 

Definition at line 1496 of file macro.c.

References POPT_ERROR_NOARG.

int poptParseArgvString const char *  s,
int *  argcPtr,
const char ***  argvPtr
[static]
 

Definition at line 1539 of file macro.c.

References POPT_ERROR_MALLOC.

void printExpansion MacroBuf  mb,
const char *  t,
const char *  te
[static]
 

Post-print expanded macro expression.

Parameters:
mb macro expansion state
t current expansion string result
te end of string

Definition at line 405 of file macro.c.

References _, MacroBuf_s::depth, iseol, and MacroBuf.

Referenced by expandMacro().

void printMacro MacroBuf  mb,
const char *  s,
const char *  se
[static]
 

Pre-print macro expression to be expanded.

Parameters:
mb macro expansion state
s current expansion string
se end of string

Definition at line 361 of file macro.c.

References _, MacroBuf_s::depth, iseol, and MacroBuf.

Referenced by expandMacro().

void pushMacro MacroEntry mep,
const char *  n,
const char *  o,
const char *  b,
int  level
[static]
 

Push new macro definition onto macro entry stack.

Parameters:
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 772 of file macro.c.

References _free(), MacroEntry, MacroEntry_s::name, xmalloc(), and xstrdup().

char* rdcl char *  buf,
size_t  size,
FD_t  fd,
int  escapes
[static]
 

fgets(3) analogue that reads \ continuations.

Last newline always trimmed.

Parameters:
buf input buffer
size inbut buffer size (bytes)
fd file handle
escapes permit escaped newlines?
Returns:
buffer, or NULL on end-of-file

Definition at line 292 of file macro.c.

References fdGetFILE, and iseol.

char* rpmCleanPath char *  path  ) 
 

Canonicalize file path.

Parameters:
path path to canonicalize (in-place)
Returns:
canonicalized path (malloc'ed)

Definition at line 2039 of file macro.c.

Referenced by doLookup(), relocateFileList(), rpmdbMoveDatabase(), rpmdbRemoveDatabase(), and rpmQueryVerify().

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

Define macro in context.

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

Definition at line 1795 of file macro.c.

References rpmGlobalMacroContext.

Referenced by ftsCacheUpdate(), rpmcliAllArgCallback(), and rpmdbRebuild().

void rpmDumpMacroTable MacroContext  mc,
FILE *  fp
 

Print macros to file stream.

Parameters:
mc macro context (NULL uses global context).
fp file stream (NULL uses stderr).

Definition at line 204 of file macro.c.

References _, MacroEntry_s::body, MacroContext_s::firstFree, MacroEntry_s::level, MacroContext, MacroEntry, MacroContext_s::macroTable, MacroEntry_s::name, MacroEntry_s::opts, rpmGlobalMacroContext, and MacroEntry_s::used.

Referenced by expandMacro(), and rpmShowRC().

char* rpmExpand const char *  arg,
... 
 

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

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

Definition at line 1989 of file macro.c.

Referenced by checkFiles(), checkForValidArchitectures(), checkPassPhrase(), cpio_doio(), db3New(), dbiTagsInit(), defaultMachine(), doPrimary(), doScript(), doSetupMacro(), fillOutMainPackage(), i18nTag(), ignoreDep(), initGlobs(), main(), makeGPGSignature(), makePGPSignature(), newRpmdb(), open_dso(), packageBinaries(), parseForRegexLang(), parseSpec(), rdToken(), readLine(), rpmcliAllArgCallback(), rpmcliQuery(), rpmdbSetIteratorRE(), rpmfcExec(), rpmfcExpandAppend(), rpmfcGenerateDependsHelper(), rpmGetPassPhrase(), rpmLookupSignatureType(), rpmPlatform(), rpmReadConfigFiles(), rpmRollback(), rpmts_IDTXglob(), rpmtsFindPubkey(), rpmtsSolve(), runScript(), skipFiles(), urlFind(), 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:
arg macro to expand
Returns:
numeric value

Definition at line 2012 of file macro.c.

Referenced by build(), checkFiles(), dbiOpen(), genCpioListAndHeader(), main(), newRpmdb(), parseRCPOT(), parseSpec(), processPackageFiles(), rpmcliQuery(), rpmcliVerify(), rpmdbInit(), rpmdbOpen(), rpmdbRebuild(), rpmdbVerify(), rpmErase(), rpmfcELF(), rpmfcGenerateDepends(), rpmInstall(), rpmLeadVersion(), rpmRollback(), rpmts_Create(), rpmts_init(), rpmtsCreate(), rpmtsOpenSDB(), and skipFiles().

void rpmFreeMacros MacroContext  mc  ) 
 

Destroy macro context.

Parameters:
mc macro context (NULL uses global context).

Definition at line 1910 of file macro.c.

References _free(), MacroEntry_s::body, MacroContext_s::firstFree, MacroEntry, MacroContext_s::macroTable, MacroEntry_s::name, MacroEntry_s::opts, and MacroEntry_s::prev.

Referenced by build(), and main().

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:
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)
Returns:
expanded, merged, canonicalized path (malloc'ed)

Definition at line 2158 of file macro.c.

References _debug, and URL_IS_DASH.

Referenced by buildForTarget(), db3close(), db3open(), db_init(), doScript(), doSetupMacro(), handlePreambleTag(), makeTempFile(), processBinaryFile(), processMetadataFile(), processPackageFiles(), rpmInstall(), rpmInstallSourcePackage(), and rpmpsmStage().

const char* rpmGetPath const char *  path,
... 
 

Return (malloc'ed) expanded, canonicalized, file path.

Parameters:
path macro(s) to expand (NULL terminates list)
Returns:
canonicalized path (malloc'ed)

Definition at line 2127 of file macro.c.

Referenced by addFileToTagAux(), addSource(), buildForTarget(), db3close(), db3open(), doPatch(), doReadRC(), doRmSource(), doUntar(), genCpioListAndHeader(), newRpmdb(), packageBinaries(), packageSources(), parseFiles(), parseForSimple(), parseSpec(), processPackageFiles(), processSourceFiles(), readIcon(), rpmcliQuery(), rpmcliVerify(), rpmdbRebuild(), rpmDetectPGPVersion(), rpmfiNew(), rpmGetFilesystemUsage(), rpmInstall(), rpmpsmStage(), rpmts_Run(), rpmtsOpenDB(), rpmtsOpenSDB(), and setPathDefault().

int rpmGlob const char *  patterns,
int *  argcPtr,
const char ***  argvPtr
 

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

glob pattern

Return values:
*argcPtr no. of paths
*argvPtr array of paths (malloc'd contiguous blob)
Returns:
0 on success

Definition at line 1608 of file macro.c.

References _debug.

Referenced by IDTXglob(), processBinaryFile(), rpmGraph(), rpmInstall(), rpmQueryVerify(), and rpmReadPackageManifest().

void rpmInitMacros MacroContext  mc,
const char *  macrofiles
 

Initialize macro context from set of macrofile(s).

Parameters:
mc macro context
macrofiles colon separated list of macro files (NULL does nothing)

Definition at line 1861 of file macro.c.

References rpmGlobalMacroContext.

Referenced by rpmReadRC().

int rpmLoadMacroFile MacroContext  mc,
const char *  macrofiles
 

Load macro context from a macro file.

Parameters:
mc (unused)
macrofiles colon separated list of macro files (NULL does nothing)

Definition at line 1829 of file macro.c.

References Fclose().

void rpmLoadMacros MacroContext  mc,
int  level
 

Load macros from specific context into global context.

Parameters:
mc macro context (NULL does nothing).
level macro recursion level (0 is entry API)

Definition at line 1808 of file macro.c.

References addMacro(), MacroEntry_s::body, MacroContext_s::firstFree, MacroEntry, MacroContext_s::macroTable, MacroEntry_s::name, and MacroEntry_s::opts.

void sortMacroTable MacroContext  mc  )  [static]
 

Sort entries in macro table.

Parameters:
mc macro context

Definition at line 183 of file macro.c.

References compareMacroName(), MacroContext_s::firstFree, MacroContext, and MacroContext_s::macroTable.

Referenced by delMacro(), and freeArgs().


Variable Documentation

int _debug = 0 [static]
 

Definition at line 1606 of file macro.c.

Referenced by rpmGenPath(), and rpmGlob().

int max_macro_depth = 16
 

Definition at line 97 of file macro.c.

Referenced by expandMacro().

int print_expand_trace = 0
 

Definition at line 105 of file macro.c.

Referenced by expandMacro(), and expandMacros().

int print_macro_trace = 0
 

Definition at line 101 of file macro.c.

Referenced by expandMacro(), and expandMacros().

MacroContext rpmCLIMacroContext = &rpmCLIMacroContext_s
 

Definition at line 70 of file macro.c.

struct MacroContext_s rpmCLIMacroContext_s [static]
 

Definition at line 68 of file macro.c.

MacroContext rpmGlobalMacroContext = &rpmGlobalMacroContext_s
 

Definition at line 65 of file macro.c.

struct MacroContext_s rpmGlobalMacroContext_s [static]
 

Definition at line 63 of file macro.c.


Generated on Fri Apr 16 16:34:01 2004 for rpm by doxygen 1.3.6