manoj 99/09/20 15:18:53
Modified: src/include httpd.h src/lib/apr/include apr_lib.h src/lib/apr/lib apr_pools.c src/main util.c Log: Move ap_pregcomp and ap_pregfree from APR to Apache proper, since these functions depend on Apache's regex libraries. This also should fix compilation on platforms not using hsregex. Revision Changes Path 1.9 +3 -0 apache-2.0/src/include/httpd.h Index: httpd.h =================================================================== RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -u -r1.8 -r1.9 --- httpd.h 1999/09/08 14:15:40 1.8 +++ httpd.h 1999/09/20 22:18:43 1.9 @@ -962,6 +962,9 @@ char *ap_double_quotes(ap_context_t *p, char *str); #endif +API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, + int cflags); +API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t *reg); API_EXPORT(int) ap_regexec(const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags); API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 1.9 +0 -4 apache-2.0/src/lib/apr/include/apr_lib.h Index: apr_lib.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_lib.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -u -r1.8 -r1.9 --- apr_lib.h 1999/09/12 10:52:16 1.8 +++ apr_lib.h 1999/09/20 22:18:46 1.9 @@ -76,7 +76,6 @@ #include "../file_io/win32/readdir.h" /* definition of DIR for WIN32 */ #include "apr_win.h" #endif -#include "hsregex.h" #ifdef HAVE_STDARG_H #include <stdarg.h> #endif @@ -372,9 +371,6 @@ API_EXPORT(ap_status_t) ap_getpass(const char *prompt, char *pwbuf, size_t *bufsize); API_EXPORT_NONSTD(ap_status_t) ap_null_cleanup(void *data); -API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, - int cflags); -API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t *reg); /*API_EXPORT(void) ap_note_subprocess(ap_pool_t *a, pid_t pid, enum kill_conditions how); */ 1.11 +0 -37 apache-2.0/src/lib/apr/lib/apr_pools.c Index: apr_pools.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/lib/apr_pools.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -u -r1.10 -r1.11 --- apr_pools.c 1999/09/20 21:51:06 1.10 +++ apr_pools.c 1999/09/20 22:18:49 1.11 @@ -1176,43 +1176,6 @@ return APR_SUCCESS; } -/* - * 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, - * the memory that you've already allocated gets forgotten, and - * regfree() doesn't clear it. So we don't allow it. - */ - -static ap_status_t regex_cleanup(void *preg) -{ - regfree((regex_t *) preg); - return APR_SUCCESS; -} - -API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, - int cflags) -{ - regex_t *preg = ap_palloc(p, sizeof(regex_t)); - - if (regcomp(preg, pattern, cflags)) { - return NULL; - } - - ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup); - - return preg; -} - - -API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t * reg) -{ - ap_block_alarms(); - regfree(reg); - ap_kill_cleanup(p, (void *) reg, regex_cleanup); - ap_unblock_alarms(); -} - /***************************************************************** * * More grotty system stuff... subprocesses. Frump. These don't use 1.8 +36 -0 apache-2.0/src/main/util.c Index: util.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/util.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -u -r1.7 -r1.8 --- util.c 1999/09/08 14:15:44 1.7 +++ util.c 1999/09/20 22:18:51 1.8 @@ -348,6 +348,42 @@ return 0; } +/* + * 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, + * the memory that you've already allocated gets forgotten, and + * regfree() doesn't clear it. So we don't allow it. + */ + +static ap_status_t regex_cleanup(void *preg) +{ + regfree((regex_t *) preg); + return APR_SUCCESS; +} + +API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern, + int cflags) +{ + regex_t *preg = ap_palloc(p, sizeof(regex_t)); + + if (regcomp(preg, pattern, cflags)) { + return NULL; + } + + ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup); + + return preg; +} + +API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t * reg) +{ + ap_block_alarms(); + regfree(reg); + ap_kill_cleanup(p, (void *) reg, regex_cleanup); + ap_unblock_alarms(); +} + /* * Apache stub function for the regex libraries regexec() to make sure the * whole regex(3) API is available through the Apache (exported) namespace.