rpm  5.2.1
rpmio/mire.h
Go to the documentation of this file.
00001 #ifndef H_MIRE
00002 #define H_MIRE
00003 
00009 /*@-noparams@*/
00010 #include <fnmatch.h>
00011 /*@=noparams@*/
00012 #if defined(__LCLINT__)
00013 /*@-declundef -exportheader -redecl @*/ /* LCL: missing annotation */
00014 extern int fnmatch (const char *__pattern, const char *__name, int __flags)
00015         /*@*/;
00016 /*@=declundef =exportheader =redecl @*/
00017 #endif
00018 
00021 /*@-exportlocal@*/
00022 /*@unchecked@*/
00023 extern int _mire_debug;
00024 /*@=exportlocal@*/
00025 
00026 /*@unchecked@*/ /*@only@*/ /*@null@*/
00027 extern rpmioPool _mirePool;
00028 
00031 /*@unchecked@*/ /*@null@*/ /*@shared@*/
00032 extern const unsigned char * _mirePCREtables;
00033 
00035 typedef enum mireEL_e { EL_LF, EL_CR, EL_CRLF, EL_ANY, EL_ANYCRLF } mireEL_t;
00036 
00037 /*@unchecked@*/
00038 extern mireEL_t _mireEL;
00039 
00041 /*@unchecked@*/
00042 extern int _mireSTRINGoptions;
00043 
00045 /*@unchecked@*/
00046 extern int _mireGLOBoptions;
00047 
00049 /*@unchecked@*/
00050 extern int _mireREGEXoptions;
00051 
00053 /*@unchecked@*/
00054 extern int _mirePCREoptions;
00055 
00058 typedef /*@abstract@*/ /*@refcounted@*/ struct miRE_s * miRE;
00059 
00063 typedef enum rpmMireMode_e {
00064     RPMMIRE_DEFAULT     = 0,    
00065     RPMMIRE_STRCMP      = 1,    
00066     RPMMIRE_REGEX       = 2,    
00067     RPMMIRE_GLOB        = 3,    
00068     RPMMIRE_PCRE        = 4     
00069 } rpmMireMode;
00070 
00071 #if defined(_MIRE_INTERNAL)
00072 
00073 #if defined(__LCLINT__)
00074 /*@-declundef -exportheader @*/ /* LCL: missing modifies (only is bogus) */
00075 extern void regfree (/*@only@*/ regex_t *preg)
00076         /*@modifies *preg @*/;
00077 /*@=declundef =exportheader @*/
00078 #endif
00079 
00080 #if defined(WITH_PCRE)
00081 #include <pcre.h>
00082 #endif
00083 #if defined(WITH_PCRE) && defined(WITH_PCRE_POSIX)
00084 #include <pcreposix.h>
00085 #else
00086 #include <regex.h>
00087 #endif
00088 
00091 struct miRE_s {
00092     struct rpmioItem_s _item;   
00093     rpmMireMode mode;           
00094 /*@only@*/ /*@relnull@*/
00095     const char *pattern;        
00096 /*@only@*/ /*@relnull@*/
00097     regex_t *preg;              
00098 /*@only@*/ /*@relnull@*/
00099     void *pcre;                 
00100 /*@only@*/ /*@relnull@*/
00101     void *hints;                
00102 /*@shared@*/ /*@relnull@*/
00103     const char * errmsg;        
00104 /*@shared@*/ /*@relnull@*/
00105     const unsigned char * table;
00106 /*@kept@*/
00107     int * offsets;              
00108     int noffsets;               
00109     int erroff;                 
00110     int errcode;                
00111     int fnflags;        
00112     int cflags;         
00113     int eflags;         
00114     int coptions;       
00115     int startoff;       
00116     int eoptions;       
00117     int notmatch;               
00118     int tag;                    
00119 #if defined(__LCLINT__)
00120 /*@refs@*/
00121     int nrefs;                          
00122 #endif
00123 };
00124 #endif  /* defined(_MIRE_INTERNAL) */
00125 
00126 #ifdef __cplusplus
00127 extern "C" {
00128 #endif
00129 
00135 int mireClean(/*@null@*/ miRE mire)
00136         /*@modifies mire @*/;
00137 
00143 miRE mireGetPool(/*@null@*/ rpmioPool pool)
00144         /*@globals _mirePool, fileSystem @*/
00145         /*@modifies pool, _mirePool, fileSystem @*/;
00146 
00152 /*@unused@*/ /*@null@*/
00153 miRE mireUnlink (/*@killref@*/ /*@only@*/ /*@null@*/ miRE mire)
00154         /*@globals fileSystem @*/
00155         /*@modifies mire, fileSystem @*/;
00156 #define mireUnlink(_mire)       \
00157     (miRE)rpmioUnlinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)
00158 
00164 /*@unused@*/ /*@newref@*/ /*@null@*/
00165 miRE mireLink (/*@null@*/ miRE mire)
00166         /*@modifies mire @*/;
00167 #define mireLink(_mire) \
00168     (miRE)rpmioLinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)
00169 
00175 /*@null@*/
00176 miRE mireFree(/*@killref@*/ /*@only@*/ /*@null@*/ miRE mire)
00177         /*@globals fileSystem @*/
00178         /*@modifies mire, fileSystem @*/;
00179 #define mireFree(_mire) \
00180     (miRE)rpmioFreePoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)
00181 
00188 /*@null@*/
00189 void * mireFreeAll(/*@only@*/ /*@null@*/ miRE mire, int nmire)
00190         /*@globals fileSystem @*/
00191         /*@modifies mire, fileSystem @*/;
00192 
00199 /*@null@*/
00200 miRE mireNew(rpmMireMode mode, int tag)
00201         /*@globals fileSystem @*/
00202         /*@modifies fileSystem @*/;
00203 
00213 int mireSetCOptions(miRE mire, rpmMireMode mode, int tag, int options,
00214                 /*@null@*/ const unsigned char * table)
00215         /*@modifies mire @*/;
00216 
00224 int mireSetEOptions(miRE mire, /*@out@*/ /*@kept@*/ int * offsets, int noffsets)
00225         /*@modifies mire @*/;
00226 
00235 int mireSetGOptions(/*@null@*/ const char * newline,
00236                 int caseless, int multiline, int utf8)
00237         /*globals _mireGLOBoptions, _mireREGEXoptions, _mirePCREoptions */
00238         /*modifies _mireGLOBoptions, _mireREGEXoptions, _mirePCREoptions */;
00239 
00246 int mireSetLocale(/*@null@*/ miRE mire, /*@null@*/ const char * locale)
00247         /*@globals _mirePCREtables, internalState @*/
00248         /*@modifies mire, _mirePCREtables, internalState @*/;
00249 
00257 int mireRegcomp(miRE mire, const char * pattern)
00258         /*@modifies mire @*/;
00259 
00267 int mireRegexec(miRE mire, const char * val, size_t vallen)
00268         /*@modifies mire @*/;
00269 
00279 /*@null@*/
00280 int mireAppend(rpmMireMode mode, int tag, const char * pattern,
00281                 /*@null@*/ const unsigned char * table,
00282                 miRE * mirep, int * nmirep)
00283         /*@globals fileSystem @*/
00284         /*@modifies *mirep, *nmirep, fileSystem @*/;
00285 
00296 int mireLoadPatterns(rpmMireMode mode, int tag,
00297                 /*@null@*/ const char ** patterns,
00298                 /*@null@*/ const unsigned char * table,
00299                 miRE * mirep, int * nmirep)
00300         /*@globals fileSystem @*/
00301         /*@modifies *mirep, *nmirep, fileSystem @*/;
00302 
00312 int mireApply(/*@null@*/ miRE mire, int nmire,
00313                 const char *s, size_t slen, int rc)
00314         /*@modifies mire@*/;
00315 
00322 int mireStudy(miRE mire, int nmires)
00323         /*@modifies mire @*/;
00324 
00325 #ifdef __cplusplus
00326 }
00327 #endif
00328 
00329 #endif