Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / include / patmatch.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
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).
6  *
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.
10  *
11  */
12
13 /* @(#)patmatch.h       1.10 03/08/24 Copyright 1985 J. Schilling */
14
15 #ifndef _PATMATCH_H
16 #define _PATMATCH_H
17 /*
18  *      Definitions for the pattern matching functions.
19  *
20  *      Copyright (c) 1985,1995 J. Schilling
21  */
22 /*
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.
26  *
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.
31  *
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.
35  */
36 /*
37  *      The pattern matching functions are based on the algorithm
38  *      presented by Martin Richards in:
39  *
40  *      "A Compact Function for Regular Expression Pattern Matching",
41  *      Software-Practice and Experience, Vol. 9, 527-534 (1979)
42  *
43  *      Several changes have been made to the original source which has been
44  *      written in BCPL:
45  *
46  *      '/'     is replaced by  '!'             (to allow UNIX filenames)
47  *      '(',')' are replaced by '{', '}'
48  *      '\''    is replaced by  '\\'            (UNIX compatible quote)
49  *
50  *      Character classes have been added to allow "[<character list>]"
51  *      to be used.
52  *      Start of line '^' and end of line '$' have been added.
53  *
54  *      Any number in the following comment is zero or more occurrencies
55  */
56 #ifndef _MCONFIG_H
57 #include <mconfig.h>
58 #endif
59 #ifndef _PROTOTYP_H
60 #include <prototyp.h>
61 #endif
62
63 #ifdef  __cplusplus
64 extern "C" {
65 #endif
66
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 */
81
82 /*
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
85  * pattern matcher.
86  *
87  * Note that this list does not contain NOT or RANGE because you need
88  * LCLASS and RCLASS in addition.
89  */
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:
93
94
95 #define MAXPAT  128     /* Maximum length of pattern */
96
97 extern  int patcompile(const unsigned char *__pat, int __patlen, int *__aux);
98
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[]);
111
112 #ifdef  __cplusplus
113 }
114 #endif
115
116 #endif  /* _PATMATCH_H */