5 * \file rpmio/rpmmacro.h
15 typedef struct rpmMacroEntry_s * rpmMacroEntry;
17 typedef struct rpmMacroContext_s * rpmMacroContext;
19 extern rpmMacroContext rpmGlobalMacroContext;
21 extern rpmMacroContext rpmCLIMacroContext;
24 * List of macro files to read when configuring rpm.
25 * This is a colon separated list of files. URI's are permitted as well,
26 * identified by the token '://', so file paths must not begin with '//'.
28 extern const char * macrofiles;
31 * Markers for sources of macros added throughout rpm.
33 #define RMIL_DEFAULT -15
34 #define RMIL_MACROFILES -13
35 #define RMIL_RPMRC -11
37 #define RMIL_CMDLINE -7
38 #define RMIL_TARBALL -5
40 #define RMIL_OLDSPEC -1
44 * Print macros to file stream.
45 * @param mc macro context (NULL uses global context).
46 * @param fp file stream (NULL uses stderr).
48 void rpmDumpMacroTable (rpmMacroContext mc,
52 * Expand macro into buffer.
53 * @deprecated Use rpmExpand().
54 * @todo Eliminate from API.
55 * @param spec cookie (unused)
56 * @param mc macro context (NULL uses global context).
57 * @retval sbuf input macro to expand, output expansion
58 * @param slen size of buffer
59 * @return 0 on success
61 int expandMacros (void * spec, rpmMacroContext mc,
66 * Add macro to context.
67 * @deprecated Use rpmDefineMacro().
68 * @param mc macro context (NULL uses global context).
70 * @param o macro paramaters
72 * @param level macro recursion level (0 is entry API)
74 void addMacro (rpmMacroContext mc, const char * n,
76 const char * b, int level);
79 * Delete macro from context.
80 * @param mc macro context (NULL uses global context).
83 void delMacro (rpmMacroContext mc, const char * n);
86 * Define macro in context.
87 * @param mc macro context (NULL uses global context).
88 * @param macro macro name, options, body
89 * @param level macro recursion level (0 is entry API)
90 * @return @todo Document.
92 int rpmDefineMacro (rpmMacroContext mc, const char * macro,
96 * Load macros from specific context into global context.
97 * @param mc macro context (NULL does nothing).
98 * @param level macro recursion level (0 is entry API)
100 void rpmLoadMacros (rpmMacroContext mc, int level);
102 /** \ingroup rpmmacro
103 * Load macro context from a macro file.
105 * @param fn macro file name
107 int rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
109 /** \ingroup rpmmacro
110 * Initialize macro context from set of macrofile(s).
111 * @param mc macro context
112 * @param macrofiles colon separated list of macro files (NULL does nothing)
114 void rpmInitMacros (rpmMacroContext mc, const char * macrofiles);
116 /** \ingroup rpmmacro
117 * Destroy macro context.
118 * @param mc macro context (NULL uses global context).
120 void rpmFreeMacros (rpmMacroContext mc);
122 /** \ingroup rpmmacro
123 * Return (malloc'ed) concatenated macro expansion(s).
124 * @param arg macro(s) to expand (NULL terminates list)
125 * @return macro expansion (malloc'ed)
127 char * rpmExpand (const char * arg, ...);
129 /** \ingroup rpmmacro
130 * Return macro expansion as a numeric value.
131 * Boolean values ('Y' or 'y' returns 1, 'N' or 'n' returns 0)
132 * are permitted as well. An undefined macro returns 0.
133 * @param arg macro to expand
134 * @return numeric value
136 int rpmExpandNumeric (const char * arg);
142 #endif /* _H_ MACRO_ */