diff options
author | Joe Orton <jorton@apache.org> | 2005-02-11 13:00:41 +0100 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2005-02-11 13:00:41 +0100 |
commit | a0570c8746d04d82b724932cdb9c96240cf3329d (patch) | |
tree | 5597985b65498e809de32f0ff3ba710d70936fb2 /server/util.c | |
parent | * modules/ssl/ssl_engine_kernel.c (ssl_hook_Access): Move the (diff) | |
download | apache2-a0570c8746d04d82b724932cdb9c96240cf3329d.tar.xz apache2-a0570c8746d04d82b724932cdb9c96240cf3329d.zip |
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
Diffstat (limited to 'server/util.c')
-rw-r--r-- | server/util.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/server/util.c b/server/util.c index f605eaaf12..4e052226c7 100644 --- a/server/util.c +++ b/server/util.c @@ -247,25 +247,25 @@ AP_DECLARE(int) ap_is_matchexp(const char *str) } /* - * Here's a pool-based interface to POSIX regex's regcomp(). - * Note that we return regex_t instead of being passed one. - * The reason is that if you use an already-used regex_t structure, + * Here's a pool-based interface to the POSIX-esque ap_regcomp(). + * Note that we return ap_regex_t instead of being passed one. + * The reason is that if you use an already-used ap_regex_t structure, * the memory that you've already allocated gets forgotten, and * regfree() doesn't clear it. So we don't allow it. */ static apr_status_t regex_cleanup(void *preg) { - regfree((regex_t *) preg); + ap_regfree((ap_regex_t *) preg); return APR_SUCCESS; } -AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, - int cflags) +AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, + 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; } @@ -275,9 +275,9 @@ AP_DECLARE(regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, 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); } @@ -344,29 +344,10 @@ AP_DECLARE(const char *) ap_stripprefix(const char *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 * submatches. Pass it the same nmatch and pmatch arguments that you * 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 * 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, const char *source, size_t nmatch, - regmatch_t pmatch[]) + ap_regmatch_t pmatch[]) { const char *src = input; char *dest, *dst; |