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

Function plugin_hooks_add

lightningd/plugin.c:1482–1522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1480}
1481
1482static const char *plugin_hooks_add(struct plugin *plugin, const char *buffer,
1483 const jsmntok_t *resulttok)
1484{
1485 const jsmntok_t *t, *hookstok, *beforetok, *aftertok, *filterstok;
1486 size_t i;
1487
1488 hookstok = json_get_member(buffer, resulttok, "hooks");
1489 if (!hookstok)
1490 return NULL;
1491
1492 json_for_each_arr(i, t, hookstok) {
1493 char *name;
1494 struct plugin_hook *hook;
1495 const char *err;
1496
1497 if (t->type == JSMN_OBJECT) {
1498 const jsmntok_t *nametok;
1499
1500 nametok = json_get_member(buffer, t, "name");
1501 if (!nametok)
1502 return tal_fmt(plugin, "no name in hook obj %.*s",
1503 json_tok_full_len(t),
1504 json_tok_full(buffer, t));
1505 name = json_strdup(tmpctx, buffer, nametok);
1506 beforetok = json_get_member(buffer, t, "before");
1507 aftertok = json_get_member(buffer, t, "after");
1508 filterstok = json_get_member(buffer, t, "filters");
1509 } else {
1510 /* Simple names also work */
1511 name = json_strdup(tmpctx, buffer, t);
1512 beforetok = aftertok = filterstok = NULL;
1513 }
1514
1515 err = plugin_hook_register(plugin, name, buffer, filterstok, &hook);
1516 if (err)
1517 return err;
1518 plugin_hook_add_deps(hook, plugin, buffer, beforetok, aftertok);
1519 tal_free(name);
1520 }
1521 return NULL;
1522}
1523
1524static struct plugin_opt *plugin_opt_find(const struct plugin *plugin,
1525 const char *name)

Callers 1

Calls 7

json_get_memberFunction · 0.85
plugin_hook_registerFunction · 0.85
plugin_hook_add_depsFunction · 0.85
tal_freeFunction · 0.85
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected