]> git.ozlabs.org Git - petitboot/blobdiff - petitboot.c
Merge branch 'master' of ssh://ozlabs.org/home/jk/git/petitboot
[petitboot] / petitboot.c
index 478b294e7ec0f8d07dd9f643e2a5e299027b1678..416434adbeba2d8bca13b7d515906eaa1493f869 100644 (file)
@@ -827,6 +827,18 @@ static void pboot_spane_draw(twin_window_t *window)
        twin_path_destroy(path);
 }
 
+void pboot_message(const char *message)
+{
+       if (pboot_spane->text)
+               free(pboot_spane->text);
+       pboot_spane->text = strdup(message);
+       twin_window_damage(pboot_spane->window,
+                          0, 0,
+                          pboot_spane->window->pixmap->width,
+                          pboot_spane->window->pixmap->height);
+       twin_window_queue_paint(pboot_spane->window);
+}
+
 static void pboot_create_spane(void)
 {
        pboot_spane = calloc(1, sizeof(pboot_spane_t));
@@ -846,7 +858,7 @@ static void pboot_create_spane(void)
 
        pboot_spane->window->draw = pboot_spane_draw;
        pboot_spane->window->client_data = pboot_spane;
-       pboot_spane->text = PBOOT_INITIAL_MESSAGE;
+       pboot_spane->text = strdup(PBOOT_INITIAL_MESSAGE);
        twin_window_show(pboot_spane->window);
        twin_window_queue_paint(pboot_spane->window);
 }
@@ -981,8 +993,35 @@ static void sigint(int sig)
        syscall(__NR_exit);
 }
 
+static void usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s [-u] [-h]\n", progname);
+}
+
 int main(int argc, char **argv)
 {
+       int c;
+       int udev_trigger = 0;
+
+       for (;;) {
+               c = getopt(argc, argv, "u::h");
+               if (c == -1)
+                       break;
+
+               switch (c) {
+               case 'u':
+                       udev_trigger = 1;
+                       break;
+               case 'h':
+                       usage(argv[0]);
+                       return EXIT_SUCCESS;
+               default:
+                       fprintf(stderr, "Unknown option '%c'\n", c);
+                       usage(argv[0]);
+                       return EXIT_FAILURE;
+               }
+       }
+
        atexit(exitfunc);
        signal(SIGINT, sigint);
 
@@ -1023,7 +1062,7 @@ int main(int argc, char **argv)
        pboot_create_rpane();
        pboot_create_spane();
 
-       if (!pboot_start_device_discovery()) {
+       if (!pboot_start_device_discovery(udev_trigger)) {
                LOG("Couldn't start device discovery!\n");
                return 1;
        }