Browse Source

options: return true if we created new directory.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
93471e06c1
  1. 6
      daemon/options.c
  2. 6
      daemon/options.h

6
daemon/options.c

@ -447,8 +447,10 @@ static void opt_parse_from_config(struct lightningd_state *dstate)
tal_free(contents); tal_free(contents);
} }
void handle_opts(struct lightningd_state *dstate, int argc, char *argv[]) bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
{ {
bool newdir = false;
opt_set_alloc(opt_allocfn, tal_reallocfn, tal_freefn); opt_set_alloc(opt_allocfn, tal_reallocfn, tal_freefn);
opt_register_noarg("--help|-h", opt_usage_and_exit, opt_register_noarg("--help|-h", opt_usage_and_exit,
@ -482,6 +484,7 @@ void handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
if (chdir(dstate->config_dir) != 0) if (chdir(dstate->config_dir) != 0)
fatal("Could not change directory %s: %s", fatal("Could not change directory %s: %s",
dstate->config_dir, strerror(errno)); dstate->config_dir, strerror(errno));
newdir = true;
} }
/* Now look for config file */ /* Now look for config file */
@ -492,4 +495,5 @@ void handle_opts(struct lightningd_state *dstate, int argc, char *argv[])
errx(1, "no arguments accepted"); errx(1, "no arguments accepted");
check_config(dstate); check_config(dstate);
return newdir;
} }

6
daemon/options.h

@ -5,7 +5,9 @@
struct lightningd_state; struct lightningd_state;
/* After this, we're in the .lightning dir, config file parsed. */ /* After this, we're in the .lightning dir, config file parsed.
void handle_opts(struct lightningd_state *dstate, int argc, char *argv[]); * If we just created the dir, returns true.
*/
bool handle_opts(struct lightningd_state *dstate, int argc, char *argv[]);
#endif /* LIGHTNING_DAEMON_OPTIONS_H */ #endif /* LIGHTNING_DAEMON_OPTIONS_H */

Loading…
Cancel
Save