rpm  4.17.0
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_BUILTIN -20
39 #define RMIL_DEFAULT -15
40 #define RMIL_MACROFILES -13
41 #define RMIL_RPMRC -11
42 
43 #define RMIL_CMDLINE -7
44 #define RMIL_TARBALL -5
45 #define RMIL_SPEC -3
46 #define RMIL_OLDSPEC -1
47 #define RMIL_GLOBAL 0
48 
49 /* Deprecated compatibility wrappers */
50 #define addMacro(_mc, _n, _o, _b, _l) rpmPushMacro(_mc, _n, _o, _b, _l)
51 #define delMacro(_mc, _n) rpmPopMacro(_mc, _n)
52 
53 /* rpm expression parser flags */
54 #define RPMEXPR_EXPAND (1 << 0)
56 /* rpm macro expansion flags */
57 #define RPMEXPAND_EXPAND_ARGS (1 << 0)
59 typedef enum rpmMacroFlags_e {
61  RPMMACRO_LITERAL = (1 << 0),
63 
70  FILE * fp);
71 
80 int rpmExpandMacros (rpmMacroContext mc, const char * sbuf,
81  char ** obuf, int flags);
82 
92 int rpmExpandThisMacro (rpmMacroContext mc, const char *n,
93  ARGV_const_t args,
94  char ** obuf, int flags);
95 
105 int rpmPushMacro (rpmMacroContext mc, const char * n,
106  const char * o,
107  const char * b, int level);
108 
119 int rpmPushMacroFlags (rpmMacroContext mc, const char * n,
120  const char * o,
121  const char * b, int level,
122  rpmMacroFlags flags);
123 
130 int rpmPopMacro (rpmMacroContext mc, const char * n);
131 
139 int rpmDefineMacro (rpmMacroContext mc, const char * macro,
140  int level);
141 
142 /*
143  * Test whether a macro is defined
144  * @param mc macro context (NULL uses global context).
145  * @param n macro name
146  * @return 1 if defined, 0 if not
147  */
148 int rpmMacroIsDefined(rpmMacroContext mc, const char *n);
149 
150 /*
151  * Test whether a macro is parametric (ie takes arguments)
152  * @param mc macro context (NULL uses global context).
153  * @param n macro name
154  * @return 1 if parametric, 0 if not
155  */
156 int rpmMacroIsParametric(rpmMacroContext mc, const char *n);
157 
163 void rpmLoadMacros (rpmMacroContext mc, int level);
164 
170 int rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
171 
177 void rpmInitMacros (rpmMacroContext mc, const char * macrofiles);
178 
184 
190 char * rpmExpand (const char * arg, ...) RPM_GNUC_NULL_TERMINATED;
191 
199 int rpmExpandNumeric (const char * arg);
200 
210 const char *rpmConfigDir(void);
211 
218 int rpmExprBoolFlags(const char * expr, int flags);
219 
226 char * rpmExprStrFlags(const char * expr, int flags);
227 
233 int rpmExprBool(const char * expr);
234 
240 char * rpmExprStr(const char * expr);
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif /* _H_ MACRO_ */
char *const * ARGV_const_t
Definition: argv.h:18
int rpmPushMacroFlags(rpmMacroContext mc, const char *n, const char *o, const char *b, int level, rpmMacroFlags flags)
Push macro to context.
void rpmFreeMacros(rpmMacroContext mc)
Destroy macro context.
char * rpmExpand(const char *arg,...) RPM_GNUC_NULL_TERMINATED
Return (malloc'ed) concatenated macro expansion(s).
int rpmLoadMacroFile(rpmMacroContext mc, const char *fn)
Load macro context from a macro file.
void rpmLoadMacros(rpmMacroContext mc, int level)
Load macros from specific context into global context.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
int rpmExprBoolFlags(const char *expr, int flags)
Evaluate boolean expression.
int rpmPopMacro(rpmMacroContext mc, const char *n)
Pop macro from context.
char * rpmExprStr(const char *expr)
Evaluate string expression.
char * rpmExprStrFlags(const char *expr, int flags)
Evaluate string expression.
void rpmInitMacros(rpmMacroContext mc, const char *macrofiles)
Initialize macro context from set of macrofile(s).
int rpmExpandMacros(rpmMacroContext mc, const char *sbuf, char **obuf, int flags)
Expand macro into buffer.
int rpmDefineMacro(rpmMacroContext mc, const char *macro, int level)
Define macro in context.
int rpmPushMacro(rpmMacroContext mc, const char *n, const char *o, const char *b, int level)
Push macro to context.
const char * rpmConfigDir(void)
Return rpm configuration base directory.
int rpmExpandThisMacro(rpmMacroContext mc, const char *n, ARGV_const_t args, char **obuf, int flags)
Expand a specific macro into buffer.
void rpmDumpMacroTable(rpmMacroContext mc, FILE *fp)
Print macros to file stream.
int rpmExprBool(const char *expr)
Evaluate boolean expression.
const char * macrofiles
List of macro files to read when configuring rpm.
int rpmMacroIsParametric(rpmMacroContext mc, const char *n)
int rpmMacroIsDefined(rpmMacroContext mc, const char *n)
struct rpmMacroEntry_s * rpmMacroEntry
Definition: rpmmacro.h:20
struct rpmMacroContext_s * rpmMacroContext
Definition: rpmmacro.h:22
enum rpmMacroFlags_e rpmMacroFlags
rpmMacroFlags_e
Definition: rpmmacro.h:59
@ RPMMACRO_DEFAULT
Definition: rpmmacro.h:60
@ RPMMACRO_LITERAL
Definition: rpmmacro.h:61
rpmMacroContext rpmCLIMacroContext
rpmMacroContext rpmGlobalMacroContext
#define RPM_GNUC_NULL_TERMINATED
Definition: rpmutil.h:49