apr_fnmatch.h revision 251886
1218887Sdim/* 2218887Sdim * Copyright (c) 1992, 1993 3218887Sdim * The Regents of the University of California. All rights reserved. 4218887Sdim * 5218887Sdim * Redistribution and use in source and binary forms, with or without 6218887Sdim * modification, are permitted provided that the following conditions 7218887Sdim * are met: 8218887Sdim * 1. Redistributions of source code must retain the above copyright 9218887Sdim * notice, this list of conditions and the following disclaimer. 10218887Sdim * 2. Redistributions in binary form must reproduce the above copyright 11218887Sdim * notice, this list of conditions and the following disclaimer in the 12218887Sdim * documentation and/or other materials provided with the distribution. 13218887Sdim * 3. All advertising materials mentioning features or use of this software 14218887Sdim * must display the following acknowledgement: 15249423Sdim * This product includes software developed by the University of 16249423Sdim * California, Berkeley and its contributors. 17234353Sdim * 4. Neither the name of the University nor the names of its contributors 18249423Sdim * may be used to endorse or promote products derived from this software 19218887Sdim * without specific prior written permission. 20249423Sdim * 21218887Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22218887Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23218887Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24218887Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25218887Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26218887Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27218887Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28218887Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29218887Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30234353Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31234353Sdim * SUCH DAMAGE. 32221345Sdim * 33221345Sdim * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 34218887Sdim */ 35218887Sdim 36251662Sdim/* This file has been modified by the Apache Software Foundation. */ 37221345Sdim#ifndef _APR_FNMATCH_H_ 38218887Sdim#define _APR_FNMATCH_H_ 39218887Sdim 40218887Sdim/** 41218887Sdim * @file apr_fnmatch.h 42218887Sdim * @brief APR FNMatch Functions 43218887Sdim */ 44218887Sdim 45221345Sdim#include "apr_errno.h" 46218887Sdim#include "apr_tables.h" 47218887Sdim 48218887Sdim#ifdef __cplusplus 49234353Sdimextern "C" { 50221345Sdim#endif 51234353Sdim 52218887Sdim/** 53218887Sdim * @defgroup apr_fnmatch Filename Matching Functions 54234353Sdim * @ingroup APR 55234353Sdim * @{ 56234353Sdim */ 57234353Sdim 58234353Sdim#define APR_FNM_NOMATCH 1 /**< Match failed. */ 59234353Sdim 60234353Sdim#define APR_FNM_NOESCAPE 0x01 /**< Disable backslash escaping. */ 61234353Sdim#define APR_FNM_PATHNAME 0x02 /**< Slash must be matched by slash. */ 62218887Sdim#define APR_FNM_PERIOD 0x04 /**< Period must be matched by period. */ 63221345Sdim#define APR_FNM_CASE_BLIND 0x08 /**< Compare characters case-insensitively. 64234353Sdim * @remark This flag is an Apache addition 65221345Sdim */ 66234353Sdim 67218887Sdim/** 68218887Sdim * Try to match the string to the given pattern, return APR_SUCCESS if 69234353Sdim * match, else return APR_FNM_NOMATCH. Note that there is no such thing as 70234353Sdim * an illegal pattern. 71234353Sdim * 72234353Sdim * With all flags unset, a pattern is interpreted as such: 73234353Sdim * 74234353Sdim * PATTERN: Backslash followed by any character, including another 75218887Sdim * backslash.<br/> 76221345Sdim * MATCHES: That character exactly. 77221345Sdim * 78221345Sdim * <p> 79218887Sdim * PATTERN: ?<br/> 80218887Sdim * MATCHES: Any single character. 81249423Sdim * </p> 82218887Sdim * 83218887Sdim * <p> 84221345Sdim * PATTERN: *<br/> 85218887Sdim * MATCHES: Any sequence of zero or more characters. (Note that multiple 86218887Sdim * *s in a row are equivalent to one.) 87249423Sdim * 88218887Sdim * PATTERN: Any character other than \?*[ or a \ at the end of the pattern<br/> 89218887Sdim * MATCHES: That character exactly. (Case sensitive.) 90234353Sdim * 91234353Sdim * PATTERN: [ followed by a class description followed by ]<br/> 92234353Sdim * MATCHES: A single character described by the class description. 93234353Sdim * (Never matches, if the class description reaches until the 94218887Sdim * end of the string without a ].) If the first character of 95226633Sdim * the class description is ^ or !, the sense of the description 96221345Sdim * is reversed. The rest of the class description is a list of 97218887Sdim * single characters or pairs of characters separated by -. Any 98218887Sdim * of those characters can have a backslash in front of them, 99218887Sdim * which is ignored; this lets you use the characters ] and - 100218887Sdim * in the character class, as well as ^ and ! at the 101221345Sdim * beginning. The pattern matches a single character if it 102218887Sdim * is one of the listed characters or falls into one of the 103218887Sdim * listed ranges (inclusive, case sensitive). Ranges with 104218887Sdim * the first character larger than the second are legal but 105218887Sdim * never match. Edge cases: [] never matches, and [^] and [!] 106218887Sdim * always match without consuming a character. 107218887Sdim * 108218887Sdim * Note that these patterns attempt to match the entire string, not 109251662Sdim * just find a substring matching the pattern. 110251662Sdim * 111243830Sdim * @param pattern The pattern to match to 112251662Sdim * @param strings The string we are trying to match 113251662Sdim * @param flags flags to use in the match. Bitwise OR of: 114251662Sdim * <pre> 115251662Sdim * APR_FNM_NOESCAPE Disable backslash escaping 116251662Sdim * APR_FNM_PATHNAME Slash must be matched by slash 117251662Sdim * APR_FNM_PERIOD Period must be matched by period 118251662Sdim * APR_FNM_CASE_BLIND Compare characters case-insensitively. 119251662Sdim * </pre> 120251662Sdim */ 121251662Sdim 122234353SdimAPR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern, 123218887Sdim const char *strings, int flags); 124243830Sdim 125243830Sdim/** 126243830Sdim * Determine if the given pattern is a regular expression. 127243830Sdim * @param pattern The pattern to search for glob characters. 128243830Sdim * @return non-zero if pattern has any glob characters in it 129234353Sdim */ 130218887SdimAPR_DECLARE(int) apr_fnmatch_test(const char *pattern); 131218887Sdim 132243830Sdim/** 133218887Sdim * Find all files that match a specified pattern. 134234353Sdim * @param pattern The pattern to use for finding files. 135218887Sdim * @param result Array to use when storing the results 136218887Sdim * @param p The pool to use. 137218887Sdim * @return non-zero if pattern has any glob characters in it 138218887Sdim */ 139218887SdimAPR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, 140234353Sdim apr_array_header_t **result, 141243830Sdim apr_pool_t *p); 142243830Sdim 143243830Sdim/** @} */ 144243830Sdim 145221345Sdim#ifdef __cplusplus 146218887Sdim} 147218887Sdim#endif 148243830Sdim 149234353Sdim#endif /* !_APR_FNMATCH_H_ */ 150221345Sdim