rpm  4.16.1.2
rpmmacro.h
Go to the documentation of this file.
1 #ifndef _H_MACRO_
2 #define _H_MACRO_
3 
10 #include <stdio.h>
11 #include <stddef.h>
12 
13 #include <rpm/rpmutil.h>
14 #include <rpm/rpmfileutil.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 typedef struct rpmMacroEntry_s * rpmMacroEntry;
21 
22 typedef struct rpmMacroContext_s * rpmMacroContext;
23 
25 
27 
33 extern const char * macrofiles;
34 
38 #define RMIL_DEFAULT -15
39 #define RMIL_MACROFILES -13
40 #define RMIL_RPMRC -11
41 
42 #define RMIL_CMDLINE -7
43 #define RMIL_TARBALL -5
44 #define RMIL_SPEC -3
45 #define RMIL_OLDSPEC -1
46 #define RMIL_GLOBAL 0
47 
48 /* Deprecated compatibility wrappers */
49 #define addMacro(_mc, _n, _o, _b, _l) rpmPushMacro(_mc, _n, _o, _b, _l)
50 #define delMacro(_mc, _n) rpmPopMacro(_mc, _n)
51 
52 /* rpm expression parser flags */
53 #define RPMEXPR_EXPAND (1 << 0)
55 typedef enum rpmMacroFlags_e {
57  RPMMACRO_LITERAL = (1 << 0),
59 
66  FILE * fp);
67 
76 int rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
77  char ** obuf, int flags);
78 
88 int rpmPushMacro (rpmMacroContext mc, const char * n,
89  const char * o,
90  const char * b, int level);
91 
102 int rpmPushMacroFlags (rpmMacroContext mc, const char * n,
103  const char * o,
104  const char * b, int level,
105  rpmMacroFlags flags);
106 
113 int rpmPopMacro (rpmMacroContext mc, const char * n);
114 
122 int rpmDefineMacro (rpmMacroContext mc, const char * macro,
123  int level);
124 
125 /*
126  * Test whether a macro is defined
127  * @param mc macro context (NULL uses global context).
128  * @param n macro name
129  * @return 1 if defined, 0 if not
130  */
131 int rpmMacroIsDefined(rpmMacroContext mc, const char *n);
132 
133 /*
134  * Test whether a macro is parametric (ie takes arguments)
135  * @param mc macro context (NULL uses global context).
136  * @param n macro name
137  * @return 1 if parametric, 0 if not
138  */
139 int rpmMacroIsParametric(rpmMacroContext mc, const char *n);
140 
146 void rpmLoadMacros (rpmMacroContext mc, int level);
147 
153 int rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
154 
160 void rpmInitMacros (rpmMacroContext mc, const char * macrofiles);
161 
167 
173 char * rpmExpand (const char * arg, ...) RPM_GNUC_NULL_TERMINATED;
174 
182 int rpmExpandNumeric (const char * arg);
183 
193 const char *rpmConfigDir(void);
194 
201 int rpmExprBoolFlags(const char * expr, int flags);
202 
209 char * rpmExprStrFlags(const char * expr, int flags);
210 
216 int rpmExprBool(const char * expr);
217 
223 char * rpmExprStr(const char * expr);
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* _H_ MACRO_ */
rpmPushMacroFlags
int rpmPushMacroFlags(rpmMacroContext mc, const char *n, const char *o, const char *b, int level, rpmMacroFlags flags)
Push macro to context.
rpmLoadMacros
void rpmLoadMacros(rpmMacroContext mc, int level)
Load macros from specific context into global context.
RPMMACRO_DEFAULT
@ RPMMACRO_DEFAULT
Definition: rpmmacro.h:56
rpmMacroFlags
enum rpmMacroFlags_e rpmMacroFlags
rpmExprStr
char * rpmExprStr(const char *expr)
Evaluate string expression.
rpmDefineMacro
int rpmDefineMacro(rpmMacroContext mc, const char *macro, int level)
Define macro in context.
rpmPushMacro
int rpmPushMacro(rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
Push macro to context.
rpmInitMacros
void rpmInitMacros(rpmMacroContext mc, const char *macrofiles)
Initialize macro context from set of macrofile(s).
RPM_GNUC_NULL_TERMINATED
#define RPM_GNUC_NULL_TERMINATED
Definition: rpmutil.h:49
rpmExpand
char * rpmExpand(const char *arg,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) concatenated macro expansion(s).
rpmExprBoolFlags
int rpmExprBoolFlags(const char *expr, int flags)
Evaluate boolean expression.
rpmExprBool
int rpmExprBool(const char *expr)
Evaluate boolean expression.
rpmMacroContext
struct rpmMacroContext_s * rpmMacroContext
Definition: rpmmacro.h:22
rpmMacroEntry
struct rpmMacroEntry_s * rpmMacroEntry
Definition: rpmmacro.h:20
rpmCLIMacroContext
rpmMacroContext rpmCLIMacroContext
rpmExprStrFlags
char * rpmExprStrFlags(const char *expr, int flags)
Evaluate string expression.
rpmExpandNumeric
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
macrofiles
const char * macrofiles
List of macro files to read when configuring rpm.
rpmPopMacro
int rpmPopMacro(rpmMacroContext mc, const char *n)
Pop macro from context.
rpmMacroIsParametric
int rpmMacroIsParametric(rpmMacroContext mc, const char *n)
rpmDumpMacroTable
void rpmDumpMacroTable(rpmMacroContext mc, FILE *fp)
Print macros to file stream.
rpmMacroIsDefined
int rpmMacroIsDefined(rpmMacroContext mc, const char *n)
rpmLoadMacroFile
int rpmLoadMacroFile(rpmMacroContext mc, const char *fn)
Load macro context from a macro file.
rpmFreeMacros
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
RPMMACRO_LITERAL
@ RPMMACRO_LITERAL
Definition: rpmmacro.h:57
rpmExpandMacros
int rpmExpandMacros(rpmMacroContext mc, const char *sbuf, char **obuf, int flags)
Expand macro into buffer.
rpmConfigDir
const char * rpmConfigDir(void)
Return rpm configuration base directory.
rpmGlobalMacroContext
rpmMacroContext rpmGlobalMacroContext