ap_regex.h revision ae6c17ab51aaa6223a4bb634bf92ac0795a894fe
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * contributor license agreements. See the NOTICE file distributed with
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * this work for additional information regarding copyright ownership.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * The ASF licenses this file to You under the Apache License, Version 2.0
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * (the "License"); you may not use this file except in compliance with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the License. You may obtain a copy of the License at
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Unless required by applicable law or agreed to in writing, software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * distributed under the License is distributed on an "AS IS" BASIS,
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * See the License for the specific language governing permissions and
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * limitations under the License.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Derived from PCRE's pcreposix.h.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding Copyright (c) 1997-2004 University of Cambridge
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding-----------------------------------------------------------------------------
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingRedistribution and use in source and binary forms, with or without
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingmodification, are permitted provided that the following conditions are met:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Redistributions of source code must retain the above copyright notice,
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding this list of conditions and the following disclaimer.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * Redistributions in binary form must reproduce the above copyright
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding notice, this list of conditions and the following disclaimer in the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding documentation and/or other materials provided with the distribution.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * Neither the name of the University of Cambridge nor the names of its
64185f9824e42f21ca7b9ae6c004484215c031a7rbb contributors may be used to endorse or promote products derived from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding this software without specific prior written permission.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingPOSSIBILITY OF SUCH DAMAGE.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding-----------------------------------------------------------------------------
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * @brief Apache Regex defines
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Allow for C++ users */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingextern "C" {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Options for ap_regexec: */
90211b595b36b22a529f9f68238f77fed273e08erbb#define AP_REG_ICASE 0x01 /** use a case-insensitive match */
b0f20a4a26bcfa85724b1c2e5ec6a077f12ef44crbb#define AP_REG_NEWLINE 0x02 /** don't match newlines against '.' etc */
b4c8a80f7dbfc9b56dbe03bdc28f0b5eb5f23697rbb#define AP_REG_NOTBOL 0x04 /** ^ will not match against start-of-string */
ab5581cc78e9d865b0a6ab1404c53347b3276968rbb#define AP_REG_NOTEOL 0x08 /** $ will not match against end-of-string */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Error values: */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* The structure representing a compiled regular expression. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* The structure in which a captured offset is returned. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* The functions */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Compile a regular expression.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param preg Returned compiled regex
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param regex The regular expression string
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param cflags Bitwise OR of AP_REG_* flags (ICASE and NEWLINE supported,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * other flags are ignored)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return Zero on success or non-zero on error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Match a NUL-terminated string against a pre-compiled regex.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param preg The pre-compiled regex
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param string The string to match
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param nmatch Provide information regarding the location of any matches
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param pmatch Provide information regarding the location of any matches
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param eflags Bitwise OR of AP_REG_* flags (NOTBOL and NOTEOL supported,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * other flags are ignored)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return 0 for successful match, \p AP_REG_NOMATCH otherwise
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Return the error code returned by regcomp or regexec into error messages
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param errcode the error code returned by regexec or regcomp
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param preg The precompiled regex
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param errbuf A buffer to store the error in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param errbuf_size The size of the buffer
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/** Destroy a pre-compiled regex.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param preg The pre-compiled regex to free.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} /* extern "C" */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /* AP_REGEX_T */