rpm  5.2.1
Macros | Functions | Variables
mire.c File Reference
#include "system.h"
#include <rpmiotypes.h>
#include <rpmio.h>
#include <rpmlog.h>
#include <mire.h>
#include "debug.h"
Include dependency graph for mire.c:

Go to the source code of this file.

Macros

#define _MIRE_INTERNAL
 

Functions

int mireClean (miRE mire)
 Deallocate pattern match memory.
 
static void mireFini (void *_mire)
 
miRE mireGetPool (rpmioPool pool)
 Allocate a miRE container from the pool.
 
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 = 0
 
const unsigned char * _mirePCREtables = NULL
 
mireEL_t _mireEL = EL_LF
 
int _mireSTRINGoptions = 0
 STRING default: 0.
 
int _mireGLOBoptions = FNM_EXTMATCH | FNM_PATHNAME | FNM_PERIOD
 GLOB default: FNM_PATHNAME | FNM_PERIOD.
 
int _mireREGEXoptions = REG_EXTENDED | REG_NEWLINE
 REGEX default: REG_EXTENDED.
 
int _mirePCREoptions = 0
 PCRE default: 0.
 
rpmioPool _mirePool
 

Macro Definition Documentation

#define _MIRE_INTERNAL

Definition at line 10 of file mire.c.

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

static void mireFini ( void *  _mire)
static

Definition at line 70 of file mire.c.

References mireClean().

Referenced by mireGetPool().

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

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.

Variable Documentation

int _mire_debug = 0

Definition at line 18 of file mire.c.

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

mireEL_t _mireEL = EL_LF

Definition at line 24 of file mire.c.

Referenced by mireSetGOptions().

int _mireGLOBoptions = FNM_EXTMATCH | FNM_PATHNAME | FNM_PERIOD

GLOB default: FNM_PATHNAME | FNM_PERIOD.

Definition at line 30 of file mire.c.

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

int _mirePCREoptions = 0

PCRE default: 0.

Definition at line 36 of file mire.c.

Referenced by mireSetCOptions(), and mireSetGOptions().

const unsigned char* _mirePCREtables = NULL

Definition at line 21 of file mire.c.

Referenced by mireSetLocale().

rpmioPool _mirePool

Definition at line 78 of file mire.c.

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

int _mireREGEXoptions = REG_EXTENDED | REG_NEWLINE

REGEX default: REG_EXTENDED.

Definition at line 33 of file mire.c.

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

int _mireSTRINGoptions = 0

STRING default: 0.

Definition at line 27 of file mire.c.