rpm  4.14.0
Functions
Macro API.

Macro API. More...

Functions

void rpmDumpMacroTable (rpmMacroContext mc, FILE *fp)
 Print macros to file stream. More...
 
int rpmExpandMacros (rpmMacroContext mc, const char *sbuf, char **obuf, int flags)
 Expand macro into buffer. More...
 
int rpmPushMacro (rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
 Push macro to context. More...
 
int rpmPopMacro (rpmMacroContext mc, const char *n)
 Pop macro from context. More...
 
int rpmDefineMacro (rpmMacroContext mc, const char *macro, int level)
 Define macro in context. More...
 
void rpmLoadMacros (rpmMacroContext mc, int level)
 Load macros from specific context into global context. More...
 
int rpmLoadMacroFile (rpmMacroContext mc, const char *fn)
 Load macro context from a macro file. More...
 
void rpmInitMacros (rpmMacroContext mc, const char *macrofiles)
 Initialize macro context from set of macrofile(s). More...
 
void rpmFreeMacros (rpmMacroContext mc)
 Destroy macro context. More...
 
char * rpmExpand (const char *arg,...) RPM_GNUC_NULL_TERMINATED
 Return (malloc'ed) concatenated macro expansion(s). More...
 
int rpmExpandNumeric (const char *arg)
 Return macro expansion as a numeric value. More...
 
const char * rpmConfigDir (void)
 Return rpm configuration base directory. More...
 

Detailed Description

Macro API.

Function Documentation

◆ rpmConfigDir()

const char* rpmConfigDir ( void  )

Return rpm configuration base directory.

If RPM_CONFIGDIR environment variable is set, it's value will be used. Otherwise the configuration directory is the one set at build time, typically /usr/lib/rpm. The value of rpmConfigDir() is determined on first call to this function and is guaranteed to remain the same on subsequent calls.

Returns
rpm configuration directory name

◆ rpmDefineMacro()

int rpmDefineMacro ( rpmMacroContext  mc,
const char *  macro,
int  level 
)

Define macro in context.

Parameters
mcmacro context (NULL uses global context).
macromacro name, options, body
levelmacro recursion level (0 is entry API)
Returns
0 on success (always)

◆ rpmDumpMacroTable()

void rpmDumpMacroTable ( rpmMacroContext  mc,
FILE *  fp 
)

Print macros to file stream.

Parameters
mcmacro context (NULL uses global context).
fpfile stream (NULL uses stderr).

◆ rpmExpand()

char* rpmExpand ( const char *  arg,
  ... 
)

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

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

◆ rpmExpandMacros()

int rpmExpandMacros ( rpmMacroContext  mc,
const char *  sbuf,
char **  obuf,
int  flags 
)

Expand macro into buffer.

Parameters
mcmacro context (NULL uses global context).
sbufinput macro to expand
obufmacro expansion (malloc'ed)
flagsflags (currently unused)
Returns
negative on failure

◆ rpmExpandNumeric()

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
argmacro to expand
Returns
numeric value

◆ rpmFreeMacros()

void rpmFreeMacros ( rpmMacroContext  mc)

Destroy macro context.

Parameters
mcmacro context (NULL uses global context).

◆ rpmInitMacros()

void rpmInitMacros ( rpmMacroContext  mc,
const char *  macrofiles 
)

Initialize macro context from set of macrofile(s).

Parameters
mcmacro context
macrofilescolon separated list of macro files (NULL does nothing)

◆ rpmLoadMacroFile()

int rpmLoadMacroFile ( rpmMacroContext  mc,
const char *  fn 
)

Load macro context from a macro file.

Parameters
mc(unused)
fnmacro file name

◆ rpmLoadMacros()

void rpmLoadMacros ( rpmMacroContext  mc,
int  level 
)

Load macros from specific context into global context.

Parameters
mcmacro context (NULL does nothing).
levelmacro recursion level (0 is entry API)

◆ rpmPopMacro()

int rpmPopMacro ( rpmMacroContext  mc,
const char *  n 
)

Pop macro from context.

Parameters
mcmacro context (NULL uses global context).
nmacro name
Returns
0 on success

◆ rpmPushMacro()

int rpmPushMacro ( rpmMacroContext  mc,
const char *  n,
const char *  o,
const char *  b,
int  level 
)

Push macro to context.

Parameters
mcmacro context (NULL uses global context).
nmacro name
omacro parameters
bmacro body
levelmacro recursion level (0 is entry API)
Returns
0 on success