ReactOS 0.4.15-dev-7674-gc0b4db1
patmatch.h
Go to the documentation of this file.
1/* @(#)patmatch.h 1.16 17/07/02 Copyright 1985,1993-2017 J. Schilling */
2
3#ifndef _SCHILY_PATMATCH_H
4#define _SCHILY_PATMATCH_H
5/*
6 * Definitions for the pattern matching functions.
7 *
8 * Copyright (c) 1985,1993-2017 J. Schilling
9 */
10/*
11 * The contents of this file are subject to the terms of the
12 * Common Development and Distribution License, Version 1.0 only
13 * (the "License"). You may not use this file except in compliance
14 * with the License.
15 *
16 * See the file CDDL.Schily.txt in this distribution for details.
17 * A copy of the CDDL is also available via the Internet at
18 * http://www.opensource.org/licenses/cddl1.txt
19 *
20 * When distributing Covered Code, include this CDDL HEADER in each
21 * file and include the License file CDDL.Schily.txt from this distribution.
22 */
23/*
24 * The pattern matching functions are based on the algorithm
25 * presented by Martin Richards in:
26 *
27 * "A Compact Function for Regular Expression Pattern Matching",
28 * Software-Practice and Experience, Vol. 9, 527-534 (1979)
29 *
30 * Several changes have been made to the original source which has been
31 * written in BCPL:
32 *
33 * '/' is replaced by '!' (to allow UNIX filenames)
34 * '(',')' are replaced by '{', '}'
35 * '\'' is replaced by '\\' (UNIX compatible quote)
36 *
37 * Character classes have been added to allow "[<character list>]"
38 * to be used.
39 * Start of line '^' and end of line '$' have been added.
40 *
41 * Any number in the following comment is zero or more occurrencies
42 */
43#ifndef _SCHILY_MCONFIG_H
44#include <schily/mconfig.h>
45#endif
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51#define ALT '!' /* Alternation in match i.e. this!that!the_other */
52#define REP '#' /* Any number of occurrences of the following expr */
53#define NIL '%' /* Empty string (exactly nothing) */
54#define STAR '*' /* Any number of any character (equivalent of #?) */
55#define ANY '?' /* Any one character */
56#define QUOTE '\\' /* Quotes the next character */
57#define LBRACK '{' /* Begin of precedence grouping */
58#define RBRACK '}' /* End of precedence grouping */
59#define LCLASS '[' /* Begin of character set */
60#define RCLASS ']' /* End of character set */
61#define NOT '^' /* If first in set: invert set content */
62#define RANGE '-' /* Range notation in sets */
63#define START '^' /* Begin of a line */
64#define END '$' /* End of a line */
65
66/*
67 * A list of case statements that may be used for a issimple() or ispattern()
68 * funtion that checks whether a string conrtains characters that need the
69 * pattern matcher.
70 *
71 * Note that this list does not contain NOT or RANGE because you need
72 * LCLASS and RCLASS in addition.
73 */
74#define casePAT case ALT: case REP: case NIL: case STAR: case ANY: \
75 case QUOTE: case LBRACK: case RBRACK: \
76 case LCLASS: case RCLASS: case START: case END:
77
78
79#define MAXPAT 128 /* Max length of pattern for opatmatch()/opatlmatch() */
80
81extern int patcompile __PR((const unsigned char *__pat, int __patlen,
82 int *__aux));
83
84extern unsigned char *opatmatch __PR((const unsigned char *__pat,
85 const int *__aux,
86 const unsigned char *__str,
87 int __soff, int __slen,
88 int __alt));
89extern unsigned char *opatlmatch __PR((const unsigned char *__pat,
90 const int *__aux,
91 const unsigned char *__str,
92 int __soff, int __slen,
93 int __alt));
94extern unsigned char *patmatch __PR((const unsigned char *__pat,
95 const int *__aux,
96 const unsigned char *__str,
97 int __soff, int __slen,
98 int __alt, int __state[]));
99extern unsigned char *patlmatch __PR((const unsigned char *__pat,
100 const int *__aux,
101 const unsigned char *__str,
102 int __soff, int __slen,
103 int __alt, int __state[]));
104
105#ifdef __cplusplus
106}
107#endif
108
109#ifdef _SCHILY_WCHAR_H
110
111#ifdef __cplusplus
112extern "C" {
113#endif
114
115extern int patwcompile __PR((const wchar_t *__pat, int __patlen,
116 int *__aux));
117extern wchar_t *patwmatch __PR((const wchar_t *__pat, const int *__aux,
118 const wchar_t *__str,
119 int __soff, int __slen,
120 int __alt, int __state[]));
121extern wchar_t *patwlmatch __PR((const wchar_t *__pat, const int *__aux,
122 const wchar_t *__str,
123 int __soff, int __slen,
124 int __alt, int __state[]));
125
126extern unsigned char *patmbmatch __PR((const wchar_t *__pat,
127 const int *__aux,
128 const unsigned char *__str,
129 int __soff, int __slen,
130 int __alt, int __state[]));
131extern unsigned char *patmblmatch __PR((const wchar_t *__pat,
132 const int *__aux,
133 const unsigned char *__str,
134 int __soff, int __slen,
135 int __alt, int __state[]));
136
137
138#ifdef __cplusplus
139}
140#endif
141#endif /* _SCHILY_WCHAR_H */
142
143#endif /* _SCHILY_PATMATCH_H */
EXPORT CHAR * patmatch(PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt, state) const
Definition: match.c:230
EXPORT CHAR * opatmatch(PCHAR *pat, const int *aux, const CHAR *str, int soff, int slen, int alt) const
Definition: match.c:209
EXPORT int patcompile(PCHAR *pat, int len, int *aux) const
Definition: match.c:584
#define __PR(a)
Definition: prototyp.h:106