rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Typedefs | Enumerations | Functions | Variables
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.

## 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. More...
typedef struct miRE_s * | miRE
typedef enum rpmMireMode_e | rpmMireMode
| Tag value pattern match mode. More...

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

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

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

enum rpmMireMode_e

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

  mode | type of pattern match
  tag | identifier (like an rpmTag)
  pattern | pattern to compile
  table | (PCRE) locale table to use (NULL uses default table)

Return values

  *mirep | pattern array
  *nmirep | no. 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

  mire | compiled pattern array
  nmire | no. of patterns in array
  s | string to apply against
  slen | length 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

  mire | pattern 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

  mire | pattern 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

  mire | pattern array
  nre | no 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

  pool | mire 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

  mire | pattern 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

  mode | type of pattern match
  tag | identifier (like an rpmTag)
  patterns | patterns to compile
  table | (PCRE) locale table to use (NULL uses default table)

Return values

  *mirep | pattern array
  *nmirep | no. 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

  mode | type of pattern match
  tag | identifier (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

  mire | pattern container
  val | pattern 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

  mire | pattern container
  val | value to match
  vallen | length 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

  mire | pattern container
  mode | type of pattern match
  tag | identifier (e.g. an rpmTag)
  options | pattern 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

  mire | pattern 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

  newline | newline ending identifier
  caseless | should case be ignored?
  multline | are multiline matches permitted?
  utf8 | assume 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

  mire | pattern container
  locale | locale 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

  mire | pattern container
  nmires | no. 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

  mire | pattern container

Returns
  new pattern container reference

## Variable Documentation

int _mire_debug

Definition at line 18 of file mire.c.

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

mireEL_t _mireEL

Definition at line 24 of file mire.c.

Referenced by mireSetGOptions().

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

rpmioPool _mirePool

Definition at line 78 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.