mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
libplugin: make init return a string.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: libplugin: init can return a non-NULL string to disable the plugin.
This commit is contained in:
committed by
Christian Decker
parent
529ae0d766
commit
27c006f7aa
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
const char *name_option;
|
||||
|
||||
static bool self_disable = false;
|
||||
|
||||
static struct command_result *json_helloworld(struct command *cmd,
|
||||
const char *buf,
|
||||
@@ -86,10 +86,15 @@ static struct command_result *json_testrpc(struct command *cmd,
|
||||
return send_outreq(cmd->plugin, req);
|
||||
}
|
||||
|
||||
static void init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED,
|
||||
const jsmntok_t *config UNUSED)
|
||||
{
|
||||
plugin_log(p, LOG_DBG, "test_libplugin initialised!");
|
||||
|
||||
if (self_disable)
|
||||
return "Disabled via selfdisable option";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct plugin_command commands[] = { {
|
||||
@@ -149,5 +154,9 @@ int main(int argc, char *argv[])
|
||||
"string",
|
||||
"Who to say hello to.",
|
||||
charp_option, &name_option),
|
||||
plugin_option("selfdisable",
|
||||
"flag",
|
||||
"Whether to disable.",
|
||||
flag_option, &self_disable),
|
||||
NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user