00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /* Derived from PCRE's pcreposix.h. 00018 00019 Copyright (c) 1997-2004 University of Cambridge 00020 00021 ----------------------------------------------------------------------------- 00022 Redistribution and use in source and binary forms, with or without 00023 modification, are permitted provided that the following conditions are met: 00024 00025 * Redistributions of source code must retain the above copyright notice, 00026 this list of conditions and the following disclaimer. 00027 00028 * Redistributions in binary form must reproduce the above copyright 00029 notice, this list of conditions and the following disclaimer in the 00030 documentation and/or other materials provided with the distribution. 00031 00032 * Neither the name of the University of Cambridge nor the names of its 00033 contributors may be used to endorse or promote products derived from 00034 this software without specific prior written permission. 00035 00036 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00037 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00038 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00039 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00040 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00041 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00042 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00043 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00044 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00045 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00046 POSSIBILITY OF SUCH DAMAGE. 00047 ----------------------------------------------------------------------------- 00048 */ 00049 00055 #ifndef AP_REGEX_H 00056 #define AP_REGEX_H 00057 00058 #include "apr.h" 00059 00060 /* Allow for C++ users */ 00061 00062 #ifdef __cplusplus 00063 extern "C" { 00064 #endif 00065 00066 /* Options for ap_regexec: */ 00067 00068 #define AP_REG_ICASE 0x01 00069 #define AP_REG_NEWLINE 0x02 00070 #define AP_REG_NOTBOL 0x04 00071 #define AP_REG_NOTEOL 0x08 00073 #define AP_REG_EXTENDED (0) 00074 #define AP_REG_NOSUB (0) 00076 /* Error values: */ 00077 enum { 00078 AP_REG_ASSERT = 1, 00079 AP_REG_ESPACE, 00080 AP_REG_INVARG, 00081 AP_REG_NOMATCH 00082 }; 00083 00084 /* The structure representing a compiled regular expression. */ 00085 typedef struct { 00086 void *re_pcre; 00087 apr_size_t re_nsub; 00088 apr_size_t re_erroffset; 00089 } ap_regex_t; 00090 00091 /* The structure in which a captured offset is returned. */ 00092 typedef struct { 00093 int rm_so; 00094 int rm_eo; 00095 } ap_regmatch_t; 00096 00097 /* The functions */ 00098 00106 AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags); 00107 00117 AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, 00118 apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags); 00119 00127 AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg, 00128 char *errbuf, apr_size_t errbuf_size); 00129 00133 AP_DECLARE(void) ap_regfree(ap_regex_t *preg); 00134 00135 #ifdef __cplusplus 00136 } /* extern "C" */ 00137 #endif 00138 00139 #endif /* AP_REGEX_T */ 00140