Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 64785 invoked from network); 29 Dec 2006 07:35:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Dec 2006 07:35:09 -0000 Received: (qmail 49340 invoked by uid 500); 29 Dec 2006 07:35:15 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 49287 invoked by uid 500); 29 Dec 2006 07:35:15 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 49276 invoked by uid 99); 29 Dec 2006 07:35:14 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Dec 2006 23:35:14 -0800 X-ASF-Spam-Status: No, hits=-9.2 required=10.0 tests=ALL_TRUSTED,MAILTO_TO_SPAM_ADDR,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Dec 2006 23:35:06 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 383DA1A981D; Thu, 28 Dec 2006 23:34:13 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r490939 - in /httpd/test/trunk/flood: NOTICE flood.vcproj flood_farm.c flood_pcre.c flood_pcre.h flood_round_robin.c Date: Fri, 29 Dec 2006 07:34:13 -0000 To: cvs@httpd.apache.org From: jerenkrantz@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061229073413.383DA1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jerenkrantz Date: Thu Dec 28 23:34:12 2006 New Revision: 490939 URL: http://svn.apache.org/viewvc?view=rev&rev=490939 Log: Better support Win32/VS2005 out-of-the-box with trunk. * flood_farm.c (run_farm): Accept APR_INCOMPLETE from apr_thread_join for Win32. * flood/flood_pcre.c, flood/flood_pcre.h: Import PCRE wrappers from httpd. * flood/flood_round_robin.c: Bring in PCRE wrappers if needed. * flood/NOTICE: Update; note PCRE wrappers inclusion. * flood/flood.vcproj: Add VS2005 project file. Added: httpd/test/trunk/flood/flood.vcproj (with props) httpd/test/trunk/flood/flood_pcre.c httpd/test/trunk/flood/flood_pcre.h Modified: httpd/test/trunk/flood/NOTICE httpd/test/trunk/flood/flood_farm.c httpd/test/trunk/flood/flood_round_robin.c Modified: httpd/test/trunk/flood/NOTICE URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/NOTICE?view=diff&rev=490939&r1=490938&r2=490939 ============================================================================== --- httpd/test/trunk/flood/NOTICE (original) +++ httpd/test/trunk/flood/NOTICE Thu Dec 28 23:34:12 2006 @@ -1,3 +1,11 @@ -This product includes software developed by +Apache Flood +Copyright 2006 The Apache Software Foundation. + +This product includes software developed at The Apache Software Foundation (http://www.apache.org/). +Regular expression support is provided by the PCRE library package, +which is open source software, written by Philip Hazel, and copyright +by the University of Cambridge, England. The original software is +available from + ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ Added: httpd/test/trunk/flood/flood.vcproj URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/flood.vcproj?view=auto&rev=490939 ============================================================================== --- httpd/test/trunk/flood/flood.vcproj (added) +++ httpd/test/trunk/flood/flood.vcproj Thu Dec 28 23:34:12 2006 @@ -0,0 +1,560 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: httpd/test/trunk/flood/flood.vcproj ------------------------------------------------------------------------------ svn:eol-style = CRLF Modified: httpd/test/trunk/flood/flood_farm.c URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/flood_farm.c?view=diff&rev=490939&r1=490938&r2=490939 ============================================================================== --- httpd/test/trunk/flood/flood_farm.c (original) +++ httpd/test/trunk/flood/flood_farm.c Thu Dec 28 23:34:12 2006 @@ -267,7 +267,8 @@ for (i = 0; i < usefarmer_count; i++) { #if APR_HAS_THREADS - if ((stat = apr_thread_join(&child_stat, farm->farmers[i])) != APR_SUCCESS) { + stat = apr_thread_join(&child_stat, farm->farmers[i]); + if (stat != APR_SUCCESS && stat != APR_INCOMPLETE) { #else if ((stat = apr_proc_wait(farm->farmers[i], NULL, NULL, APR_WAIT)) != APR_CHILD_DONE) { #endif Added: httpd/test/trunk/flood/flood_pcre.c URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/flood_pcre.c?view=auto&rev=490939 ============================================================================== --- httpd/test/trunk/flood/flood_pcre.c (added) +++ httpd/test/trunk/flood/flood_pcre.c Thu Dec 28 23:34:12 2006 @@ -0,0 +1,230 @@ +/************************************************* +* 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 + + 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 "flood_pcre.h" +#include "apr_strings.h" +#include "pcre.h" + +#define APR_WANT_STRFUNC +#include "apr_want.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/flood_regex.h's FLOOD_REG_E* definitions. */ + +static const char *const pstring[] = { + "", /* Dummy for value 0 */ + "internal error", /* FLOOD_REG_ASSERT */ + "failed to get memory", /* FLOOD_REG_ESPACE */ + "bad argument", /* FLOOD_REG_INVARG */ + "match failed" /* FLOOD_REG_NOMATCH */ +}; + +apr_size_t flood_regerror(int errcode, const flood_regex_t *preg, + char *errbuf, apr_size_t errbuf_size) +{ +const char *message, *addmessage; +apr_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 * +*************************************************/ + +void flood_regfree(flood_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 +*/ + +int flood_regcomp(flood_regex_t *preg, const char *pattern, int cflags) +{ +const char *errorptr; +int erroffset; +int options = 0; + +if ((cflags & FLOOD_REG_ICASE) != 0) options |= PCRE_CASELESS; +if ((cflags & FLOOD_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 FLOOD_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. */ + +int flood_regexec(const flood_regex_t *preg, const char *string, + apr_size_t nmatch, flood_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 & FLOOD_REG_NOTBOL) != 0) options |= PCRE_NOTBOL; +if ((eflags & FLOOD_REG_NOTEOL) != 0) options |= PCRE_NOTEOL; + +((flood_regex_t *)preg)->re_erroffset = (apr_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 FLOOD_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) + { + apr_size_t i; + for (i = 0; i < (apr_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 FLOOD_REG_NOMATCH; + case PCRE_ERROR_NULL: return FLOOD_REG_INVARG; + case PCRE_ERROR_BADOPTION: return FLOOD_REG_INVARG; + case PCRE_ERROR_BADMAGIC: return FLOOD_REG_INVARG; + case PCRE_ERROR_UNKNOWN_NODE: return FLOOD_REG_ASSERT; + case PCRE_ERROR_NOMEMORY: return FLOOD_REG_ESPACE; +#ifdef PCRE_ERROR_MATCHLIMIT + case PCRE_ERROR_MATCHLIMIT: return FLOOD_REG_ESPACE; +#endif +#ifdef PCRE_ERROR_BADUTF8 + case PCRE_ERROR_BADUTF8: return FLOOD_REG_INVARG; +#endif +#ifdef PCRE_ERROR_BADUTF8_OFFSET + case PCRE_ERROR_BADUTF8_OFFSET: return FLOOD_REG_INVARG; +#endif + default: return FLOOD_REG_ASSERT; + } + } +} + +/* End of pcreposix.c */ Added: httpd/test/trunk/flood/flood_pcre.h URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/flood_pcre.h?view=auto&rev=490939 ============================================================================== --- httpd/test/trunk/flood/flood_pcre.h (added) +++ httpd/test/trunk/flood/flood_pcre.h Thu Dec 28 23:34:12 2006 @@ -0,0 +1,149 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +/* Derived from PCRE's pcreposix.h. + + 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. +----------------------------------------------------------------------------- +*/ + +/** + * @file flood_regex.h + * @brief Apache Regex defines + */ + +#ifndef FLOOD_REGEX_H +#define FLOOD_REGEX_H + +#include "apr.h" + +/* Allow for C++ users */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Options for flood_regexec: */ + +#define FLOOD_REG_ICASE 0x01 /** use a case-insensitive match */ +#define FLOOD_REG_NEWLINE 0x02 /** don't match newlines against '.' etc */ +#define FLOOD_REG_NOTBOL 0x04 /** ^ will not match against start-of-string */ +#define FLOOD_REG_NOTEOL 0x08 /** $ will not match against end-of-string */ + +#define FLOOD_REG_EXTENDED (0) /** unused */ +#define FLOOD_REG_NOSUB (0) /** unused */ + +/* Error values: */ +enum { + FLOOD_REG_ASSERT = 1, /** internal error ? */ + FLOOD_REG_ESPACE, /** failed to get memory */ + FLOOD_REG_INVARG, /** invalid argument */ + FLOOD_REG_NOMATCH /** match failed */ +}; + +/* The structure representing a compiled regular expression. */ +typedef struct { + void *re_pcre; + apr_size_t re_nsub; + apr_size_t re_erroffset; +} flood_regex_t; + +/* The structure in which a captured offset is returned. */ +typedef struct { + int rm_so; + int rm_eo; +} flood_regmatch_t; + +/* The functions */ + +/** + * Compile a regular 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 + */ +int flood_regcomp(flood_regex_t *preg, const char *regex, + int cflags); + +/** + * Match a NUL-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 FLOOD_REG_* flags + * @return 0 for successful match, #REG_NOMATCH otherwise + */ +int flood_regexec(const flood_regex_t *preg, const char *string, + apr_size_t nmatch, flood_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 + */ +apr_size_t flood_regerror(int errcode, const flood_regex_t *preg, + char *errbuf, apr_size_t errbuf_size); + +/** Destroy a pre-compiled regex. + * @param preg The pre-compiled regex to free. + */ +void flood_regfree(flood_regex_t *preg); + +/* Expose our API as the POSIX compatibility layer */ +#define regcomp flood_regcomp +#define regexec flood_regexec +#define regfree flood_regfree +#define regex_t flood_regex_t +#define regmatch_t flood_regmatch_t +#define REG_EXTENDED FLOOD_REG_EXTENDED + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* FLOOD_REGEX_T */ + Modified: httpd/test/trunk/flood/flood_round_robin.c URL: http://svn.apache.org/viewvc/httpd/test/trunk/flood/flood_round_robin.c?view=diff&rev=490939&r1=490938&r2=490939 ============================================================================== --- httpd/test/trunk/flood/flood_round_robin.c (original) +++ httpd/test/trunk/flood/flood_round_robin.c Thu Dec 28 23:34:12 2006 @@ -45,7 +45,11 @@ #include #endif #include +#ifdef FLOOD_USE_PCRE +#include "flood_pcre.h" +#else #include "regex.h" +#endif #include "config.h" #include "flood_net.h"