summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/mappers/mod_rewrite.c371
1 files changed, 205 insertions, 166 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 3970cff5a9..ad90d60dcf 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -128,14 +128,21 @@ static const char* really_last_key = "rewrite_really_last";
#ifndef REWRITELOG_DISABLED
-#define rewritelog(x) do_rewritelog x
+#ifdef AP_HAVE_C99
+#define rewritelog(...) do_rewritelog(__LINE__, __VA_ARGS__)
+#else
+#define rewritelog do_rewritelog
+#endif
#define REWRITELOG_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
#define REWRITELOG_FLAGS ( APR_WRITE | APR_APPEND | APR_CREATE )
#else /* !REWRITELOG_DISABLED */
-#define rewritelog(x)
-
+#ifdef AP_HAVE_C99
+#define rewritelog(...)
+#else
+#define rewritelog do_rewritelog
+#endif
#endif /* REWRITELOG_DISABLED */
/* remembered mime-type for [T=...] */
@@ -439,14 +446,42 @@ static char *escape_backref(apr_pool_t *p, const char *path, const char *escapem
* +-------------------------------------------------------+
*/
-#ifndef REWRITELOG_DISABLED
+/* Slightly complicated definitions follow here to support
+ * compile-time choice of enabled/disabled of rewritelog both with or
+ * without C99 support, where varargs macros are only available with
+ * C99.
+ *
+ * do_rewritelog is defined for (rewritelog enabled) or (rewritelog
+ * disabled AND no C99 support) but is an noop for the latter case and
+ * should get optimized away.
+ *
+ * For the (rewritelog disabled) case the function is defined
+ * differently for C99/non-C99. For C99, the rewritelog() macro passes
+ * __LINE__, allowing accurate logging of line numbers. For non-C99
+ * the line number used for rewritelog() tracing is always
+ * constant. */
+
+#if !defined(REWRITELOG_DISABLED) || !defined(AP_HAVE_C99)
+
+#ifdef AP_HAVE_C99
+static void do_rewritelog(int line,
+ request_rec *r, int level, char *perdir,
+ const char *fmt, ...)
+ __attribute__((format(printf,5,6)));
+#else
static void do_rewritelog(request_rec *r, int level, char *perdir,
const char *fmt, ...)
__attribute__((format(printf,4,5)));
+#endif
-static void do_rewritelog(request_rec *r, int level, char *perdir,
+static void do_rewritelog(
+#ifdef AP_HAVE_C99
+ int line,
+#endif
+ request_rec *r, int level, char *perdir,
const char *fmt, ...)
{
+#ifndef REWRITELOG_DISABLED
char *logline, *text;
const char *rhost, *rname;
int redir;
@@ -486,11 +521,15 @@ static void do_rewritelog(request_rec *r, int level, char *perdir,
AP_REWRITE_LOG((uintptr_t)r, level, r->main ? 0 : 1, (char *)ap_get_server_name(r), logline);
/* Intentional no APLOGNO */
+#ifdef AP_HAVE_C99
+ ap_log_rerror(__FILE__, line, APLOG_MODULE_INDEX, APLOG_DEBUG + level, 0, r, "%s", logline);
+#else
ap_log_rerror(APLOG_MARK, APLOG_DEBUG + level, 0, r, "%s", logline);
-
- return;
-}
+#endif
+
#endif /* !REWRITELOG_DISABLED */
+}
+#endif /* !defined(REWRITELOG_DISABLED) || !defined(AP_HAVE_C99) */
/*
@@ -782,7 +821,7 @@ static void splitout_queryargs(request_rec *r, int qsappend, int qsdiscard,
if ( qsdiscard ) {
r->args = NULL; /* Discard query string */
- rewritelog((r, 2, NULL, "discarding query string"));
+ rewritelog(r, 2, NULL, "discarding query string");
}
q = qslast ? ap_strrchr(r->filename, '?') : ap_strchr(r->filename, '?');
@@ -813,8 +852,8 @@ static void splitout_queryargs(request_rec *r, int qsappend, int qsdiscard,
}
}
- rewritelog((r, 3, NULL, "split uri=%s -> uri=%s, args=%s", olduri,
- r->filename, r->args ? r->args : "<none>"));
+ rewritelog(r, 3, NULL, "split uri=%s -> uri=%s, args=%s", olduri,
+ r->filename, r->args ? r->args : "<none>");
}
return;
@@ -876,7 +915,7 @@ static void reduce_uri(request_rec *r)
if (ap_matches_request_vhost(r, host, port)) {
rewrite_server_conf *conf =
ap_get_module_config(r->server->module_config, &rewrite_module);
- rewritelog((r, 3, NULL, "reduce %s -> %s", r->filename, url));
+ rewritelog(r, 3, NULL, "reduce %s -> %s", r->filename, url);
r->filename = apr_pstrdup(r->pool, url);
/* remember that the uri was reduced */
@@ -978,8 +1017,8 @@ static char *subst_prefix_path(request_rec *r, char *input, const char *match,
apr_size_t slen, outlen;
char *output;
- rewritelog((r, 5, NULL, "strip matching prefix: %s -> %s", input,
- input+len));
+ rewritelog(r, 5, NULL, "strip matching prefix: %s -> %s", input,
+ input+len);
slen = strlen(subst);
if (slen && subst[slen - 1] != '/') {
@@ -996,8 +1035,8 @@ static char *subst_prefix_path(request_rec *r, char *input, const char *match,
memcpy(output+slen, input+len, outlen - slen);
output[outlen] = '\0';
- rewritelog((r, 4, NULL, "add subst prefix: %s -> %s", input+len,
- output));
+ rewritelog(r, 4, NULL, "add subst prefix: %s -> %s", input+len,
+ output);
return output;
}
@@ -1441,7 +1480,7 @@ static char *lookup_map_dbd(request_rec *r, char *key, const char *label)
return ret;
default:
/* what's a fair rewritelog level for this? */
- rewritelog((r, 3, NULL, "Multiple values found for %s", key));
+ rewritelog(r, 3, NULL, "Multiple values found for %s", key);
return ret;
}
}
@@ -1646,29 +1685,29 @@ static char *lookup_map(request_rec *r, char *name, char *key)
value = get_cache_value(s->cachename, st.mtime, key, r->pool);
if (!value) {
- rewritelog((r, 6, NULL,
- "cache lookup FAILED, forcing new map lookup"));
-
+ rewritelog(r, 6, NULL,
+ "cache lookup FAILED, forcing new map lookup");
+
value = lookup_map_txtfile(r, s->datafile, key);
if (!value) {
- rewritelog((r, 5, NULL, "map lookup FAILED: map=%s[txt] key=%s",
- name, key));
+ rewritelog(r, 5, NULL, "map lookup FAILED: map=%s[txt] key=%s",
+ name, key);
set_cache_value(s->cachename, st.mtime, key, "");
return NULL;
}
- rewritelog((r, 5, NULL,"map lookup OK: map=%s[txt] key=%s -> val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "map lookup OK: map=%s[txt] key=%s -> val=%s",
+ name, key, value);
set_cache_value(s->cachename, st.mtime, key, value);
}
else {
- rewritelog((r,5,NULL,"cache lookup OK: map=%s[txt] key=%s -> val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "cache lookup OK: map=%s[txt] key=%s -> val=%s",
+ name, key, value);
}
if (s->type == MAPTYPE_RND && *value) {
value = select_random_value_part(r, value);
- rewritelog((r, 5, NULL, "randomly chosen the subvalue `%s'",value));
+ rewritelog(r, 5, NULL, "randomly chosen the subvalue `%s'",value);
}
return *value ? value : NULL;
@@ -1702,26 +1741,26 @@ static char *lookup_map(request_rec *r, char *name, char *key)
value = get_cache_value(s->cachename, st.mtime, key, r->pool);
if (!value) {
- rewritelog((r, 6, NULL,
- "cache lookup FAILED, forcing new map lookup"));
+ rewritelog(r, 6, NULL,
+ "cache lookup FAILED, forcing new map lookup");
value = lookup_map_dbmfile(r, s->datafile, s->dbmtype, key);
if (!value) {
- rewritelog((r, 5, NULL, "map lookup FAILED: map=%s[dbm] key=%s",
- name, key));
+ rewritelog(r, 5, NULL, "map lookup FAILED: map=%s[dbm] key=%s",
+ name, key);
set_cache_value(s->cachename, st.mtime, key, "");
return NULL;
}
- rewritelog((r, 5, NULL, "map lookup OK: map=%s[dbm] key=%s -> "
- "val=%s", name, key, value));
+ rewritelog(r, 5, NULL, "map lookup OK: map=%s[dbm] key=%s -> "
+ "val=%s", name, key, value);
set_cache_value(s->cachename, st.mtime, key, value);
return value;
}
- rewritelog((r, 5, NULL, "cache lookup OK: map=%s[dbm] key=%s -> val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "cache lookup OK: map=%s[dbm] key=%s -> val=%s",
+ name, key, value);
return *value ? value : NULL;
/*
@@ -1730,13 +1769,13 @@ static char *lookup_map(request_rec *r, char *name, char *key)
case MAPTYPE_DBD:
value = lookup_map_dbd(r, key, s->dbdq);
if (!value) {
- rewritelog((r, 5, NULL, "SQL map lookup FAILED: map %s key=%s",
- name, key));
+ rewritelog(r, 5, NULL, "SQL map lookup FAILED: map %s key=%s",
+ name, key);
return NULL;
}
- rewritelog((r, 5, NULL, "SQL map lookup OK: map %s key=%s, val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "SQL map lookup OK: map %s key=%s, val=%s",
+ name, key, value);
return value;
@@ -1746,26 +1785,26 @@ static char *lookup_map(request_rec *r, char *name, char *key)
case MAPTYPE_DBD_CACHE:
value = get_cache_value(s->cachename, 0, key, r->pool);
if (!value) {
- rewritelog((r, 6, NULL,
- "cache lookup FAILED, forcing new map lookup"));
+ rewritelog(r, 6, NULL,
+ "cache lookup FAILED, forcing new map lookup");
value = lookup_map_dbd(r, key, s->dbdq);
if (!value) {
- rewritelog((r, 5, NULL, "SQL map lookup FAILED: map %s key=%s",
- name, key));
+ rewritelog(r, 5, NULL, "SQL map lookup FAILED: map %s key=%s",
+ name, key);
set_cache_value(s->cachename, 0, key, "");
return NULL;
}
- rewritelog((r, 5, NULL, "SQL map lookup OK: map %s key=%s, val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "SQL map lookup OK: map %s key=%s, val=%s",
+ name, key, value);
set_cache_value(s->cachename, 0, key, value);
return value;
}
- rewritelog((r, 5, NULL, "cache lookup OK: map=%s[SQL] key=%s, val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "cache lookup OK: map=%s[SQL] key=%s, val=%s",
+ name, key, value);
return *value ? value : NULL;
/*
@@ -1774,13 +1813,13 @@ static char *lookup_map(request_rec *r, char *name, char *key)
case MAPTYPE_PRG:
value = lookup_map_program(r, s->fpin, s->fpout, key);
if (!value) {
- rewritelog((r, 5,NULL,"map lookup FAILED: map=%s key=%s", name,
- key));
+ rewritelog(r, 5, NULL, "map lookup FAILED: map=%s key=%s", name,
+ key);
return NULL;
}
- rewritelog((r, 5, NULL, "map lookup OK: map=%s key=%s -> val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "map lookup OK: map=%s key=%s -> val=%s",
+ name, key, value);
return value;
/*
@@ -1789,13 +1828,13 @@ static char *lookup_map(request_rec *r, char *name, char *key)
case MAPTYPE_INT:
value = s->func(r, key);
if (!value) {
- rewritelog((r, 5,NULL,"map lookup FAILED: map=%s key=%s", name,
- key));
+ rewritelog(r, 5, NULL, "map lookup FAILED: map=%s key=%s", name,
+ key);
return NULL;
}
- rewritelog((r, 5, NULL, "map lookup OK: map=%s key=%s -> val=%s",
- name, key, value));
+ rewritelog(r, 5, NULL, "map lookup OK: map=%s key=%s -> val=%s",
+ name, key, value);
return value;
}
@@ -1892,8 +1931,8 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
ctx->r = r;
ap_destroy_sub_req(rr);
- rewritelog((r, 5, ctx->perdir, "lookahead: path=%s var=%s "
- "-> val=%s", path, var+5, result));
+ rewritelog(r, 5, ctx->perdir, "lookahead: path=%s var=%s "
+ "-> val=%s", path, var+5, result);
return (char *)result;
}
@@ -1927,8 +1966,8 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
ctx->r = r;
ap_destroy_sub_req(rr);
- rewritelog((r, 5, ctx->perdir, "lookahead: path=%s var=%s "
- "-> val=%s", path, var+5, result));
+ rewritelog(r, 5, ctx->perdir, "lookahead: path=%s var=%s "
+ "-> val=%s", path, var+5, result);
return (char *)result;
}
@@ -1950,7 +1989,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
result = apr_psprintf(r->pool, "%04d%02d%02d%02d%02d%02d",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
- rewritelog((r, 1, ctx->perdir, "RESULT='%s'", result));
+ rewritelog(r, 1, ctx->perdir, "RESULT='%s'", result);
return (char *)result;
}
else if (!strcmp(var, "IPV6")) {
@@ -1959,9 +1998,9 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
apr_sockaddr_t *addr = r->useragent_addr;
flag = (addr->family == AF_INET6 &&
!IN6_IS_ADDR_V4MAPPED((struct in6_addr *)addr->ipaddr_ptr));
- rewritelog((r, 1, ctx->perdir, "IPV6='%s'", flag ? "on" : "off"));
+ rewritelog(r, 1, ctx->perdir, "IPV6='%s'", flag ? "on" : "off");
#else
- rewritelog((r, 1, ctx->perdir, "IPV6='off' (IPv6 is not enabled)"));
+ rewritelog(r, 1, ctx->perdir, "IPV6='off' (IPv6 is not enabled)");
#endif
result = (flag ? "on" : "off");
}
@@ -2435,8 +2474,8 @@ static char *do_expand(char *input, rewrite_ctx *ctx, rewriterule_entry *entry,
char *tmp2, *tmp;
tmp = apr_pstrmemdup(pool, bri->source + bri->regmatch[n].rm_so, span);
tmp2 = escape_backref(pool, tmp, entry->escapes, entry->flags & RULEFLAG_ESCAPENOPLUS);
- rewritelog((ctx->r, 5, ctx->perdir, "escaping backreference '%s' to '%s'",
- tmp, tmp2));
+ rewritelog(ctx->r, 5, ctx->perdir, "escaping backreference '%s' to '%s'",
+ tmp, tmp2);
current->len = span = strlen(tmp2);
current->string = tmp2;
@@ -2508,7 +2547,7 @@ static void do_expand_env(data_item *env, rewrite_ctx *ctx)
if (*name == '!') {
name++;
apr_table_unset(ctx->r->subprocess_env, name);
- rewritelog((ctx->r, 5, NULL, "unsetting env variable '%s'", name));
+ rewritelog(ctx->r, 5, NULL, "unsetting env variable '%s'", name);
}
else {
if ((val = ap_strchr(name, ':')) != NULL) {
@@ -2518,8 +2557,8 @@ static void do_expand_env(data_item *env, rewrite_ctx *ctx)
}
apr_table_set(ctx->r->subprocess_env, name, val);
- rewritelog((ctx->r, 5, NULL, "setting env variable '%s' to '%s'",
- name, val));
+ rewritelog(ctx->r, 5, NULL, "setting env variable '%s' to '%s'",
+ name, val);
}
env = env->next;
@@ -2617,11 +2656,11 @@ static void add_cookie(request_rec *r, char *s)
apr_table_addn(rmain->err_headers_out, "Set-Cookie", cookie);
apr_pool_userdata_set("set", notename, NULL, rmain->pool);
- rewritelog((rmain, 5, NULL, "setting cookie '%s'", cookie));
+ rewritelog(rmain, 5, NULL, "setting cookie '%s'", cookie);
}
else {
- rewritelog((rmain, 5, NULL, "skipping already set cookie '%s'",
- var));
+ rewritelog(rmain, 5, NULL, "skipping already set cookie '%s'",
+ var);
}
}
@@ -3931,8 +3970,8 @@ static int apply_rewrite_cond(rewritecond_entry *p, rewrite_ctx *ctx, apr_pool_t
if (rsub->status < 400) {
rc = 1;
}
- rewritelog((r, 5, NULL, "RewriteCond URI (-U) check: "
- "path=%s -> status=%d", input, rsub->status));
+ rewritelog(r, 5, NULL, "RewriteCond URI (-U check: "
+ "path=%s -> status=%d", input, rsub->status);
ap_destroy_sub_req(rsub);
}
break;
@@ -3946,9 +3985,9 @@ static int apply_rewrite_cond(rewritecond_entry *p, rewrite_ctx *ctx, apr_pool_t
r->pool) == APR_SUCCESS) {
rc = 1;
}
- rewritelog((r, 5, NULL, "RewriteCond file (-F) check: path=%s "
+ rewritelog(r, 5, NULL, "RewriteCond file (-F check: path=%s "
"-> file=%s status=%d", input, rsub->filename,
- rsub->status));
+ rsub->status);
ap_destroy_sub_req(rsub);
}
break;
@@ -4005,9 +4044,9 @@ test_str_l:
rc = ap_expr_exec_re(r, p->expr, AP_MAX_REG_MATCH, regmatch,
&source, &err);
if (rc < 0 || err) {
- rewritelog((r, 1, ctx->perdir,
+ rewritelog(r, 1, ctx->perdir,
"RewriteCond: expr='%s' evaluation failed: %s",
- p->pattern - p->pskip, err));
+ p->pattern - p->pskip, err);
rc = 0;
}
/* update briRC backref info */
@@ -4033,10 +4072,10 @@ test_str_l:
rc = !rc;
}
- rewritelog((r, 4, ctx->perdir, "RewriteCond: input='%s' pattern='%s'%s "
- "=> %s", input, p->pattern - p->pskip,
- (p->flags & CONDFLAG_NOCASE) ? " [NC]" : "",
- rc ? "matched" : "not-matched"));
+ rewritelog(r, 4, ctx->perdir, "RewriteCond: input='%s' pattern='%s'%s "
+ "=> %s", input, p->pattern - p->pskip,
+ (p->flags & CONDFLAG_NOCASE) ? " [NC]" : "",
+ rc ? "matched" : "not-matched");
return rc;
}
@@ -4053,8 +4092,8 @@ static APR_INLINE void force_type_handler(rewriterule_entry *p,
if (*expanded) {
ap_str_tolower(expanded);
- rewritelog((ctx->r, 2, ctx->perdir, "remember %s to have MIME-type "
- "'%s'", ctx->r->filename, expanded));
+ rewritelog(ctx->r, 2, ctx->perdir, "remember %s to have MIME-type "
+ "'%s'", ctx->r->filename, expanded);
apr_table_setn(ctx->r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,
expanded);
@@ -4067,8 +4106,8 @@ static APR_INLINE void force_type_handler(rewriterule_entry *p,
if (*expanded) {
ap_str_tolower(expanded);
- rewritelog((ctx->r, 2, ctx->perdir, "remember %s to have "
- "Content-handler '%s'", ctx->r->filename, expanded));
+ rewritelog(ctx->r, 2, ctx->perdir, "remember %s to have "
+ "Content-handler '%s'", ctx->r->filename, expanded);
apr_table_setn(ctx->r->notes, REWRITE_FORCED_HANDLER_NOTEVAR,
expanded);
@@ -4104,8 +4143,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
* to re-add the PATH_INFO postfix
*/
if (r->path_info && *r->path_info) {
- rewritelog((r, 3, ctx->perdir, "add path info postfix: %s -> %s%s",
- ctx->uri, ctx->uri, r->path_info));
+ rewritelog(r, 3, ctx->perdir, "add path info postfix: %s -> %s%s",
+ ctx->uri, ctx->uri, r->path_info);
ctx->uri = apr_pstrcat(r->pool, ctx->uri, r->path_info, NULL);
}
@@ -4115,8 +4154,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
if (!is_proxyreq && strlen(ctx->uri) >= dirlen &&
!strncmp(ctx->uri, ctx->perdir, dirlen)) {
- rewritelog((r, 3, ctx->perdir, "strip per-dir prefix: %s -> %s",
- ctx->uri, ctx->uri + dirlen));
+ rewritelog(r, 3, ctx->perdir, "strip per-dir prefix: %s -> %s",
+ ctx->uri, ctx->uri + dirlen);
ctx->uri = ctx->uri + dirlen;
}
}
@@ -4124,8 +4163,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
/* Try to match the URI against the RewriteRule pattern
* and exit immediately if it didn't apply.
*/
- rewritelog((r, 3, ctx->perdir, "applying pattern '%s' to uri '%s'",
- p->pattern, ctx->uri));
+ rewritelog(r, 3, ctx->perdir, "applying pattern '%s' to uri '%s'",
+ p->pattern, ctx->uri);
rc = !ap_regexec(p->regexp, ctx->uri, AP_MAX_REG_MATCH, regmatch, 0);
if (! (( rc && !(p->flags & RULEFLAG_NOTMATCH)) ||
@@ -4202,8 +4241,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
/* expand the result */
if (!(p->flags & RULEFLAG_NOSUB)) {
newuri = do_expand(p->output, ctx, p, ctx->r->pool);
- rewritelog((r, 2, ctx->perdir, "rewrite '%s' -> '%s'", ctx->uri,
- newuri));
+ rewritelog(r, 2, ctx->perdir, "rewrite '%s' -> '%s'", ctx->uri,
+ newuri);
}
/* expand [E=var:val] and [CO=<cookie>] */
@@ -4215,8 +4254,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
force_type_handler(p, ctx);
if (p->flags & RULEFLAG_STATUS) {
- rewritelog((r, 2, ctx->perdir, "forcing responsecode %d for %s",
- p->forced_responsecode, r->filename));
+ rewritelog(r, 2, ctx->perdir, "forcing responsecode %d for %s",
+ p->forced_responsecode, r->filename);
r->status = p->forced_responsecode;
}
@@ -4241,8 +4280,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
*/
if ( ctx->perdir && !is_proxyreq && *r->filename != '/'
&& !is_absolute_uri(r->filename, NULL)) {
- rewritelog((r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
- r->filename, ctx->perdir, r->filename));
+ rewritelog(r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
+ r->filename, ctx->perdir, r->filename);
r->filename = apr_pstrcat(r->pool, ctx->perdir, r->filename, NULL);
}
@@ -4265,14 +4304,14 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
char *old_filename = r->filename;
r->filename = ap_escape_uri(r->pool, r->filename);
- rewritelog((r, 2, ctx->perdir, "escaped URI in per-dir context "
- "for proxy, %s -> %s", old_filename, r->filename));
+ rewritelog(r, 2, ctx->perdir, "escaped URI in per-dir context "
+ "for proxy, %s -> %s", old_filename, r->filename);
}
fully_qualify_uri(r);
- rewritelog((r, 2, ctx->perdir, "forcing proxy-throughput with %s",
- r->filename));
+ rewritelog(r, 2, ctx->perdir, "forcing proxy-throughput with %s",
+ r->filename);
r->filename = apr_pstrcat(r->pool, "proxy:", r->filename, NULL);
return 1;
@@ -4286,8 +4325,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
if (p->flags & RULEFLAG_FORCEREDIRECT) {
fully_qualify_uri(r);
- rewritelog((r, 2, ctx->perdir, "explicitly forcing redirect with %s",
- r->filename));
+ rewritelog(r, 2, ctx->perdir, "explicitly forcing redirect with %s",
+ r->filename);
r->status = p->forced_responsecode;
return 1;
@@ -4308,8 +4347,8 @@ static int apply_rewrite_rule(rewriterule_entry *p, rewrite_ctx *ctx)
* directly force an external HTTP redirect.
*/
if (is_absolute_uri(r->filename, NULL)) {
- rewritelog((r, 2, ctx->perdir, "implicitly forcing redirect (rc=%d) "
- "with %s", p->forced_responsecode, r->filename));
+ rewritelog(r, 2, ctx->perdir, "implicitly forcing redirect (rc=%d "
+ "with %s", p->forced_responsecode, r->filename);
r->status = p->forced_responsecode;
return 1;
@@ -4422,8 +4461,8 @@ static int apply_rewrite_list(request_rec *r, apr_array_header_t *rewriterules,
* modules like mod_alias, mod_userdir, etc.
*/
if (p->flags & RULEFLAG_PASSTHROUGH) {
- rewritelog((r, 2, perdir, "forcing '%s' to get passed through "
- "to next API URI-to-filename handler", r->filename));
+ rewritelog(r, 2, perdir, "forcing '%s' to get passed through "
+ "to next API URI-to-filename handler", r->filename);
r->filename = apr_pstrcat(r->pool, "passthrough:",
r->filename, NULL);
changed = ACTION_NORMAL;
@@ -4431,7 +4470,7 @@ static int apply_rewrite_list(request_rec *r, apr_array_header_t *rewriterules,
}
if (p->flags & RULEFLAG_END) {
- rewritelog((r, 8, perdir, "Rule has END flag, no further rewriting for this request"));
+ rewritelog(r, 8, perdir, "Rule has END flag, no further rewriting for this request");
apr_pool_userdata_set("1", really_last_key, apr_pool_cleanup_null, r->pool);
break;
}
@@ -4634,7 +4673,7 @@ static int hook_uri2file(request_rec *r)
/* END flag was used as a RewriteRule flag on this request */
apr_pool_userdata_get(&skipdata, really_last_key, r->pool);
if (skipdata != NULL) {
- rewritelog((r, 8, NULL, "Declining, no further rewriting due to END flag"));
+ rewritelog(r, 8, NULL, "Declining, no further rewriting due to END flag");
return DECLINED;
}
@@ -4644,10 +4683,10 @@ static int hook_uri2file(request_rec *r)
if ((dconf->options & OPTION_ANYURI) == 0
&& ((r->unparsed_uri[0] == '*' && r->unparsed_uri[1] == '\0')
|| !r->uri || r->uri[0] != '/')) {
- rewritelog((r, 8, NULL, "Declining, request-URI '%s' is not a URL-path. "
+ rewritelog(r, 8, NULL, "Declining, request-URI '%s' is not a URL-path. "
"Consult the manual entry for the RewriteOptions directive "
"for options and caveats about matching other strings.",
- r->uri));
+ r->uri);
return DECLINED;
}
@@ -4702,12 +4741,12 @@ static int hook_uri2file(request_rec *r)
*/
if (r->filename == NULL) {
r->filename = apr_pstrdup(r->pool, r->uri);
- rewritelog((r, 2, NULL, "init rewrite engine with requested uri %s",
- r->filename));
+ rewritelog(r, 2, NULL, "init rewrite engine with requested uri %s",
+ r->filename);
}
else {
- rewritelog((r, 2, NULL, "init rewrite engine with passed filename "
- "%s. Original uri = %s", r->filename, r->uri));
+ rewritelog(r, 2, NULL, "init rewrite engine with passed filename "
+ "%s. Original uri = %s", r->filename, r->uri);
}
/*
@@ -4718,8 +4757,8 @@ static int hook_uri2file(request_rec *r)
apr_psprintf(r->pool,"%d",rulestatus));
}
else {
- rewritelog((r, 2, NULL, "uri already rewritten. Status %s, Uri %s, "
- "r->filename %s", saved_rulestatus, r->uri, r->filename));
+ rewritelog(r, 2, NULL, "uri already rewritten. Status %s, Uri %s, "
+ "r->filename %s", saved_rulestatus, r->uri, r->filename);
rulestatus = atoi(saved_rulestatus);
}
@@ -4774,8 +4813,8 @@ static int hook_uri2file(request_rec *r)
}
r->handler = "proxy-server";
- rewritelog((r, 1, NULL, "go-ahead with proxy request %s [OK]",
- r->filename));
+ rewritelog(r, 1, NULL, "go-ahead with proxy request %s [OK]",
+ r->filename);
return OK;
}
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0) {
@@ -4784,8 +4823,8 @@ static int hook_uri2file(request_rec *r)
/* it was finally rewritten to a remote URL */
if (rulestatus != ACTION_NOESCAPE) {
- rewritelog((r, 1, NULL, "escaping %s for redirect",
- r->filename));
+ rewritelog(r, 1, NULL, "escaping %s for redirect",
+ r->filename);
r->filename = escape_absolute_uri(r->pool, r->filename, skip);
}
@@ -4802,10 +4841,10 @@ static int hook_uri2file(request_rec *r)
ap_escape_uri(r->pool, r->args)),
NULL);
- rewritelog((r, 1, NULL, "%s %s to query string for redirect %s",
- noescape ? "copying" : "escaping",
- r->args ,
- noescape ? "" : escaped_args));
+ rewritelog(r, 1, NULL, "%s %s to query string for redirect %s",
+ noescape ? "copying" : "escaping",
+ r->args ,
+ noescape ? "" : escaped_args);
}
/* determine HTTP redirect response code */
@@ -4819,8 +4858,8 @@ static int hook_uri2file(request_rec *r)
/* now do the redirection */
apr_table_setn(r->headers_out, "Location", r->filename);
- rewritelog((r, 1, NULL, "redirect to %s [REDIRECT/%d]", r->filename,
- n));
+ rewritelog(r, 1, NULL, "redirect to %s [REDIRECT/%d]", r->filename,
+ n);
return n;
}
@@ -4844,7 +4883,7 @@ static int hook_uri2file(request_rec *r)
#if APR_HAS_USER
r->filename = expand_tildepaths(r, r->filename);
#endif
- rewritelog((r, 2, NULL, "local path result: %s", r->filename));
+ rewritelog(r, 2, NULL, "local path result: %s", r->filename);
/* the filename must be either an absolute local path or an
* absolute local URL.
@@ -4888,22 +4927,22 @@ static int hook_uri2file(request_rec *r)
r->uri = tmp;
if (res != OK) {
- rewritelog((r, 1, NULL, "prefixing with document_root of %s"
- " FAILED", r->filename));
+ rewritelog(r, 1, NULL, "prefixing with document_root of %s"
+ " FAILED", r->filename);
return res;
}
- rewritelog((r, 2, NULL, "prefixed with document_root to %s",
- r->filename));
+ rewritelog(r, 2, NULL, "prefixed with document_root to %s",
+ r->filename);
}
- rewritelog((r, 1, NULL, "go-ahead with %s [OK]", r->filename));
+ rewritelog(r, 1, NULL, "go-ahead with %s [OK]", r->filename);
return OK;
}
}
else {
- rewritelog((r, 1, NULL, "pass through %s", r->filename));
+ rewritelog(r, 1, NULL, "pass through %s", r->filename);
return DECLINED;
}
}
@@ -4971,7 +5010,7 @@ static int hook_fixup(request_rec *r)
/* END flag was used as a RewriteRule flag on this request */
apr_pool_userdata_get(&skipdata, really_last_key, r->pool);
if (skipdata != NULL) {
- rewritelog((r, 8, dconf->directory, "Declining, no further rewriting due to END flag"));
+ rewritelog(r, 8, dconf->directory, "Declining, no further rewriting due to END flag");
return DECLINED;
}
@@ -5001,8 +5040,8 @@ static int hook_fixup(request_rec *r)
if (r->filename == NULL) {
r->filename = apr_pstrdup(r->pool, r->uri);
- rewritelog((r, 2, dconf->directory, "init rewrite engine with"
- " requested uri %s", r->filename));
+ rewritelog(r, 2, dconf->directory, "init rewrite engine with"
+ " requested uri %s", r->filename);
}
/*
@@ -5050,8 +5089,8 @@ static int hook_fixup(request_rec *r)
}
r->handler = "proxy-server";
- rewritelog((r, 1, dconf->directory, "go-ahead with proxy request "
- "%s [OK]", r->filename));
+ rewritelog(r, 1, dconf->directory, "go-ahead with proxy request "
+ "%s [OK]", r->filename);
return OK;
}
else if ((skip = is_absolute_uri(r->filename, NULL)) > 0) {
@@ -5066,9 +5105,9 @@ static int hook_fixup(request_rec *r)
cp = r->filename + skip;
if ((cp = ap_strchr(cp, '/')) != NULL && *(++cp)) {
- rewritelog((r, 2, dconf->directory,
- "trying to replace prefix %s with %s",
- dconf->directory, dconf->baseurl));
+ rewritelog(r, 2, dconf->directory,
+ "trying to replace prefix %s with %s",
+ dconf->directory, dconf->baseurl);
/* I think, that hack needs an explanation:
* well, here is it:
@@ -5106,8 +5145,8 @@ static int hook_fixup(request_rec *r)
/* now prepare the redirect... */
if (rulestatus != ACTION_NOESCAPE) {
- rewritelog((r, 1, dconf->directory, "escaping %s for redirect",
- r->filename));
+ rewritelog(r, 1, dconf->directory, "escaping %s for redirect",
+ r->filename);
r->filename = escape_absolute_uri(r->pool, r->filename, skip);
}
@@ -5123,10 +5162,10 @@ static int hook_fixup(request_rec *r)
: (escaped_args = ap_escape_uri(r->pool, r->args)),
NULL);
- rewritelog((r, 1, dconf->directory, "%s %s to query string for redirect %s",
- noescape ? "copying" : "escaping",
- r->args ,
- noescape ? "" : escaped_args));
+ rewritelog(r, 1, dconf->directory, "%s %s to query string for redirect %s",
+ noescape ? "copying" : "escaping",
+ r->args ,
+ noescape ? "" : escaped_args);
}
/* determine HTTP redirect response code */
@@ -5140,8 +5179,8 @@ static int hook_fixup(request_rec *r)
/* now do the redirection */
apr_table_setn(r->headers_out, "Location", r->filename);
- rewritelog((r, 1, dconf->directory, "redirect to %s [REDIRECT/%d]",
- r->filename, n));
+ rewritelog(r, 1, dconf->directory, "redirect to %s [REDIRECT/%d]",
+ r->filename, n);
return n;
}
else {
@@ -5156,7 +5195,7 @@ static int hook_fixup(request_rec *r)
r->filename = apr_pstrdup(r->pool, r->filename+12);
}
- rewritelog((r, 2, NULL, "local path result: %s", r->filename));
+ rewritelog(r, 2, NULL, "local path result: %s", r->filename);
/* the filename must be either an absolute local path or an
* absolute local URL.
@@ -5174,8 +5213,8 @@ static int hook_fixup(request_rec *r)
* this would lead to a deadloop.
*/
if (ofilename != NULL && strcmp(r->filename, ofilename) == 0) {
- rewritelog((r, 1, dconf->directory, "initial URL equal rewritten"
- " URL: %s [IGNORING REWRITE]", r->filename));
+ rewritelog(r, 1, dconf->directory, "initial URL equal rewritten"
+ " URL: %s [IGNORING REWRITE]", r->filename);
return OK;
}
@@ -5188,8 +5227,8 @@ static int hook_fixup(request_rec *r)
* plain URL
*/
if (dconf->baseurl != NULL) {
- rewritelog((r, 2, dconf->directory, "trying to replace prefix "
- "%s with %s", dconf->directory, dconf->baseurl));
+ rewritelog(r, 2, dconf->directory, "trying to replace prefix "
+ "%s with %s", dconf->directory, dconf->baseurl);
r->filename = subst_prefix_path(r, r->filename,
dconf->directory,
@@ -5209,9 +5248,9 @@ static int hook_fixup(request_rec *r)
}
if (!strncmp(r->filename, ccp, l) &&
r->filename[l] == '/') {
- rewritelog((r, 2,dconf->directory, "strip document_root"
- " prefix: %s -> %s", r->filename,
- r->filename+l));
+ rewritelog(r, 2,dconf->directory, "strip document_root"
+ " prefix: %s -> %s", r->filename,
+ r->filename+l);
r->filename = apr_pstrdup(r->pool, r->filename+l);
}
@@ -5230,9 +5269,9 @@ static int hook_fixup(request_rec *r)
if ((ccp = ap_context_document_root(r)) != NULL) {
const char *prefix = ap_context_prefix(r);
if (prefix != NULL) {
- rewritelog((r, 2, dconf->directory, "trying to replace "
+ rewritelog(r, 2, dconf->directory, "trying to replace "
"context docroot %s with context prefix %s",
- ccp, prefix));
+ ccp, prefix);
r->filename = subst_prefix_path(r, r->filename,
ccp, prefix);
}
@@ -5242,15 +5281,15 @@ static int hook_fixup(request_rec *r)
apr_table_setn(r->notes, "redirect-keeps-vary", "");
/* now initiate the internal redirect */
- rewritelog((r, 1, dconf->directory, "internal redirect with %s "
- "[INTERNAL REDIRECT]", r->filename));
+ rewritelog(r, 1, dconf->directory, "internal redirect with %s "
+ "[INTERNAL REDIRECT]", r->filename);
r->filename = apr_pstrcat(r->pool, "redirect:", r->filename, NULL);
r->handler = REWRITE_REDIRECT_HANDLER_NAME;
return OK;
}
}
else {
- rewritelog((r, 1, dconf->directory, "pass through %s", r->filename));
+ rewritelog(r, 1, dconf->directory, "pass through %s", r->filename);
r->filename = ofilename;
return DECLINED;
}
@@ -5267,8 +5306,8 @@ static int hook_mimetype(request_rec *r)
/* type */
t = apr_table_get(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR);
if (t && *t) {
- rewritelog((r, 1, NULL, "force filename %s to have MIME-type '%s'",
- r->filename, t));
+ rewritelog(r, 1, NULL, "force filename %s to have MIME-type '%s'",
+ r->filename, t);
ap_set_content_type(r, t);
}
@@ -5276,8 +5315,8 @@ static int hook_mimetype(request_rec *r)
/* handler */
t = apr_table_get(r->notes, REWRITE_FORCED_HANDLER_NOTEVAR);
if (t && *t) {
- rewritelog((r, 1, NULL, "force filename %s to have the "
- "Content-handler '%s'", r->filename, t));
+ rewritelog(r, 1, NULL, "force filename %s to have the "
+ "Content-handler '%s'", r->filename, t);
r->handler = t;
}