Atrinik Server 2.5
Defines | Functions | Variables
server/re-cmp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <limits.h>
#include <re-cmp.h>
#include <ctype.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 (kjetilho@ifi.uio.no) 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 69 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 223 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 387 of file re-cmp.c.

static void re_init ( ) [static]

Init the regular expression structures.

Definition at line 332 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 351 of file re-cmp.c.