]> granicus.if.org Git - apache/commitdiff
Add -T operator to allow easy evaluation of on/off, 1/0, ... variables
authorStefan Fritsch <sf@apache.org>
Thu, 30 Dec 2010 11:59:02 +0000 (11:59 +0000)
committerStefan Fritsch <sf@apache.org>
Thu, 30 Dec 2010 11:59:02 +0000 (11:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1053865 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/expr.html.en
docs/manual/expr.xml
server/util_expr_eval.c

index af94f551d270d7a3c7bfa5740a20641441a6f261..919c109faedd374bc824f4ce63b9f6eb2b7f7a6b 100644 (file)
@@ -307,10 +307,14 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</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>
index 6aed34d1805b51cd13d40d4790a7d36d315b0410..e3096d7f52398c173ac257cea82ac04a76d93a0d 100644 (file)
@@ -323,9 +323,13 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</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>
index 9d7f3a89f9f179f87322473196702f102679dae9..ba0df24060e098edbc64b069826f213e16aa44d2 100644 (file)
@@ -1161,6 +1161,27 @@ static int op_R(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1)
     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 unary_op_providers[] = {
     { op_nz, "n", NULL },
     { op_nz, "z", NULL },
     { op_R,  "R", subnet_parse_arg },
+    { op_T,  "T", NULL },
     { NULL, NULL, NULL }
 };