~ This returns the PKGLIBEXEC path which is where binaries get installed. * Note the `TAKES` annotation which indicates that the `my_path` parameter * can be take(); in which case, this function will handle freeing it. * * TAKES is only a convention unfortunately, and ignored by the compiler. */
| 470 | * TAKES is only a convention unfortunately, and ignored by the compiler. |
| 471 | */ |
| 472 | static const char *find_my_pkglibexec_path(struct lightningd *ld, |
| 473 | const char *my_path TAKES) |
| 474 | { |
| 475 | const char *pkglibexecdir; |
| 476 | |
| 477 | /*~`path_join` is declared in ccan/path/path.h as: |
| 478 | * |
| 479 | * char *path_join(const tal_t *ctx, |
| 480 | * const char *base TAKES, const char *a TAKES); |
| 481 | * |
| 482 | * So, as we promised with 'TAKES' in our own declaration, if the |
| 483 | * caller has called `take()` the `my_path` parameter, path_join() |
| 484 | * will free it. */ |
| 485 | pkglibexecdir = path_join(NULL, my_path, BINTOPKGLIBEXECDIR); |
| 486 | |
| 487 | /*~ The plugin dir is in ../libexec/c-lightning/plugins, which (unlike |
| 488 | * those given on the command line) does not need to exist. */ |
| 489 | plugins_set_builtin_plugins_dir(ld->plugins, |
| 490 | path_join(tmpctx, |
| 491 | pkglibexecdir, "plugins")); |
| 492 | |
| 493 | /*~ Sometimes take() can be more efficient, since the routine can |
| 494 | * manipulate the string in place. This is the case here. */ |
| 495 | return path_simplify(ld, take(pkglibexecdir)); |
| 496 | } |
| 497 | |
| 498 | /* Determine the correct daemon dir. */ |
| 499 | static const char *find_daemon_dir(struct lightningd *ld, const char *argv0) |
no test coverage detected