mod_rewrite.c revision 87dbf205c2a957ab59e2446de92de49f4ea10529
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg/* ====================================================================
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * Copyright (c) 1996-2000 The Apache Software Foundation. All rights reserved.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * Redistribution and use in source and binary forms, with or without
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * modification, are permitted provided that the following conditions
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * 1. Redistributions of source code must retain the above copyright
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * notice, this list of conditions and the following disclaimer.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * 2. Redistributions in binary form must reproduce the above copyright
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * notice, this list of conditions and the following disclaimer in
0662ed52e814f8f08ef0e09956413a792584eddffuankg * the documentation and/or other materials provided with the
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * distribution.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * 3. All advertising materials mentioning features or use of this
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * software must display the following acknowledgment:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * "This product includes software developed by the Apache Software Foundation
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * for use in the Apache HTTP server project (http://www.apache.org/)."
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * 4. The names "Apache Server" and "Apache Software Foundation" must not be used to
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * endorse or promote products derived from this software without
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * prior written permission. For written permission, please contact
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * apache@apache.org.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * 5. Products derived from this software may not be called "Apache"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * nor may "Apache" appear in their names without prior written
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * permission of the Apache Software Foundation.
16b55a35cff91315d261d1baa776138af465c4e4fuankg * 6. Redistributions of any form whatsoever must retain the following
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * acknowledgment:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * "This product includes software developed by the Apache Software Foundation
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * for use in the Apache HTTP server project (http://www.apache.org/)."
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * THIS SOFTWARE IS PROVIDED BY THE Apache Software Foundation ``AS IS'' AND ANY
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Apache Software Foundation OR
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * OF THE POSSIBILITY OF SUCH DAMAGE.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * ====================================================================
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * This software consists of voluntary contributions made by many
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * individuals on behalf of the Apache Software Foundation and was originally based
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * on public domain software written at the National Center for
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * Supercomputing Applications, University of Illinois, Urbana-Champaign.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * For more information on the Apache Software Foundation and the Apache HTTP server
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * project, please see <http://www.apache.org/>.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** URL Rewriting Module
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** This module uses a rule-based rewriting engine (based on a
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** regular-expression parser) to rewrite requested URLs on the fly.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** It supports an unlimited number of additional rule conditions (which can
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** operate on a lot of variables, even on HTTP headers) for granular
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** matching and even external database lookups (either via plain text
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** tables, DBM hash files or even external processes) for advanced URL
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** substitution.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** It operates on the full URLs (including the PATH_INFO part) both in
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** per-server context (httpd.conf) and per-dir context (.htaccess) and even
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** can generate QUERY_STRING parts on result. The rewriting result finally
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** can lead to internal subprocessing, external request redirection or even
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** to internal proxy throughput.
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** This module was originally written in April 1996 and
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** gifted exclusively to the The Apache Software Foundation in July 1997 by
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** Ralf S. Engelschall
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** rse@engelschall.com
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** +-------------------------------------------------------+
0662ed52e814f8f08ef0e09956413a792584eddffuankg** | static module configuration
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** +-------------------------------------------------------+
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** Our interface to the Apache server kernel:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** o Runtime logic of a request is as following:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** while(request or subrequest)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** foreach(stage #0...#9)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** foreach(module) (**)
0662ed52e814f8f08ef0e09956413a792584eddffuankg** try to run hook
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** o the order of modules at (**) is the inverted order as
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** given in the "Configuration" file, i.e. the last module
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** specified is the first one called for each hook!
0662ed52e814f8f08ef0e09956413a792584eddffuankg** The core module is always the last!
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** o there are two different types of result checking and
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** continue processing:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** for hook #0,#1,#4,#5,#6,#8:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** hook run loop stops on first modules which gives
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** back a result != DECLINED, i.e. it usually returns OK
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** which says "OK, module has handled this _stage_" and for #1
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** this have not to mean "Ok, the filename is now valid".
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** for hook #2,#3,#7,#9:
0662ed52e814f8f08ef0e09956413a792584eddffuankg** all hooks are run, independend of result
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** o at the last stage, the core module always
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** - says "BAD_REQUEST" if r->filename does not begin with "/"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** - prefix URL with document_root or replaced server_root
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** with document_root and sets r->filename
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** - always return a "OK" independed if the file really exists
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg /* The section for the Configure script:
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * XXX: this needs updating for apache-2.0 configuration method
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * MODULE-DEFINITION-START
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * Name: rewrite_module
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * ConfigStart
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg if [ "x$found_dbm" = "x1" ]; then
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg echo " enabling DBM support for mod_rewrite"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg echo " disabling DBM support for mod_rewrite"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * ConfigEnd
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg * MODULE-DEFINITION-END
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg /* the ap_table_t of commands we provide */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteEngine", cmd_rewriteengine, NULL, OR_FILEINFO, FLAG,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "On or Off to enable or disable (default) the whole rewriting engine" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteOptions", cmd_rewriteoptions, NULL, OR_FILEINFO, ITERATE,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "List of option strings to set" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteBase", cmd_rewritebase, NULL, OR_FILEINFO, TAKE1,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "the base URL of the per-directory context" },
cf7ca2f9eaa6523fefcccba4287b91637391fb51fuankg { "RewriteCond", cmd_rewritecond, NULL, OR_FILEINFO, RAW_ARGS,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "an input string and a to be applied regexp-pattern" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteRule", cmd_rewriterule, NULL, OR_FILEINFO, RAW_ARGS,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "an URL-applied regexp-pattern and a substitution URL" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteMap", cmd_rewritemap, NULL, RSRC_CONF, TAKE2,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "a mapname and a filename" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteLock", cmd_rewritelock, NULL, RSRC_CONF, TAKE1,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "the filename of a lockfile used for inter-process synchronization"},
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteLog", cmd_rewritelog, NULL, RSRC_CONF, TAKE1,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "the filename of the rewriting logfile" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg { "RewriteLogLevel", cmd_rewriteloglevel, NULL, RSRC_CONF, TAKE1,
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "the level of the rewriting logfile verbosity "
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg "(0=none, 1=std, .., 9=max)" },
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg /* the ap_table_t of content handlers we provide */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankgstatic void register_hooks(void)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg ap_hook_post_config(init_module,NULL,NULL,HOOK_MIDDLE);
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg ap_hook_child_init(init_child,NULL,NULL,HOOK_MIDDLE);
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg ap_hook_translate_name(hook_uri2file,NULL,NULL,HOOK_FIRST);
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg ap_hook_type_checker(hook_mimetype,NULL,NULL,HOOK_MIDDLE);
8ffac2c334103c0336602aaede650cb578611151fuankg /* the main config structure */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg config_perdir_create, /* create per-dir config structures */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg config_perdir_merge, /* merge per-dir config structures */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg config_server_create, /* create per-server config structures */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg config_server_merge, /* merge per-server config structures */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg command_table, /* ap_table_t of config file commands */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg handler_table, /* [#8] MIME-typed-dispatched handlers */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg /* the cache */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg /* whether proxy module is available or not */
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankgstatic int once_through = 0;
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankgstatic const char *lockname;
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** +-------------------------------------------------------+
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** | configuration directive handling
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** +-------------------------------------------------------+
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg** per-server configuration structure handling
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankgstatic void *config_server_create(ap_context_t *p, server_rec *s)
cb8c861baa9316dc6ecc8a29e18178b224d7445afuankg a = (rewrite_server_conf *)ap_pcalloc(p, sizeof(rewrite_server_conf));
a->rewriteloglevel = 0;
a->server = s;
sizeof(rewrite_perdir_conf));
sconf =
return NULL;
const char *err;
return err;
char *name)
return NULL;
return NULL;
return NULL;
char *a2)
#ifndef NO_DBM_REWRITEMAP
return NULL;
const char *error;
return error;
return NULL;
char *a1)
return NULL;
char *str)
char *a1;
char *a2;
char *a3;
char *cp;
const char *err;
int rc;
return err;
cp++;
== NULL);
if (rc) {
return NULL;
char *str)
char *cp;
char *cp1;
char *cp2;
char *cp3;
char *key;
char *val;
const char *err;
return err;
return NULL;
return NULL;
char *str)
char *a1;
char *a2;
char *a3;
char *cp;
const char *err;
int mode;
return err;
cp++;
sizeof(rewritecond_entry));
sizeof(rewritecond_entry));
return NULL;
char *str)
char *cp;
char *cp1;
char *cp2;
char *cp3;
char *key;
char *val;
const char *err;
return err;
return NULL;
int status = 0;
if (i < MAX_ENV_FLAGS) {
return NULL;
server_rec *s)
rewritelock_create(s, p);
for (; s; s = s->next) {
open_rewritelog(s, p);
if (once_through > 0)
run_rewritemap_programs(s, p);
once_through++;
rewritelock_open(s, p);
void *sconf;
const char *var;
const char *thisserver;
char *thisport;
const char *thisurl;
const char *ccp;
unsigned int port;
return DECLINED;
return DECLINED;
r->filename);
if (!proxy_available) {
return FORBIDDEN;
r->filename);
return OK;
n = r->status;
n = REDIRECT;
return FORBIDDEN;
return HTTP_GONE;
return DECLINED;
return BAD_REQUEST;
(r->filename +
r->filename);
return OK;
return DECLINED;
if (t == NULL) {
return DECLINED;
r->filename, t);
r->content_type = t;
return OK;
char *cp;
char *cp2;
const char *ccp;
char *prefix;
char *ofilename;
return DECLINED;
return DECLINED;
return DECLINED;
return FORBIDDEN;
return DECLINED;
return OK;
n = r->status;
n = REDIRECT;
return FORBIDDEN;
return HTTP_GONE;
return BAD_REQUEST;
return OK;
r->filename+l);
return OK;
return DECLINED;
return DECLINED;
return OK;
char *perdir)
int changed;
int rc;
changed = 0;
loop:
p = &entries[i];
if (rc) {
goto loop;
if (p->skip > 0) {
s = p->skip;
p = &entries[i];
p = &entries[i];
return changed;
char *perdir)
char *uri;
char *output;
const char *vary;
int prefixstrip;
int failed;
int rc;
prefixstrip = 0;
sizeof(regmatch));
failed = 0;
c = &conds[i];
if (rc == 0) {
c = &conds[i];
if (rc == 0) {
if (failed) {
p->forced_mimetype);
if ( prefixstrip
reduce_uri(r);
r->filename);
p->forced_mimetype);
int rc;
rc = 0;
sizeof(regmatch));
return rc;
char *olduri;
if (q != NULL) {
if (qsappend) {
r->filename);
char *cp;
unsigned short port;
char *portp;
char *hostp;
char *url;
char *olduri;
c = *cp;
*cp = c;
const char *thisserver;
char *thisport;
int port;
char *newuri;
return newuri;
char *cpI;
char *cpIE;
char *cpO;
char *cpT;
char *cpT2;
cpO += n;
cpO += n;
cpO += n;
cpI += n;
void *sconf;
rewritemap_entry *s;
char *value;
s = &entries[i];
return NULL;
if ((value =
return value;
return NULL;
#ifndef NO_DBM_REWRITEMAP
return NULL;
if ((value =
return value;
return NULL;
return NULL;
if ((value =
return value;
return value;
return NULL;
if ((value =
return NULL;
return value;
return NULL;
char *cpT;
char *curkey;
char *curval;
return NULL;
if (skip == 0)
++cpT;
if (skip == 0)
return value;
#ifndef NO_DBM_REWRITEMAP
return value;
#ifndef NO_WRITEV
return NULL;
#ifdef NO_WRITEV
buf[i++] = c;
rewritelock_free(r);
return NULL;
char *key)
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) {
static int rewrite_rand(int l, int h)
char *buf;
return value;
return buf;
const char *fname;
char *str1;
char *ruser;
const char *rhost;
(unsigned long)(r->server), (unsigned long)r,
int rc;
#ifdef SIGHUP
!= APR_SUCCESS) ||
if (fpin) {
if (fpout) {
if (fperr) {
return (rc);
char *newbuf;
char *cp;
char *cp2;
char *cp3;
int expanded;
char *outp;
char *endp;
expanded = 0;
const char *result;
#ifndef WIN32
/* XXX: wow this has gotta be slow if you actually use it for a lot, recalculates exploded time for each variable */
return (char *)result; \
return NULL;
cache *c;
return NULL;
return NULL;
return NULL;
return NULL;
return n % CACHE_TLB_ROWS;
char *key)
for (i=0; i < CACHE_TLB_COLS; ++i) {
return NULL;
return &elt[j];
return NULL;
cacheentry *e)
cachelist *l;
cacheentry *e;
cachetlbentry *t;
int found_list;
found_list = 0;
if (e != NULL) {
if (!found_list) {
sizeof(cachetlbentry));
for (i=0; i<CACHE_TLB_ROWS; ++i) {
for (j=0; j<CACHE_TLB_COLS; ++j)
cachelist *l;
cacheentry *e;
if (e != NULL)
return NULL;
char *subst)
char *output;
return output;
char *cp;
int isquoted;
cp++; \
isquoted = 0; \
cp++; \
cp++; \
char *cp;
char *cp;
#ifdef USE_FCNTL
int rc;
int sys_file;
#ifdef USE_FCNTL
#ifdef USE_FLOCK
#ifdef USE_LOCKING
if (rc < 0) {
int rc;
int sys_file;
#ifdef USE_FCNTL
#ifdef USE_FLOCK
#ifdef USE_LOCKING
if (rc < 0) {
for (i = 0; i < n1; i++) {
#ifdef NETWARE