X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=ui%2Fncurses%2Fgeneric-main.c;h=365034ceea3c402d1870e33fa627d80c9fcb4539;hp=983ba474917ab629a47b2c36b61398c31125452c;hb=efab1ab1bef78711e764f52e49c518f140d6ea67;hpb=6b842bb2559116a949c6a569ac39f5c56ebc1be1 diff --git a/ui/ncurses/generic-main.c b/ui/ncurses/generic-main.c index 983ba47..365034c 100644 --- a/ui/ncurses/generic-main.c +++ b/ui/ncurses/generic-main.c @@ -45,7 +45,7 @@ static void print_usage(void) { print_version(); printf( -"Usage: petitboot-nc [-d, --dry-run] [-h, --help] [-l, --log log-file]\n" +"Usage: petitboot-nc [-h, --help] [-l, --log log-file]\n" " [-s, --start-daemon] [-V, --version]\n"); } @@ -60,7 +60,6 @@ enum opt_value {opt_undef = 0, opt_yes, opt_no}; */ struct opts { - enum opt_value dry_run; enum opt_value show_help; const char *log_file; enum opt_value start_daemon; @@ -74,7 +73,6 @@ struct opts { static int opts_parse(struct opts *opts, int argc, char *argv[]) { static const struct option long_options[] = { - {"dry-run", no_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, {"log", required_argument, NULL, 'l'}, {"start-daemon", no_argument, NULL, 's'}, @@ -96,9 +94,6 @@ static int opts_parse(struct opts *opts, int argc, char *argv[]) break; switch (c) { - case 'd': - opts->dry_run = opt_yes; - break; case 'h': opts->show_help = opt_yes; break; @@ -131,31 +126,6 @@ struct pb_cui { struct cui *cui; }; -static struct pb_cui *pb_from_cui(struct cui *cui) -{ - struct pb_cui *pb; - - assert(cui->c_sig == pb_cui_sig); - pb = cui->platform_info; - assert(pb->cui->c_sig == pb_cui_sig); - return pb; -} - -/** - * pb_kexec_cb - The kexec callback. - */ - -static int pb_kexec_cb(struct cui *cui, struct cui_opt_data *cod) -{ - struct pb_cui *pb = pb_from_cui(cui); - - pb_log("%s: %s\n", __func__, cod->name); - - assert(pb->cui->current == &pb->cui->main->scr); - - return pb_run_kexec(cod->bd, pb->cui->dry_run); -} - /** * pb_mm_init - Setup the main menu instance. */ @@ -176,8 +146,7 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui) m->on_open = cui_on_open; m->scr.frame.title = talloc_asprintf(m, - "Petitboot (" PACKAGE_VERSION ")%s", - (pb_cui->cui->dry_run ? " (dry-run)" : "")); + "Petitboot (" PACKAGE_VERSION ")"); m->scr.frame.help = talloc_strdup(m, "ESC=exit, Enter=accept, e=edit, o=open"); m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot"); @@ -262,6 +231,9 @@ int main(int argc, char *argv[]) if (strcmp(opts.log_file, "-")) { FILE *log = fopen(opts.log_file, "a"); + if (!log) + log = fopen("/dev/null", "a"); + assert(log); pb_log_set_stream(log); } else @@ -285,8 +257,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } - pb.cui = cui_init(&pb, pb_kexec_cb, NULL, opts.start_daemon, - opts.dry_run); + pb.cui = cui_init(&pb, NULL, opts.start_daemon); if (!pb.cui) return EXIT_FAILURE;