rpmio/rpmmacro.h File Reference

#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  MacroEntry_s
struct  MacroContext_s

Defines

#define RMIL_DEFAULT   -15
 Markers for sources of macros added throughout rpm.
#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_sMacroEntry
typedef struct MacroContext_sMacroContext
typedef enum rpmCompressedMagic_e rpmCompressedMagic

Enumerations

enum  rpmCompressedMagic_e {
  COMPRESSED_NOT = 0, COMPRESSED_OTHER = 1, COMPRESSED_BZIP2 = 2, COMPRESSED_ZIP = 3,
  COMPRESSED_LZMA = 4
}

Functions

void rpmDumpMacroTable (MacroContext mc, FILE *fp)
 Print macros to file stream.
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).
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.
int rpmExpandNumeric (const char *arg)
 Return macro expansion as a numeric value.

Variables

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


Detailed Description

Definition in file rpmmacro.h.


Define Documentation

#define RMIL_CMDLINE   -7

Definition at line 53 of file rpmmacro.h.

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

#define RMIL_DEFAULT   -15

Markers for sources of macros added throughout rpm.

Definition at line 49 of file rpmmacro.h.

Referenced by main(), rpmtsOpenSDB(), setDefaults(), setPathDefault(), and setVarDefault().

#define RMIL_GLOBAL   0

Definition at line 57 of file rpmmacro.h.

Referenced by expandMacro().

#define RMIL_MACROFILES   -13

Definition at line 50 of file rpmmacro.h.

Referenced by rpmLoadMacroFile().

#define RMIL_OLDSPEC   -1

Definition at line 56 of file rpmmacro.h.

Referenced by handlePreambleTag().

#define RMIL_RPMRC   -11

Definition at line 51 of file rpmmacro.h.

Referenced by doReadRC(), parseSpec(), and rpmRebuildTargetVars().

#define RMIL_SPEC   -3

Definition at line 55 of file rpmmacro.h.

Referenced by addSource(), doScript(), doSetupMacro(), handlePreambleTag(), and parseSpec().

#define RMIL_TARBALL   -5

Definition at line 54 of file rpmmacro.h.

Referenced by buildForTarget().


Typedef Documentation

typedef struct MacroContext_s * MacroContext

The structure used to store the set of macros in a context.

typedef struct MacroEntry_s * MacroEntry

The structure used to store a macro.


Enumeration Type Documentation

Enumerator:
COMPRESSED_NOT  not compressed
COMPRESSED_OTHER  gzip can handle
COMPRESSED_BZIP2  bzip2 can handle
COMPRESSED_ZIP  unzip can handle
COMPRESSED_LZMA  lzma can handle

Definition at line 174 of file rpmmacro.h.


Function Documentation

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

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 1907 of file macro.c.

References findEntry(), popMacro(), and sortMacroTable().

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

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 1846 of file macro.c.

References _, alloca(), MacroBuf_s::depth, MacroBuf_s::expand_trace, expandMacro(), MacroBuf_s::macro_trace, MacroBuf_s::mc, MacroBuf_s::nb, print_expand_trace, print_macro_trace, RPMERR_BADSPEC, rpmError, MacroBuf_s::s, MacroBuf_s::spec, and MacroBuf_s::t.

Referenced by addFileToTagAux(), copyNextLineFromOFI(), processPackageFiles(), rpmExpand(), and rpmGetPath().

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 2082 of file macro.c.

References _, COMPRESSED_BZIP2, COMPRESSED_LZMA, COMPRESSED_NOT, COMPRESSED_OTHER, COMPRESSED_ZIP, Fclose(), Ferror(), Fopen(), Fread(), Fstrerror(), RPMERR_BADSPEC, rpmError, and rpmFileHasSuffix().

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

char* rpmCleanPath ( char *  path  ) 

Canonicalize file path.

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

Definition at line 2191 of file macro.c.

Referenced by doLookup(), relocateFileList(), rpmdbMoveDatabase(), rpmdbRemoveDatabase(), rpmGetPath(), 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 1923 of file macro.c.

References alloca(), doDefine(), and MacroBuf_s::mc.

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

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 209 of file macro.c.

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

Referenced by expandMacro(), and rpmShowRC().

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

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 2164 of file macro.c.

References _free(), and rpmExpand().

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

void rpmFreeMacros ( MacroContext  mc  ) 

Destroy macro context.

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

Definition at line 2046 of file macro.c.

References _free(), MacroEntry_s::body, MacroContext_s::firstFree, 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 2310 of file macro.c.

References _free(), alloca(), file, rpmGetPath(), URL_IS_DASH, and urlPath().

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

const char* rpmGetPath ( const char *  path,
  ... 
)

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

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

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

Definition at line 1698 of file macro.c.

References _free(), argv, getenv(), Glob(), Glob_error(), Glob_pattern_p(), Globfree(), setlocale, URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, urlPath(), xmalloc(), XpoptParseArgvString(), xrealloc(), and xstrdup().

Referenced by IDTXglob(), processBinaryFile(), rpmgiGlobArgv(), rpmGraph(), rpmInitMacros(), rpmInstall(), 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 1990 of file macro.c.

References _free(), RMIL_CMDLINE, rpmGlob(), rpmLoadMacroFile(), rpmLoadMacros(), and xstrdup().

Referenced by rpmReadRC().

int rpmLoadMacroFile ( MacroContext  mc,
const char *  fn 
)

Load macro context from a macro file.

Parameters:
mc (unused)
fn macro file name

Definition at line 1957 of file macro.c.

References Fclose(), Ferror(), Fopen(), max_macro_depth, rdcl(), RMIL_MACROFILES, rpmDefineMacro(), and SKIPBLANK.

Referenced by rpmInitMacros().

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 1936 of file macro.c.

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

Referenced by rpmInitMacros().


Variable Documentation

Definition at line 75 of file macro.c.

Definition at line 70 of file macro.c.


Generated on Fri Dec 12 13:02:12 2008 for rpm by  doxygen 1.5.6