| 59 | } |
| 60 | |
| 61 | static struct command_result *param_list_or_string(struct command *cmd, |
| 62 | const char *name, |
| 63 | const char *buffer, |
| 64 | const jsmntok_t *tok, |
| 65 | const char ***str) |
| 66 | { |
| 67 | if (tok->type == JSMN_ARRAY && tok->size <= 0) { |
| 68 | return command_fail_badparam(cmd, name, |
| 69 | buffer, tok, |
| 70 | "should not be empty"); |
| 71 | } else if (tok->type == JSMN_ARRAY) { |
| 72 | size_t i; |
| 73 | const jsmntok_t *t; |
| 74 | *str = tal_arr(cmd, const char *, tok->size); |
| 75 | json_for_each_arr(i, t, tok) { |
| 76 | if (t->type != JSMN_STRING && t->type != JSMN_PRIMITIVE) |
| 77 | return command_fail_badparam(cmd, name, |
| 78 | buffer, t, |
| 79 | "should be string"); |
| 80 | (*str)[i] = json_strdup(*str, buffer, t); |
| 81 | } |
| 82 | } else if (tok->type == JSMN_STRING || tok->type == JSMN_PRIMITIVE) { |
| 83 | *str = tal_arr(cmd, const char *, 1); |
| 84 | (*str)[0] = json_strdup(*str, buffer, tok); |
| 85 | } else |
| 86 | return command_fail_badparam(cmd, name, |
| 87 | buffer, tok, |
| 88 | "should be string or array"); |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | static char *datastore_key_fmt(const tal_t *ctx, const char **key) |
| 93 | { |
nothing calls this directly
no test coverage detected