| 968 | }; |
| 969 | |
| 970 | static struct command_result *listdatastore_done(struct command *cmd, |
| 971 | const char *method, |
| 972 | const char *buf, |
| 973 | const jsmntok_t *result, |
| 974 | struct get_ds_info *dsi) |
| 975 | { |
| 976 | const jsmntok_t *ds = json_get_member(buf, result, "datastore"); |
| 977 | void *val; |
| 978 | |
| 979 | if (ds->size == 0) |
| 980 | val = NULL; |
| 981 | else { |
| 982 | /* First element in array is object */ |
| 983 | ds = ds + 1; |
| 984 | if (dsi->string_cb) { |
| 985 | const jsmntok_t *s; |
| 986 | s = json_get_member(buf, ds, "string"); |
| 987 | if (!s) { |
| 988 | /* Complain loudly, since they |
| 989 | * expected string! */ |
| 990 | plugin_log(cmd->plugin, LOG_BROKEN, |
| 991 | "Datastore gave nonstring result %.*s", |
| 992 | json_tok_full_len(result), |
| 993 | json_tok_full(buf, result)); |
| 994 | val = NULL; |
| 995 | } else { |
| 996 | val = json_strdup(cmd, buf, s); |
| 997 | } |
| 998 | } else { |
| 999 | const jsmntok_t *hex; |
| 1000 | hex = json_get_member(buf, ds, "hex"); |
| 1001 | val = json_tok_bin_from_hex(cmd, buf, hex); |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | if (dsi->string_cb) |
| 1006 | return dsi->string_cb(cmd, val, dsi->arg); |
| 1007 | return dsi->binary_cb(cmd, val, dsi->arg); |
| 1008 | } |
| 1009 | |
| 1010 | struct command_result *jsonrpc_get_datastore_(struct command *cmd, |
| 1011 | const char **keys, |
nothing calls this directly
no test coverage detected