MCPcopy Create free account
hub / github.com/ElementsProject/lightning / rune_restr_from_json

Function rune_restr_from_json

plugins/commando.c:785–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

783}
784
785static struct rune_restr *rune_restr_from_json(const tal_t *ctx,
786 const char *buffer,
787 const jsmntok_t *tok)
788{
789 const jsmntok_t *t;
790 size_t i;
791 struct rune_restr *restr;
792
793 /* \| is not valid JSON, so they use \\|: undo it! */
794 if (deprecated_apis && tok->type == JSMN_STRING) {
795 const char *unescape;
796 struct json_escape *e = json_escape_string_(tmpctx,
797 buffer + tok->start,
798 tok->end - tok->start);
799 unescape = json_escape_unescape(tmpctx, e);
800 if (!unescape)
801 return NULL;
802 return rune_restr_from_string(ctx, unescape, strlen(unescape));
803 }
804
805 restr = tal(ctx, struct rune_restr);
806 /* FIXME: after deprecation removed, allow singletons again! */
807 if (tok->type != JSMN_ARRAY)
808 return NULL;
809
810 restr->alterns = tal_arr(restr, struct rune_altern *, tok->size);
811 json_for_each_arr(i, t, tok) {
812 restr->alterns[i] = rune_altern_from_json(restr->alterns,
813 buffer, t);
814 if (!restr->alterns[i])
815 return tal_free(restr);
816 }
817 return restr;
818}
819
820static struct command_result *param_restrictions(struct command *cmd,
821 const char *name,

Callers 1

param_restrictionsFunction · 0.85

Calls 5

json_escape_string_Function · 0.85
json_escape_unescapeFunction · 0.85
rune_restr_from_stringFunction · 0.85
rune_altern_from_jsonFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected