Remove some old craft
[platform/upstream/rpm.git] / rpmio / rpmmacro.h
1 #ifndef _H_MACRO_
2 #define _H_MACRO_
3
4 /** \ingroup rpmio
5  * \file rpmio/rpmmacro.h
6  */
7
8 #include <stdio.h>
9 #include <stddef.h>
10
11 #include <rpm/rpmutil.h>
12 #include <rpm/rpmfileutil.h>
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 typedef struct rpmMacroEntry_s * rpmMacroEntry;
19
20 typedef struct rpmMacroContext_s * rpmMacroContext;
21
22 extern rpmMacroContext rpmGlobalMacroContext;
23
24 extern rpmMacroContext rpmCLIMacroContext;
25
26 /** \ingroup rpmrc
27  * List of macro files to read when configuring rpm.
28  * This is a colon separated list of files. URI's are permitted as well,
29  * identified by the token '://', so file paths must not begin with '//'.
30  */
31 extern const char * macrofiles;
32
33 /**
34  * Markers for sources of macros added throughout rpm.
35  */
36 #define RMIL_DEFAULT    -15
37 #define RMIL_MACROFILES -13
38 #define RMIL_RPMRC      -11
39
40 #define RMIL_CMDLINE    -7
41 #define RMIL_TARBALL    -5
42 #define RMIL_SPEC       -3
43 #define RMIL_OLDSPEC    -1
44 #define RMIL_GLOBAL     0
45
46 /** \ingroup rpmmacro
47  * Print macros to file stream.
48  * @param mc            macro context (NULL uses global context).
49  * @param fp            file stream (NULL uses stderr).
50  */
51 void    rpmDumpMacroTable       (rpmMacroContext mc,
52                                         FILE * fp);
53
54 /** \ingroup rpmmacro
55  * Expand macro into buffer.
56  * @deprecated Use rpmExpand().
57  * @todo Eliminate from API.
58  * @param spec          cookie (unused)
59  * @param mc            macro context (NULL uses global context).
60  * @retval sbuf         input macro to expand, output expansion
61  * @param slen          size of buffer
62  * @return              0 on success
63  */
64 int     expandMacros    (void * spec, rpmMacroContext mc,
65                                 char * sbuf,
66                                 size_t slen);
67
68 /** \ingroup rpmmacro
69  * Add macro to context.
70  * @deprecated Use rpmDefineMacro().
71  * @param mc            macro context (NULL uses global context).
72  * @param n             macro name
73  * @param o             macro paramaters
74  * @param b             macro body
75  * @param level         macro recursion level (0 is entry API)
76  */
77 void    addMacro        (rpmMacroContext mc, const char * n,
78                                 const char * o,
79                                 const char * b, int level);
80
81 /** \ingroup rpmmacro
82  * Delete macro from context.
83  * @param mc            macro context (NULL uses global context).
84  * @param n             macro name
85  */
86 void    delMacro        (rpmMacroContext mc, const char * n);
87
88 /** \ingroup rpmmacro
89  * Define macro in context.
90  * @param mc            macro context (NULL uses global context).
91  * @param macro         macro name, options, body
92  * @param level         macro recursion level (0 is entry API)
93  * @return              0 on success (always)
94  */
95 int     rpmDefineMacro  (rpmMacroContext mc, const char * macro,
96                                 int level);
97
98 /** \ingroup rpmmacro
99  * Load macros from specific context into global context.
100  * @param mc            macro context (NULL does nothing).
101  * @param level         macro recursion level (0 is entry API)
102  */
103 void    rpmLoadMacros   (rpmMacroContext mc, int level);
104
105 /** \ingroup rpmmacro
106  * Load macro context from a macro file.
107  * @param mc            (unused)
108  * @param fn            macro file name
109  */
110 int     rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
111
112 /** \ingroup rpmmacro
113  * Initialize macro context from set of macrofile(s).
114  * @param mc            macro context
115  * @param macrofiles    colon separated list of macro files (NULL does nothing)
116  */
117 void    rpmInitMacros   (rpmMacroContext mc, const char * macrofiles);
118
119 /** \ingroup rpmmacro
120  * Destroy macro context.
121  * @param mc            macro context (NULL uses global context).
122  */
123 void    rpmFreeMacros   (rpmMacroContext mc);
124
125 /** \ingroup rpmmacro
126  * Return (malloc'ed) concatenated macro expansion(s).
127  * @param arg           macro(s) to expand (NULL terminates list)
128  * @return              macro expansion (malloc'ed)
129  */
130 char * rpmExpand        (const char * arg, ...) RPM_GNUC_NULL_TERMINATED;
131
132 /** \ingroup rpmmacro
133  * Return macro expansion as a numeric value.
134  * Boolean values ('Y' or 'y' returns 1, 'N' or 'n' returns 0)
135  * are permitted as well. An undefined macro returns 0.
136  * @param arg           macro to expand
137  * @return              numeric value
138  */
139 int     rpmExpandNumeric (const char * arg);
140
141 /** \ingroup rpmmacro
142  * Return rpm configuration base directory.
143  * If RPM_CONFIGDIR environment variable is set, it's value will be used.
144  * Otherwise the configuration directory is the one set at build time,
145  * typically /usr/lib/rpm. The value of rpmConfigDir() is determined
146  * on first call to this function and is guaranteed to remain the same
147  * on subsequent calls.
148  * @return              rpm configuration directory name
149  */
150 const char *rpmConfigDir(void);
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif  /* _H_ MACRO_ */