#include <stdio.h>
#include <stdlib.h>
#include <json.h>
#include "blobmsg.h"
#include "blobmsg_json.h"
#include "json_script.h"
Go to the source code of this file.
◆ handle_command()
Definition at line 13 of file test-json-script.c.
19 fprintf(stdout,
"%s",
name);
22 fprintf(stdout,
"\n");
#define blobmsg_for_each_attr(pos, attr, rem)
static void * blobmsg_data(const struct blob_attr *attr)
◆ handle_file()
Definition at line 26 of file test-json-script.c.
30 obj = json_object_from_file(filename);
32 fprintf(stderr,
"load JSON data from %s failed.\n", filename);
int blob_buf_init(struct blob_buf *buf, int id)
static size_t blob_len(const struct blob_attr *attr)
static void * blob_data(const struct blob_attr *attr)
bool blobmsg_add_json_element(struct blob_buf *b, const char *name, json_object *obj)
struct json_script_file * json_script_file_from_blobmsg(const char *name, void *data, int len)
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 50 of file test-json-script.c.
54 const char *prog = argv[0];
63 for (i = 1; i < argc; i++) {
64 char *sep = strchr(argv[i],
'=');
74 if (i < argc || !file)
void blob_buf_free(struct blob_buf *buf)
static int blobmsg_add_string(struct blob_buf *buf, const char *name, const char *string)
static int blobmsg_buf_init(struct blob_buf *buf)
void json_script_init(struct json_script_ctx *ctx)
void json_script_free(struct json_script_ctx *ctx)
void json_script_run(struct json_script_ctx *ctx, const char *name, struct blob_attr *vars)
void(* handle_command)(struct json_script_ctx *ctx, const char *name, struct blob_attr *cmd, struct blob_attr *vars)
struct json_script_file *(* handle_file)(struct json_script_ctx *ctx, const char *name)
static void handle_command(struct json_script_ctx *ctx, const char *name, struct blob_attr *data, struct blob_attr *vars)
static struct json_script_file * handle_file(struct json_script_ctx *ctx, const char *filename)
struct json_script_ctx jctx
static void usage(const char *prog, int exit_code)
◆ usage()
static void usage |
( |
const char * |
prog, |
|
|
int |
exit_code |
|
) |
| |
|
static |
Definition at line 44 of file test-json-script.c.
46 fprintf(stderr,
"Usage: %s [VARNAME=value] <filename_json_script>\n", prog);
◆ b_script
◆ b_vars
◆ jctx