| 818 | } |
| 819 | |
| 820 | static struct command_result *param_restrictions(struct command *cmd, |
| 821 | const char *name, |
| 822 | const char *buffer, |
| 823 | const jsmntok_t *tok, |
| 824 | struct rune_restr ***restrs) |
| 825 | { |
| 826 | if (json_tok_streq(buffer, tok, "readonly")) |
| 827 | *restrs = readonly_restrictions(cmd); |
| 828 | else if (tok->type == JSMN_ARRAY) { |
| 829 | size_t i; |
| 830 | const jsmntok_t *t; |
| 831 | |
| 832 | *restrs = tal_arr(cmd, struct rune_restr *, tok->size); |
| 833 | json_for_each_arr(i, t, tok) { |
| 834 | (*restrs)[i] = rune_restr_from_json(*restrs, buffer, t); |
| 835 | if (!(*restrs)[i]) { |
| 836 | return command_fail_badparam(cmd, name, buffer, t, |
| 837 | "not a valid restriction (should be array)"); |
| 838 | } |
| 839 | } |
| 840 | } else { |
| 841 | *restrs = tal_arr(cmd, struct rune_restr *, 1); |
| 842 | (*restrs)[0] = rune_restr_from_json(*restrs, buffer, tok); |
| 843 | if (!(*restrs)[0]) |
| 844 | return command_fail_badparam(cmd, name, buffer, tok, |
| 845 | "not a valid restriction (should be array)"); |
| 846 | } |
| 847 | return NULL; |
| 848 | } |
| 849 | |
| 850 | static struct command_result *reply_with_rune(struct command *cmd, |
| 851 | const char *buf UNUSED, |
nothing calls this directly
no test coverage detected