mod_rewrite.c revision 5fac45c1ef49924141fe28497deb350cf031b377
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
* ITS 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/* _ _ _
** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
** |_____|
**
** URL Rewriting Module
**
** This module uses a rule-based rewriting engine (based on a
** regular-expression parser) to rewrite requested URLs on the fly.
**
** It supports an unlimited number of additional rule conditions (which can
** operate on a lot of variables, even on HTTP headers) for granular
** matching and even external database lookups (either via plain text
** tables, DBM hash files or even external processes) for advanced URL
** substitution.
**
** It operates on the full URLs (including the PATH_INFO part) both in
** per-server context (httpd.conf) and per-dir context (.htaccess) and even
** can generate QUERY_STRING parts on result. The rewriting result finally
** can lead to internal subprocessing, external request redirection or even
** to internal proxy throughput.
**
** This module was originally written in April 1996 and
** gifted exclusively to the The Apache Software Foundation in July 1997 by
**
** Ralf S. Engelschall
** rse@engelschall.com
** www.engelschall.com
*/
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_core.h"
#include "http_log.h"
#include "http_protocol.h"
#include "mod_rewrite.h"
#include "apr_strings.h"
#include "apr_user.h"
#include "unixd.h"
#endif
#ifndef NO_WRITEV
#ifndef NETWARE
#ifdef HAVE_SYS_TYPES_H
#endif
#endif
#endif
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
/*
** +-------------------------------------------------------+
** | |
** | static module configuration
** | |
** +-------------------------------------------------------+
*/
/*
** Our interface to the Apache server kernel:
**
** o Runtime logic of a request is as following:
** while(request or subrequest)
** foreach(stage #0...#9)
** foreach(module) (**)
** try to run hook
**
** o the order of modules at (**) is the inverted order as
** given in the "Configuration" file, i.e. the last module
** specified is the first one called for each hook!
** The core module is always the last!
**
** o there are two different types of result checking and
** continue processing:
** for hook #0,#1,#4,#5,#6,#8:
** hook run loop stops on first modules which gives
** back a result != DECLINED, i.e. it usually returns OK
** which says "OK, module has handled this _stage_" and for #1
** this have not to mean "Ok, the filename is now valid".
** for hook #2,#3,#7,#9:
** all hooks are run, independend of result
**
** o at the last stage, the core module always
** - says "HTTP_BAD_REQUEST" if r->filename does not begin with "/"
** - prefix URL with document_root or replaced server_root
** with document_root and sets r->filename
** - always return a "OK" independed if the file really exists
** or not!
*/
/* The section for the Configure script:
* XXX: this needs updating for apache-2.0 configuration method
* MODULE-DEFINITION-START
* Name: rewrite_module
* ConfigStart
. ./helpers/find-dbm-lib
if [ "x$found_dbm" = "x1" ]; then
echo " enabling DBM support for mod_rewrite"
else
echo " disabling DBM support for mod_rewrite"
echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
fi
* ConfigEnd
* MODULE-DEFINITION-END
*/
/* the apr_table_t of commands we provide */
static const command_rec command_table[] = {
"On or Off to enable or disable (default) the whole "
"rewriting engine"),
"List of option strings to set"),
"the base URL of the per-directory context"),
"an input string and a to be applied regexp-pattern"),
"an URL-applied regexp-pattern and a substitution URL"),
"a mapname and a filename"),
"the filename of a lockfile used for inter-process "
"synchronization"),
"the filename of the rewriting logfile"),
"the level of the rewriting logfile verbosity "
"(0=none, 1=std, .., 9=max)"),
{ NULL }
};
/* the apr_table_t of content handlers we provide */
static const handler_rec handler_table[] = {
{ "redirect-handler", handler_redirect },
{ NULL }
};
static void register_hooks(void)
{
}
/* the main config structure */
config_perdir_create, /* create per-dir config structures */
config_perdir_merge, /* merge per-dir config structures */
config_server_create, /* create per-server config structures */
config_server_merge, /* merge per-server config structures */
command_table, /* apr_table_t of config file commands */
handler_table, /* [#8] MIME-typed-dispatched handlers */
register_hooks /* register hooks */
};
/* the cache */
/* whether proxy module is available or not */
static int proxy_available;
static int once_through = 0;
static const char *lockname;
/*
** +-------------------------------------------------------+
** | |
** | configuration directive handling
** | |
** +-------------------------------------------------------+
*/
/*
**
** per-server configuration structure handling
**
*/
{
a->state = ENGINE_DISABLED;
a->options = OPTION_NONE;
a->rewritelogfile = NULL;
a->rewritelogfp = NULL;
a->rewriteloglevel = 0;
a->server = s;
return (void *)a;
}
{
if (a->options & OPTION_INHERIT) {
/*
* local directives override
* and anything else is inherited
*/
: base->rewriteloglevel;
: base->rewritelogfile;
: base->rewritelogfp;
base->rewritemaps);
base->rewriteconds);
base->rewriterules);
}
else {
/*
* local directives override
* and anything else gets defaults
*/
}
return (void *)a;
}
/*
**
** per-directory configuration structure handling
**
*/
{
a->state = ENGINE_DISABLED;
a->options = OPTION_NONE;
}
else {
/* make sure it has a trailing slash */
}
else {
}
}
return (void *)a;
}
{
a = (rewrite_perdir_conf *)apr_pcalloc(p,
sizeof(rewrite_perdir_conf));
if (a->options & OPTION_INHERIT) {
base->rewriteconds);
base->rewriterules);
}
else {
}
return (void *)a;
}
/*
**
** the configuration commands
**
*/
{
sconf =
}
else /* is per-directory command */ {
}
return NULL;
}
{
const char *err;
sconf = (rewrite_server_conf *)
}
else { /* is per-directory command */
}
return err;
}
const char *name)
{
*options |= OPTION_INHERIT;
}
else {
return apr_pstrcat(p, "RewriteOptions: unknown option '",
}
return NULL;
}
{
sconf = (rewrite_server_conf *)
return NULL;
}
{
sconf = (rewrite_server_conf *)
return NULL;
}
const char *a2)
{
sconf = (rewrite_server_conf *)
}
}
#ifndef NO_DBM_REWRITEMAP
#else
"because no NDBM support is compiled in");
#endif
}
}
}
}
}
}
}
}
else {
}
"RewriteMap: map file or program not found:",
}
return NULL;
}
{
const char *error;
return error;
return NULL;
}
const char *a1)
{
return "RewriteBase: only valid in per-directory config files";
}
if (a1[0] == '\0') {
return "RewriteBase: empty URL not allowed";
}
if (a1[0] != '/') {
return "RewriteBase: argument is not a valid URL";
}
return NULL;
}
const char *in_str)
{
char *a1;
char *a2;
char *a3;
char *cp;
const char *err;
int rc;
sconf = (rewrite_server_conf *)
/* make a new entry in the internal temporary rewrite rule list */
}
else { /* is per-directory command */
}
/* parse the argument line ourself */
"'", NULL);
}
/* arg1: the input string */
/* arg3: optional flags field
(this have to be first parsed, because we need to
know if the regex should be compiled with ICASE!) */
return err;
}
}
/* arg2: the pattern
try to compile the regexp to test if is ok */
if (cp[0] == '!') {
cp++;
}
/* now be careful: Under the POSIX regex library
we can compile the pattern for case insensitive matching,
under the old V8 library we have to do it self via a hack */
== NULL);
}
else {
}
if (rc) {
"RewriteCond: cannot compile regular expression '",
}
return NULL;
}
static const char *cmd_rewritecond_parseflagfield(apr_pool_t *p,
char *str)
{
char *cp;
char *cp1;
char *cp2;
char *cp3;
char *key;
char *val;
const char *err;
return "RewriteCond: bad flag delimiters";
}
for ( ; *cp != '\0'; ) {
/* skip whitespaces */
;
if (*cp == '\0') {
break;
}
;
*cp2 = '\0';
*cp3 = '\0';
}
else {
val = "";
}
return err;
}
}
else {
break;
}
}
return NULL;
}
{
}
}
else {
}
return NULL;
}
const char *in_str)
{
char *a1;
char *a2;
char *a3;
char *cp;
const char *err;
int mode;
sconf = (rewrite_server_conf *)
/* make a new entry in the internal rewrite rule list */
}
else { /* is per-directory command */
}
/* parse the argument line ourself */
"'", NULL);
}
/* arg3: optional flags field */
return err;
}
}
/* arg1: the pattern
* try to compile the regexp to test if is ok
*/
if (cp[0] == '!') {
cp++;
}
mode = REG_EXTENDED;
}
"RewriteRule: cannot compile regular expression '",
}
/* arg2: the output string
* replace the $<N> by \<n> which is needed by the currently
* used Regular Expression library
*
* TODO: Is this still required for PCRE? If not, does it *work* with PCRE?
*/
/* now, if the server or per-dir config holds an
* array of RewriteCond entries, we take it for us
* and clear the array
*/
sizeof(rewritecond_entry));
}
else { /* is per-directory command */
sizeof(rewritecond_entry));
}
return NULL;
}
static const char *cmd_rewriterule_parseflagfield(apr_pool_t *p,
char *str)
{
char *cp;
char *cp1;
char *cp2;
char *cp3;
char *key;
char *val;
const char *err;
return "RewriteRule: bad flag delimiters";
}
for ( ; *cp != '\0'; ) {
/* skip whitespaces */
;
if (*cp == '\0') {
break;
}
;
*cp2 = '\0';
*cp3 = '\0';
}
else {
val = "";
}
return err;
}
}
else {
break;
}
}
return NULL;
}
{
int status = 0;
int i;
}
}
}
else if (apr_isdigit(*val)) {
}
if (!ap_is_HTTP_REDIRECT(status)) {
return "RewriteRule: invalid HTTP response code "
"for flag 'R'";
}
}
}
}
}
}
}
;
if (i < MAX_ENV_FLAGS) {
}
else {
return "RewriteRule: too many environment flags 'E'";
}
}
}
}
}
}
}
}
}
}
else {
}
return NULL;
}
/*
**
** Global Module Initialization
** [called from read_config() after all
** config commands were already called]
**
*/
static void init_module(apr_pool_t *p,
server_rec *s)
{
/* check if proxy module is available */
/* create the rewriting lockfiles in the parent */
"mod_rewrite: could not create rewrite_log_lock");
exit(1);
}
rewritelock_create(s, p);
/* step through the servers and
* - open each rewriting logfile
* - open the RewriteMap prg:xxx programs
*/
for (; s; s = s->next) {
open_rewritelog(s, p);
if (once_through > 0)
run_rewritemap_programs(s, p);
}
once_through++;
}
/*
**
** Per-Child Module Initialization
** [called after a child process is spawned]
**
*/
{
{
if (rv != APR_SUCCESS) {
"mod_rewrite: could not init rewrite_mapr_lock "
"in child");
}
}
/* create the lookup cache */
cachep = init_cache(p);
}
/*
** +-------------------------------------------------------+
** | |
** | runtime hooks
** | |
** +-------------------------------------------------------+
*/
/*
**
** URI-to-filename hook
**
** [used for the rewriting engine triggered by
** the per-server 'RewriteRule' directives]
**
*/
static int hook_uri2file(request_rec *r)
{
void *sconf;
const char *var;
const char *thisserver;
char *thisport;
const char *thisurl;
char buf[512];
char docroot[512];
const char *ccp;
unsigned int port;
int n;
int l;
/*
* retrieve the config structures
*/
/*
* only do something under runtime if the engine is really enabled,
* else return immediately!
*/
return DECLINED;
}
/*
* check for the ugly API case of a virtual host section where no
* mod_rewrite directives exists. In this situation we became no chance
* by the API to setup our default per-server config so we have to
* on-the-fly assume we have the default config. But because the default
* config has a disabled rewriting engine we are lucky because can
* just stop operating now.
*/
return DECLINED;
}
/*
* add the SCRIPT_URL variable to the env. this is a bit complicated
* due to the fact that apache uses subrequests and internal redirects
*/
}
else {
}
}
else {
}
/*
* create the SCRIPT_URI variable for the env
*/
/* add the canonical URI of this URL */
thisserver = ap_get_server_name(r);
port = ap_get_server_port(r);
if (ap_is_default_port(port, r)) {
thisport = "";
}
else {
}
/* set the variable */
/* if filename was not initially set,
* we start with the requested URI
*/
r->filename);
}
/*
* now apply the rules ...
*/
/* it should be go on as an internal proxy request */
/* check if the proxy module is enabled, so
* we can actually use it!
*/
if (!proxy_available) {
"attempt to make remote request from mod_rewrite "
"without proxy enabled: %s", r->filename);
return HTTP_FORBIDDEN;
}
/* make sure the QUERY_STRING and
* PATH_INFO parts get incorporated
*/
}
r->uri == r->unparsed_uri) {
/* see proxy_http:proxy_http_canon() */
}
/* now make sure the request gets handled by the proxy handler */
r->proxyreq = 1;
r->handler = "proxy-server";
r->filename);
return OK;
}
else if (is_absolute_uri(r->filename)) {
/* it was finally rewritten to a remote URL */
/* skip 'scheme:' */
;
/* skip '://' */
cp += 3;
/* skip host part */
;
if (*cp != '\0') {
*cp = '\0';
}
/* append the QUERY_STRING part */
}
/* determine HTTP redirect response code */
if (ap_is_HTTP_REDIRECT(r->status)) {
n = r->status;
}
else {
}
/* now do the redirection */
return n;
}
/* This URLs is forced to be forbidden for the requester */
return HTTP_FORBIDDEN;
}
/* This URLs is forced to be gone */
return HTTP_GONE;
}
/*
* Hack because of underpowered API: passing the current
* rewritten filename through to other URL-to-filename handlers
* just as it were the requested URL. This is to enable
* post-processing by mod_alias, etc. which always act on
* r->uri! The difference here is: We do not try to
* add the document root
*/
return DECLINED;
}
else {
/* it was finally rewritten to a local path */
/* expand "/~user" prefix */
#if APR_HAS_USER
#endif
/* the filename has to start with a slash! */
if (r->filename[0] != '/') {
return HTTP_BAD_REQUEST;
}
/* if there is no valid prefix, we have
* to emulate the translator from the core and
* prefix the filename with document_root
*
* NOTICE:
* We cannot leave out the prefix_stat because
* - when we always prefix with document_root
* then no absolute path can be created, e.g. via
* emulating a ScriptAlias directive, etc.
* - when we always NOT prefix with document_root
* then the files under document_root have to
* be references directly and document_root
* gets never used and will be a dummy parameter -
* this is also bad
*
* BUT:
* Under real Unix systems this is no problem,
* because we only do stat() on the first directory
* and this gets cached by the kernel for along time!
*/
if (n == 0) {
/* always NOT have a trailing slash */
}
(r->filename +
}
else {
}
r->filename);
}
}
return OK;
}
}
else {
return DECLINED;
}
}
/*
**
** MIME-type hook
**
** [used to support the forced-MIME-type feature]
**
*/
static int hook_mimetype(request_rec *r)
{
const char *t;
/* now check if we have to force a MIME-type */
if (t == NULL) {
return DECLINED;
}
else {
r->filename, t);
r->content_type = t;
return OK;
}
}
/*
**
** Fixup hook
**
** [used for the rewriting engine triggered by
** the per-directory 'RewriteRule' directives]
**
*/
static int hook_fixup(request_rec *r)
{
char *cp;
char *cp2;
const char *ccp;
char *prefix;
int l;
int n;
char *ofilename;
/* if there is no per-dir config we return immediately */
return DECLINED;
}
/* we shouldn't do anything in subrequests */
return DECLINED;
}
/* if there are no real (i.e. no RewriteRule directives!)
per-dir config of us, we return also immediately */
return DECLINED;
}
/*
* only do something under runtime if the engine is really enabled,
* for this directory, else return immediately!
*/
/* FollowSymLinks is mandatory! */
"Options FollowSymLinks or SymLinksIfOwnerMatch is off "
"which implies that RewriteRule directive is forbidden: "
"%s", r->filename);
return HTTP_FORBIDDEN;
}
else {
/* FollowSymLinks is given, but the user can
* still turn off the rewriting engine
*/
return DECLINED;
}
}
/*
* remember the current filename before rewriting for later check
* to prevent deadlooping because of internal redirects
*/
/*
* now apply the rules ...
*/
/* it should go on as an internal proxy request */
/* make sure the QUERY_STRING and
* PATH_INFO parts get incorporated
* (r->path_info was already appended by the
* rewriting engine because of the per-dir context!)
*/
}
/* now make sure the request gets handled by the proxy handler */
r->proxyreq = 1;
r->handler = "proxy-server";
return OK;
}
else if (is_absolute_uri(r->filename)) {
/* it was finally rewritten to a remote URL */
/* because we are in a per-dir context
* first try to replace the directory with its base-URL
* if there is a base-URL available
*/
/* skip 'scheme:' */
;
/* skip '://' */
cp += 3;
rewritelog(r, 2,
"[per-dir %s] trying to replace "
"prefix %s with %s",
*cp = '\0';
}
}
}
/* now prepare the redirect... */
/* skip 'scheme:' */
;
/* skip '://' */
cp += 3;
/* skip host part */
;
if (*cp != '\0') {
*cp = '\0';
}
/* append the QUERY_STRING part */
}
/* determine HTTP redirect response code */
if (ap_is_HTTP_REDIRECT(r->status)) {
n = r->status;
}
else {
}
/* now do the redirection */
return n;
}
/* This URL is forced to be forbidden for the requester */
return HTTP_FORBIDDEN;
}
/* This URL is forced to be gone */
return HTTP_GONE;
}
else {
/* it was finally rewritten to a local path */
/* if someone used the PASSTHROUGH flag in per-dir
* context we just ignore it. It is only useful
* in per-server context
*/
}
/* the filename has to start with a slash! */
if (r->filename[0] != '/') {
return HTTP_BAD_REQUEST;
}
/* Check for deadlooping:
* At this point we KNOW that at least one rewriting
* rule was applied, but when the resulting URL is
* the same as the initial URL, we are not allowed to
* use the following internal redirection stuff because
* this would lead to a deadloop.
*/
"URL: %s [IGNORING REWRITE]",
return OK;
}
/* if there is a valid base-URL then substitute
* the per-dir prefix with this base-URL if the
* current filename still is inside this per-dir
* context. If not then treat the result as a
* plain URL
*/
rewritelog(r, 2,
"[per-dir %s] trying to replace prefix %s with %s",
}
else {
/* if no explicit base-URL exists we assume
* that the directory prefix is also a valid URL
* for this webserver and only try to remove the
* document_root if it is prefix
*/
/* always NOT have a trailing slash */
l--;
}
rewritelog(r, 2,
"[per-dir %s] strip document_root "
"prefix: %s -> %s",
r->filename+l);
}
}
}
/* now initiate the internal redirect */
r->handler = "redirect-handler";
return OK;
}
}
else {
return DECLINED;
}
}
/*
**
** Content-Handlers
**
** [used for redirect support]
**
*/
static int handler_redirect(request_rec *r)
{
/* just make sure that we are really meant! */
return DECLINED;
}
/* now do the internal redirect */
/* and return gracefully */
return OK;
}
/*
** +-------------------------------------------------------+
** | |
** | the rewriting engine
** | |
** +-------------------------------------------------------+
*/
/*
* Apply a complete rule set,
* i.e. a list of rewrite rules
*/
char *perdir)
{
int i;
int changed;
int rc;
int s;
/*
* Iterate over all existing rules
*/
changed = 0;
loop:
for (i = 0; i < rewriterules->nelts; i++) {
p = &entries[i];
/*
* Ignore this rule on subrequests if we are explicitly
* asked to do so or this is a proxy-throughput or a
* forced redirect rule.
*/
(p->flags & RULEFLAG_IGNOREONSUBREQ ||
p->flags & RULEFLAG_PROXY ||
p->flags & RULEFLAG_FORCEREDIRECT )) {
continue;
}
/*
* Apply the current rule.
*/
if (rc) {
/*
* Indicate a change if this was not a match-only rule.
*/
if (rc != 2) {
changed = 1;
}
/*
* Pass-Through Feature (`RewriteRule .. .. [PT]'):
* Because the Apache 1.x API is very limited we
* need this hack to pass the rewritten URL to other
* modules like mod_alias, mod_userdir, etc.
*/
if (p->flags & RULEFLAG_PASSTHROUGH) {
"to next API URI-to-filename handler", r->filename);
changed = 1;
break;
}
/*
* Rule has the "forbidden" flag set which means that
* we stop processing and indicate this to the caller.
*/
if (p->flags & RULEFLAG_FORBIDDEN) {
changed = 1;
break;
}
/*
* Rule has the "gone" flag set which means that
* we stop processing and indicate this to the caller.
*/
if (p->flags & RULEFLAG_GONE) {
changed = 1;
break;
}
/*
* Stop processing also on proxy pass-through and
* last-rule and new-round flags.
*/
if (p->flags & RULEFLAG_PROXY) {
break;
}
if (p->flags & RULEFLAG_LASTRULE) {
break;
}
/*
* On "new-round" flag we just start from the top of
* the rewriting ruleset again.
*/
if (p->flags & RULEFLAG_NEWROUND) {
goto loop;
}
/*
* If we are forced to skip N next rules, do it now.
*/
if (p->skip > 0) {
s = p->skip;
while ( i < rewriterules->nelts
&& s > 0) {
i++;
p = &entries[i];
s--;
}
}
}
else {
/*
* If current rule is chained with next rule(s),
* skip all this next rule(s)
*/
while ( i < rewriterules->nelts
&& p->flags & RULEFLAG_CHAIN) {
i++;
p = &entries[i];
}
}
}
return changed;
}
/*
* Apply a single(!) rewrite rule
*/
char *perdir)
{
char *uri;
char *output;
const char *vary;
char newuri[MAX_STRING_LEN];
int prefixstrip;
int failed;
int i;
int rc;
/*
* Initialisation
*/
/*
* Add (perhaps splitted away) PATH_INFO postfix to URL to
* make sure we really match against the complete URL.
*/
}
/*
* On per-directory context (.htaccess) strip the location
* prefix from the URL to make sure patterns apply only to
* the local part. Additionally indicate this special
* threatment in the logfile.
*/
prefixstrip = 0;
prefixstrip = 1;
}
}
/*
* Try to match the URI against the RewriteRule pattern
* and exit immeddiately if it didn't apply.
*/
}
else {
}
return 0;
}
/*
* Else create the RewriteRule `regsubinfo' structure which
* holds the substitution information.
*/
/* empty info on negative patterns */
}
else {
sizeof(regmatch));
}
/*
* Initiallally create the RewriteCond backrefinfo with
* empty backrefinfo, i.e. not subst parts
* (this one is adjusted inside apply_rewrite_cond() later!!)
*/
/*
* Ok, we already know the pattern has matched, but we now
* additionally have to check for all existing preconditions
* (RewriteCond) which have to be also true. We do this at
* this very late stage to avoid unnessesary checks which
* would slow down the rewriting engine!!
*/
rewriteconds = p->rewriteconds;
failed = 0;
for (i = 0; i < rewriteconds->nelts; i++) {
c = &conds[i];
if (c->flags & CONDFLAG_ORNEXT) {
/*
* The "OR" case
*/
if (rc == 0) {
/* One condition is false, but another can be
* still true, so we have to continue...
*/
continue;
}
else {
/* One true condition is enough in "or" case, so
* skip the other conditions which are "ornext"
* chained
*/
while ( i < rewriteconds->nelts
&& c->flags & CONDFLAG_ORNEXT) {
i++;
c = &conds[i];
}
continue;
}
}
else {
/*
* The "AND" case, i.e. no "or" flag,
* so a single failure means total failure.
*/
if (rc == 0) {
failed = 1;
break;
}
}
}
}
/* if any condition fails the complete rule fails */
if (failed) {
return 0;
}
/*
* Regardless of what we do next, we've found a match. Check to see
* if any of the request header fields were involved, and add them
* to the Vary field of the response.
*/
}
/*
* If this is a pure matching rule (`RewriteRule <pat> -')
* we stop processing and return immediately. The only thing
* we have not to forget are the environment variables
* (`RewriteRule <pat> - [E=...]')
*/
if (p->forced_mimetype != NULL) {
/* In the per-server context we can force the MIME-type
* the correct way by notifying our MIME-type hook handler
* to do the job when the MIME-type API stage is reached.
*/
r->filename, p->forced_mimetype);
p->forced_mimetype);
}
else {
/* In per-directory context we operate in the Fixup API hook
* which is after the MIME-type hook, so our MIME-type handler
* has no chance to set r->content_type. And because we are
* in the situation where no substitution takes place no
* sub-request will happen (which could solve the
* restriction). As a workaround we do it ourself now
* immediately although this is not strictly API-conforming.
* But it's the only chance we have...
*/
r->content_type = p->forced_mimetype;
}
}
return 2;
}
/*
* Ok, now we finally know all patterns have matched and
* that there is something to replace, so we create the
* substitution URL string in `newuri'.
*/
}
else {
}
/*
* Additionally do expansion for the environment variable
* strings (`RewriteRule .. .. [E=<string>]').
*/
/*
* Now replace API's knowledge of the current URI:
* Replace r->filename with the new URI string and split out
* an on-the-fly generated QUERY_STRING part into r->args
*/
/*
* Again add the previously stripped per-directory location
* prefix if the new URI is not a new one for this
* location, i.e. if it's not starting with either a slash
* or a fully qualified URL scheme.
*/
&& !is_absolute_uri(r->filename)) {
}
/*
* If this rule is forced for proxy throughput
* (`RewriteRule ... ... [P]') then emulate mod_proxy's
* URL-to-filename handler to be sure mod_proxy is triggered
* for this URL later in the Apache API. But make sure it is
* a fully-qualified URL. (If not it is qualified with
* ourself).
*/
if (p->flags & RULEFLAG_PROXY) {
}
else {
}
return 1;
}
/*
* If this rule is explicitly forced for HTTP redirection
* (`RewriteRule .. .. [R]') then force an external HTTP
* redirect. But make sure it is a fully-qualified URL. (If
* not it is qualified with ourself).
*/
if (p->flags & RULEFLAG_FORCEREDIRECT) {
rewritelog(r, 2,
"explicitly forcing redirect with %s", r->filename);
}
else {
rewritelog(r, 2,
"[per-dir %s] explicitly forcing redirect with %s",
}
r->status = p->forced_responsecode;
return 1;
}
/*
* Special Rewriting Feature: Self-Reduction
* We reduce the URL by stripping a possible
* http[s]://<ourhost>[:<port>] prefix, i.e. a prefix which
* corresponds to ourself. This is to simplify rewrite maps
* and to avoid recursion, etc. When this prefix is not a
* coincidence then the user has to use [R] explicitly (see
* above).
*/
reduce_uri(r);
/*
* If this rule is still implicitly forced for HTTP
* redirection (`RewriteRule .. <scheme>://...') then
* directly force an external HTTP redirect.
*/
if (is_absolute_uri(r->filename)) {
rewritelog(r, 2,
"implicitly forcing redirect (rc=%d) with %s",
p->forced_responsecode, r->filename);
}
else {
r->filename);
}
r->status = p->forced_responsecode;
return 1;
}
/*
* Now we are sure it is not a fully qualified URL. But
* there is still one special case left: A local rewrite in
* per-directory context, i.e. a substitution URL which does
* not start with a slash. Here we add again the initially
* stripped per-directory prefix.
*/
}
/*
* Finally we had to remember if a MIME-type should be
* forced for this URL (`RewriteRule .. .. [T=<type>]')
* Later in the API processing phase this is forced by our
* MIME API-hook function. This time its no problem even for
* the per-directory context (where the MIME-type hook was
* already processed) because a sub-request happens ;-)
*/
if (p->forced_mimetype != NULL) {
p->forced_mimetype);
r->filename, p->forced_mimetype);
}
else {
rewritelog(r, 2,
"[per-dir %s] remember %s to have MIME-type '%s'",
}
}
/*
* Puuhhhhhhhh... WHAT COMPLICATED STUFF ;_)
* But now we're done for this particular rule.
*/
return 1;
}
{
char input[MAX_STRING_LEN];
int rc;
/*
* Construct the string we match against
*/
/*
* Apply the patterns
*/
rc = 0;
rc = 1;
}
}
}
rc = 1;
}
}
}
#if !defined(OS2)
rc = 1;
}
}
#endif
}
rc = 1;
}
}
}
/* avoid infinite subrequest recursion */
/* run a URI-based subrequest */
/* URI exists for any result up to 3xx, redirects allowed */
rc = 1;
/* log it */
/* cleanup by destroying the subrequest */
}
}
/* avoid infinite subrequest recursion */
/* process a file-based subrequest:
* this differs from -U in that no path translation is done.
*/
/* file exists for any result up to 2xx, no redirects */
/* double-check that file exists since default result is 200 */
rc = 1;
}
/* log it */
/* cleanup by destroying the subrequest */
}
}
}
}
}
else {
}
}
else {
/* it is really a regexp pattern, so apply it */
/* if it isn't a negated pattern and really matched
we update the passed-through regex subst info structure */
sizeof(regmatch));
}
}
/* if this is a non-matching regexp, just negate the result */
if (p->flags & CONDFLAG_NOTMATCH) {
}
/* end just return the result */
return rc;
}
/*
** +-------------------------------------------------------+
** | |
** | URL transformation functions
** | |
** +-------------------------------------------------------+
*/
/*
**
** perform all the expansions on the input string
** leaving the result in the supplied buffer
**
*/
{
/*
* for security reasons this expansion must be perfomed in a
* single pass, otherwise an attacker can arrange for the result
* of an earlier expansion to include expansion specifiers that
* are interpreted by a later expansion, producing results that
* were not intended by the administrator.
*/
for (;;) {
}
break;
}
/* now we have a '$' or a '%' */
char *endp;
goto skip;
}
*endp = '\0';
if (inp[0] == '$') {
/* ${...} map lookup expansion */
/*
* To make rewrite maps useful the lookup key and
* default values must be expanded, so we make
* recursive calls to do the work. For security
* reasons we must never expand a string that includes
* verbatim data from the network. The recursion here
* isn't a problem because the result of expansion is
* only passed to lookup_map() so it cannot be
* re-expanded, only re-looked-up. Another way of
* looking at it is that the recursion is entirely
* driven by the syntax of the nested curly brackets.
*/
char xkey[MAX_STRING_LEN];
char xdflt[MAX_STRING_LEN];
char *empty = "";
*endp = '}';
goto skip;
}
*key++ = '\0';
}
else {
*dflt++ = '\0';
}
}
}
}
else if (inp[0] == '%') {
/* %{...} variable lookup expansion */
}
else {
span = 0;
}
*endp = '}';
continue;
}
if (inp[0] == '$') {
/* $N RewriteRule regexp backref expansion */
}
else if (inp[0] == '%') {
/* %N RewriteCond regexp backref expansion */
}
}
}
inp += 2;
continue;
}
skip:
space--;
}
*outp++ = '\0';
}
/*
**
** perform all the expansions on the environment variables
**
*/
{
int i;
char buf[MAX_STRING_LEN];
add_env_variable(r, buf);
}
}
/*
**
** split out a QUERY_STRING part from
** the current URI string
**
*/
{
char *q;
char *olduri;
if (q != NULL) {
*q++ = '\0';
if (qsappend) {
}
else {
}
r->filename);
}
else {
}
}
}
return;
}
/*
**
** strip 'http[s]://ourhost/' from URI
**
*/
static void reduce_uri(request_rec *r)
{
char *cp;
unsigned short port;
char *portp;
char *hostp;
char *url;
char c;
char host[LONG_STRING_LEN];
char buf[MAX_STRING_LEN];
char *olduri;
int l;
cp = (char *)ap_http_method(r);
&& r->filename[l] == ':'
/* there was really a rewrite to a remote path */
/* cut the hostname and port out of the URI */
;
if (*cp == ':') {
/* set host */
*cp++ = '\0';
/* set port */
;
c = *cp;
*cp = '\0';
*cp = c;
/* set remaining url */
}
else if (*cp == '/') {
/* set host */
*cp = '\0';
*cp = '/';
/* set port */
port = ap_default_port(r);
/* set remaining url */
}
else {
/* set host */
/* set port */
port = ap_default_port(r);
/* set remaining url */
url = "/";
}
/* now check whether we could reduce it to a local path... */
/* this is our host, so only the URL remains */
}
}
return;
}
/*
**
** add 'http[s]://ourhost[:ourport]/' to URI
** if URI is still not fully qualified
**
*/
static void fully_qualify_uri(request_rec *r)
{
char buf[32];
const char *thisserver;
char *thisport;
int port;
if (!is_absolute_uri(r->filename)) {
thisserver = ap_get_server_name(r);
port = ap_get_server_port(r);
if (ap_is_default_port(port,r)) {
thisport = "";
}
else {
}
if (r->filename[0] == '/') {
ap_http_method(r), thisserver,
}
else {
ap_http_method(r), thisserver,
}
}
return;
}
/*
**
** return non-zero if the URI is absolute (includes a scheme etc.)
**
*/
static int is_absolute_uri(char *uri)
{
return 1;
}
else {
return 0;
}
}
/*
**
** database information (or other OS-specific database)
**
*/
#if APR_HAS_USER
{
char user[LONG_STRING_LEN];
char *newuri;
int i, j;
char *homedir;
/* cut out the username */
&& uri[i] != '\0'
&& uri[i] != '/' ; ) {
}
user[j] = '\0';
/* lookup username in systems passwd file */
/* ok, user was found, so expand the ~user string */
if (uri[i] != '\0') {
}
}
else {
/* only ~user has to be expanded */
}
}
}
return newuri;
}
#endif /* if APR_HAS_USER */
/*
** +-------------------------------------------------------+
** | |
** | DBM hashfile support
** | |
** +-------------------------------------------------------+
*/
{
void *sconf;
rewritemap_entry *s;
char *value;
int i;
/* get map configuration */
for (i = 0; i < rewritemaps->nelts; i++) {
s = &entries[i];
if (s->type == MAPTYPE_TXT) {
"mod_rewrite: can't access text RewriteMap "
"file %s", s->checkfile);
"see error log");
return NULL;
}
"map lookup");
if ((value =
return value;
}
else {
return NULL;
}
}
else {
}
}
else if (s->type == MAPTYPE_DBM) {
#ifndef NO_DBM_REWRITEMAP
"mod_rewrite: can't access DBM RewriteMap "
"file %s", s->checkfile);
"see error log");
return NULL;
}
rewritelog(r, 6,
"cache lookup FAILED, forcing new map lookup");
if ((value =
return value;
}
else {
return NULL;
}
}
else {
}
#else
return NULL;
#endif
}
else if (s->type == MAPTYPE_PRG) {
if ((value =
return value;
}
else {
}
}
else if (s->type == MAPTYPE_INT) {
return value;
}
else {
}
}
else if (s->type == MAPTYPE_RND) {
"mod_rewrite: can't access text RewriteMap "
"file %s", s->checkfile);
"see error log");
return NULL;
}
"map lookup");
if ((value =
}
else {
return NULL;
}
}
else {
}
if (value[0] != '\0') {
}
else {
}
return value;
}
}
}
return NULL;
}
{
char line[1024];
char *cpT;
char *curkey;
char *curval;
if (rc != APR_SUCCESS) {
return NULL;
}
if (line[0] == '#')
continue; /* ignore comments */
if (skip == 0)
continue; /* ignore lines that start with a space, tab, CR, or LF */
*cpT = '\0';
continue; /* key does not match... */
/* found a matching key; now extract and return the value */
++cpT;
if (skip == 0)
continue; /* no value... */
*cpT = '\0';
break;
}
return value;
}
#ifndef NO_DBM_REWRITEMAP
{
char buf[MAX_STRING_LEN];
}
}
return value;
}
#endif
{
char buf[LONG_STRING_LEN];
char c;
int i;
#ifndef NO_WRITEV
#endif
/* when `RewriteEngine off' was used in the per-server
* context then the rewritemap-programs were not spawned.
* In this case using such a map (usually in per-dir context)
* is useless because it is not available.
*/
return NULL;
}
/* take the lock */
if (rewrite_mapr_lock) {
}
/* write out the request key */
#ifdef NO_WRITEV
nbytes = 1;
#else
niov = 2;
#endif
/* read in the response value */
i = 0;
nbytes = 1;
if (c == '\n') {
break;
}
buf[i++] = c;
}
buf[i] = '\0';
/* give the lock back */
if (rewrite_mapr_lock) {
}
return NULL;
}
else {
}
}
static char *lookup_map_internal(request_rec *r,
char *(*func)(request_rec *, char *),
char *key)
{
/* currently we just let the function convert
the key to a corresponding value */
}
{
cp++) {
}
return value;
}
{
cp++) {
}
return value;
}
{
char *value;
return value;
}
{
char *value;
return value;
}
static int rewrite_rand_init_done = 0;
static void rewrite_rand_init(void)
{
if (!rewrite_rand_init_done) {
}
return;
}
static int rewrite_rand(int l, int h)
{
/* Get [0,1) and then scale to the appropriate range. Note that using
* a floating point value ensures that we use all bits of the rand()
* result. Doing an integer modulus would only use the lower-order bits
* which may not be as uniformly random.
*/
}
{
char *buf;
int n, i, k;
/* count number of distinct values */
if (value[i] == '|') {
n++;
}
}
/* when only one value we have no option to choose */
if (n == 1) {
return value;
}
/* else randomly select one */
k = rewrite_rand(1, n);
/* and grep it out */
if (n == k) {
break;
}
if (value[i] == '|') {
n++;
}
}
;
buf[i] = '\0';
return buf;
}
/*
** +-------------------------------------------------------+
** | |
** | rewriting logfile support
** | |
** +-------------------------------------------------------+
*/
{
const char *fname;
return;
}
return;
}
return; /* virtual log shared w/ main server */
}
"mod_rewrite: could not open reliable pipe "
exit(1);
}
}
if (rc != APR_SUCCESS) {
"mod_rewrite: could not open RewriteLog "
"file %s", fname);
exit(1);
}
}
return;
}
{
char *str1;
char str2[512];
char str3[1024];
char type[20];
char redir[20];
int i;
char *ruser;
const char *rhost;
conn = r->connection;
return;
}
return;
}
return;
}
return;
}
ruser = "-";
}
}
else {
ruser = "\"\"";
}
rhost = "UNKNOWN-HOST";
}
}
else {
}
i++;
}
if (i == 0) {
redir[0] = '\0';
}
else {
}
current_logtime(r), ap_get_server_name(r),
(unsigned long)(r->server), (unsigned long)r,
return;
}
static char *current_logtime(request_rec *r)
{
char tstr[80];
apr_explode_localtime(&t, apr_now());
}
/*
** +-------------------------------------------------------+
** | |
** | rewriting lockfile support
** | |
** +-------------------------------------------------------+
*/
{
/* only operate if a lockfile is used */
return;
}
/* fixup the path, especially for rewritelock_remove() */
/* create the lockfile */
if (rc != APR_SUCCESS) {
"mod_rewrite: Parent could not create RewriteLock "
"file %s", lockname);
exit(1);
}
return;
}
{
/* only operate if a lockfile is used */
return APR_SUCCESS;
}
/* destroy the rewritelock */
return(0);
}
/*
** +-------------------------------------------------------+
** | |
** | program map support
** | |
** +-------------------------------------------------------+
*/
{
int i;
/* If the engine isn't turned on,
* don't even try to do anything.
*/
return;
}
for (i = 0; i < rewritemaps->nelts; i++) {
continue;
}
continue;
}
"mod_rewrite: could not fork child for "
"RewriteMap process");
exit(1);
}
}
return;
}
/* child process code */
apr_file_t **fperr)
{
#ifdef SIGHUP
#endif
APR_FULL_NONBLOCK)) != APR_SUCCESS) ||
!= APR_SUCCESS) ||
/* Something bad happened, give up and go away. */
}
else {
if (rc == APR_SUCCESS) {
if (fpin) {
}
if (fpout) {
}
if (fperr) {
}
}
}
return (rc);
}
/*
** +-------------------------------------------------------+
** | |
** | environment variable support
** | |
** +-------------------------------------------------------+
*/
{
const char *result;
char resultbuf[LONG_STRING_LEN];
#ifndef WIN32
#endif
/* HTTP headers */
}
}
}
}
}
}
}
/* all other headers from which we are still not know about */
}
/* connection stuff */
}
r->per_dir_config, REMOTE_NAME);
}
}
result = (char *)ap_get_remote_logname(r);
}
/* request stuff */
result = r->the_request;
}
}
}
}
}
}
result = r->ap_auth_type;
}
}
/* internal server stuff */
result = ap_document_root(r);
}
}
result = ap_get_server_name(r);
}
}
}
}
}
}
/* XXX: wow this has gotta be slow if you actually use it for a lot, recalculates exploded time for each variable */
/* underlaying Unix system stuff */
}
}
}
}
}
}
}
}
/* all other env-variables from the parent Apache process */
/* first try the internal Apache notes structure */
/* second try the internal Apache env structure */
}
/* third try the external OS env */
}
}
#define LOOKAHEAD(subrecfunc) \
if ( \
/* filename is safe to use */ \
/* - and we're either not in a subrequest */ \
/* - or in a subrequest where paths are non-NULL... */ \
/* ...and sub and main paths differ */ \
/* process a file-based subrequest */ \
/* now recursively lookup the variable in the sub_req */ \
/* copy it up to our scope before we destroy sub_req's apr_pool_t */ \
/* cleanup by destroying the subrequest */ \
/* log it */ \
/* return ourself to prevent re-pstrdup */ \
return (char *)result; \
}
/* look-ahead for parameter through URI-based sub-request */
}
/* look-ahead for parameter through file-based sub-request */
}
/* Win32 has a rather different view of file ownerships.
For now, just forget it */
/* file stuff */
result = "<unknown>";
if (r->finfo.protection != 0) {
}
}
else {
}
}
}
}
result = "<unknown>";
if (r->finfo.protection != 0) {
}
}
else {
}
}
}
}
#endif /* ndef WIN32 && NETWARE*/
}
else {
}
}
{
int i;
continue;
}
}
}
return NULL;
}
/*
** +-------------------------------------------------------+
** | |
** | caching support
** | |
** +-------------------------------------------------------+
*/
{
cache *c;
return NULL;
return c;
}
{
return;
}
{
cacheentry *ce;
return NULL;
}
if (mode & CACHEMODE_TS) {
return NULL;
}
}
else if (mode & CACHEMODE_TTL) {
return NULL;
}
}
}
static int cache_tlb_hash(char *key)
{
unsigned long n;
char *p;
n = 0;
for (p = key; *p != '\0'; p++) {
n = ((n << 5) + n) ^ (unsigned long)(*p++);
}
return n % CACHE_TLB_ROWS;
}
char *key)
{
int i;
int j;
for (i=0; i < CACHE_TLB_COLS; ++i) {
if (j < 0)
return NULL;
return &elt[j];
}
return NULL;
}
cacheentry *e)
{
int i;
for (i=1; i < CACHE_TLB_COLS; ++i)
}
{
int i;
int j;
cachelist *l;
cacheentry *e;
cachetlbentry *t;
int found_list;
found_list = 0;
/* first try to edit an existing entry */
found_list = 1;
if (e != NULL) {
return;
}
return;
}
}
}
}
/* create a needed new list */
if (!found_list) {
l = apr_push_array(c->lists);
sizeof(cachetlbentry));
for (i=0; i<CACHE_TLB_ROWS; ++i) {
for (j=0; j<CACHE_TLB_COLS; ++j)
t->t[j] = -1;
}
}
/* create the new entry */
e = apr_push_array(l->entries);
return;
}
}
/* not reached, but when it is no problem... */
return;
}
{
int i;
int j;
cachelist *l;
cacheentry *e;
if (e != NULL)
return e;
return e;
}
}
}
}
return NULL;
}
/*
** +-------------------------------------------------------+
** | |
** | misc functions
** | |
** +-------------------------------------------------------+
*/
const char *subst)
{
char matchbuf[LONG_STRING_LEN];
char substbuf[LONG_STRING_LEN];
char *output;
int l;
/* first create a match string which always has a trailing slash */
matchbuf[l] = '/';
l++;
}
/* now compare the prefix */
/* and now add the base-URL as replacement prefix */
substbuf[l] = '/';
l++;
}
if (output[0] == '/') {
}
else {
}
}
return output;
}
/*
**
** own command line parser which don't have the '\\' problem
**
*/
{
char *cp;
int isquoted;
#define SKIP_WHITESPACE(cp) \
cp++; \
};
isquoted = 0; \
if (*cp == '"') { \
isquoted = 1; \
cp++; \
}
cp++; \
continue; \
} \
break; \
} \
}
/* determine first argument */
if (*cp == '\0') {
return 1;
}
*cp++ = '\0';
/* determine second argument */
if (*cp == '\0') {
*cp++ = '\0';
return 0;
}
*cp++ = '\0';
/* again check if there are only two arguments */
if (*cp == '\0') {
*cp++ = '\0';
return 0;
}
/* determine second argument */
*cp++ = '\0';
return 0;
}
static void add_env_variable(request_rec *r, char *s)
{
char var[MAX_STRING_LEN];
char val[MAX_STRING_LEN];
char *cp;
int n;
var[n] = '\0';
}
}
/*
**
** check that a subrequest won't cause infinite recursion
**
*/
static int subreq_ok(request_rec *r)
{
/*
* either not in a subrequest, or in a subrequest
*/
}
/*
**
** stat() for only the prefix of a path
**
*/
{
char curpath[LONG_STRING_LEN];
char *cp;
if (curpath[0] != '/') {
return 0;
}
*cp = '\0';
}
return 1;
}
else {
return 0;
}
}
/*
**
** Lexicographic Compare
**
*/
{
int i;
return 1;
}
return -1;
}
for (i = 0; i < n1; i++) {
return 1;
}
return -1;
}
}
return 0;
}
/*
**
** Find end of bracketed expression
** s points after the opening bracket
**
*/
{
int depth;
for (depth = 1; *s; ++s) {
return s;
}
else if (*s == left) {
++depth;
}
}
return NULL;
}
#ifdef NETWARE
{
ExitThread(TSR_THREAD, 0);
}
#endif
/*EOF*/