You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2010/12/30 12:59:03 UTC
svn commit: r1053865 - in /httpd/httpd/trunk: docs/manual/expr.html.en
docs/manual/expr.xml server/util_expr_eval.c
Author: sf
Date: Thu Dec 30 11:59:02 2010
New Revision: 1053865
URL: http://svn.apache.org/viewvc?rev=1053865&view=rev
Log:
Add -T operator to allow easy evaluation of on/off, 1/0, ... variables
Modified:
httpd/httpd/trunk/docs/manual/expr.html.en
httpd/httpd/trunk/docs/manual/expr.xml
httpd/httpd/trunk/server/util_expr_eval.c
Modified: httpd/httpd/trunk/docs/manual/expr.html.en
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/expr.html.en?rev=1053865&r1=1053864&r2=1053865&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/expr.html.en (original)
+++ httpd/httpd/trunk/docs/manual/expr.html.en Thu Dec 30 11:59:02 2010
@@ -307,10 +307,14 @@ listfunction ::= listfuncname "<strong>(
<table class="bordered"><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><code>-n</code></td>
- <td>String is not empty</td></tr>
+ <td>True if string is not empty</td></tr>
<tr class="odd"><td><code>-z</code></td>
- <td>String is empty</td></tr>
-<tr><td><code>-R</code></td>
+ <td>True if string is empty</td></tr>
+<tr><td><code>-T</code></td>
+ <td>False if string is empty, "<code>0</code>", "<code>off</code>",
+ "<code>false</code>", or "<code>no</code>" (case insensitive).
+ True otherwise.</td></tr>
+<tr class="odd"><td><code>-R</code></td>
<td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
</td></tr>
</table>
Modified: httpd/httpd/trunk/docs/manual/expr.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/expr.xml?rev=1053865&r1=1053864&r2=1053865&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/expr.xml (original)
+++ httpd/httpd/trunk/docs/manual/expr.xml Thu Dec 30 11:59:02 2010
@@ -323,9 +323,13 @@ listfunction ::= listfuncname "<strong>(
<tr><th>Name</th><th>Description</th></tr>
<tr><td><code>-n</code></td>
- <td>String is not empty</td></tr>
+ <td>True if string is not empty</td></tr>
<tr><td><code>-z</code></td>
- <td>String is empty</td></tr>
+ <td>True if string is empty</td></tr>
+ <tr><td><code>-T</code></td>
+ <td>False if string is empty, "<code>0</code>", "<code>off</code>",
+ "<code>false</code>", or "<code>no</code>" (case insensitive).
+ True otherwise.</td></tr>
<tr><td><code>-R</code></td>
<td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
</td></tr>
Modified: httpd/httpd/trunk/server/util_expr_eval.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr_eval.c?rev=1053865&r1=1053864&r2=1053865&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr_eval.c (original)
+++ httpd/httpd/trunk/server/util_expr_eval.c Thu Dec 30 11:59:02 2010
@@ -1161,6 +1161,27 @@ static int op_R(ap_expr_eval_ctx_t *ctx,
return apr_ipsubnet_test(subnet, ctx->c->remote_addr);
}
+static int op_T(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg)
+{
+ switch (arg[0]) {
+ case '\0':
+ return FALSE;
+ case 'o':
+ case 'O':
+ return strcasecmp(arg, "off") == 0 ? FALSE : TRUE;
+ case 'n':
+ case 'N':
+ return strcasecmp(arg, "no") == 0 ? FALSE : TRUE;
+ case 'f':
+ case 'F':
+ return strcasecmp(arg, "false") == 0 ? FALSE : TRUE;
+ case '0':
+ return arg[1] == '\0' ? FALSE : TRUE;
+ default:
+ return TRUE;
+ }
+}
+
static int op_fnmatch(ap_expr_eval_ctx_t *ctx, const void *data,
const char *arg1, const char *arg2)
{
@@ -1220,6 +1241,7 @@ static const struct expr_provider_single
{ op_nz, "n", NULL },
{ op_nz, "z", NULL },
{ op_R, "R", subnet_parse_arg },
+ { op_T, "T", NULL },
{ NULL, NULL, NULL }
};