rpm  4.13.0
Macros | Typedefs | Functions | Variables
rpmmacro.h File Reference
#include <stdio.h>
#include <stddef.h>
#include <rpm/rpmutil.h>
#include <rpm/rpmfileutil.h>
Include dependency graph for rpmmacro.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 rpmMacroEntry_s * rpmMacroEntry
 
typedef struct rpmMacroContext_s * rpmMacroContext
 

Functions

void rpmDumpMacroTable (rpmMacroContext mc, FILE *fp)
 Print macros to file stream. More...
 
int expandMacros (void *spec, rpmMacroContext mc, char *sbuf, size_t slen)
 Expand macro into buffer. More...
 
int rpmExpandMacros (rpmMacroContext mc, const char *sbuf, char **obuf, int flags)
 Expand macro into buffer. More...
 
void addMacro (rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
 Add macro to context. More...
 
void delMacro (rpmMacroContext mc, const char *n)
 Delete 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...
 

Variables

rpmMacroContext rpmGlobalMacroContext
 
rpmMacroContext rpmCLIMacroContext
 
const char * macrofiles
 List of macro files to read when configuring rpm. More...
 

Macro Definition Documentation

§ RMIL_CMDLINE

#define RMIL_CMDLINE   -7

Definition at line 40 of file rpmmacro.h.

Referenced by doSign().

§ RMIL_DEFAULT

#define RMIL_DEFAULT   -15

Markers for sources of macros added throughout rpm.

Definition at line 36 of file rpmmacro.h.

§ RMIL_GLOBAL

#define RMIL_GLOBAL   0

Definition at line 44 of file rpmmacro.h.

Referenced by doSign().

§ RMIL_MACROFILES

#define RMIL_MACROFILES   -13

Definition at line 37 of file rpmmacro.h.

§ RMIL_OLDSPEC

#define RMIL_OLDSPEC   -1

Definition at line 43 of file rpmmacro.h.

§ RMIL_RPMRC

#define RMIL_RPMRC   -11

Definition at line 38 of file rpmmacro.h.

§ RMIL_SPEC

#define RMIL_SPEC   -3

Definition at line 42 of file rpmmacro.h.

§ RMIL_TARBALL

#define RMIL_TARBALL   -5

Definition at line 41 of file rpmmacro.h.

Referenced by buildForTarget().

Typedef Documentation

§ rpmMacroContext

typedef struct rpmMacroContext_s* rpmMacroContext

Definition at line 20 of file rpmmacro.h.

§ rpmMacroEntry

typedef struct rpmMacroEntry_s* rpmMacroEntry

Definition at line 18 of file rpmmacro.h.

Function Documentation

§ addMacro()

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

Add macro to context.

Deprecated:
Use rpmDefineMacro().
Parameters
mcmacro context (NULL uses global context).
nmacro name
omacro paramaters
bmacro body
levelmacro recursion level (0 is entry API)

Referenced by buildForTarget(), and doSign().

§ delMacro()

void delMacro ( rpmMacroContext  mc,
const char *  n 
)

Delete macro from context.

Parameters
mcmacro context (NULL uses global context).
nmacro name

§ expandMacros()

int expandMacros ( void *  spec,
rpmMacroContext  mc,
char *  sbuf,
size_t  slen 
)

Expand macro into buffer.

Deprecated:
Use rpmExpand().
Todo:
Eliminate from API.
Parameters
speccookie (unused)
mcmacro context (NULL uses global context).
Return values
sbufinput macro to expand, output expansion
Parameters
slensize of buffer
Returns
0 on success

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

Referenced by build(), and buildArgCallback().

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

Referenced by doSign(), and getTarSpec().

§ 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

Referenced by build(), and main().

§ rpmFreeMacros()

void rpmFreeMacros ( rpmMacroContext  mc)

Destroy macro context.

Parameters
mcmacro context (NULL uses global context).

Referenced by build(), and main().

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

Variable Documentation

§ macrofiles

const char* macrofiles

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 '//'.

§ rpmCLIMacroContext

rpmMacroContext rpmCLIMacroContext

§ rpmGlobalMacroContext

rpmMacroContext rpmGlobalMacroContext