]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/generic-main.c
Move boot to discover server
[petitboot] / ui / ncurses / generic-main.c
index 9a22265811bd3c87cb49e4191a817160d24d2ff0..ddf0de34e7be5d6efd8b646d755bd5e07445de22 100644 (file)
@@ -129,34 +129,8 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
 struct pb_cui {
        struct pmenu *mm;
        struct cui *cui;
-       struct opts opts;
 };
 
-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->kd, pb->opts.dry_run);
-}
-
 /**
  * pb_mm_init - Setup the main menu instance.
  */
@@ -176,7 +150,9 @@ static struct pmenu *pb_mm_init(struct pb_cui *pb_cui)
 
        m->on_open = cui_on_open;
 
-       m->scr.frame.title = talloc_strdup(m, "Petitboot");
+       m->scr.frame.title = talloc_asprintf(m,
+               "Petitboot (" PACKAGE_VERSION ")%s",
+               (pb_cui->cui->dry_run ? " (dry-run)" : ""));
        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");
@@ -239,26 +215,27 @@ int main(int argc, char *argv[])
        static struct sigaction sa;
        int result;
        int cui_result;
+       struct opts opts;
 
-       result = opts_parse(&pb.opts, argc, argv);
+       result = opts_parse(&opts, argc, argv);
 
        if (result) {
                print_usage();
                return EXIT_FAILURE;
        }
 
-       if (pb.opts.show_help == opt_yes) {
+       if (opts.show_help == opt_yes) {
                print_usage();
                return EXIT_SUCCESS;
        }
 
-       if (pb.opts.show_version == opt_yes) {
+       if (opts.show_version == opt_yes) {
                print_version();
                return EXIT_SUCCESS;
        }
 
-       if (strcmp(pb.opts.log_file, "-")) {
-               FILE *log = fopen(pb.opts.log_file, "a");
+       if (strcmp(opts.log_file, "-")) {
+               FILE *log = fopen(opts.log_file, "a");
 
                assert(log);
                pb_log_set_stream(log);
@@ -283,7 +260,7 @@ int main(int argc, char *argv[])
                return EXIT_FAILURE;
        }
 
-       pb.cui = cui_init(&pb, pb_kexec_cb, NULL, pb.opts.start_daemon);
+       pb.cui = cui_init(&pb, NULL, opts.start_daemon, opts.dry_run);
 
        if (!pb.cui)
                return EXIT_FAILURE;