]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS_10597: [mod_expr] add logic AND & OR
authorlazedo <luis.azedo@factorlusitano.com>
Thu, 17 Aug 2017 01:35:10 +0000 (02:35 +0100)
committerlazedo <luis.azedo@factorlusitano.com>
Thu, 17 Aug 2017 01:35:10 +0000 (02:35 +0100)
src/mod/applications/mod_expr/exprilfs.h
src/mod/applications/mod_expr/exprinit.c
src/mod/applications/mod_expr/exprpriv.h

index 05abb5f12ba2725cea7bf107467d20a15a5029fc..f89eadfadcd2bc24ef96b4106d988082c3c72b8e 100644 (file)
@@ -946,3 +946,35 @@ case EXPR_NODEFUNC_MANY:
 
        break;
 }
+
+/* logical and */
+case EXPR_NODEFUNC_LOGICAL_AND:
+{
+       err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+       if (!err)
+               err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+       if (!err) {
+               *val = (EXPRTYPE) (((unsigned int)d1) & ((unsigned int)d2));
+       } else
+               return err;
+
+       break;
+}
+
+/* or */
+case EXPR_NODEFUNC_LOGICAL_OR:
+{
+       err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
+
+       if (!err)
+               err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
+
+       if (!err) {
+               *val = (EXPRTYPE) (((unsigned int)d1) | ((unsigned int)d2));
+       } else
+               return err;
+
+       break;
+}
index 82eadafe107f1100938db7e99abc10fcdfd344e8..387aaee534db98b4a62a78e6e6923dcbe83746a7 100644 (file)
@@ -82,6 +82,8 @@ int exprFuncListInit(exprFuncList * flist)
        EXPR_ADDFUNC_TYPE("not", EXPR_NODEFUNC_NOT, 1, 1, 0, 0);
        EXPR_ADDFUNC_TYPE("for", EXPR_NODEFUNC_FOR, 4, -1, 0, 0);
        EXPR_ADDFUNC_TYPE("many", EXPR_NODEFUNC_MANY, 1, -1, 0, 0);
+       EXPR_ADDFUNC_TYPE("land", EXPR_NODEFUNC_LOGICAL_AND, 2, 2, 0, 0);
+       EXPR_ADDFUNC_TYPE("lor", EXPR_NODEFUNC_LOGICAL_OR, 2, 2, 0, 0);
 
        return EXPR_ERROR_NOERROR;
 }
index 08d9fc0ddc1136c680776b057a7225b32e767541..a11dc52c97608029d6c555adf32d5307491d9309 100644 (file)
@@ -97,7 +97,9 @@ extern "C" {
                EXPR_NODEFUNC_OR,
                EXPR_NODEFUNC_NOT,
                EXPR_NODEFUNC_FOR,
-               EXPR_NODEFUNC_MANY
+               EXPR_NODEFUNC_MANY,
+               EXPR_NODEFUNC_LOGICAL_AND,
+               EXPR_NODEFUNC_LOGICAL_OR
        };
 
 /* Forward declarations */