More missing system includes for size_t & friends
[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 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 typedef struct rpmMacroEntry_s * rpmMacroEntry;
16
17 typedef struct rpmMacroContext_s * rpmMacroContext;
18
19 extern rpmMacroContext rpmGlobalMacroContext;
20
21 extern rpmMacroContext rpmCLIMacroContext;
22
23 /** \ingroup rpmrc
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 '//'.
27  */
28 extern const char * macrofiles;
29
30 /**
31  * Markers for sources of macros added throughout rpm.
32  */
33 #define RMIL_DEFAULT    -15
34 #define RMIL_MACROFILES -13
35 #define RMIL_RPMRC      -11
36
37 #define RMIL_CMDLINE    -7
38 #define RMIL_TARBALL    -5
39 #define RMIL_SPEC       -3
40 #define RMIL_OLDSPEC    -1
41 #define RMIL_GLOBAL     0
42
43 /** \ingroup rpmmacro
44  * Print macros to file stream.
45  * @param mc            macro context (NULL uses global context).
46  * @param fp            file stream (NULL uses stderr).
47  */
48 void    rpmDumpMacroTable       (rpmMacroContext mc,
49                                         FILE * fp);
50
51 /** \ingroup rpmmacro
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
60  */
61 int     expandMacros    (void * spec, rpmMacroContext mc,
62                                 char * sbuf,
63                                 size_t slen);
64
65 /** \ingroup rpmmacro
66  * Add macro to context.
67  * @deprecated Use rpmDefineMacro().
68  * @param mc            macro context (NULL uses global context).
69  * @param n             macro name
70  * @param o             macro paramaters
71  * @param b             macro body
72  * @param level         macro recursion level (0 is entry API)
73  */
74 void    addMacro        (rpmMacroContext mc, const char * n,
75                                 const char * o,
76                                 const char * b, int level);
77
78 /** \ingroup rpmmacro
79  * Delete macro from context.
80  * @param mc            macro context (NULL uses global context).
81  * @param n             macro name
82  */
83 void    delMacro        (rpmMacroContext mc, const char * n);
84
85 /** \ingroup rpmmacro
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.
91  */
92 int     rpmDefineMacro  (rpmMacroContext mc, const char * macro,
93                                 int level);
94
95 /** \ingroup rpmmacro
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)
99  */
100 void    rpmLoadMacros   (rpmMacroContext mc, int level);
101
102 /** \ingroup rpmmacro
103  * Load macro context from a macro file.
104  * @param mc            (unused)
105  * @param fn            macro file name
106  */
107 int     rpmLoadMacroFile(rpmMacroContext mc, const char * fn);
108
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)
113  */
114 void    rpmInitMacros   (rpmMacroContext mc, const char * macrofiles);
115
116 /** \ingroup rpmmacro
117  * Destroy macro context.
118  * @param mc            macro context (NULL uses global context).
119  */
120 void    rpmFreeMacros   (rpmMacroContext mc);
121
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)
126  */
127 char * rpmExpand        (const char * arg, ...);
128
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
135  */
136 int     rpmExpandNumeric (const char * arg);
137
138 #ifdef __cplusplus
139 }
140 #endif
141
142 #endif  /* _H_ MACRO_ */