mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
lightningd/plugin.c: Add specific function to give the directory for built-in plugins.
This commit is contained in:
parent
3dafddd717
commit
3df2333d5d
4 changed files with 28 additions and 7 deletions
|
@ -469,9 +469,9 @@ static const char *find_my_pkglibexec_path(struct lightningd *ld,
|
|||
|
||||
/*~ The plugin dir is in ../libexec/c-lightning/plugins, which (unlike
|
||||
* those given on the command line) does not need to exist. */
|
||||
add_plugin_dir(ld->plugins,
|
||||
path_join(tmpctx, pkglibexecdir, "plugins"),
|
||||
true);
|
||||
plugins_set_builtin_plugins_dir(ld->plugins,
|
||||
path_join(tmpctx,
|
||||
pkglibexecdir, "plugins"));
|
||||
|
||||
/*~ Sometimes take() can be more efficient, since the routine can
|
||||
* manipulate the string in place. This is the case here. */
|
||||
|
@ -484,10 +484,11 @@ static const char *find_daemon_dir(struct lightningd *ld, const char *argv0)
|
|||
const char *my_path = find_my_directory(ld, argv0);
|
||||
/* If we're running in-tree, all the subdaemons are with lightningd. */
|
||||
if (has_all_subdaemons(my_path)) {
|
||||
/* In this case, look in ../plugins */
|
||||
add_plugin_dir(ld->plugins,
|
||||
path_join(tmpctx, my_path, "../plugins"),
|
||||
true);
|
||||
/* In this case, look for built-in plugins in ../plugins */
|
||||
plugins_set_builtin_plugins_dir(ld->plugins,
|
||||
path_join(tmpctx,
|
||||
my_path,
|
||||
"../plugins"));
|
||||
return my_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -1526,6 +1526,16 @@ struct log *plugin_get_log(struct plugin *plugin)
|
|||
return plugin->log;
|
||||
}
|
||||
|
||||
void plugins_set_builtin_plugins_dir(struct plugins *plugins,
|
||||
const char *dir)
|
||||
{
|
||||
/*~ The builtin-plugins dir does not need to exist, but
|
||||
* we would error those anyway for our important built-in
|
||||
* plugins.
|
||||
*/
|
||||
add_plugin_dir(plugins, dir, true);
|
||||
}
|
||||
|
||||
struct plugin_destroyed {
|
||||
const struct plugin *plugin;
|
||||
};
|
||||
|
@ -1536,6 +1546,7 @@ static void mark_plugin_destroyed(const struct plugin *unused,
|
|||
pd->plugin = NULL;
|
||||
}
|
||||
|
||||
|
||||
struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin)
|
||||
{
|
||||
struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed);
|
||||
|
|
|
@ -334,6 +334,12 @@ struct io_plan *plugin_stdout_conn_init(struct io_conn *conn,
|
|||
*/
|
||||
struct log *plugin_get_log(struct plugin *plugin);
|
||||
|
||||
/**
|
||||
* Tells the plugin system the directory for builtin plugins.
|
||||
*/
|
||||
void plugins_set_builtin_plugins_dir(struct plugins *plugins,
|
||||
const char *dir);
|
||||
|
||||
/* Pair of functions to detect if plugin destroys itself: must always
|
||||
* call both! */
|
||||
struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin);
|
||||
|
|
|
@ -207,6 +207,9 @@ void plugins_init(struct plugins *plugins UNNEEDED)
|
|||
struct plugins *plugins_new(const tal_t *ctx UNNEEDED, struct log_book *log_book UNNEEDED,
|
||||
struct lightningd *ld UNNEEDED)
|
||||
{ fprintf(stderr, "plugins_new called!\n"); abort(); }
|
||||
void plugins_set_builtin_plugins_dir(struct plugins *plugins UNNEEDED,
|
||||
const char *dir UNNEEDED)
|
||||
{ fprintf(stderr, "plugins_set_builtin_plugins_dir called!\n"); abort(); }
|
||||
/* Generated stub for setup_color_and_alias */
|
||||
void setup_color_and_alias(struct lightningd *ld UNNEEDED)
|
||||
{ fprintf(stderr, "setup_color_and_alias called!\n"); abort(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue