2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)patmatch.h 1.10 03/08/24 Copyright 1985 J. Schilling */
18 * Definitions for the pattern matching functions.
20 * Copyright (c) 1985,1995 J. Schilling
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License version 2
25 * as published by the Free Software Foundation.
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
32 * You should have received a copy of the GNU General Public License along with
33 * this program; see the file COPYING. If not, write to the Free Software
34 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 * The pattern matching functions are based on the algorithm
38 * presented by Martin Richards in:
40 * "A Compact Function for Regular Expression Pattern Matching",
41 * Software-Practice and Experience, Vol. 9, 527-534 (1979)
43 * Several changes have been made to the original source which has been
46 * '/' is replaced by '!' (to allow UNIX filenames)
47 * '(',')' are replaced by '{', '}'
48 * '\'' is replaced by '\\' (UNIX compatible quote)
50 * Character classes have been added to allow "[<character list>]"
52 * Start of line '^' and end of line '$' have been added.
54 * Any number in the following comment is zero or more occurrencies
67 #define ALT '!' /* Alternation in match i.e. this!that!the_other */
68 #define REP '#' /* Any number of occurrences of the following expr */
69 #define NIL '%' /* Empty string (exactly nothing) */
70 #define STAR '*' /* Any number of any character (equivalent of #?) */
71 #define ANY '?' /* Any one character */
72 #define QUOTE '\\' /* Quotes the next character */
73 #define LBRACK '{' /* Begin of precedence grouping */
74 #define RBRACK '}' /* End of precedence grouping */
75 #define LCLASS '[' /* Begin of character set */
76 #define RCLASS ']' /* End of character set */
77 #define NOT '^' /* If first in set: invert set content */
78 #define RANGE '-' /* Range notation in sets */
79 #define START '^' /* Begin of a line */
80 #define END '$' /* End of a line */
83 * A list of case statements that may be used for a issimple() or ispattern()
84 * funtion that checks whether a string conrtains characters that need the
87 * Note that this list does not contain NOT or RANGE because you need
88 * LCLASS and RCLASS in addition.
90 #define casePAT case ALT: case REP: case NIL: case STAR: case ANY: \
91 case QUOTE: case LBRACK: case RBRACK: \
92 case LCLASS: case RCLASS: case START: case END:
95 #define MAXPAT 128 /* Maximum length of pattern */
97 extern int patcompile(const unsigned char *__pat, int __patlen, int *__aux);
99 extern unsigned char *opatmatch(const unsigned char *__pat, const int *__aux,
100 const unsigned char *__str, int __soff,
101 int __slen, int __alt);
102 extern unsigned char *opatlmatch(const unsigned char *__pat, const int *__aux,
103 const unsigned char *__str, int __soff,
104 int __slen, int __alt);
105 extern unsigned char *patmatch(const unsigned char *__pat, const int *__aux,
106 const unsigned char *__str, int __soff,
107 int __slen, int __alt, int __state[]);
108 extern unsigned char *patlmatch(const unsigned char *__pat, const int *__aux,
109 const unsigned char *__str, int __soff,
110 int __slen, int __alt, int __state[]);
116 #endif /* _PATMATCH_H */