rpm  5.4.10
Macros | Typedefs | Enumerations | Functions | Variables
mire.h File Reference

RPM pattern matching. More...

#include <rpmiotypes.h>
#include <fnmatch.h>
Include dependency graph for mire.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define mireUnlink(_mire)   (miRE)rpmioUnlinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)
#define mireLink(_mire)   (miRE)rpmioLinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)
#define mireFree(_mire)   (miRE)rpmioFreePoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)

Typedefs

typedef enum mireEL_e mireEL_t
 Line ending types.
typedef struct miRE_s * miRE
typedef enum rpmMireMode_e rpmMireMode
 Tag value pattern match mode.

Enumerations

enum  mireEL_e {
  EL_LF, EL_CR, EL_CRLF, EL_ANY,
  EL_ANYCRLF
}
 Line ending types. More...
enum  rpmMireMode_e {
  RPMMIRE_DEFAULT = 0, RPMMIRE_STRCMP = 1, RPMMIRE_REGEX = 2, RPMMIRE_GLOB = 3,
  RPMMIRE_PCRE = 4
}
 Tag value pattern match mode. More...

Functions

int mireClean (miRE mire)
 Deallocate pattern match memory.
miRE mireGetPool (rpmioPool pool)
 Allocate a miRE container from the pool.
miRE mireUnlink (miRE mire)
 Unreference a pattern container instance.
miRE mireLink (miRE mire)
 Reference a pattern container instance.
miRE mireFree (miRE mire)
 Free pattern container.
void * mireFreeAll (miRE mire, int nmire)
 Destroy compiled patterns.
miRE mireNew (rpmMireMode mode, int tag)
 Create pattern container.
int mireSetCOptions (miRE mire, rpmMireMode mode, int tag, int options, const unsigned char *table)
 Initialize pattern compile options.
int mireSetEOptions (miRE mire, int *offsets, int noffsets)
 Initialize pattern execute options (PCRE only).
int mireSetGOptions (const char *newline, int caseless, int multiline, int utf8)
 Initialize pattern global options (PCRE only).
int mireSetLocale (miRE mire, const char *locale)
 Compile locale-specific PCRE tables.
int mireRegcomp (miRE mire, const char *pattern)
 Compile pattern match.
int mireRegexec (miRE mire, const char *val, size_t vallen)
 Execute pattern match.
int mireAppend (rpmMireMode mode, int tag, const char *pattern, const unsigned char *table, miRE *mirep, int *nmirep)
 Append pattern to array.
int mireLoadPatterns (rpmMireMode mode, int tag, const char **patterns, const unsigned char *table, miRE *mirep, int *nmirep)
 Load patterns from string array.
int mireApply (miRE mire, int nmire, const char *s, size_t slen, int rc)
 Apply array of patterns to a string.
int mireStudy (miRE mire, int nmires)
 Study PCRE patterns (if any).

Variables

int _mire_debug
rpmioPool _mirePool
const unsigned char * _mirePCREtables
mireEL_t _mireEL
int _mireSTRINGoptions
 STRING default: 0.
int _mireGLOBoptions
 GLOB default: FNM_PATHNAME | FNM_PERIOD.
int _mireREGEXoptions
 REGEX default: REG_EXTENDED.
int _mirePCREoptions
 PCRE default: 0.

Detailed Description

RPM pattern matching.

Definition in file mire.h.

Macro Definition Documentation

#define mireFree (   _mire)    (miRE)rpmioFreePoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)

Definition at line 181 of file mire.h.

#define mireLink (   _mire)    (miRE)rpmioLinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)

Definition at line 169 of file mire.h.

#define mireUnlink (   _mire)    (miRE)rpmioUnlinkPoolItem((rpmioItem)_mire, __FUNCTION__, __FILE__, __LINE__)

Definition at line 158 of file mire.h.

Typedef Documentation

typedef struct miRE_s* miRE

Definition at line 60 of file mire.h.

typedef enum mireEL_e mireEL_t

Line ending types.

typedef enum rpmMireMode_e rpmMireMode

Tag value pattern match mode.

Enumeration Type Documentation

enum mireEL_e

Line ending types.

Enumerator:
EL_LF 
EL_CR 
EL_CRLF 
EL_ANY 
EL_ANYCRLF 

Definition at line 37 of file mire.h.

Tag value pattern match mode.

Enumerator:
RPMMIRE_DEFAULT 

posix regex with ., .* and ^...$ added

RPMMIRE_STRCMP 

strings using strcmp(3)

RPMMIRE_REGEX 

posix regex(7) patterns using regcomp(3)

RPMMIRE_GLOB 

glob(7) patterns using fnmatch(3)

RPMMIRE_PCRE 

pcre patterns using pcre_compile2(3)

Definition at line 65 of file mire.h.

Function Documentation

int mireAppend ( rpmMireMode  mode,
int  tag,
const char *  pattern,
const unsigned char *  table,
miRE mirep,
int *  nmirep 
)

Append pattern to array.

Parameters
modetype of pattern match
tagidentifier (like an rpmTag)
patternpattern to compile
table(PCRE) locale table to use (NULL uses default table)
Return values
*mireppattern array
*nmirepno. of patterns in array

Definition at line 499 of file mire.c.

References mireGetPool(), mireRegcomp(), mireSetCOptions(), and xrealloc.

Referenced by mireLoadPatterns(), rpmdbTriggerGlobs(), rpmfcExpandRegexps(), rpmPlatform(), and strsubFormat().

int mireApply ( miRE  mire,
int  nmire,
const char *  s,
size_t  slen,
int  rc 
)

Apply array of patterns to a string.

Parameters
mirecompiled pattern array
nmireno. of patterns in array
sstring to apply against
slenlength of string (0 will use strlen(s))
rc-1 == excluding, +1 == including, 0 == single pattern
Returns
termination condition

Definition at line 553 of file mire.c.

References mireRegexec().

Referenced by grep_or_recurse(), and rpmrepoGetFileList().

int mireClean ( miRE  mire)

Deallocate pattern match memory.

Parameters
mirepattern container
Returns
0 on success

Definition at line 38 of file mire.c.

References _free(), _mire_debug, RPMMIRE_PCRE, and RPMMIRE_REGEX.

Referenced by handleOneTrigger(), mireFini(), mireFreeAll(), and mireRegcomp().

miRE mireFree ( miRE  mire)

Free pattern container.

Parameters
mirepattern container
Returns
NULL on last derefernce

Referenced by dbiMireKeys(), handleOneTrigger(), rpmcliFini(), rpmcliInstallElementPath(), rpmfcApply(), rpmfcExpandRegexps(), rpmfcSCRIPT(), rpmmiAddPattern(), and tagValidate().

void* mireFreeAll ( miRE  mire,
int  nmire 
)

Destroy compiled patterns.

Parameters
mirepattern array
nreno of patterns in array
Returns
NULL always

Definition at line 96 of file mire.c.

References mireClean(), and rpmioFreePoolItem().

Referenced by main(), rpmdsFini(), rpmfcFreeRegexps(), rpmfiFini(), rpmFreeRpmrc(), rpmmiFini(), rpmPlatform(), rpmrepoFini(), runTriggers(), and strsubFormat().

miRE mireGetPool ( rpmioPool  pool)

Allocate a miRE container from the pool.

Parameters
poolmire pool
Returns
miRE container

Definition at line 81 of file mire.c.

References _mire_debug, _mirePool, mireFini(), rpmioGetPool(), and rpmioNewPool().

Referenced by mireAppend(), mireNew(), and rpmmiAddPattern().

miRE mireLink ( miRE  mire)

Reference a pattern container instance.

Parameters
mirepattern container
Returns
new pattern container reference

Referenced by mireNew(), and rpmmiAddPattern().

int mireLoadPatterns ( rpmMireMode  mode,
int  tag,
const char **  patterns,
const unsigned char *  table,
miRE mirep,
int *  nmirep 
)

Load patterns from string array.

Parameters
modetype of pattern match
tagidentifier (like an rpmTag)
patternspatterns to compile
table(PCRE) locale table to use (NULL uses default table)
Return values
*mireppattern array
*nmirepno. of patterns in array
Returns
0 on success

Definition at line 531 of file mire.c.

References mireAppend().

Referenced by main().

miRE mireNew ( rpmMireMode  mode,
int  tag 
)

Create pattern container.

Parameters
modetype of pattern match
tagidentifier (e.g. an rpmTag)
Returns
new pattern container (NULL on error)

Definition at line 113 of file mire.c.

References mireGetPool(), and mireLink().

Referenced by dbiMireKeys(), handleOneTrigger(), rpmcliInstallElementPath(), rpmEVRmire(), rpmfcApply(), rpmfcSCRIPT(), rpmmiAddPattern(), and tagValidate().

int mireRegcomp ( miRE  mire,
const char *  pattern 
)
int mireRegexec ( miRE  mire,
const char *  val,
size_t  vallen 
)

Execute pattern match.

Parameters
mirepattern container
valvalue to match
vallenlength of value string (0 will use strlen)
Returns
>=0 if pattern matches, -1 on nomatch, else error

Definition at line 398 of file mire.c.

References _, _mire_debug, alloca(), FNM_NOMATCH, fnmatch(), rpmlog(), RPMLOG_ERR, RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_PCRE, RPMMIRE_REGEX, and RPMMIRE_STRCMP.

Referenced by dbiMireKeys(), handleOneTrigger(), mireApply(), mireSkip(), pcregrep(), rpmcliWalkFirst(), rpmEVRparse(), rpmfcApply(), rpmfcMatchRegexps(), rpmfcSCRIPT(), rpmGetMacroEntries(), rpmPlatformScore(), runTriggersLoop(), strsubFormat(), and tagValidate().

int mireSetCOptions ( miRE  mire,
rpmMireMode  mode,
int  tag,
int  options,
const unsigned char *  table 
)

Initialize pattern compile options.

Parameters
mirepattern container
modetype of pattern match
tagidentifier (e.g. an rpmTag)
optionspattern options (0 uses default options)
table(PCRE only) locale tables
Returns
0 on success

Definition at line 121 of file mire.c.

References _mireGLOBoptions, _mirePCREoptions, _mireREGEXoptions, RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_PCRE, RPMMIRE_REGEX, and RPMMIRE_STRCMP.

Referenced by compile_single_pattern(), mireAppend(), rpmEVRmire(), and tagValidate().

int mireSetEOptions ( miRE  mire,
int *  offsets,
int  noffsets 
)

Initialize pattern execute options (PCRE only).

Parameters
mirepattern container
*offsets(PCRE only) string offset(s)
noffsets(PCRE only) no. of string offsets
Returns
0 on success

Definition at line 156 of file mire.c.

References RPMMIRE_PCRE, and RPMMIRE_REGEX.

Referenced by pcregrep(), rpmEVRparse(), and strsubFormat().

int mireSetGOptions ( const char *  newline,
int  caseless,
int  multiline,
int  utf8 
)

Initialize pattern global options (PCRE only).

Parameters
newlinenewline ending identifier
caselessshould case be ignored?
multlineare multiline matches permitted?
utf8assume utf8 matching?
Returns
0 on success

Definition at line 180 of file mire.c.

References _mireEL, _mireGLOBoptions, _mirePCREoptions, _mireREGEXoptions, EL_ANY, EL_ANYCRLF, EL_CR, EL_CRLF, EL_LF, and FNM_CASEFOLD.

Referenced by main().

int mireSetLocale ( miRE  mire,
const char *  locale 
)

Compile locale-specific PCRE tables.

Parameters
mirepattern container
localelocale string (NULL uses usual envvar's)
Returns
0 on success

Definition at line 278 of file mire.c.

References _, __progname, _mirePCREtables, getenv(), setlocale, and xstrdup().

Referenced by main().

int mireStudy ( miRE  mire,
int  nmires 
)

Study PCRE patterns (if any).

Parameters
mirepattern container
nmiresno. of patterns in container
Returns
0 on success

Definition at line 576 of file mire.c.

References _, __progname, rpmlog(), RPMLOG_ERR, and RPMMIRE_PCRE.

Referenced by main().

miRE mireUnlink ( miRE  mire)

Unreference a pattern container instance.

Parameters
mirepattern container
Returns
new pattern container reference

Variable Documentation

int _mire_debug

Definition at line 18 of file mire.c.

Referenced by mireClean(), mireGetPool(), mireRegcomp(), mireRegexec(), and rpmmiAddPattern().

mireEL_t _mireEL

Definition at line 24 of file mire.c.

Referenced by end_of_line(), mireSetGOptions(), and previous_line().

int _mireGLOBoptions

GLOB default: FNM_PATHNAME | FNM_PERIOD.

Definition at line 30 of file mire.c.

Referenced by mireRegcomp(), mireSetCOptions(), and mireSetGOptions().

int _mirePCREoptions

PCRE default: 0.

Definition at line 36 of file mire.c.

Referenced by mireSetCOptions(), and mireSetGOptions().

const unsigned char* _mirePCREtables

Definition at line 21 of file mire.c.

Referenced by compile_single_pattern(), and mireSetLocale().

rpmioPool _mirePool

Definition at line 79 of file mire.c.

Referenced by mireGetPool(), rpmioClean(), and rpmmiAddPattern().

int _mireREGEXoptions

REGEX default: REG_EXTENDED.

Definition at line 33 of file mire.c.

Referenced by mireRegcomp(), mireSetCOptions(), and mireSetGOptions().

int _mireSTRINGoptions

STRING default: 0.

Definition at line 27 of file mire.c.