Back to index

nagios-plugins  1.4.16
Classes | Defines | Typedefs | Enumerations | Functions | Variables
regex.h File Reference
#include <sys/types.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  re_pattern_buffer
struct  re_registers
struct  regmatch_t

Defines

#define __USE_GNU_REGEX   1
#define RE_BACKSLASH_ESCAPE_IN_LISTS   ((unsigned long int) 1)
#define RE_BK_PLUS_QM   (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
#define RE_CHAR_CLASSES   (RE_BK_PLUS_QM << 1)
#define RE_CONTEXT_INDEP_ANCHORS   (RE_CHAR_CLASSES << 1)
#define RE_CONTEXT_INDEP_OPS   (RE_CONTEXT_INDEP_ANCHORS << 1)
#define RE_CONTEXT_INVALID_OPS   (RE_CONTEXT_INDEP_OPS << 1)
#define RE_DOT_NEWLINE   (RE_CONTEXT_INVALID_OPS << 1)
#define RE_DOT_NOT_NULL   (RE_DOT_NEWLINE << 1)
#define RE_HAT_LISTS_NOT_NEWLINE   (RE_DOT_NOT_NULL << 1)
#define RE_INTERVALS   (RE_HAT_LISTS_NOT_NEWLINE << 1)
#define RE_LIMITED_OPS   (RE_INTERVALS << 1)
#define RE_NEWLINE_ALT   (RE_LIMITED_OPS << 1)
#define RE_NO_BK_BRACES   (RE_NEWLINE_ALT << 1)
#define RE_NO_BK_PARENS   (RE_NO_BK_BRACES << 1)
#define RE_NO_BK_REFS   (RE_NO_BK_PARENS << 1)
#define RE_NO_BK_VBAR   (RE_NO_BK_REFS << 1)
#define RE_NO_EMPTY_RANGES   (RE_NO_BK_VBAR << 1)
#define RE_UNMATCHED_RIGHT_PAREN_ORD   (RE_NO_EMPTY_RANGES << 1)
#define RE_NO_POSIX_BACKTRACKING   (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
#define RE_NO_GNU_OPS   (RE_NO_POSIX_BACKTRACKING << 1)
#define RE_DEBUG   (RE_NO_GNU_OPS << 1)
#define RE_INVALID_INTERVAL_ORD   (RE_DEBUG << 1)
#define RE_ICASE   (RE_INVALID_INTERVAL_ORD << 1)
#define RE_CARET_ANCHORS_HERE   (RE_ICASE << 1)
#define RE_CONTEXT_INVALID_DUP   (RE_CARET_ANCHORS_HERE << 1)
#define RE_NO_SUB   (RE_CONTEXT_INVALID_DUP << 1)
#define RE_SYNTAX_EMACS   0
#define RE_SYNTAX_AWK
#define RE_SYNTAX_GNU_AWK
#define RE_SYNTAX_POSIX_AWK
#define RE_SYNTAX_GREP
#define RE_SYNTAX_EGREP
#define RE_SYNTAX_POSIX_EGREP
#define RE_SYNTAX_ED   RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED   RE_SYNTAX_POSIX_BASIC
#define _RE_SYNTAX_POSIX_COMMON
#define RE_SYNTAX_POSIX_BASIC   (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)
#define RE_SYNTAX_POSIX_MINIMAL_BASIC   (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
#define RE_SYNTAX_POSIX_EXTENDED
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED
#define RE_DUP_MAX   (0x7fff)
#define REG_EXTENDED   1
#define REG_ICASE   (1 << 1)
#define REG_NEWLINE   (1 << 2)
#define REG_NOSUB   (1 << 3)
#define REG_NOTBOL   1
#define REG_NOTEOL   (1 << 1)
#define REG_STARTEND   (1 << 2)
#define REG_NOERROR   _REG_NOERROR
#define REG_NOMATCH   _REG_NOMATCH
#define REG_BADPAT   _REG_BADPAT
#define REG_ECOLLATE   _REG_ECOLLATE
#define REG_ECTYPE   _REG_ECTYPE
#define REG_EESCAPE   _REG_EESCAPE
#define REG_ESUBREG   _REG_ESUBREG
#define REG_EBRACK   _REG_EBRACK
#define REG_EPAREN   _REG_EPAREN
#define REG_EBRACE   _REG_EBRACE
#define REG_BADBR   _REG_BADBR
#define REG_ERANGE   _REG_ERANGE
#define REG_ESPACE   _REG_ESPACE
#define REG_BADRPT   _REG_BADRPT
#define REG_EEND   _REG_EEND
#define REG_ESIZE   _REG_ESIZE
#define REG_ERPAREN   _REG_ERPAREN
#define _REG_RE_NAME(id)   id
#define _REG_RM_NAME(id)   id
#define RE_TRANSLATE_TYPE   unsigned char *
#define REG_TRANSLATE_TYPE   RE_TRANSLATE_TYPE
#define REGS_UNALLOCATED   0
#define REGS_REALLOCATE   1
#define REGS_FIXED   2
#define RE_NREGS   30
#define _Restrict_
#define _Restrict_arr_

Typedefs

typedef int regoff_t
typedef int __re_idx_t
typedef unsigned int __re_size_t
typedef unsigned long int __re_long_size_t
typedef long int s_reg_t
typedef unsigned long int active_reg_t
typedef unsigned long int reg_syntax_t
typedef struct re_pattern_buffer

Enumerations

enum  reg_errcode_t {
  _REG_ENOSYS = -1, _REG_NOERROR = 0, _REG_NOMATCH, _REG_BADPAT,
  _REG_ECOLLATE, _REG_ECTYPE, _REG_EESCAPE, _REG_ESUBREG,
  _REG_EBRACK, _REG_EPAREN, _REG_EBRACE, _REG_BADBR,
  _REG_ERANGE, _REG_ESPACE, _REG_BADRPT, _REG_EEND,
  _REG_ESIZE, _REG_ERPAREN
}

Functions

reg_syntax_t re_set_syntax (reg_syntax_t __syntax)
const char * re_compile_pattern (const char *__pattern, size_t __length, struct re_pattern_buffer *__buffer)
int re_compile_fastmap (struct re_pattern_buffer *__buffer)
regoff_t re_search (struct re_pattern_buffer *__buffer, const char *__string, __re_idx_t __length, __re_idx_t __start, regoff_t __range, struct re_registers *__regs)
regoff_t re_search_2 (struct re_pattern_buffer *__buffer, const char *__string1, __re_idx_t __length1, const char *__string2, __re_idx_t __length2, __re_idx_t __start, regoff_t __range, struct re_registers *__regs, __re_idx_t __stop)
regoff_t re_match (struct re_pattern_buffer *__buffer, const char *__string, __re_idx_t __length, __re_idx_t __start, struct re_registers *__regs)
regoff_t re_match_2 (struct re_pattern_buffer *__buffer, const char *__string1, __re_idx_t __length1, const char *__string2, __re_idx_t __length2, __re_idx_t __start, struct re_registers *__regs, __re_idx_t __stop)
void re_set_registers (struct re_pattern_buffer *__buffer, struct re_registers *__regs, __re_size_t __num_regs, regoff_t *__starts, regoff_t *__ends)
int regcomp (regex_t *_Restrict_ __preg, const char *_Restrict_ __pattern, int __cflags)
int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __string, size_t __nmatch, regmatch_t __pmatch[_Restrict_arr_], int __eflags)
size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, char *_Restrict_ __errbuf, size_t __errbuf_size)
void regfree (regex_t *__preg)

Variables

reg_syntax_t re_syntax_options

Class Documentation

struct regmatch_t

Definition at line 542 of file regex.h.

Class Members
regoff_t rm_eo
regoff_t rm_so

Define Documentation

#define __USE_GNU_REGEX   1

Definition at line 38 of file regex.h.

#define _REG_RE_NAME (   id)    id

Definition at line 425 of file regex.h.

#define _REG_RM_NAME (   id)    id

Definition at line 426 of file regex.h.

#define _Restrict_

Definition at line 639 of file regex.h.

#define _Restrict_arr_

Definition at line 652 of file regex.h.

#define RE_BACKSLASH_ESCAPE_IN_LISTS   ((unsigned long int) 1)

Definition at line 101 of file regex.h.

Definition at line 106 of file regex.h.

#define RE_CARET_ANCHORS_HERE   (RE_ICASE << 1)

Definition at line 220 of file regex.h.

#define RE_CHAR_CLASSES   (RE_BK_PLUS_QM << 1)

Definition at line 112 of file regex.h.

Definition at line 126 of file regex.h.

Definition at line 134 of file regex.h.

Definition at line 224 of file regex.h.

Definition at line 138 of file regex.h.

#define RE_DEBUG   (RE_NO_GNU_OPS << 1)

Definition at line 206 of file regex.h.

Definition at line 142 of file regex.h.

#define RE_DOT_NOT_NULL   (RE_DOT_NEWLINE << 1)

Definition at line 146 of file regex.h.

#define RE_DUP_MAX   (0x7fff)

Definition at line 328 of file regex.h.

Definition at line 150 of file regex.h.

#define RE_ICASE   (RE_INVALID_INTERVAL_ORD << 1)

Definition at line 215 of file regex.h.

Definition at line 155 of file regex.h.

#define RE_INVALID_INTERVAL_ORD   (RE_DEBUG << 1)

Definition at line 211 of file regex.h.

#define RE_LIMITED_OPS   (RE_INTERVALS << 1)

Definition at line 159 of file regex.h.

#define RE_NEWLINE_ALT   (RE_LIMITED_OPS << 1)

Definition at line 163 of file regex.h.

#define RE_NO_BK_BRACES   (RE_NEWLINE_ALT << 1)

Definition at line 168 of file regex.h.

#define RE_NO_BK_PARENS   (RE_NO_BK_BRACES << 1)

Definition at line 172 of file regex.h.

#define RE_NO_BK_REFS   (RE_NO_BK_PARENS << 1)

Definition at line 176 of file regex.h.

#define RE_NO_BK_VBAR   (RE_NO_BK_REFS << 1)

Definition at line 180 of file regex.h.

#define RE_NO_EMPTY_RANGES   (RE_NO_BK_VBAR << 1)

Definition at line 186 of file regex.h.

Definition at line 198 of file regex.h.

Definition at line 194 of file regex.h.

#define RE_NO_SUB   (RE_CONTEXT_INVALID_DUP << 1)

Definition at line 228 of file regex.h.

#define RE_NREGS   30

Definition at line 535 of file regex.h.

#define RE_SYNTAX_AWK

Definition at line 277 of file regex.h.

#define RE_SYNTAX_EGREP
#define RE_SYNTAX_EMACS   0

Definition at line 243 of file regex.h.

#define RE_SYNTAX_GREP

Definition at line 286 of file regex.h.

Value:

Definition at line 272 of file regex.h.

Definition at line 292 of file regex.h.

Definition at line 279 of file regex.h.

#define RE_TRANSLATE_TYPE   unsigned char *

Definition at line 438 of file regex.h.

Definition at line 190 of file regex.h.

#define REG_BADBR   _REG_BADBR

Definition at line 413 of file regex.h.

#define REG_BADPAT   _REG_BADPAT

Definition at line 405 of file regex.h.

#define REG_BADRPT   _REG_BADRPT

Definition at line 416 of file regex.h.

#define REG_EBRACE   _REG_EBRACE

Definition at line 412 of file regex.h.

#define REG_EBRACK   _REG_EBRACK

Definition at line 410 of file regex.h.

Definition at line 406 of file regex.h.

#define REG_ECTYPE   _REG_ECTYPE

Definition at line 407 of file regex.h.

#define REG_EEND   _REG_EEND

Definition at line 417 of file regex.h.

#define REG_EESCAPE   _REG_EESCAPE

Definition at line 408 of file regex.h.

#define REG_EPAREN   _REG_EPAREN

Definition at line 411 of file regex.h.

#define REG_ERANGE   _REG_ERANGE

Definition at line 414 of file regex.h.

#define REG_ERPAREN   _REG_ERPAREN

Definition at line 419 of file regex.h.

#define REG_ESIZE   _REG_ESIZE

Definition at line 418 of file regex.h.

#define REG_ESPACE   _REG_ESPACE

Definition at line 415 of file regex.h.

#define REG_ESUBREG   _REG_ESUBREG

Definition at line 409 of file regex.h.

#define REG_EXTENDED   1

Definition at line 337 of file regex.h.

#define REG_ICASE   (1 << 1)

Definition at line 341 of file regex.h.

#define REG_NEWLINE   (1 << 2)

Definition at line 346 of file regex.h.

#define REG_NOERROR   _REG_NOERROR

Definition at line 403 of file regex.h.

#define REG_NOMATCH   _REG_NOMATCH

Definition at line 404 of file regex.h.

#define REG_NOSUB   (1 << 3)

Definition at line 350 of file regex.h.

#define REG_NOTBOL   1

Definition at line 360 of file regex.h.

#define REG_NOTEOL   (1 << 1)

Definition at line 363 of file regex.h.

#define REG_STARTEND   (1 << 2)

Definition at line 367 of file regex.h.

Definition at line 440 of file regex.h.

#define REGS_FIXED   2

Definition at line 494 of file regex.h.

#define REGS_REALLOCATE   1

Definition at line 493 of file regex.h.

#define REGS_UNALLOCATED   0

Definition at line 492 of file regex.h.


Typedef Documentation

typedef int __re_idx_t

Definition at line 77 of file regex.h.

typedef unsigned long int __re_long_size_t

Definition at line 79 of file regex.h.

typedef unsigned int __re_size_t

Definition at line 78 of file regex.h.

typedef unsigned long int active_reg_t

Definition at line 88 of file regex.h.

typedef struct re_pattern_buffer

Definition at line 519 of file regex.h.

typedef unsigned long int reg_syntax_t

Definition at line 95 of file regex.h.

typedef int regoff_t

Definition at line 76 of file regex.h.

typedef long int s_reg_t

Definition at line 87 of file regex.h.


Enumeration Type Documentation

Enumerator:
_REG_ENOSYS 
_REG_NOERROR 
_REG_NOMATCH 
_REG_BADPAT 
_REG_ECOLLATE 
_REG_ECTYPE 
_REG_EESCAPE 
_REG_ESUBREG 
_REG_EBRACK 
_REG_EPAREN 
_REG_EBRACE 
_REG_BADBR 
_REG_ERANGE 
_REG_ESPACE 
_REG_BADRPT 
_REG_EEND 
_REG_ESIZE 
_REG_ERPAREN 

Definition at line 373 of file regex.h.

{
  _REG_ENOSYS = -1,  /* This will never happen for this implementation.  */
  _REG_NOERROR = 0,  /* Success.  */
  _REG_NOMATCH,             /* Didn't find a match (for regexec).  */

  /* POSIX regcomp return error codes.  (In the order listed in the
     standard.)  */
  _REG_BADPAT,              /* Invalid pattern.  */
  _REG_ECOLLATE,     /* Invalid collating element.  */
  _REG_ECTYPE,              /* Invalid character class name.  */
  _REG_EESCAPE,             /* Trailing backslash.  */
  _REG_ESUBREG,             /* Invalid back reference.  */
  _REG_EBRACK,              /* Unmatched left bracket.  */
  _REG_EPAREN,              /* Parenthesis imbalance.  */
  _REG_EBRACE,              /* Unmatched \{.  */
  _REG_BADBR,        /* Invalid contents of \{\}.  */
  _REG_ERANGE,              /* Invalid range end.  */
  _REG_ESPACE,              /* Ran out of memory.  */
  _REG_BADRPT,              /* No preceding re for repetition op.  */

  /* Error codes we've added.  */
  _REG_EEND,         /* Premature end.  */
  _REG_ESIZE,        /* Compiled pattern bigger than 2^16 bytes.  */
  _REG_ERPAREN              /* Unmatched ) or \); not returned from regcomp.  */
} reg_errcode_t;

Function Documentation

int re_compile_fastmap ( struct re_pattern_buffer __buffer)

Definition at line 274 of file regcomp.c.

{
  re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
  char *fastmap = bufp->fastmap;

  memset (fastmap, '\0', sizeof (char) * SBC_MAX);
  re_compile_fastmap_iter (bufp, dfa->init_state, fastmap);
  if (dfa->init_state != dfa->init_state_word)
    re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap);
  if (dfa->init_state != dfa->init_state_nl)
    re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap);
  if (dfa->init_state != dfa->init_state_begbuf)
    re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap);
  bufp->fastmap_accurate = 1;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* re_compile_pattern ( const char *  __pattern,
size_t  __length,
struct re_pattern_buffer __buffer 
)

Definition at line 221 of file regcomp.c.

{
  reg_errcode_t ret;

  /* And GNU code determines whether or not to get register information
     by passing null for the REGS argument to re_match, etc., not by
     setting no_sub, unless RE_NO_SUB is set.  */
  bufp->no_sub = !!(re_syntax_options & RE_NO_SUB);

  /* Match anchors at newline.  */
  bufp->newline_anchor = 1;

  ret = re_compile_internal (bufp, pattern, length, re_syntax_options);

  if (!ret)
    return NULL;
  return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
}

Here is the call graph for this function:

regoff_t re_match ( struct re_pattern_buffer __buffer,
const char *  __string,
__re_idx_t  __length,
__re_idx_t  __start,
struct re_registers __regs 
)

Definition at line 312 of file regexec.c.

{
  return re_search_stub (bufp, string, length, start, 0, length, regs, true);
}

Here is the call graph for this function:

regoff_t re_match_2 ( struct re_pattern_buffer __buffer,
const char *  __string1,
__re_idx_t  __length1,
const char *  __string2,
__re_idx_t  __length2,
__re_idx_t  __start,
struct re_registers __regs,
__re_idx_t  __stop 
)

Definition at line 340 of file regexec.c.

{
  return re_search_2_stub (bufp, string1, length1, string2, length2,
                        start, 0, regs, stop, true);
}

Here is the call graph for this function:

regoff_t re_search ( struct re_pattern_buffer __buffer,
const char *  __string,
__re_idx_t  __length,
__re_idx_t  __start,
regoff_t  __range,
struct re_registers __regs 
)

Definition at line 325 of file regexec.c.

{
  return re_search_stub (bufp, string, length, start, range, length, regs,
                      false);
}

Here is the call graph for this function:

regoff_t re_search_2 ( struct re_pattern_buffer __buffer,
const char *  __string1,
__re_idx_t  __length1,
const char *  __string2,
__re_idx_t  __length2,
__re_idx_t  __start,
regoff_t  __range,
struct re_registers __regs,
__re_idx_t  __stop 
)

Definition at line 354 of file regexec.c.

{
  return re_search_2_stub (bufp, string1, length1, string2, length2,
                        start, range, regs, stop, false);
}

Here is the call graph for this function:

void re_set_registers ( struct re_pattern_buffer __buffer,
struct re_registers __regs,
__re_size_t  __num_regs,
regoff_t __starts,
regoff_t __ends 
)

Definition at line 589 of file regexec.c.

{
  if (num_regs)
    {
      bufp->regs_allocated = REGS_REALLOCATE;
      regs->num_regs = num_regs;
      regs->start = starts;
      regs->end = ends;
    }
  else
    {
      bufp->regs_allocated = REGS_UNALLOCATED;
      regs->num_regs = 0;
      regs->start = regs->end = NULL;
    }
}

Definition at line 261 of file regcomp.c.

{
  reg_syntax_t ret = re_syntax_options;

  re_syntax_options = syntax;
  return ret;
}
int regcomp ( regex_t *_Restrict_  __preg,
const char *_Restrict_  __pattern,
int  __cflags 
)

Definition at line 474 of file regcomp.c.

{
  reg_errcode_t ret;
  reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
                      : RE_SYNTAX_POSIX_BASIC);

  preg->buffer = NULL;
  preg->allocated = 0;
  preg->used = 0;

  /* Try to allocate space for the fastmap.  */
  preg->fastmap = re_malloc (char, SBC_MAX);
  if (BE (preg->fastmap == NULL, 0))
    return REG_ESPACE;

  syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;

  /* If REG_NEWLINE is set, newlines are treated differently.  */
  if (cflags & REG_NEWLINE)
    { /* REG_NEWLINE implies neither . nor [^...] match newline.  */
      syntax &= ~RE_DOT_NEWLINE;
      syntax |= RE_HAT_LISTS_NOT_NEWLINE;
      /* It also changes the matching behavior.  */
      preg->newline_anchor = 1;
    }
  else
    preg->newline_anchor = 0;
  preg->no_sub = !!(cflags & REG_NOSUB);
  preg->translate = NULL;

  ret = re_compile_internal (preg, pattern, strlen (pattern), syntax);

  /* POSIX doesn't distinguish between an unmatched open-group and an
     unmatched close-group: both are REG_EPAREN.  */
  if (ret == REG_ERPAREN)
    ret = REG_EPAREN;

  /* We have already checked preg->fastmap != NULL.  */
  if (BE (ret == REG_NOERROR, 1))
    /* Compute the fastmap now, since regexec cannot modify the pattern
       buffer.  This function never fails in this implementation.  */
    (void) re_compile_fastmap (preg);
  else
    {
      /* Some error occurred while compiling the expression.  */
      re_free (preg->fastmap);
      preg->fastmap = NULL;
    }

  return (int) ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t regerror ( int  __errcode,
const regex_t *_Restrict_  __preg,
char *_Restrict_  __errbuf,
size_t  __errbuf_size 
)

Definition at line 544 of file regcomp.c.

{
  const char *msg;
  size_t msg_size;

  if (BE (errcode < 0
         || errcode >= (int) (sizeof (__re_error_msgid_idx)
                            / sizeof (__re_error_msgid_idx[0])), 0))
    /* Only error codes returned by the rest of the code should be passed
       to this routine.  If we are given anything else, or if other regex
       code generates an invalid error code, then the program has a bug.
       Dump core so we can fix it.  */
    abort ();

  msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);

  msg_size = strlen (msg) + 1; /* Includes the null.  */

  if (BE (errbuf_size != 0, 1))
    {
      size_t cpy_size = msg_size;
      if (BE (msg_size > errbuf_size, 0))
       {
         cpy_size = errbuf_size - 1;
         errbuf[cpy_size] = '\0';
       }
      memcpy (errbuf, msg, cpy_size);
    }

  return msg_size;
}

Here is the caller graph for this function:

int regexec ( const regex_t *_Restrict_  __preg,
const char *_Restrict_  __string,
size_t  __nmatch,
regmatch_t  __pmatch[_Restrict_arr_],
int  __eflags 
)

Here is the caller graph for this function:

void regfree ( regex_t *  __preg)

Definition at line 658 of file regcomp.c.

{
  re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
  if (BE (dfa != NULL, 1))
    free_dfa_content (dfa);
  preg->buffer = NULL;
  preg->allocated = 0;

  re_free (preg->fastmap);
  preg->fastmap = NULL;

  re_free (preg->translate);
  preg->translate = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 250 of file regcomp.c.