json_script: enable custom expr handler callback
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]
This commit is contained in:
parent
7237302147
commit
fa9937cc4f
1 changed files with 5 additions and 2 deletions
|
@ -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);
|
ret = __json_process_type(call, cur, expr, ARRAY_SIZE(expr), &found);
|
||||||
if (!found)
|
if (!found) {
|
||||||
ctx->handle_error(ctx, "Unknown expression type", cur);
|
const char *name = blobmsg_data(blobmsg_data(cur));
|
||||||
|
ctx->handle_expr(ctx, name, cur, call->vars);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -671,6 +673,7 @@ static int
|
||||||
__default_handle_expr(struct json_script_ctx *ctx, const char *name,
|
__default_handle_expr(struct json_script_ctx *ctx, const char *name,
|
||||||
struct blob_attr *expr, struct blob_attr *vars)
|
struct blob_attr *expr, struct blob_attr *vars)
|
||||||
{
|
{
|
||||||
|
ctx->handle_error(ctx, "Unknown expression type", expr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue