Atrinik Server  4.0
Macros | Functions | Variables
re-cmp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <memory.h>
#include <limits.h>
#include <re-cmp.h>
#include <ctype.h>
#include <string.h>

Go to the source code of this file.

Functions

const char * re_cmp (const char *, const char *)
 
static int re_cmp_step (const char *, const char *, int, int)
 
static void re_init (void)
 
static int re_match_token (unsigned char, selection *)
 
static const char * re_get_token (selection *, const char *)
 

Variables

static int re_init_done = 0
 
static selectionre_token [RE_TOKEN_MAX]
 
static const char * re_substr [RE_TOKEN_MAX]
 
static unsigned int re_token_depth
 

Detailed Description

Pattern match a string, parsing some of the common RE-metacharacters.

This code is public domain, but I would appreciate to hear of improvements or even the fact that you use it in your program.

Deliberate BUGS:

Author: Kjetil T. Homme (kjeti.nosp@m.lho@.nosp@m.ifi.u.nosp@m.io.n.nosp@m.o) May 1993

Definition in file re-cmp.c.

Function Documentation

const char* re_cmp ( const char *  str,
const char *  regexp 
)

Get regular expression match.

Parameters
strString that will be matched against the regexp.
regexpRegular expression.
Returns
  • No match or error in regexp.
  • Pointer to beginning of matching string

Definition at line 76 of file re-cmp.c.

static int re_cmp_step ( const char *  str,
const char *  regexp,
int  slot,
int  matches 
)
static

Tries to match a string with a regexp.

Parameters
strString to match.
regexpPattern.
slotNumber of the token which under consideration.
matchesHow many times the token has matched.
Returns
1 if match, 0 otherwise.

Definition at line 219 of file re-cmp.c.

static const char * re_get_token ( selection sel,
const char *  regexp 
)
static

Get the first regular expression token found in regexp in sel.

Parameters
[out]selWhere to store the token.
regexpRegular expression.
Returns
  • NULL: syntax error
  • Pointer to first character past token.

Definition at line 376 of file re-cmp.c.

static void re_init ( void  )
static

Init the regular expression structures.

Definition at line 316 of file re-cmp.c.

static int re_match_token ( unsigned char  c,
selection sel 
)
static

Tests if a char matches a token.

Parameters
cChar to test.
selToken to test.
Returns
1 if matches, 0 otherwise.

Definition at line 338 of file re-cmp.c.