* 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.
+/* Derived from PCRE's pcreposix.h.
Copyright (c) 1997-2004 University of Cambridge
#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>
+#include "apr.h"
/* Allow for C++ users */
/* The structure representing a compiled regular expression. */
typedef struct {
- void *re_pcre;
- size_t re_nsub;
- size_t re_erroffset;
+ void *re_pcre;
+ apr_size_t re_nsub;
+ apr_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;
+ int rm_so;
+ int rm_eo;
} ap_regmatch_t;
#ifndef AP_DECLARE
/* The functions */
/**
- * Compile a regeular expression.
+ * Compile a regular expression.
* @param preg Returned compiled regex
* @param regex The regular expression string
* @param cflags Must be zero (currently).
AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags);
/**
- * Match a null-terminated string against a pre-compiled regex.
+ * 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
* @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);
+ apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags);
/**
* Return the error code returned by regcomp or regexec into error messages
* @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);
+AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
+ char *errbuf, apr_size_t errbuf_size);
/** Destroy a pre-compiled regex.
* @param preg The pre-compiled regex to free.
"match failed" /* AP_REG_NOMATCH */
};
-AP_DECLARE(size_t) ap_regerror(int errcode, const ap_regex_t *preg,
- char *errbuf, size_t errbuf_size)
+AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg,
+ char *errbuf, apr_size_t errbuf_size)
{
const char *message, *addmessage;
-size_t length, addlength;
+apr_size_t length, addlength;
message = (errcode >= (int)(sizeof(pstring)/sizeof(char *)))?
"unknown error code" : pstring[errcode];
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)
+AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
+ apr_size_t nmatch, ap_regmatch_t pmatch[],
+ int eflags)
{
int rc;
int options = 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 */
+((ap_regex_t *)preg)->re_erroffset = (apr_size_t)(-1); /* Only has meaning after compile */
if (nmatch > 0)
{
if (rc >= 0)
{
- size_t i;
- for (i = 0; i < (size_t)rc; i++)
+ 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];