mirror of
https://github.com/apache/httpd.git
synced 2025-07-29 09:01:18 +03:00
Move the POSIX reg* implementations into the ap_* namespace;
internalise the ap_reg*<->PCRE wrapper: * configure.in: Add srclib/pcre to the include path. * include/ap_regex.h: Renamed from include/pcreposix.h. Prefix all constants with AP_; prefix all functions and types with ap_. Define AP_DECLARE to nothing if necessary. Remove regcomp error codes. * include/httpd.h: Include ap_regex.h not pcreposix.h. (ap_pregcomp, ap_regexec, ap_regfree): s/regex_t/ap_regex_t/. (ap_regexec, ap_regerror): Prototypes moved to ap_regex.h. * server/util.c (regex_cleanup, ap_pregcomp, ap_pregsub, ap_pregfree): Adjust for ap_ prefixed types. (ap_regexec, ap_regerror): Removed. * server/Makefile.in: Build util_pcre.c. * server/util_pcre.c: Copied from srclib/pcre/pcreposix.c; remove use of PCRE-internals to do error mapping; rename types to add AP_/ap_ prefixes as above. Use APR includes. (ap_regerror): Use apr_snprintf. * srclib/pcre/Makefile.in: Don't build pcreposix.c into libpcre.la. * modules/*: Update to use new type and constant names. PR: 27750 (part one) Submitted by: Andres Salomon <dilinger voxel.net>, Joe Orton git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@153384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@ -512,6 +512,7 @@ APACHE_HELP_STRING(--with-suexec-umask,umask for suexec'd process),[
|
|||||||
|
|
||||||
dnl AP_LIBS specifies the actual libraries. note we have some required libs.
|
dnl AP_LIBS specifies the actual libraries. note we have some required libs.
|
||||||
AP_LIBS="$abs_builddir/srclib/pcre/libpcre.la $AP_LIBS"
|
AP_LIBS="$abs_builddir/srclib/pcre/libpcre.la $AP_LIBS"
|
||||||
|
APR_ADDTO(CPPFLAGS, [-I$abs_builddir/srclib/pcre])
|
||||||
|
|
||||||
dnl APR should go after the other libs, so the right symbols can be picked up
|
dnl APR should go after the other libs, so the right symbols can be picked up
|
||||||
AP_LIBS="$AP_LIBS `$apu_config --link-libtool --libs` `$apr_config --link-libtool --libs`"
|
AP_LIBS="$AP_LIBS `$apu_config --link-libtool --libs` `$apr_config --link-libtool --libs`"
|
||||||
|
@ -86,12 +86,15 @@
|
|||||||
* ap_setup_prelinked_modules, ap_process_resource_config
|
* ap_setup_prelinked_modules, ap_process_resource_config
|
||||||
* 20040425.1 (2.1.0-dev) Added ap_module_symbol_t and ap_prelinked_module_symbols
|
* 20040425.1 (2.1.0-dev) Added ap_module_symbol_t and ap_prelinked_module_symbols
|
||||||
* 20050101.0 (2.1.2-dev) Axed misnamed http_method for http_scheme (which it was!)
|
* 20050101.0 (2.1.2-dev) Axed misnamed http_method for http_scheme (which it was!)
|
||||||
|
* 20050127.0 (2.1.3-dev) renamed regex_t->ap_regex_t, regmatch_t->ap_regmatch_t,
|
||||||
|
* REG_*->AP_REG_*, removed reg* in place of ap_reg*;
|
||||||
|
* added ap_regex.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
|
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
|
||||||
|
|
||||||
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
#ifndef MODULE_MAGIC_NUMBER_MAJOR
|
||||||
#define MODULE_MAGIC_NUMBER_MAJOR 20050101
|
#define MODULE_MAGIC_NUMBER_MAJOR 20050127
|
||||||
#endif
|
#endif
|
||||||
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
|
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
|
||||||
|
|
||||||
|
145
include/ap_regex.h
Normal file
145
include/ap_regex.h
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
|
||||||
|
* applicable.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This is the header for the POSIX wrapper interface to the PCRE Perl-
|
||||||
|
Compatible Regular Expression library. It defines the things POSIX says should
|
||||||
|
be there. I hope.
|
||||||
|
|
||||||
|
Copyright (c) 1997-2004 University of Cambridge
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the University of Cambridge nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef AP_REGEX_H
|
||||||
|
#define AP_REGEX_H
|
||||||
|
|
||||||
|
/* Have to include stdlib.h in order to ensure that size_t is defined. */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
/* Allow for C++ users */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Options for ap_regexec: */
|
||||||
|
|
||||||
|
#define AP_REG_ICASE 0x01 /** use a case-insensitive match */
|
||||||
|
#define AP_REG_NEWLINE 0x02 /** don't match newlines against '.' etc */
|
||||||
|
#define AP_REG_NOTBOL 0x04 /** ^ will not match against start-of-string */
|
||||||
|
#define AP_REG_NOTEOL 0x08 /** $ will not match against end-of-string */
|
||||||
|
|
||||||
|
#define AP_REG_EXTENDED (0) /** unused */
|
||||||
|
#define AP_REG_NOSUB (0) /** unused */
|
||||||
|
|
||||||
|
/* Error values: */
|
||||||
|
enum {
|
||||||
|
AP_REG_ASSERT = 1, /** internal error ? */
|
||||||
|
AP_REG_ESPACE, /** failed to get memory */
|
||||||
|
AP_REG_INVARG, /** invalid argument */
|
||||||
|
AP_REG_NOMATCH /** match failed */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The structure representing a compiled regular expression. */
|
||||||
|
typedef struct {
|
||||||
|
void *re_pcre;
|
||||||
|
size_t re_nsub;
|
||||||
|
size_t re_erroffset;
|
||||||
|
} ap_regex_t;
|
||||||
|
|
||||||
|
typedef int regoff_t;
|
||||||
|
|
||||||
|
/* The structure in which a captured offset is returned. */
|
||||||
|
typedef struct {
|
||||||
|
regoff_t rm_so;
|
||||||
|
regoff_t rm_eo;
|
||||||
|
} ap_regmatch_t;
|
||||||
|
|
||||||
|
#ifndef AP_DECLARE
|
||||||
|
#define AP_DECLARE(x) x
|
||||||
|
#endif /* AP_DECLARE */
|
||||||
|
|
||||||
|
/* The functions */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile a regeular expression.
|
||||||
|
* @param preg Returned compiled regex
|
||||||
|
* @param regex The regular expression string
|
||||||
|
* @param cflags Must be zero (currently).
|
||||||
|
* @return Zero on success or non-zero on error
|
||||||
|
*/
|
||||||
|
AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match a null-terminated string against a pre-compiled regex.
|
||||||
|
* @param preg The pre-compiled regex
|
||||||
|
* @param string The string to match
|
||||||
|
* @param nmatch Provide information regarding the location of any matches
|
||||||
|
* @param pmatch Provide information regarding the location of any matches
|
||||||
|
* @param eflags Bitwise OR of any of AP_REG_* flags
|
||||||
|
* @return 0 for successful match, #REG_NOMATCH otherwise
|
||||||
|
*/
|
||||||
|
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
|
||||||
|
size_t nmatch, ap_regmatch_t *pmatch, int eflags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the error code returned by regcomp or regexec into error messages
|
||||||
|
* @param errcode the error code returned by regexec or regcomp
|
||||||
|
* @param preg The precompiled regex
|
||||||
|
* @param errbuf A buffer to store the error in
|
||||||
|
* @param errbuf_size The size of the buffer
|
||||||
|
*/
|
||||||
|
AP_DECLARE(size_t) ap_regerror(int errcode, const ap_regex_t *preg,
|
||||||
|
char *errbuf, size_t errbuf_size);
|
||||||
|
|
||||||
|
/** Destroy a pre-compiled regex.
|
||||||
|
* @param preg The pre-compiled regex to free.
|
||||||
|
*/
|
||||||
|
AP_DECLARE(void) ap_regfree(ap_regex_t *preg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* AP_REGEX_T */
|
||||||
|
|
@ -489,7 +489,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Access control */
|
/* Access control */
|
||||||
apr_array_header_t *sec_file;
|
apr_array_header_t *sec_file;
|
||||||
regex_t *r;
|
ap_regex_t *r;
|
||||||
|
|
||||||
const char *mime_type; /* forced with ForceType */
|
const char *mime_type; /* forced with ForceType */
|
||||||
const char *handler; /* forced with SetHandler */
|
const char *handler; /* forced with SetHandler */
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "pcreposix.h"
|
#include "ap_regex.h"
|
||||||
|
|
||||||
/* Note: util_uri.h is also included, see below */
|
/* Note: util_uri.h is also included, see below */
|
||||||
|
|
||||||
@ -1541,40 +1541,15 @@ AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string);
|
|||||||
* @li #REG_NEWLINE - Match-any-character operators don't match new-line
|
* @li #REG_NEWLINE - Match-any-character operators don't match new-line
|
||||||
* @return The compiled regular expression
|
* @return The compiled regular expression
|
||||||
*/
|
*/
|
||||||
AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
|
AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
|
||||||
int cflags);
|
int cflags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the memory associated with a compiled regular expression
|
* Free the memory associated with a compiled regular expression
|
||||||
* @param p The pool the regex was allocated from
|
* @param p The pool the regex was allocated from
|
||||||
* @param reg The regular expression to free
|
* @param reg The regular expression to free
|
||||||
*/
|
*/
|
||||||
AP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t *reg);
|
AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
|
||||||
|
|
||||||
/**
|
|
||||||
* Match a null-terminated string against a pre-compiled regex.
|
|
||||||
* @param preg The pre-compiled regex
|
|
||||||
* @param string The string to match
|
|
||||||
* @param nmatch Provide information regarding the location of any matches
|
|
||||||
* @param pmatch Provide information regarding the location of any matches
|
|
||||||
* @param eflags Bitwise or of any of:
|
|
||||||
* @li #REG_NOTBOL - match-beginning-of-line operator always
|
|
||||||
* fails to match
|
|
||||||
* @li #REG_NOTEOL - match-end-of-line operator always fails to match
|
|
||||||
* @return 0 for successful match, #REG_NOMATCH otherwise
|
|
||||||
*/
|
|
||||||
AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string,
|
|
||||||
size_t nmatch, regmatch_t pmatch[], int eflags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the error code returned by regcomp or regexec into error messages
|
|
||||||
* @param errcode the error code returned by regexec or regcomp
|
|
||||||
* @param preg The precompiled regex
|
|
||||||
* @param errbuf A buffer to store the error in
|
|
||||||
* @param errbuf_size The size of the buffer
|
|
||||||
*/
|
|
||||||
AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg,
|
|
||||||
char *errbuf, size_t errbuf_size);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After performing a successful regex match, you may use this function to
|
* After performing a successful regex match, you may use this function to
|
||||||
@ -1588,7 +1563,7 @@ AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg,
|
|||||||
* @param pmatch the pmatch array returned from ap_pregex
|
* @param pmatch the pmatch array returned from ap_pregex
|
||||||
*/
|
*/
|
||||||
AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
|
AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
|
||||||
size_t nmatch, regmatch_t pmatch[]);
|
size_t nmatch, ap_regmatch_t pmatch[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We want to downcase the type/subtype for comparison purposes
|
* We want to downcase the type/subtype for comparison purposes
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
/*************************************************
|
|
||||||
* Perl-Compatible Regular Expressions *
|
|
||||||
*************************************************/
|
|
||||||
|
|
||||||
#ifndef _PCREPOSIX_H
|
|
||||||
#define _PCREPOSIX_H
|
|
||||||
|
|
||||||
/* This is the header for the POSIX wrapper interface to the PCRE Perl-
|
|
||||||
Compatible Regular Expression library. It defines the things POSIX says should
|
|
||||||
be there. I hope.
|
|
||||||
|
|
||||||
Copyright (c) 1997-2004 University of Cambridge
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the University of Cambridge nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
-----------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Have to include stdlib.h in order to ensure that size_t is defined. */
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* Allow for C++ users */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Options defined by POSIX. */
|
|
||||||
|
|
||||||
#define REG_ICASE 0x01
|
|
||||||
#define REG_NEWLINE 0x02
|
|
||||||
#define REG_NOTBOL 0x04
|
|
||||||
#define REG_NOTEOL 0x08
|
|
||||||
|
|
||||||
/* These are not used by PCRE, but by defining them we make it easier
|
|
||||||
to slot PCRE into existing programs that make POSIX calls. */
|
|
||||||
|
|
||||||
#define REG_EXTENDED 0
|
|
||||||
#define REG_NOSUB 0
|
|
||||||
|
|
||||||
/* Error values. Not all these are relevant or used by the wrapper. */
|
|
||||||
|
|
||||||
enum {
|
|
||||||
REG_ASSERT = 1, /* internal error ? */
|
|
||||||
REG_BADBR, /* invalid repeat counts in {} */
|
|
||||||
REG_BADPAT, /* pattern error */
|
|
||||||
REG_BADRPT, /* ? * + invalid */
|
|
||||||
REG_EBRACE, /* unbalanced {} */
|
|
||||||
REG_EBRACK, /* unbalanced [] */
|
|
||||||
REG_ECOLLATE, /* collation error - not relevant */
|
|
||||||
REG_ECTYPE, /* bad class */
|
|
||||||
REG_EESCAPE, /* bad escape sequence */
|
|
||||||
REG_EMPTY, /* empty expression */
|
|
||||||
REG_EPAREN, /* unbalanced () */
|
|
||||||
REG_ERANGE, /* bad range inside [] */
|
|
||||||
REG_ESIZE, /* expression too big */
|
|
||||||
REG_ESPACE, /* failed to get memory */
|
|
||||||
REG_ESUBREG, /* bad back reference */
|
|
||||||
REG_INVARG, /* bad argument */
|
|
||||||
REG_NOMATCH /* match failed */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* The structure representing a compiled regular expression. */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void *re_pcre;
|
|
||||||
size_t re_nsub;
|
|
||||||
size_t re_erroffset;
|
|
||||||
} regex_t;
|
|
||||||
|
|
||||||
/* The structure in which a captured offset is returned. */
|
|
||||||
|
|
||||||
typedef int regoff_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
regoff_t rm_so;
|
|
||||||
regoff_t rm_eo;
|
|
||||||
} regmatch_t;
|
|
||||||
|
|
||||||
/* The functions */
|
|
||||||
|
|
||||||
extern int regcomp(regex_t *, const char *, int);
|
|
||||||
extern int regexec(const regex_t *, const char *, size_t, regmatch_t *, int);
|
|
||||||
extern size_t regerror(int, const regex_t *, char *, size_t);
|
|
||||||
extern void regfree(regex_t *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
} /* extern "C" */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* End of pcreposix.h */
|
|
@ -66,7 +66,7 @@ struct ap_filter_provider_t {
|
|||||||
/** The dispatch match itself - union member depends on match_type */
|
/** The dispatch match itself - union member depends on match_type */
|
||||||
union {
|
union {
|
||||||
const char *string;
|
const char *string;
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
int number;
|
int number;
|
||||||
} match;
|
} match;
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ static int filter_lookup(ap_filter_t *f, ap_filter_rec_t *filter)
|
|||||||
break;
|
break;
|
||||||
case REGEX_MATCH:
|
case REGEX_MATCH:
|
||||||
if (ap_regexec(provider->match.regex, str, 0, NULL, 0)
|
if (ap_regexec(provider->match.regex, str, 0, NULL, 0)
|
||||||
== REG_NOMATCH) {
|
== AP_REG_NOMATCH) {
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -590,10 +590,10 @@ static const char *filter_provider(cmd_parms *cmd, void *CFG, const char *args)
|
|||||||
if (!rxend) {
|
if (!rxend) {
|
||||||
return "Bad regexp syntax";
|
return "Bad regexp syntax";
|
||||||
}
|
}
|
||||||
flags = REG_NOSUB; /* we're not mod_rewrite:-) */
|
flags = AP_REG_NOSUB; /* we're not mod_rewrite:-) */
|
||||||
for (c = rxend+1; *c; ++c) {
|
for (c = rxend+1; *c; ++c) {
|
||||||
switch (*c) {
|
switch (*c) {
|
||||||
case 'i': flags |= REG_ICASE; break;
|
case 'i': flags |= AP_REG_ICASE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
provider->match.regex = ap_pregcomp(cmd->pool,
|
provider->match.regex = ap_pregcomp(cmd->pool,
|
||||||
|
@ -155,7 +155,7 @@ typedef struct {
|
|||||||
const char *source;
|
const char *source;
|
||||||
const char *rexp;
|
const char *rexp;
|
||||||
apr_size_t nsub;
|
apr_size_t nsub;
|
||||||
regmatch_t match[AP_MAX_REG_MATCH];
|
ap_regmatch_t match[AP_MAX_REG_MATCH];
|
||||||
} backref_t;
|
} backref_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -917,11 +917,11 @@ static char *ap_ssi_parse_string(include_ctx_t *ctx, const char *in, char *out,
|
|||||||
static APR_INLINE int re_check(include_ctx_t *ctx, const char *string,
|
static APR_INLINE int re_check(include_ctx_t *ctx, const char *string,
|
||||||
const char *rexp)
|
const char *rexp)
|
||||||
{
|
{
|
||||||
regex_t *compiled;
|
ap_regex_t *compiled;
|
||||||
backref_t *re = ctx->intern->re;
|
backref_t *re = ctx->intern->re;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
compiled = ap_pregcomp(ctx->dpool, rexp, REG_EXTENDED);
|
compiled = ap_pregcomp(ctx->dpool, rexp, AP_REG_EXTENDED);
|
||||||
if (!compiled) {
|
if (!compiled) {
|
||||||
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->intern->r, "unable to "
|
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, ctx->intern->r, "unable to "
|
||||||
"compile pattern \"%s\"", rexp);
|
"compile pattern \"%s\"", rexp);
|
||||||
|
@ -40,7 +40,7 @@ typedef struct {
|
|||||||
const char *real;
|
const char *real;
|
||||||
const char *fake;
|
const char *fake;
|
||||||
char *handler;
|
char *handler;
|
||||||
regex_t *regexp;
|
ap_regex_t *regexp;
|
||||||
int redir_status; /* 301, 302, 303, 410, etc */
|
int redir_status; /* 301, 302, 303, 410, etc */
|
||||||
} alias_entry;
|
} alias_entry;
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ static const char *add_alias_internal(cmd_parms *cmd, void *dummy,
|
|||||||
/* XX r can NOT be relative to DocumentRoot here... compat bug. */
|
/* XX r can NOT be relative to DocumentRoot here... compat bug. */
|
||||||
|
|
||||||
if (use_regex) {
|
if (use_regex) {
|
||||||
new->regexp = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
|
new->regexp = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
|
||||||
if (new->regexp == NULL)
|
if (new->regexp == NULL)
|
||||||
return "Regular expression could not be compiled.";
|
return "Regular expression could not be compiled.";
|
||||||
new->real = r;
|
new->real = r;
|
||||||
@ -176,7 +176,7 @@ static const char *add_redirect_internal(cmd_parms *cmd,
|
|||||||
alias_server_conf *serverconf = ap_get_module_config(s->module_config,
|
alias_server_conf *serverconf = ap_get_module_config(s->module_config,
|
||||||
&alias_module);
|
&alias_module);
|
||||||
int status = (int) (long) cmd->info;
|
int status = (int) (long) cmd->info;
|
||||||
regex_t *r = NULL;
|
ap_regex_t *r = NULL;
|
||||||
const char *f = arg2;
|
const char *f = arg2;
|
||||||
const char *url = arg3;
|
const char *url = arg3;
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ static const char *add_redirect_internal(cmd_parms *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (use_regex) {
|
if (use_regex) {
|
||||||
r = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
|
r = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return "Regular expression could not be compiled.";
|
return "Regular expression could not be compiled.";
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ static char *try_alias_list(request_rec *r, apr_array_header_t *aliases,
|
|||||||
int doesc, int *status)
|
int doesc, int *status)
|
||||||
{
|
{
|
||||||
alias_entry *entries = (alias_entry *) aliases->elts;
|
alias_entry *entries = (alias_entry *) aliases->elts;
|
||||||
regmatch_t regm[AP_MAX_REG_MATCH];
|
ap_regmatch_t regm[AP_MAX_REG_MATCH];
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ typedef enum {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char *input; /* Input string of RewriteCond */
|
char *input; /* Input string of RewriteCond */
|
||||||
char *pattern; /* the RegExp pattern string */
|
char *pattern; /* the RegExp pattern string */
|
||||||
regex_t *regexp; /* the precompiled regexp */
|
ap_regex_t *regexp; /* the precompiled regexp */
|
||||||
int flags; /* Flags which control the match */
|
int flags; /* Flags which control the match */
|
||||||
pattern_type ptype; /* pattern type */
|
pattern_type ptype; /* pattern type */
|
||||||
} rewritecond_entry;
|
} rewritecond_entry;
|
||||||
@ -259,7 +259,7 @@ typedef struct data_item {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
apr_array_header_t *rewriteconds;/* the corresponding RewriteCond entries */
|
apr_array_header_t *rewriteconds;/* the corresponding RewriteCond entries */
|
||||||
char *pattern; /* the RegExp pattern string */
|
char *pattern; /* the RegExp pattern string */
|
||||||
regex_t *regexp; /* the RegExp pattern compilation */
|
ap_regex_t *regexp; /* the RegExp pattern compilation */
|
||||||
char *output; /* the Substitution string */
|
char *output; /* the Substitution string */
|
||||||
int flags; /* Flags which control the substitution */
|
int flags; /* Flags which control the substitution */
|
||||||
char *forced_mimetype; /* forced MIME type of substitution */
|
char *forced_mimetype; /* forced MIME type of substitution */
|
||||||
@ -318,7 +318,7 @@ typedef struct {
|
|||||||
typedef struct backrefinfo {
|
typedef struct backrefinfo {
|
||||||
char *source;
|
char *source;
|
||||||
int nsub;
|
int nsub;
|
||||||
regmatch_t regmatch[AP_MAX_REG_MATCH];
|
ap_regmatch_t regmatch[AP_MAX_REG_MATCH];
|
||||||
} backrefinfo;
|
} backrefinfo;
|
||||||
|
|
||||||
/* single linked list used for
|
/* single linked list used for
|
||||||
@ -3046,7 +3046,7 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
|
|||||||
char *str = apr_pstrdup(cmd->pool, in_str);
|
char *str = apr_pstrdup(cmd->pool, in_str);
|
||||||
rewrite_server_conf *sconf;
|
rewrite_server_conf *sconf;
|
||||||
rewritecond_entry *newcond;
|
rewritecond_entry *newcond;
|
||||||
regex_t *regexp;
|
ap_regex_t *regexp;
|
||||||
char *a1;
|
char *a1;
|
||||||
char *a2;
|
char *a2;
|
||||||
char *a3;
|
char *a3;
|
||||||
@ -3133,8 +3133,8 @@ static const char *cmd_rewritecond(cmd_parms *cmd, void *in_dconf,
|
|||||||
|
|
||||||
if (!newcond->ptype) {
|
if (!newcond->ptype) {
|
||||||
regexp = ap_pregcomp(cmd->pool, a2,
|
regexp = ap_pregcomp(cmd->pool, a2,
|
||||||
REG_EXTENDED | ((newcond->flags & CONDFLAG_NOCASE)
|
AP_REG_EXTENDED | ((newcond->flags & CONDFLAG_NOCASE)
|
||||||
? REG_ICASE : 0));
|
? AP_REG_ICASE : 0));
|
||||||
if (!regexp) {
|
if (!regexp) {
|
||||||
return apr_pstrcat(cmd->pool, "RewriteCond: cannot compile regular "
|
return apr_pstrcat(cmd->pool, "RewriteCond: cannot compile regular "
|
||||||
"expression '", a2, "'", NULL);
|
"expression '", a2, "'", NULL);
|
||||||
@ -3374,7 +3374,7 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
|
|||||||
char *str = apr_pstrdup(cmd->pool, in_str);
|
char *str = apr_pstrdup(cmd->pool, in_str);
|
||||||
rewrite_server_conf *sconf;
|
rewrite_server_conf *sconf;
|
||||||
rewriterule_entry *newrule;
|
rewriterule_entry *newrule;
|
||||||
regex_t *regexp;
|
ap_regex_t *regexp;
|
||||||
char *a1;
|
char *a1;
|
||||||
char *a2;
|
char *a2;
|
||||||
char *a3;
|
char *a3;
|
||||||
@ -3419,9 +3419,9 @@ static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
|
|||||||
++a1;
|
++a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
regexp = ap_pregcomp(cmd->pool, a1, REG_EXTENDED |
|
regexp = ap_pregcomp(cmd->pool, a1, AP_REG_EXTENDED |
|
||||||
((newrule->flags & RULEFLAG_NOCASE)
|
((newrule->flags & RULEFLAG_NOCASE)
|
||||||
? REG_ICASE : 0));
|
? AP_REG_ICASE : 0));
|
||||||
if (!regexp) {
|
if (!regexp) {
|
||||||
return apr_pstrcat(cmd->pool,
|
return apr_pstrcat(cmd->pool,
|
||||||
"RewriteRule: cannot compile regular expression '",
|
"RewriteRule: cannot compile regular expression '",
|
||||||
@ -3493,7 +3493,7 @@ static int apply_rewrite_cond(rewritecond_entry *p, rewrite_ctx *ctx)
|
|||||||
char *input = do_expand(p->input, ctx);
|
char *input = do_expand(p->input, ctx);
|
||||||
apr_finfo_t sb;
|
apr_finfo_t sb;
|
||||||
request_rec *rsub, *r = ctx->r;
|
request_rec *rsub, *r = ctx->r;
|
||||||
regmatch_t regmatch[AP_MAX_REG_MATCH];
|
ap_regmatch_t regmatch[AP_MAX_REG_MATCH];
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
switch (p->ptype) {
|
switch (p->ptype) {
|
||||||
@ -3646,7 +3646,7 @@ static APR_INLINE void force_type_handler(rewriterule_entry *p,
|
|||||||
*/
|
*/
|
||||||
static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
|
static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
|
||||||
{
|
{
|
||||||
regmatch_t regmatch[AP_MAX_REG_MATCH];
|
ap_regmatch_t regmatch[AP_MAX_REG_MATCH];
|
||||||
apr_array_header_t *rewriteconds;
|
apr_array_header_t *rewriteconds;
|
||||||
rewritecond_entry *conds;
|
rewritecond_entry *conds;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
|
@ -117,7 +117,7 @@ typedef struct {
|
|||||||
hdr_actions action;
|
hdr_actions action;
|
||||||
const char *header;
|
const char *header;
|
||||||
apr_array_header_t *ta; /* Array of format_tag structs */
|
apr_array_header_t *ta; /* Array of format_tag structs */
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
const char *condition_var;
|
const char *condition_var;
|
||||||
} header_entry;
|
} header_entry;
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (new->action == hdr_echo) {
|
else if (new->action == hdr_echo) {
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
if (envclause) {
|
if (envclause) {
|
||||||
@ -419,7 +419,7 @@ static APR_INLINE const char *header_inout_cmd(cmd_parms *cmd,
|
|||||||
return "Header echo only valid on Header "
|
return "Header echo only valid on Header "
|
||||||
"directives";
|
"directives";
|
||||||
else {
|
else {
|
||||||
regex = ap_pregcomp(cmd->pool, hdr, REG_EXTENDED | REG_NOSUB);
|
regex = ap_pregcomp(cmd->pool, hdr, AP_REG_EXTENDED | AP_REG_NOSUB);
|
||||||
if (regex == NULL) {
|
if (regex == NULL) {
|
||||||
return "Header echo regex could not be compiled";
|
return "Header echo regex could not be compiled";
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ enum special {
|
|||||||
};
|
};
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name; /* header name */
|
char *name; /* header name */
|
||||||
regex_t *pnamereg; /* compiled header name regex */
|
ap_regex_t *pnamereg; /* compiled header name regex */
|
||||||
char *regex; /* regex to match against */
|
char *regex; /* regex to match against */
|
||||||
regex_t *preg; /* compiled regex */
|
ap_regex_t *preg; /* compiled regex */
|
||||||
const apr_strmatch_pattern *pattern; /* non-regex pattern to match */
|
const apr_strmatch_pattern *pattern; /* non-regex pattern to match */
|
||||||
apr_table_t *features; /* env vars to set (or unset) */
|
apr_table_t *features; /* env vars to set (or unset) */
|
||||||
enum special special_type; /* is it a "special" header ? */
|
enum special special_type; /* is it a "special" header ? */
|
||||||
@ -159,7 +159,7 @@ static void *merge_setenvif_config(apr_pool_t *p, void *basev, void *overridesv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* any non-NULL magic constant will do... used to indicate if REG_ICASE should
|
* any non-NULL magic constant will do... used to indicate if AP_REG_ICASE should
|
||||||
* be used
|
* be used
|
||||||
*/
|
*/
|
||||||
#define ICASE_MAGIC ((void *)(&setenvif_module))
|
#define ICASE_MAGIC ((void *)(&setenvif_module))
|
||||||
@ -171,8 +171,8 @@ static int is_header_regex(apr_pool_t *p, const char* name)
|
|||||||
* -,_,[A-Z\, [a-z] and [0-9].
|
* -,_,[A-Z\, [a-z] and [0-9].
|
||||||
* assume the header name is a regular expression.
|
* assume the header name is a regular expression.
|
||||||
*/
|
*/
|
||||||
regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
|
ap_regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
|
||||||
(REG_EXTENDED | REG_NOSUB ));
|
(AP_REG_EXTENDED | AP_REG_NOSUB ));
|
||||||
ap_assert(preg != NULL);
|
ap_assert(preg != NULL);
|
||||||
|
|
||||||
if (ap_regexec(preg, name, 0, NULL, 0)) {
|
if (ap_regexec(preg, name, 0, NULL, 0)) {
|
||||||
@ -318,7 +318,7 @@ static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
new->preg = ap_pregcomp(cmd->pool, regex,
|
new->preg = ap_pregcomp(cmd->pool, regex,
|
||||||
(REG_EXTENDED | (icase ? REG_ICASE : 0)));
|
(AP_REG_EXTENDED | (icase ? AP_REG_ICASE : 0)));
|
||||||
if (new->preg == NULL) {
|
if (new->preg == NULL) {
|
||||||
return apr_pstrcat(cmd->pool, cmd->cmd->name,
|
return apr_pstrcat(cmd->pool, cmd->cmd->name,
|
||||||
" regex could not be compiled.", NULL);
|
" regex could not be compiled.", NULL);
|
||||||
@ -354,8 +354,8 @@ static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
|
|||||||
*/
|
*/
|
||||||
if (is_header_regex(cmd->pool, fname)) {
|
if (is_header_regex(cmd->pool, fname)) {
|
||||||
new->pnamereg = ap_pregcomp(cmd->pool, fname,
|
new->pnamereg = ap_pregcomp(cmd->pool, fname,
|
||||||
(REG_EXTENDED | REG_NOSUB
|
(AP_REG_EXTENDED | AP_REG_NOSUB
|
||||||
| (icase ? REG_ICASE : 0)));
|
| (icase ? AP_REG_ICASE : 0)));
|
||||||
if (new->pnamereg == NULL)
|
if (new->pnamereg == NULL)
|
||||||
return apr_pstrcat(cmd->pool, cmd->cmd->name,
|
return apr_pstrcat(cmd->pool, cmd->cmd->name,
|
||||||
"Header name regex could not be "
|
"Header name regex could not be "
|
||||||
@ -453,7 +453,7 @@ static int match_headers(request_rec *r)
|
|||||||
apr_size_t val_len = 0;
|
apr_size_t val_len = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
char *last_name;
|
char *last_name;
|
||||||
regmatch_t regm[AP_MAX_REG_MATCH];
|
ap_regmatch_t regm[AP_MAX_REG_MATCH];
|
||||||
|
|
||||||
if (!ap_get_module_config(r->request_config, &setenvif_module)) {
|
if (!ap_get_module_config(r->request_config, &setenvif_module)) {
|
||||||
ap_set_module_config(r->request_config, &setenvif_module,
|
ap_set_module_config(r->request_config, &setenvif_module,
|
||||||
|
@ -84,7 +84,7 @@ typedef struct {
|
|||||||
char *cookie_name;
|
char *cookie_name;
|
||||||
char *cookie_domain;
|
char *cookie_domain;
|
||||||
char *regexp_string; /* used to compile regexp; save for debugging */
|
char *regexp_string; /* used to compile regexp; save for debugging */
|
||||||
regex_t *regexp; /* used to find usertrack cookie in cookie header */
|
ap_regex_t *regexp; /* used to find usertrack cookie in cookie header */
|
||||||
} cookie_dir_rec;
|
} cookie_dir_rec;
|
||||||
|
|
||||||
/* Make Cookie: Now we have to generate something that is going to be
|
/* Make Cookie: Now we have to generate something that is going to be
|
||||||
@ -200,7 +200,7 @@ static void set_and_comp_regexp(cookie_dir_rec *dcfg,
|
|||||||
cookie_name,
|
cookie_name,
|
||||||
"=([^;,]+)", NULL);
|
"=([^;,]+)", NULL);
|
||||||
|
|
||||||
dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
|
dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, AP_REG_EXTENDED);
|
||||||
ap_assert(dcfg->regexp != NULL);
|
ap_assert(dcfg->regexp != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ static int spot_cookie(request_rec *r)
|
|||||||
cookie_dir_rec *dcfg = ap_get_module_config(r->per_dir_config,
|
cookie_dir_rec *dcfg = ap_get_module_config(r->per_dir_config,
|
||||||
&usertrack_module);
|
&usertrack_module);
|
||||||
const char *cookie_header;
|
const char *cookie_header;
|
||||||
regmatch_t regm[NUM_SUBS];
|
ap_regmatch_t regm[NUM_SUBS];
|
||||||
|
|
||||||
/* Do not run in subrequests */
|
/* Do not run in subrequests */
|
||||||
if (!dcfg->enabled || r->main) {
|
if (!dcfg->enabled || r->main) {
|
||||||
|
@ -141,11 +141,11 @@ static int compare_version(char *version_string, const char **error)
|
|||||||
static int match_version(apr_pool_t *pool, char *version_string,
|
static int match_version(apr_pool_t *pool, char *version_string,
|
||||||
const char **error)
|
const char **error)
|
||||||
{
|
{
|
||||||
regex_t *compiled;
|
ap_regex_t *compiled;
|
||||||
const char *to_match;
|
const char *to_match;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
compiled = ap_pregcomp(pool, version_string, REG_EXTENDED);
|
compiled = ap_pregcomp(pool, version_string, AP_REG_EXTENDED);
|
||||||
if (!compiled) {
|
if (!compiled) {
|
||||||
*error = "Unable to compile regular expression";
|
*error = "Unable to compile regular expression";
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -795,7 +795,7 @@ static const char *
|
|||||||
struct proxy_remote *new;
|
struct proxy_remote *new;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
char *r, *f, *scheme;
|
char *r, *f, *scheme;
|
||||||
regex_t *reg = NULL;
|
ap_regex_t *reg = NULL;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
r = apr_pstrdup(cmd->pool, r1);
|
r = apr_pstrdup(cmd->pool, r1);
|
||||||
@ -825,7 +825,7 @@ static const char *
|
|||||||
port = -1;
|
port = -1;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
if (regex) {
|
if (regex) {
|
||||||
reg = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
|
reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
|
||||||
if (!reg)
|
if (!reg)
|
||||||
return "Regular expression for ProxyRemoteMatch could not be compiled.";
|
return "Regular expression for ProxyRemoteMatch could not be compiled.";
|
||||||
}
|
}
|
||||||
@ -1441,7 +1441,7 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
char *old_path = cmd->path;
|
char *old_path = cmd->path;
|
||||||
proxy_dir_conf *conf;
|
proxy_dir_conf *conf;
|
||||||
ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
|
ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
|
||||||
regex_t *r = NULL;
|
ap_regex_t *r = NULL;
|
||||||
const command_rec *thiscmd = cmd->cmd;
|
const command_rec *thiscmd = cmd->cmd;
|
||||||
|
|
||||||
const char *err = ap_check_cmd_context(cmd,
|
const char *err = ap_check_cmd_context(cmd,
|
||||||
@ -1475,7 +1475,7 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
* scheme? See proxy_fixup()
|
* scheme? See proxy_fixup()
|
||||||
*/
|
*/
|
||||||
if (thiscmd->cmd_data) { /* <ProxyMatch> */
|
if (thiscmd->cmd_data) { /* <ProxyMatch> */
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
@ -1486,7 +1486,7 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
return "<Proxy ~ > block must specify a path";
|
return "<Proxy ~ > block must specify a path";
|
||||||
if (strncasecmp(cmd->path, "proxy:", 6))
|
if (strncasecmp(cmd->path, "proxy:", 6))
|
||||||
cmd->path += 6;
|
cmd->path += 6;
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ struct proxy_remote {
|
|||||||
const char *protocol; /* the scheme used to talk to this proxy */
|
const char *protocol; /* the scheme used to talk to this proxy */
|
||||||
const char *hostname; /* the hostname of this proxy */
|
const char *hostname; /* the hostname of this proxy */
|
||||||
apr_port_t port; /* the port for this proxy */
|
apr_port_t port; /* the port for this proxy */
|
||||||
regex_t *regexp; /* compiled regex (if any) for the remote */
|
ap_regex_t *regexp; /* compiled regex (if any) for the remote */
|
||||||
int use_regex; /* simple boolean. True if we have a regex pattern */
|
int use_regex; /* simple boolean. True if we have a regex pattern */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
const char *p; /* The path */
|
const char *p; /* The path */
|
||||||
int p_is_fnmatch; /* Is this path an fnmatch candidate? */
|
int p_is_fnmatch; /* Is this path an fnmatch candidate? */
|
||||||
regex_t *r; /* Is this a regex? */
|
ap_regex_t *r; /* Is this a regex? */
|
||||||
} proxy_dir_conf;
|
} proxy_dir_conf;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -425,11 +425,11 @@ static apr_status_t proxy_send_dir_filter(ap_filter_t *f,
|
|||||||
int found = 0;
|
int found = 0;
|
||||||
int eos = 0;
|
int eos = 0;
|
||||||
|
|
||||||
regex_t *re = NULL;
|
ap_regex_t *re = NULL;
|
||||||
regmatch_t re_result[LS_REG_MATCH];
|
ap_regmatch_t re_result[LS_REG_MATCH];
|
||||||
|
|
||||||
/* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
|
/* Compile the output format of "ls -s1" as a fallback for non-unix ftp listings */
|
||||||
re = ap_pregcomp(p, LS_REG_PATTERN, REG_EXTENDED);
|
re = ap_pregcomp(p, LS_REG_PATTERN, AP_REG_EXTENDED);
|
||||||
ap_assert(re != NULL);
|
ap_assert(re != NULL);
|
||||||
|
|
||||||
/* get a complete line */
|
/* get a complete line */
|
||||||
|
@ -126,24 +126,24 @@ static BOOL ssl_expr_eval_comp(request_rec *r, ssl_expr *node)
|
|||||||
ssl_expr *e1;
|
ssl_expr *e1;
|
||||||
ssl_expr *e2;
|
ssl_expr *e2;
|
||||||
char *word;
|
char *word;
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
|
|
||||||
e1 = (ssl_expr *)node->node_arg1;
|
e1 = (ssl_expr *)node->node_arg1;
|
||||||
e2 = (ssl_expr *)node->node_arg2;
|
e2 = (ssl_expr *)node->node_arg2;
|
||||||
word = ssl_expr_eval_word(r, e1);
|
word = ssl_expr_eval_word(r, e1);
|
||||||
regex = (regex_t *)(e2->node_arg1);
|
regex = (ap_regex_t *)(e2->node_arg1);
|
||||||
return (ap_regexec(regex, word, 0, NULL, 0) == 0);
|
return (ap_regexec(regex, word, 0, NULL, 0) == 0);
|
||||||
}
|
}
|
||||||
case op_NRE: {
|
case op_NRE: {
|
||||||
ssl_expr *e1;
|
ssl_expr *e1;
|
||||||
ssl_expr *e2;
|
ssl_expr *e2;
|
||||||
char *word;
|
char *word;
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
|
|
||||||
e1 = (ssl_expr *)node->node_arg1;
|
e1 = (ssl_expr *)node->node_arg1;
|
||||||
e2 = (ssl_expr *)node->node_arg2;
|
e2 = (ssl_expr *)node->node_arg2;
|
||||||
word = ssl_expr_eval_word(r, e1);
|
word = ssl_expr_eval_word(r, e1);
|
||||||
regex = (regex_t *)(e2->node_arg1);
|
regex = (ap_regex_t *)(e2->node_arg1);
|
||||||
return !(ap_regexec(regex, word, 0, NULL, 0) == 0);
|
return !(ap_regexec(regex, word, 0, NULL, 0) == 0);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -818,9 +818,9 @@ case 23:
|
|||||||
case 24:
|
case 24:
|
||||||
#line 148 "ssl_expr_parse.y"
|
#line 148 "ssl_expr_parse.y"
|
||||||
{
|
{
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
if ((regex = ap_pregcomp(ssl_expr_info.pool, ssl_expr_yyvsp[0].cpVal,
|
if ((regex = ap_pregcomp(ssl_expr_info.pool, ssl_expr_yyvsp[0].cpVal,
|
||||||
REG_EXTENDED|REG_NOSUB)) == NULL) {
|
AP_REG_EXTENDED|AP_REG_NOSUB)) == NULL) {
|
||||||
ssl_expr_error = "Failed to compile regular expression";
|
ssl_expr_error = "Failed to compile regular expression";
|
||||||
YYERROR;
|
YYERROR;
|
||||||
regex = NULL;
|
regex = NULL;
|
||||||
@ -831,9 +831,9 @@ case 24:
|
|||||||
case 25:
|
case 25:
|
||||||
#line 158 "ssl_expr_parse.y"
|
#line 158 "ssl_expr_parse.y"
|
||||||
{
|
{
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
if ((regex = ap_pregcomp(ssl_expr_info.pool, ssl_expr_yyvsp[0].cpVal,
|
if ((regex = ap_pregcomp(ssl_expr_info.pool, ssl_expr_yyvsp[0].cpVal,
|
||||||
REG_EXTENDED|REG_NOSUB|REG_ICASE)) == NULL) {
|
AP_REG_EXTENDED|AP_REG_NOSUB|AP_REG_ICASE)) == NULL) {
|
||||||
ssl_expr_error = "Failed to compile regular expression";
|
ssl_expr_error = "Failed to compile regular expression";
|
||||||
YYERROR;
|
YYERROR;
|
||||||
regex = NULL;
|
regex = NULL;
|
||||||
|
@ -112,18 +112,18 @@ word : T_DIGIT { $$ = ssl_expr_make(op_Digit, $1, NUL
|
|||||||
;
|
;
|
||||||
|
|
||||||
regex : T_REGEX {
|
regex : T_REGEX {
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
|
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
|
||||||
REG_EXTENDED|REG_NOSUB)) == NULL) {
|
AP_REG_EXTENDED|AP_REG_NOSUB)) == NULL) {
|
||||||
ssl_expr_error = "Failed to compile regular expression";
|
ssl_expr_error = "Failed to compile regular expression";
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
$$ = ssl_expr_make(op_Regex, regex, NULL);
|
$$ = ssl_expr_make(op_Regex, regex, NULL);
|
||||||
}
|
}
|
||||||
| T_REGEX_I {
|
| T_REGEX_I {
|
||||||
regex_t *regex;
|
ap_regex_t *regex;
|
||||||
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
|
if ((regex = ap_pregcomp(ssl_expr_info.pool, $1,
|
||||||
REG_EXTENDED|REG_NOSUB|REG_ICASE)) == NULL) {
|
AP_REG_EXTENDED|AP_REG_NOSUB|AP_REG_ICASE)) == NULL) {
|
||||||
ssl_expr_error = "Failed to compile regular expression";
|
ssl_expr_error = "Failed to compile regular expression";
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ LTLIBRARY_SOURCES = \
|
|||||||
util_script.c util_md5.c util_cfgtree.c util_ebcdic.c util_time.c \
|
util_script.c util_md5.c util_cfgtree.c util_ebcdic.c util_time.c \
|
||||||
connection.c listen.c \
|
connection.c listen.c \
|
||||||
mpm_common.c util_charset.c util_debug.c util_xml.c \
|
mpm_common.c util_charset.c util_debug.c util_xml.c \
|
||||||
util_filter.c exports.c \
|
util_filter.c util_pcre.c exports.c \
|
||||||
scoreboard.c error_bucket.c protocol.c core.c request.c provider.c \
|
scoreboard.c error_bucket.c protocol.c core.c request.c provider.c \
|
||||||
eoc_bucket.c core_filters.c
|
eoc_bucket.c core_filters.c
|
||||||
|
|
||||||
|
@ -1730,7 +1730,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define USE_ICASE REG_ICASE
|
#define USE_ICASE AP_REG_ICASE
|
||||||
#else
|
#else
|
||||||
#define USE_ICASE 0
|
#define USE_ICASE 0
|
||||||
#endif
|
#endif
|
||||||
@ -1743,7 +1743,7 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
char *old_path = cmd->path;
|
char *old_path = cmd->path;
|
||||||
core_dir_config *conf;
|
core_dir_config *conf;
|
||||||
ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
|
ap_conf_vector_t *new_dir_conf = ap_create_per_dir_config(cmd->pool);
|
||||||
regex_t *r = NULL;
|
ap_regex_t *r = NULL;
|
||||||
const command_rec *thiscmd = cmd->cmd;
|
const command_rec *thiscmd = cmd->cmd;
|
||||||
|
|
||||||
const char *err = ap_check_cmd_context(cmd,
|
const char *err = ap_check_cmd_context(cmd,
|
||||||
@ -1776,13 +1776,13 @@ static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
||||||
if (!cmd->path)
|
if (!cmd->path)
|
||||||
return "<Directory ~ > block must specify a path";
|
return "<Directory ~ > block must specify a path";
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
|
else if (thiscmd->cmd_data) { /* <DirectoryMatch> */
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
@ -1847,7 +1847,7 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
int old_overrides = cmd->override;
|
int old_overrides = cmd->override;
|
||||||
char *old_path = cmd->path;
|
char *old_path = cmd->path;
|
||||||
core_dir_config *conf;
|
core_dir_config *conf;
|
||||||
regex_t *r = NULL;
|
ap_regex_t *r = NULL;
|
||||||
const command_rec *thiscmd = cmd->cmd;
|
const command_rec *thiscmd = cmd->cmd;
|
||||||
ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);
|
ap_conf_vector_t *new_url_conf = ap_create_per_dir_config(cmd->pool);
|
||||||
const char *err = ap_check_cmd_context(cmd,
|
const char *err = ap_check_cmd_context(cmd,
|
||||||
@ -1870,14 +1870,14 @@ static const char *urlsection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
cmd->override = OR_ALL|ACCESS_CONF;
|
cmd->override = OR_ALL|ACCESS_CONF;
|
||||||
|
|
||||||
if (thiscmd->cmd_data) { /* <LocationMatch> */
|
if (thiscmd->cmd_data) { /* <LocationMatch> */
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd->path, "~")) {
|
else if (!strcmp(cmd->path, "~")) {
|
||||||
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
@ -1915,7 +1915,7 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
int old_overrides = cmd->override;
|
int old_overrides = cmd->override;
|
||||||
char *old_path = cmd->path;
|
char *old_path = cmd->path;
|
||||||
core_dir_config *conf;
|
core_dir_config *conf;
|
||||||
regex_t *r = NULL;
|
ap_regex_t *r = NULL;
|
||||||
const command_rec *thiscmd = cmd->cmd;
|
const command_rec *thiscmd = cmd->cmd;
|
||||||
core_dir_config *c = mconfig;
|
core_dir_config *c = mconfig;
|
||||||
ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
|
ap_conf_vector_t *new_file_conf = ap_create_per_dir_config(cmd->pool);
|
||||||
@ -1942,14 +1942,14 @@ static const char *filesection(cmd_parms *cmd, void *mconfig, const char *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (thiscmd->cmd_data) { /* <FilesMatch> */
|
if (thiscmd->cmd_data) { /* <FilesMatch> */
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(cmd->path, "~")) {
|
else if (!strcmp(cmd->path, "~")) {
|
||||||
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
cmd->path = ap_getword_conf(cmd->pool, &arg);
|
||||||
r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
|
r = ap_pregcomp(cmd->pool, cmd->path, AP_REG_EXTENDED|USE_ICASE);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return "Regex could not be compiled";
|
return "Regex could not be compiled";
|
||||||
}
|
}
|
||||||
|
@ -1048,7 +1048,7 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ap_regexec(entry_core->r, r->filename, 0, NULL, REG_NOTEOL)) {
|
if (ap_regexec(entry_core->r, r->filename, 0, NULL, AP_REG_NOTEOL)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,25 +247,25 @@ AP_DECLARE(int) ap_is_matchexp(const char *str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here's a pool-based interface to POSIX regex's regcomp().
|
* Here's a pool-based interface to the POSIX-esque ap_regcomp().
|
||||||
* Note that we return regex_t instead of being passed one.
|
* Note that we return ap_regex_t instead of being passed one.
|
||||||
* The reason is that if you use an already-used regex_t structure,
|
* The reason is that if you use an already-used ap_regex_t structure,
|
||||||
* the memory that you've already allocated gets forgotten, and
|
* the memory that you've already allocated gets forgotten, and
|
||||||
* regfree() doesn't clear it. So we don't allow it.
|
* regfree() doesn't clear it. So we don't allow it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static apr_status_t regex_cleanup(void *preg)
|
static apr_status_t regex_cleanup(void *preg)
|
||||||
{
|
{
|
||||||
regfree((regex_t *) preg);
|
ap_regfree((ap_regex_t *) preg);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
|
AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
|
||||||
int cflags)
|
int cflags)
|
||||||
{
|
{
|
||||||
regex_t *preg = apr_palloc(p, sizeof(regex_t));
|
ap_regex_t *preg = apr_palloc(p, sizeof *preg);
|
||||||
|
|
||||||
if (regcomp(preg, pattern, cflags)) {
|
if (ap_regcomp(preg, pattern, cflags)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,9 +275,9 @@ AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern,
|
|||||||
return preg;
|
return preg;
|
||||||
}
|
}
|
||||||
|
|
||||||
AP_DECLARE(void) ap_pregfree(apr_pool_t *p, regex_t * reg)
|
AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg)
|
||||||
{
|
{
|
||||||
regfree(reg);
|
ap_regfree(reg);
|
||||||
apr_pool_cleanup_kill(p, (void *) reg, regex_cleanup);
|
apr_pool_cleanup_kill(p, (void *) reg, regex_cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,29 +344,10 @@ AP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
|
|||||||
return bigstring;
|
return bigstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Apache stub function for the regex libraries regexec() to make sure the
|
|
||||||
* whole regex(3) API is available through the Apache (exported) namespace.
|
|
||||||
* This is especially important for the DSO situations of modules.
|
|
||||||
* DO NOT MAKE A MACRO OUT OF THIS FUNCTION!
|
|
||||||
*/
|
|
||||||
AP_DECLARE(int) ap_regexec(regex_t *preg, const char *string,
|
|
||||||
size_t nmatch, regmatch_t pmatch[], int eflags)
|
|
||||||
{
|
|
||||||
return regexec(preg, string, nmatch, pmatch, eflags);
|
|
||||||
}
|
|
||||||
|
|
||||||
AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg, char *errbuf,
|
|
||||||
size_t errbuf_size)
|
|
||||||
{
|
|
||||||
return regerror(errcode, preg, errbuf, errbuf_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* This function substitutes for $0-$9, filling in regular expression
|
/* This function substitutes for $0-$9, filling in regular expression
|
||||||
* submatches. Pass it the same nmatch and pmatch arguments that you
|
* submatches. Pass it the same nmatch and pmatch arguments that you
|
||||||
* passed ap_regexec(). pmatch should not be greater than the maximum number
|
* passed ap_regexec(). pmatch should not be greater than the maximum number
|
||||||
* of subexpressions - i.e. one more than the re_nsub member of regex_t.
|
* of subexpressions - i.e. one more than the re_nsub member of ap_regex_t.
|
||||||
*
|
*
|
||||||
* input should be the string with the $-expressions, source should be the
|
* input should be the string with the $-expressions, source should be the
|
||||||
* string that was matched against.
|
* string that was matched against.
|
||||||
@ -379,7 +360,7 @@ AP_DECLARE(size_t) ap_regerror(int errcode, const regex_t *preg, char *errbuf,
|
|||||||
|
|
||||||
AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
|
AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
|
||||||
const char *source, size_t nmatch,
|
const char *source, size_t nmatch,
|
||||||
regmatch_t pmatch[])
|
ap_regmatch_t pmatch[])
|
||||||
{
|
{
|
||||||
const char *src = input;
|
const char *src = input;
|
||||||
char *dest, *dst;
|
char *dest, *dst;
|
||||||
|
225
server/util_pcre.c
Normal file
225
server/util_pcre.c
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
/*************************************************
|
||||||
|
* Perl-Compatible Regular Expressions *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is a library of functions to support regular expressions whose syntax
|
||||||
|
and semantics are as close as possible to those of the Perl 5 language. See
|
||||||
|
the file Tech.Notes for some information on the internals.
|
||||||
|
|
||||||
|
This module is a wrapper that provides a POSIX API to the underlying PCRE
|
||||||
|
functions.
|
||||||
|
|
||||||
|
Written by: Philip Hazel <ph10@cam.ac.uk>
|
||||||
|
|
||||||
|
Copyright (c) 1997-2004 University of Cambridge
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the University of Cambridge nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "apr.h"
|
||||||
|
#include "apr_strings.h"
|
||||||
|
|
||||||
|
#define APR_WANT_STRFUNC
|
||||||
|
#include "apr_want.h"
|
||||||
|
|
||||||
|
#include "ap_regex.h"
|
||||||
|
#include "pcre.h"
|
||||||
|
|
||||||
|
#ifndef POSIX_MALLOC_THRESHOLD
|
||||||
|
#define POSIX_MALLOC_THRESHOLD (10)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Table of error strings corresponding to POSIX error codes; must be
|
||||||
|
* kept in synch with include/ap_regex.h's AP_REG_E* definitions. */
|
||||||
|
|
||||||
|
static const char *const pstring[] = {
|
||||||
|
"", /* Dummy for value 0 */
|
||||||
|
"internal error", /* AP_REG_ASSERT */
|
||||||
|
"failed to get memory", /* AP_REG_ESPACE */
|
||||||
|
"bad argument", /* AP_REG_INVARG */
|
||||||
|
"match failed" /* AP_REG_NOMATCH */
|
||||||
|
};
|
||||||
|
|
||||||
|
AP_DECLARE(size_t) ap_regerror(int errcode, const ap_regex_t *preg,
|
||||||
|
char *errbuf, size_t errbuf_size)
|
||||||
|
{
|
||||||
|
const char *message, *addmessage;
|
||||||
|
size_t length, addlength;
|
||||||
|
|
||||||
|
message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
|
||||||
|
"unknown error code" : pstring[errcode];
|
||||||
|
length = strlen(message) + 1;
|
||||||
|
|
||||||
|
addmessage = " at offset ";
|
||||||
|
addlength = (preg != NULL && (int)preg->re_erroffset != -1)?
|
||||||
|
strlen(addmessage) + 6 : 0;
|
||||||
|
|
||||||
|
if (errbuf_size > 0)
|
||||||
|
{
|
||||||
|
if (addlength > 0 && errbuf_size >= length + addlength)
|
||||||
|
apr_snprintf(errbuf, sizeof errbuf,
|
||||||
|
"%s%s%-6d", message, addmessage, (int)preg->re_erroffset);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strncpy(errbuf, message, errbuf_size - 1);
|
||||||
|
errbuf[errbuf_size-1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return length + addlength;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Free store held by a regex *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
AP_DECLARE(void) ap_regfree(ap_regex_t *preg)
|
||||||
|
{
|
||||||
|
(pcre_free)(preg->re_pcre);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Compile a regular expression *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Arguments:
|
||||||
|
preg points to a structure for recording the compiled expression
|
||||||
|
pattern the pattern to compile
|
||||||
|
cflags compilation flags
|
||||||
|
|
||||||
|
Returns: 0 on success
|
||||||
|
various non-zero codes on failure
|
||||||
|
*/
|
||||||
|
|
||||||
|
AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *pattern, int cflags)
|
||||||
|
{
|
||||||
|
const char *errorptr;
|
||||||
|
int erroffset;
|
||||||
|
int options = 0;
|
||||||
|
|
||||||
|
if ((cflags & AP_REG_ICASE) != 0) options |= PCRE_CASELESS;
|
||||||
|
if ((cflags & AP_REG_NEWLINE) != 0) options |= PCRE_MULTILINE;
|
||||||
|
|
||||||
|
preg->re_pcre = pcre_compile(pattern, options, &errorptr, &erroffset, NULL);
|
||||||
|
preg->re_erroffset = erroffset;
|
||||||
|
|
||||||
|
if (preg->re_pcre == NULL) return AP_REG_INVARG;
|
||||||
|
|
||||||
|
preg->re_nsub = pcre_info((const pcre *)preg->re_pcre, NULL, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* Match a regular expression *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
/* Unfortunately, PCRE requires 3 ints of working space for each captured
|
||||||
|
substring, so we have to get and release working store instead of just using
|
||||||
|
the POSIX structures as was done in earlier releases when PCRE needed only 2
|
||||||
|
ints. However, if the number of possible capturing brackets is small, use a
|
||||||
|
block of store on the stack, to reduce the use of malloc/free. The threshold is
|
||||||
|
in a macro that can be changed at configure time. */
|
||||||
|
|
||||||
|
AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, size_t nmatch,
|
||||||
|
ap_regmatch_t pmatch[], int eflags)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
int options = 0;
|
||||||
|
int *ovector = NULL;
|
||||||
|
int small_ovector[POSIX_MALLOC_THRESHOLD * 3];
|
||||||
|
int allocated_ovector = 0;
|
||||||
|
|
||||||
|
if ((eflags & AP_REG_NOTBOL) != 0) options |= PCRE_NOTBOL;
|
||||||
|
if ((eflags & AP_REG_NOTEOL) != 0) options |= PCRE_NOTEOL;
|
||||||
|
|
||||||
|
((ap_regex_t *)preg)->re_erroffset = (size_t)(-1); /* Only has meaning after compile */
|
||||||
|
|
||||||
|
if (nmatch > 0)
|
||||||
|
{
|
||||||
|
if (nmatch <= POSIX_MALLOC_THRESHOLD)
|
||||||
|
{
|
||||||
|
ovector = &(small_ovector[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ovector = (int *)malloc(sizeof(int) * nmatch * 3);
|
||||||
|
if (ovector == NULL) return AP_REG_ESPACE;
|
||||||
|
allocated_ovector = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = pcre_exec((const pcre *)preg->re_pcre, NULL, string, (int)strlen(string),
|
||||||
|
0, options, ovector, nmatch * 3);
|
||||||
|
|
||||||
|
if (rc == 0) rc = nmatch; /* All captured slots were filled in */
|
||||||
|
|
||||||
|
if (rc >= 0)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < (size_t)rc; i++)
|
||||||
|
{
|
||||||
|
pmatch[i].rm_so = ovector[i*2];
|
||||||
|
pmatch[i].rm_eo = ovector[i*2+1];
|
||||||
|
}
|
||||||
|
if (allocated_ovector) free(ovector);
|
||||||
|
for (; i < nmatch; i++) pmatch[i].rm_so = pmatch[i].rm_eo = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (allocated_ovector) free(ovector);
|
||||||
|
switch(rc)
|
||||||
|
{
|
||||||
|
case PCRE_ERROR_NOMATCH: return AP_REG_NOMATCH;
|
||||||
|
case PCRE_ERROR_NULL: return AP_REG_INVARG;
|
||||||
|
case PCRE_ERROR_BADOPTION: return AP_REG_INVARG;
|
||||||
|
case PCRE_ERROR_BADMAGIC: return AP_REG_INVARG;
|
||||||
|
case PCRE_ERROR_UNKNOWN_NODE: return AP_REG_ASSERT;
|
||||||
|
case PCRE_ERROR_NOMEMORY: return AP_REG_ESPACE;
|
||||||
|
case PCRE_ERROR_MATCHLIMIT: return AP_REG_ESPACE;
|
||||||
|
case PCRE_ERROR_BADUTF8: return AP_REG_INVARG;
|
||||||
|
case PCRE_ERROR_BADUTF8_OFFSET: return AP_REG_INVARG;
|
||||||
|
default: return AP_REG_ASSERT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of pcreposix.c */
|
@ -1,5 +1,5 @@
|
|||||||
LTLIBRARY_NAME = libpcre.la
|
LTLIBRARY_NAME = libpcre.la
|
||||||
LTLIBRARY_SOURCES = maketables.c get.c study.c pcre.c pcreposix.c
|
LTLIBRARY_SOURCES = maketables.c get.c study.c pcre.c
|
||||||
|
|
||||||
CLEAN_TARGETS = dftables chartables.c
|
CLEAN_TARGETS = dftables chartables.c
|
||||||
DISTCLEAN_TARGETS = pcre.h pcre-config config.h config.log config.status $(CLEAN_TARGETS)
|
DISTCLEAN_TARGETS = pcre.h pcre-config config.h config.log config.status $(CLEAN_TARGETS)
|
||||||
|
Reference in New Issue
Block a user