]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/ps3-main.c
ui/ncurses: in lockdown ensure system reboot in ncurses menu exit
[petitboot] / ui / ncurses / ps3-main.c
index 5be8c3258a9477671322f8ffcc0418a028a8d8a7..eda15d05e2230388cf779860bbf34eef2241a7c7 100644 (file)
@@ -24,9 +24,9 @@
  * ncurses mouse support
  */
 
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
-
-#define _GNU_SOURCE
+#endif
 
 #include <assert.h>
 #include <errno.h>
@@ -275,7 +275,7 @@ static int ps3_boot_cb(struct cui *cui, struct cui_opt_data *cod)
        int altered_args;
        char *orig_args;
 
-       pb_log("%s: %s\n", __func__, cod->name);
+       pb_debug("%s: %s\n", __func__, cod->name);
 
        assert(ps3->cui->current == &ps3->cui->main->scr);
 
@@ -343,7 +343,7 @@ static int ps3_svm_to_mm_cb(struct pmenu_item *item)
 }
 
 /**
- * ps3_svm_to_mm_helper - The svm ESC callback.
+ * ps3_svm_to_mm_helper - The svm exit callback.
  */
 
 static void ps3_svm_to_mm_helper(struct pmenu *menu)
@@ -407,12 +407,20 @@ static struct pmenu *ps3_mm_init(struct ps3_cui *ps3_cui)
        m = pmenu_init(ps3_cui->cui, 3, cui_on_exit);
 
        if (!m) {
-               pb_log("%s: failed\n", __func__);
+               pb_log_fn("failed\n");
                return NULL;
        }
 
-       m->hot_key = ps3_hot_key;
-       m->on_open = cui_on_open;
+       m->n_hot_keys = 2;
+       m->hot_keys = talloc_array(m, hot_key_fn *, m->n_hot_keys);
+       if (!m->hot_keys) {
+               pb_log_fn("failed to allocate hot_keys\n");
+               talloc_free(m);
+               return NULL;
+       }
+       m->hot_keys[0] = ps3_hot_key;
+       m->hot_keys[1] = pmenu_main_hot_keys;
+       m->on_new = cui_item_new;
 
 #if defined(DEBUG)
        m->scr.frame.title = talloc_strdup(m,
@@ -421,7 +429,7 @@ static struct pmenu *ps3_mm_init(struct ps3_cui *ps3_cui)
        m->scr.frame.title = talloc_strdup(m, "Petitboot PS3");
 #endif
        m->scr.frame.help = talloc_strdup(m,
-               "ESC=exit, Enter=accept, e=edit, o=open");
+               "Enter=accept, e=edit, o=open, x=exit");
        m->scr.frame.status = talloc_strdup(m, "Welcome to Petitboot");
 
        i = pmenu_item_init(m, 0, "Boot GameOS");
@@ -466,13 +474,13 @@ static struct pmenu *ps3_svm_init(struct ps3_cui *ps3_cui)
        m = pmenu_init(ps3_cui->cui, 12, ps3_svm_to_mm_helper);
 
        if (!m) {
-               pb_log("%s: failed\n", __func__);
+               pb_log_fn("failed\n");
                return NULL;
        }
 
        m->hot_key = ps3_hot_key;
        m->scr.frame.title = talloc_strdup(m, "Select PS3 Video Mode");
-       m->scr.frame.help = talloc_strdup(m, "ESC=exit, Enter=accept");
+       m->scr.frame.help = talloc_strdup(m, "Enter=accept, x=exit");
 
        i = pmenu_item_init(m, 0, "auto detect");
        i->on_execute = ps3_svm_cb;
@@ -613,7 +621,7 @@ int main(int argc, char *argv[])
        result += sigaction(SIGWINCH, &sa, NULL);
 
        if (result) {
-               pb_log("%s sigaction failed.\n", __func__);
+               pb_log_fn("sigaction failed.\n");
                return EXIT_FAILURE;
        }