rpm  5.2.1
Defines | Typedefs | Enumerations | Functions | Variables
rpmio/mire.h File Reference

RPM pattern matching. More...

#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.

Defines

#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.


Define Documentation

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

Definition at line 179 of file mire.h.

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

Definition at line 167 of file mire.h.

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

Definition at line 156 of file mire.h.


Typedef Documentation

typedef struct miRE_s* miRE

Definition at line 58 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 35 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 63 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 479 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 533 of file mire.c.

References mireRegexec().

Referenced by repoGetFileList().

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 handleOneTrigger(), rpmcliFini(), rpmcliInstallElementPath(), rpmdbMireApply(), rpmfcExpandRegexps(), 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 93 of file mire.c.

References _free(), mireClean(), rpmioFreePoolItem(), and xrealloc().

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

miRE mireGetPool ( rpmioPool  pool)

Allocate a miRE container from the pool.

Parameters:
poolmire pool
Returns:
miRE container

Definition at line 80 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().

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 511 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 111 of file mire.c.

References mireGetPool(), and mireLink().

Referenced by handleOneTrigger(), rpmcliInstallElementPath(), rpmdbMireApply(), rpmEVRmire(), rpmmiAddPattern(), and tagValidate().

int mireRegcomp ( miRE  mire,
const char *  pattern 
)

Compile pattern match.

Parameters:
mirepattern container
valpattern to compile
Returns:
0 on success

Definition at line 332 of file mire.c.

References _, _mire_debug, _mireGLOBoptions, _mireREGEXoptions, mireClean(), rpmlog(), RPMLOG_ERR, RPMMIRE_DEFAULT, RPMMIRE_GLOB, RPMMIRE_PCRE, RPMMIRE_REGEX, RPMMIRE_STRCMP, xcalloc(), and xstrdup().

Referenced by handleOneTrigger(), mireAppend(), rpmcliInstallElementPath(), rpmdbMireApply(), rpmEVRmire(), rpmmiAddPattern(), and tagValidate().

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 396 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 handleOneTrigger(), mireApply(), mireSkip(), rpmcliWalkFirst(), rpmdbMireApply(), rpmEVRparse(), rpmfcApply(), rpmfcMatchRegexps(), 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 119 of file mire.c.

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

Referenced by 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 154 of file mire.c.

References RPMMIRE_PCRE, and RPMMIRE_REGEX.

Referenced by 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 178 of file mire.c.

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

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 276 of file mire.c.

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

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 556 of file mire.c.

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

miRE mireUnlink ( miRE  mire)

Unreference a pattern container instance.

Parameters:
mirepattern container
Returns:
new pattern container reference

Variable Documentation

Definition at line 18 of file mire.c.

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

Definition at line 24 of file mire.c.

Referenced by mireSetGOptions().

GLOB default: FNM_PATHNAME | FNM_PERIOD.

Definition at line 30 of file mire.c.

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

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 mireSetLocale().

Definition at line 78 of file mire.c.

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

REGEX default: REG_EXTENDED.

Definition at line 33 of file mire.c.

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

STRING default: 0.

Definition at line 27 of file mire.c.