rpm  5.2.1
rpmio/rpmmacro.h
Go to the documentation of this file.
00001 #ifndef _H_MACRO_
00002 #define _H_MACRO_
00003 
00007 typedef /*@abstract@*/ struct MacroEntry_s * MacroEntry;
00008 typedef /*@abstract@*/ struct MacroContext_s * MacroContext;
00009 
00010 #if defined(_MACRO_INTERNAL)
00011 
00012 struct MacroEntry_s {
00013     struct MacroEntry_s *prev;  
00014     const char *name;           
00015     const char *opts;           
00016     const char *body;           
00017     int used;                   
00018     short level;                
00019     unsigned short flags;       
00020 };
00021 
00023 struct MacroContext_s {
00024 /*@owned@*//*@null@*/
00025     MacroEntry *macroTable;     
00026     int macrosAllocated;        
00027     int firstFree;              
00028 };
00029 #endif
00030 
00031 /*@-redecl@*/
00032 /*@checked@*/
00033 extern MacroContext rpmGlobalMacroContext;
00034 
00035 /*@checked@*/
00036 extern MacroContext rpmCLIMacroContext;
00037 
00043 /*@observer@*/ /*@checked@*/
00044 extern const char * rpmMacrofiles;
00045 /*@=redecl@*/
00046 
00050 #define RMIL_DEFAULT    -15
00051 #define RMIL_MACROFILES -13
00052 #define RMIL_RPMRC      -11
00053 
00054 #define RMIL_CMDLINE    -7
00055 #define RMIL_TARBALL    -5
00056 #define RMIL_SPEC       -3
00057 #define RMIL_OLDSPEC    -1
00058 #define RMIL_GLOBAL     0
00059 
00060 #ifdef __cplusplus
00061 extern "C" {
00062 #endif
00063 
00069 void rpmDumpMacroTable(/*@null@*/ MacroContext mc, /*@null@*/ FILE * fp)
00070         /*@globals rpmGlobalMacroContext, fileSystem @*/
00071         /*@modifies *fp, fileSystem @*/;
00072 
00081 int
00082 rpmGetMacroEntries(/*@null@*/ MacroContext mc, /*@null@*/ void * _mire,
00083                 int used, /*@null@*/ const char *** avp)
00084         /*@globals rpmGlobalMacroContext @*/
00085         /*@modifies _mire, *avp @*/;
00086 
00092 int rpmSecuritySaneFile(const char *filename)
00093         /*@globals internalState @*/;
00094 
00102 int rpmGlob(const char * patterns, /*@out@*/ int * argcPtr,
00103                 /*@out@*/ const char *** argvPtr)
00104         /*@globals fileSystem, internalState @*/
00105         /*@modifies *argcPtr, *argvPtr, fileSystem, internalState @*/;
00106 
00117 int expandMacros(/*@null@*/ void * spec, /*@null@*/ MacroContext mc,
00118                 /*@in@*/ /*@out@*/ char * sbuf, size_t slen)
00119         /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
00120         /*@modifies *sbuf, rpmGlobalMacroContext, fileSystem, internalState @*/;
00121 
00131 void addMacro(/*@null@*/ MacroContext mc, const char * n,
00132                 /*@null@*/ const char * o, /*@null@*/ const char * b, int level)
00133         /*@globals rpmGlobalMacroContext, internalState @*/
00134         /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
00135 
00141 void delMacro(/*@null@*/ MacroContext mc, const char * n)
00142         /*@globals rpmGlobalMacroContext @*/
00143         /*@modifies mc, rpmGlobalMacroContext @*/;
00144 
00152 int rpmDefineMacro(/*@null@*/ MacroContext mc, const char * macro, int level)
00153         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00154         /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
00155 
00162 int rpmUndefineMacro(/*@null@*/ MacroContext mc, const char * macro)
00163         /*@globals rpmGlobalMacroContext, internalState @*/
00164         /*@modifies mc, rpmGlobalMacroContext, internalState @*/;
00165 
00171 void rpmLoadMacros(/*@null@*/ MacroContext mc, int level)
00172         /*@globals rpmGlobalMacroContext, internalState @*/
00173         /*@modifies rpmGlobalMacroContext, internalState @*/;
00174 
00180 int rpmLoadMacroFile(/*@null@*/ MacroContext mc, const char * fn)
00181         /*@globals rpmGlobalMacroContext,
00182                 h_errno, fileSystem, internalState @*/
00183         /*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
00184 
00190 void rpmInitMacros(/*@null@*/ MacroContext mc, const char * macrofiles)
00191         /*@globals rpmGlobalMacroContext, rpmCLIMacroContext,
00192                 h_errno, fileSystem, internalState @*/
00193         /*@modifies mc, rpmGlobalMacroContext, fileSystem, internalState @*/;
00194 
00199 void rpmFreeMacros(/*@null@*/ MacroContext mc)
00200         /*@globals rpmGlobalMacroContext @*/
00201         /*@modifies mc, rpmGlobalMacroContext @*/;
00202 
00203 typedef enum rpmCompressedMagic_e {
00204     COMPRESSED_NOT              = 0,    
00205     COMPRESSED_OTHER            = 1,    
00206     COMPRESSED_BZIP2            = 2,    
00207     COMPRESSED_ZIP              = 3,    
00208     COMPRESSED_LZOP             = 4,    
00209     COMPRESSED_LZMA             = 5,    
00210     COMPRESSED_XZ               = 6     
00211 } rpmCompressedMagic;
00212 
00219 int isCompressed(const char * file, /*@out@*/ rpmCompressedMagic * compressed)
00220         /*@globals h_errno, fileSystem, internalState @*/
00221         /*@modifies *compressed, fileSystem, internalState @*/;
00222 
00228 char * rpmExpand(/*@null@*/ const char * arg, ...)
00229 #if defined(__GNUC__) && __GNUC__ >= 4
00230         /* issue a warning if the list is not  NULL-terminated */
00231         __attribute__((sentinel))
00232 #endif
00233         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00234         /*@modifies rpmGlobalMacroContext, internalState @*/;
00235 
00242 char * rpmMCExpand(/*@null@*/ MacroContext mc, /*@null@*/ const char * arg, ...)
00243 #if defined(__GNUC__) && __GNUC__ >= 4
00244         /* issue a warning if the list is not  NULL-terminated */
00245         __attribute__((sentinel))
00246 #endif
00247         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00248         /*@modifies rpmGlobalMacroContext, internalState @*/;
00249 
00255 /*@null@*/
00256 char * rpmCleanPath(/*@returned@*/ /*@null@*/ char * path)
00257         /*@modifies *path @*/;
00258 
00264 /*@-redecl@*/ /* LCL: shrug */
00265 const char * rpmGetPath(/*@null@*/ const char * path, ...)
00266 #if defined(__GNUC__) && __GNUC__ >= 4
00267         /* issue a warning if the list is not  NULL-terminated */
00268          __attribute__((sentinel))
00269 #endif
00270         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00271         /*@modifies rpmGlobalMacroContext, internalState @*/;
00272 /*@=redecl@*/
00273 
00284 /*@-redecl@*/ /* LCL: shrug */
00285 const char * rpmGenPath(/*@null@*/ const char * urlroot,
00286                         /*@null@*/ const char * urlmdir,
00287                         /*@null@*/ const char * urlfile)
00288         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00289         /*@modifies rpmGlobalMacroContext, internalState @*/;
00290 /*@=redecl@*/
00291 
00299 int rpmExpandNumeric (const char * arg)
00300         /*@globals rpmGlobalMacroContext, h_errno, internalState @*/
00301         /*@modifies rpmGlobalMacroContext, internalState @*/;
00302 
00303 #ifdef __cplusplus
00304 }
00305 #endif
00306 
00307 #endif  /* _H_ MACRO_ */