rpm  5.4.14
rpmmacro.h
Go to the documentation of this file.
1 #ifndef _H_MACRO_
2 #define _H_MACRO_
3 
4 #include <stdio.h> /* XXX FILE * typedef */
5 #include <sys/types.h> /* XXX size_t typedef */
6 
10 #include <stdio.h>
11 
12 typedef /*@abstract@*/ struct MacroEntry_s * MacroEntry;
13 typedef /*@abstract@*/ struct MacroContext_s * MacroContext;
14 
15 #if defined(_MACRO_INTERNAL)
16 
17 struct MacroEntry_s {
18  struct MacroEntry_s *prev;
19  const char *name;
20  const char *opts;
21  const char *body;
22  int used;
23  short level;
24  unsigned short flags;
25 };
26 
28 struct MacroContext_s {
29 /*@owned@*//*@null@*/
30  MacroEntry *macroTable;
31  int macrosAllocated;
32  int firstFree;
33 };
34 #endif
35 
36 /*@-redecl@*/
37 /*@checked@*/
39 
40 /*@checked@*/
42 
48 /*@observer@*/ /*@checked@*/
49 extern const char * rpmMacrofiles;
50 /*@=redecl@*/
51 
55 #define RMIL_DEFAULT -15
56 #define RMIL_MACROFILES -13
57 #define RMIL_RPMRC -11
58 
59 #define RMIL_CMDLINE -7
60 #define RMIL_TARBALL -5
61 #define RMIL_SPEC -3
62 #define RMIL_OLDSPEC -1
63 #define RMIL_GLOBAL 0
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
74 void rpmDumpMacroTable(/*@null@*/ MacroContext mc, /*@null@*/ FILE * fp)
75  /*@globals rpmGlobalMacroContext, fileSystem @*/
76  /*@modifies *fp, fileSystem @*/;
77 
86 int
87 rpmGetMacroEntries(/*@null@*/ MacroContext mc, /*@null@*/ void * _mire,
88  int used, /*@null@*/ const char *** avp)
89  /*@globals rpmGlobalMacroContext @*/
90  /*@modifies _mire, *avp @*/;
91 
98 int rpmSecuritySaneFile(const char *filename)
99  /*@globals internalState @*/;
100 
109 int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
110  /*@out@*/ const char *** argvPtr)
111  /*@globals fileSystem, internalState @*/
112  /*@modifies *argcPtr, *argvPtr, fileSystem, internalState @*/;
113 
124 int expandMacros(/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
125  /*@in@*/ /*@out@*/ char * sbuf, size_t slen)
126  /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
127  /*@modifies *sbuf, rpmGlobalMacroContext, fileSystem, internalState @*/;
128 
138 void addMacro(/*@null@*/ MacroContext mc, const char * n,
139  /*@null@*/ const char * o, /*@null@*/ const char * b, int level)
140  /*@globals rpmGlobalMacroContext, internalState @*/
141  /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
142 
148 void delMacro(/*@null@*/ MacroContext mc, const char * n)
149  /*@globals rpmGlobalMacroContext @*/
150  /*@modifies mc, rpmGlobalMacroContext @*/;
151 
159 int rpmDefineMacro(/*@null@*/ MacroContext mc, const char * macro, int level)
160  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
161  /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
162 
169 int rpmUndefineMacro(/*@null@*/ MacroContext mc, const char * macro)
170  /*@globals rpmGlobalMacroContext, internalState @*/
171  /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
172 
178 void rpmLoadMacros(/*@null@*/ MacroContext mc, int level)
179  /*@globals rpmGlobalMacroContext, internalState @*/
180  /*@modifies rpmGlobalMacroContext, internalState @*/;
181 
188 int rpmLoadMacroFile(/*@null@*/ MacroContext mc, const char * fn, int nesting)
189  /*@globals rpmGlobalMacroContext,
190  h_errno, fileSystem, internalState @*/
191  /*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
192 
198 void rpmInitMacros(/*@null@*/ MacroContext mc, const char * macrofiles)
199  /*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
200  h_errno, fileSystem, internalState @*/
201  /*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
202 
207 void rpmFreeMacros(/*@null@*/ MacroContext mc)
208  /*@globals rpmGlobalMacroContext @*/
209  /*@modifies mc, rpmGlobalMacroContext @*/;
210 
211 typedef enum rpmCompressedMagic_e {
223 
230 int isCompressed(const char * file, /*@out@*/ rpmCompressedMagic * compressed)
231  /*@globals h_errno, fileSystem, internalState @*/
232  /*@modifies *compressed, fileSystem, internalState @*/;
233 
239 char * rpmExpand(/*@null@*/ const char * arg, ...)
240 #if defined(__GNUC__) && __GNUC__ >= 4
241  /* issue a warning if the list is not NULL-terminated */
242  __attribute__((sentinel))
243 #endif
244  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
245  /*@modifies rpmGlobalMacroContext, internalState @*/;
246 
253 char * rpmMCExpand(/*@null@*/ MacroContext mc, /*@null@*/ const char * arg, ...)
254 #if defined(__GNUC__) && __GNUC__ >= 4
255  /* issue a warning if the list is not NULL-terminated */
256  __attribute__((sentinel))
257 #endif
258  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
259  /*@modifies rpmGlobalMacroContext, internalState @*/;
260 
267 /*@null@*/
268 char * rpmCleanPath(/*@returned@*/ /*@null@*/ char * path)
269  /*@modifies *path @*/;
270 
277 /*@-redecl@*/ /* LCL: shrug */
278 char * rpmGetPath(/*@null@*/ const char * path, ...)
279 #if defined(__GNUC__) && __GNUC__ >= 4
280  /* issue a warning if the list is not NULL-terminated */
281  __attribute__((sentinel))
282 #endif
283  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
284  /*@modifies rpmGlobalMacroContext, internalState @*/;
285 /*@=redecl@*/
286 
297 /*@-redecl@*/ /* LCL: shrug */
298 const char * rpmGenPath(/*@null@*/ const char * urlroot,
299  /*@null@*/ const char * urlmdir,
300  /*@null@*/ const char * urlfile)
301  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
302  /*@modifies rpmGlobalMacroContext, internalState @*/;
303 /*@=redecl@*/
304 
312 int rpmExpandNumeric (const char * arg)
313  /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
314  /*@modifies rpmGlobalMacroContext, internalState @*/;
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 
320 #endif /* _H_ MACRO_ */
void rpmInitMacros(MacroContext mc, const char *macrofiles)
Initialize macro context from set of macrofile(s).
Definition: macro.c:2930
int isCompressed(const char *file, rpmCompressedMagic *compressed)
Return type of compression used in file.
Definition: macro.c:3045
sbuf
Definition: macro.c:616
char * rpmCleanPath(char *path)
Canonicalize file path.
Definition: macro.c:3279
char * rpmGetPath(const char *path,...)
Return (malloc&#39;ed) expanded, canonicalized, file path.
Definition: macro.c:3371
void rpmLoadMacros(MacroContext mc, int level)
Load macros from specific context into global context.
Definition: macro.c:2811
MacroContext rpmCLIMacroContext
Definition: macro.c:127
rpmCompressedMagic_e
Definition: rpmmacro.h:211
static ARGV_t patterns
Definition: rpmgrep.c:87
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
Definition: macro.c:2722
delMacro(mc, n)
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
Definition: macro.c:2547
rpmFreeMacros(NULL)
const char * rpmMacrofiles
List of macro files to read when configuring rpm.
Definition: macro.c:62
MacroContext rpmGlobalMacroContext
Definition: macro.c:122
int rpmGetMacroEntries(MacroContext mc, void *_mire, int used, const char ***avp)
Return macro entries as string array.
Definition: macro.c:319
int rpmDefineMacro(MacroContext mc, const char *macro, int level)
Define macro in context.
Definition: macro.c:2789
static const char * file
Definition: parseFiles.c:20
char * o
Definition: macro.c:745
const char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
Definition: macro.c:3417
void rpmDumpMacroTable(MacroContext mc, FILE *fp)
Print macros to file stream.
Definition: macro.c:285
char * rpmExpand(const char *arg,...)
Return (malloc&#39;ed) concatenated macro expansion(s).
Definition: macro.c:3178
char * n
Definition: macro.c:744
enum rpmCompressedMagic_e rpmCompressedMagic
char * path
Definition: poptALL.c:744
struct MacroContext_s * MacroContext
Definition: rpmmacro.h:13
int flags
Definition: fnmatch.c:282
int rpmSecuritySaneFile(const char *filename)
Check whether configuration file is moderately secure to load.
Definition: macro.c:2524
int expandMacros(void *spec, MacroContext mc, char *sbuf, size_t slen)
Expand macro into buffer.
Definition: macro.c:2687
static const char * name
char * b
Definition: macro.c:746
int rpmLoadMacroFile(MacroContext mc, const char *fn, int nesting)
Load macro context from a macro file.
Definition: macro.c:2851
struct MacroEntry_s * MacroEntry
Definition: rpmmacro.h:12
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
Definition: macro.c:3252
size_t fn
Definition: macro.c:1698
int rpmUndefineMacro(MacroContext mc, const char *macro)
Undefine macro in context.
Definition: macro.c:2803
Spec spec
Definition: spec-py.c:121
char * rpmMCExpand(MacroContext mc, const char *arg,...)
Return (malloc&#39;ed) concatenated macro expansion(s) in a context.
Definition: macro.c:3215