X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=json_script.h;h=66563e9de4350a6ef6c3e03b797b43ca5b9b924d;hp=e28b51100cccdaac897fb35558ef7bf60fef905e;hb=368fd2645878edadc72c60948d1f19c6769751d6;hpb=38ea521911a1bf01b3714f1dfc725e941159c0f1 diff --git a/json_script.h b/json_script.h index e28b511..66563e9 100644 --- a/json_script.h +++ b/json_script.h @@ -16,10 +16,10 @@ #ifndef __JSON_SCRIPT_H #define __JSON_SCRIPT_H -#include -#include -#include -#include +#include "avl.h" +#include "blob.h" +#include "blobmsg.h" +#include "utils.h" struct json_script_file; @@ -28,6 +28,7 @@ struct json_script_ctx { struct blob_buf buf; uint32_t run_seq; + bool abort; /* * handle_command: handle a command that was not recognized by the @@ -97,6 +98,30 @@ void json_script_free(struct json_script_ctx *ctx); void json_script_run(struct json_script_ctx *ctx, const char *filename, struct blob_attr *vars); +void json_script_run_file(struct json_script_ctx *ctx, struct json_script_file *file, + struct blob_attr *vars); + +/* + * json_script_abort - abort current json script run + * + * to be called from a script context callback + */ +static inline void +json_script_abort(struct json_script_ctx *ctx) +{ + ctx->abort = true; +} + +/* + * json_script_eval_string - evaluate a string and store the result + * + * Can be used to process variable references outside of a script + * in a same way that they would be interpreted in the script context. + */ +int json_script_eval_string(struct json_script_ctx *ctx, struct blob_attr *vars, + struct blob_buf *buf, const char *name, + const char *pattern); + struct json_script_file * json_script_file_from_blobmsg(const char *name, void *data, int len);