1
/* @(#)patmatch.h 1.10 03/08/24 Copyright 1985 J. Schilling */
6
* Definitions for the pattern matching functions.
8
* Copyright (c) 1985,1995 J. Schilling
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2, or (at your option)
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License along with
22
* this program; see the file COPYING. If not, write to the Free Software
23
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
* The pattern matching functions are based on the algorithm
27
* presented by Martin Richards in:
29
* "A Compact Function for Regular Expression Pattern Matching",
30
* Software-Practice and Experience, Vol. 9, 527-534 (1979)
32
* Several changes have been made to the original source which has been
35
* '/' is replaced by '!' (to allow UNIX filenames)
36
* '(',')' are replaced by '{', '}'
37
* '\'' is replaced by '\\' (UNIX compatible quote)
39
* Character classes have been added to allow "[<character list>]"
41
* Start of line '^' and end of line '$' have been added.
43
* Any number in the following comment is zero or more occurrencies
56
#define ALT '!' /* Alternation in match i.e. this!that!the_other */
57
#define REP '#' /* Any number of occurrences of the following expr */
58
#define NIL '%' /* Empty string (exactly nothing) */
59
#define STAR '*' /* Any number of any character (equivalent of #?) */
60
#define ANY '?' /* Any one character */
61
#define QUOTE '\\' /* Quotes the next character */
62
#define LBRACK '{' /* Begin of precedence grouping */
63
#define RBRACK '}' /* End of precedence grouping */
64
#define LCLASS '[' /* Begin of character set */
65
#define RCLASS ']' /* End of character set */
66
#define NOT '^' /* If first in set: invert set content */
67
#define RANGE '-' /* Range notation in sets */
68
#define START '^' /* Begin of a line */
69
#define END '$' /* End of a line */
72
* A list of case statements that may be used for a issimple() or ispattern()
73
* funtion that checks whether a string conrtains characters that need the
76
* Note that this list does not contain NOT or RANGE because you need
77
* LCLASS and RCLASS in addition.
79
#define casePAT case ALT: case REP: case NIL: case STAR: case ANY: \
80
case QUOTE: case LBRACK: case RBRACK: \
81
case LCLASS: case RCLASS: case START: case END:
84
#define MAXPAT 128 /* Maximum length of pattern */
86
extern int patcompile __PR((const unsigned char * __pat, int __patlen, int * __aux));
88
extern unsigned char *opatmatch __PR((const unsigned char * __pat, const int * __aux,
89
const unsigned char * __str, int __soff, int __slen,
91
extern unsigned char *opatlmatch __PR((const unsigned char * __pat, const int * __aux,
92
const unsigned char * __str, int __soff, int __slen,
94
extern unsigned char *patmatch __PR((const unsigned char * __pat, const int * __aux,
95
const unsigned char * __str, int __soff, int __slen,
96
int __alt, int __state[]));
97
extern unsigned char *patlmatch __PR((const unsigned char * __pat, const int * __aux,
98
const unsigned char * __str, int __soff, int __slen,
99
int __alt, int __state[]));
105
#endif /* _PATMATCH_H */