1251875Speter/*
2251875Speter * Copyright (c) 1992, 1993
3251875Speter *	The Regents of the University of California.  All rights reserved.
4251875Speter *
5251875Speter * Redistribution and use in source and binary forms, with or without
6251875Speter * modification, are permitted provided that the following conditions
7251875Speter * are met:
8251875Speter * 1. Redistributions of source code must retain the above copyright
9251875Speter *    notice, this list of conditions and the following disclaimer.
10251875Speter * 2. Redistributions in binary form must reproduce the above copyright
11251875Speter *    notice, this list of conditions and the following disclaimer in the
12251875Speter *    documentation and/or other materials provided with the distribution.
13251875Speter * 3. All advertising materials mentioning features or use of this software
14251875Speter *    must display the following acknowledgement:
15251875Speter *	This product includes software developed by the University of
16251875Speter *	California, Berkeley and its contributors.
17251875Speter * 4. Neither the name of the University nor the names of its contributors
18251875Speter *    may be used to endorse or promote products derived from this software
19251875Speter *    without specific prior written permission.
20251875Speter *
21251875Speter * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22251875Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23251875Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24251875Speter * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25251875Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26251875Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27251875Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28251875Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29251875Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30251875Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31251875Speter * SUCH DAMAGE.
32251875Speter *
33251875Speter *	@(#)fnmatch.h	8.1 (Berkeley) 6/2/93
34251875Speter */
35251875Speter
36251875Speter/* This file has been modified by the Apache Software Foundation. */
37251875Speter#ifndef	_APR_FNMATCH_H_
38251875Speter#define	_APR_FNMATCH_H_
39251875Speter
40251875Speter/**
41251875Speter * @file apr_fnmatch.h
42251875Speter * @brief APR FNMatch Functions
43251875Speter */
44251875Speter
45251875Speter#include "apr_errno.h"
46251875Speter#include "apr_tables.h"
47251875Speter
48251875Speter#ifdef __cplusplus
49251875Speterextern "C" {
50251875Speter#endif
51251875Speter
52251875Speter/**
53251875Speter * @defgroup apr_fnmatch Filename Matching Functions
54251875Speter * @ingroup APR
55251875Speter * @{
56251875Speter */
57251875Speter
58251875Speter#define APR_FNM_NOMATCH     1     /**< Match failed. */
59251875Speter
60251875Speter#define APR_FNM_NOESCAPE    0x01  /**< Disable backslash escaping. */
61251875Speter#define APR_FNM_PATHNAME    0x02  /**< Slash must be matched by slash. */
62251875Speter#define APR_FNM_PERIOD      0x04  /**< Period must be matched by period. */
63266735Speter#define APR_FNM_CASE_BLIND  0x08  /**< Compare characters case-insensitively. */
64251875Speter
65251875Speter/**
66251875Speter * Try to match the string to the given pattern, return APR_SUCCESS if
67251875Speter *    match, else return APR_FNM_NOMATCH.  Note that there is no such thing as
68251875Speter *    an illegal pattern.
69251875Speter *
70251875Speter * With all flags unset, a pattern is interpreted as such:
71251875Speter *
72251875Speter * PATTERN: Backslash followed by any character, including another
73251875Speter *          backslash.<br/>
74251875Speter * MATCHES: That character exactly.
75251875Speter *
76251875Speter * <p>
77251875Speter * PATTERN: ?<br/>
78251875Speter * MATCHES: Any single character.
79251875Speter * </p>
80251875Speter *
81251875Speter * <p>
82251875Speter * PATTERN: *<br/>
83251875Speter * MATCHES: Any sequence of zero or more characters. (Note that multiple
84251875Speter *          *s in a row are equivalent to one.)
85251875Speter *
86251875Speter * PATTERN: Any character other than \?*[ or a \ at the end of the pattern<br/>
87251875Speter * MATCHES: That character exactly. (Case sensitive.)
88251875Speter *
89251875Speter * PATTERN: [ followed by a class description followed by ]<br/>
90251875Speter * MATCHES: A single character described by the class description.
91251875Speter *          (Never matches, if the class description reaches until the
92251875Speter *          end of the string without a ].) If the first character of
93251875Speter *          the class description is ^ or !, the sense of the description
94251875Speter *          is reversed.  The rest of the class description is a list of
95251875Speter *          single characters or pairs of characters separated by -. Any
96251875Speter *          of those characters can have a backslash in front of them,
97251875Speter *          which is ignored; this lets you use the characters ] and -
98251875Speter *          in the character class, as well as ^ and ! at the
99251875Speter *          beginning.  The pattern matches a single character if it
100251875Speter *          is one of the listed characters or falls into one of the
101251875Speter *          listed ranges (inclusive, case sensitive).  Ranges with
102251875Speter *          the first character larger than the second are legal but
103251875Speter *          never match. Edge cases: [] never matches, and [^] and [!]
104251875Speter *          always match without consuming a character.
105251875Speter *
106251875Speter * Note that these patterns attempt to match the entire string, not
107251875Speter * just find a substring matching the pattern.
108251875Speter *
109251875Speter * @param pattern The pattern to match to
110251875Speter * @param strings The string we are trying to match
111251875Speter * @param flags flags to use in the match.  Bitwise OR of:
112251875Speter * <pre>
113251875Speter *              APR_FNM_NOESCAPE       Disable backslash escaping
114251875Speter *              APR_FNM_PATHNAME       Slash must be matched by slash
115251875Speter *              APR_FNM_PERIOD         Period must be matched by period
116251875Speter *              APR_FNM_CASE_BLIND     Compare characters case-insensitively.
117251875Speter * </pre>
118251875Speter */
119251875Speter
120251875SpeterAPR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern,
121251875Speter                                      const char *strings, int flags);
122251875Speter
123251875Speter/**
124251875Speter * Determine if the given pattern is a regular expression.
125251875Speter * @param pattern The pattern to search for glob characters.
126251875Speter * @return non-zero if pattern has any glob characters in it
127251875Speter */
128251875SpeterAPR_DECLARE(int) apr_fnmatch_test(const char *pattern);
129251875Speter
130251875Speter/**
131266735Speter * Find all files that match a specified pattern in a directory.
132266735Speter * @param dir_pattern The pattern to use for finding files, appended
133266735Speter * to the search directory.  The pattern is anything following the
134266735Speter * final forward or backward slash in the parameter.  If no slash
135266735Speter * is found, the current directory is searched.
136251875Speter * @param result Array to use when storing the results
137251875Speter * @param p The pool to use.
138266735Speter * @return APR_SUCCESS if no processing errors occurred, APR error
139266735Speter * code otherwise
140266735Speter * @remark The returned array may be empty even if APR_SUCCESS was
141266735Speter * returned.
142251875Speter */
143266735SpeterAPR_DECLARE(apr_status_t) apr_match_glob(const char *dir_pattern,
144251875Speter                                         apr_array_header_t **result,
145251875Speter                                         apr_pool_t *p);
146251875Speter
147251875Speter/** @} */
148251875Speter
149251875Speter#ifdef __cplusplus
150251875Speter}
151251875Speter#endif
152251875Speter
153251875Speter#endif /* !_APR_FNMATCH_H_ */
154