json_script: enable custom expr handler callback
authorDenis Osvald <denis.osvald@sartura.hr>
Thu, 18 May 2017 07:39:28 +0000 (09:39 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Jun 2017 09:23:16 +0000 (11:23 +0200)
This wires in custom expression handler functionality, which was present
in json script since the original version, but never used.

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [error handling fix]
json_script.c

index 463aac88dee42cef14e848f878a0548c96c0134d..87b1d71b1837168e7a6aa55163b41084c79e7455 100644 (file)
@@ -415,8 +415,10 @@ static int json_process_expr(struct json_call *call, struct blob_attr *cur)
        }
 
        ret = __json_process_type(call, cur, expr, ARRAY_SIZE(expr), &found);
-       if (!found)
-               ctx->handle_error(ctx, "Unknown expression type", cur);
+       if (!found) {
+               const char *name = blobmsg_data(blobmsg_data(cur));
+               ctx->handle_expr(ctx, name, cur, call->vars);
+       }
 
        return ret;
 }
@@ -671,6 +673,7 @@ static int
 __default_handle_expr(struct json_script_ctx *ctx, const char *name,
                      struct blob_attr *expr, struct blob_attr *vars)
 {
+       ctx->handle_error(ctx, "Unknown expression type", expr);
        return -1;
 }