| 1304 | } |
| 1305 | |
| 1306 | static const char *plugin_hooks_add(struct plugin *plugin, const char *buffer, |
| 1307 | const jsmntok_t *resulttok) |
| 1308 | { |
| 1309 | const jsmntok_t *t, *hookstok, *beforetok, *aftertok; |
| 1310 | size_t i; |
| 1311 | |
| 1312 | hookstok = json_get_member(buffer, resulttok, "hooks"); |
| 1313 | if (!hookstok) |
| 1314 | return NULL; |
| 1315 | |
| 1316 | json_for_each_arr(i, t, hookstok) { |
| 1317 | char *name; |
| 1318 | struct plugin_hook *hook; |
| 1319 | |
| 1320 | if (t->type == JSMN_OBJECT) { |
| 1321 | const jsmntok_t *nametok; |
| 1322 | |
| 1323 | nametok = json_get_member(buffer, t, "name"); |
| 1324 | if (!nametok) |
| 1325 | return tal_fmt(plugin, "no name in hook obj %.*s", |
| 1326 | json_tok_full_len(t), |
| 1327 | json_tok_full(buffer, t)); |
| 1328 | name = json_strdup(tmpctx, buffer, nametok); |
| 1329 | beforetok = json_get_member(buffer, t, "before"); |
| 1330 | aftertok = json_get_member(buffer, t, "after"); |
| 1331 | } else { |
| 1332 | /* FIXME: deprecate in 3 releases after v0.9.2! */ |
| 1333 | name = json_strdup(tmpctx, plugin->buffer, t); |
| 1334 | beforetok = aftertok = NULL; |
| 1335 | } |
| 1336 | |
| 1337 | hook = plugin_hook_register(plugin, name); |
| 1338 | if (!hook) { |
| 1339 | return tal_fmt(plugin, |
| 1340 | "could not register hook '%s', either the " |
| 1341 | "name doesn't exist or another plugin " |
| 1342 | "already registered it.", |
| 1343 | name); |
| 1344 | } |
| 1345 | |
| 1346 | plugin_hook_add_deps(hook, plugin, buffer, beforetok, aftertok); |
| 1347 | tal_free(name); |
| 1348 | } |
| 1349 | return NULL; |
| 1350 | } |
| 1351 | |
| 1352 | static struct plugin_opt *plugin_opt_find(struct plugin *plugin, |
| 1353 | const char *name, size_t namelen) |
no test coverage detected