]> git.ozlabs.org Git - petitboot/blob - ui/test/pb-test.c
551c9b070f8eaaa475eb6cd7b3be8bf23f07c0db
[petitboot] / ui / test / pb-test.c
1
2 #include <stdio.h>
3
4 #include "ui/common/discover-client.h"
5
6 static int print_device_add(const struct device *device,
7         void __attribute__((unused)) *arg)
8 {
9         struct boot_option *opt;
10
11         printf("new device:\n");
12         printf("\tid:   %s\n", device->id);
13         printf("\tname: %s\n", device->name);
14         printf("\tdesc: %s\n", device->description);
15         printf("\ticon: %s\n", device->icon_file);
16
17         printf("\tboot options:\n");
18         list_for_each_entry(&device->boot_options, opt, list) {
19                 printf("\t\tid:   %s\n", opt->id);
20                 printf("\t\tname: %s\n", opt->name);
21                 printf("\t\tdesc: %s\n", opt->description);
22                 printf("\t\ticon: %s\n", opt->icon_file);
23                 printf("\t\tboot: %s\n", opt->boot_image_file);
24                 printf("\t\tinit: %s\n", opt->initrd_file);
25                 printf("\t\targs: %s\n", opt->boot_args);
26         }
27
28         return 0;
29 }
30
31 static void print_device_remove(const char *dev_id,
32         void __attribute__((unused)) *arg)
33 {
34         printf("removed device:\n");
35         printf("\tid:   %s\n", dev_id);
36 }
37
38 static struct discover_client_ops client_ops = {
39         .add_device = print_device_add,
40         .remove_device = print_device_remove,
41 };
42
43 int main(void)
44 {
45         struct discover_client *client;
46
47         client = discover_client_init(&client_ops);
48         if (!client)
49                 return -1;
50
51         for (;;) {
52                 int rc;
53
54                 rc = discover_client_process(client);
55                 if (rc)
56                         break;
57         }
58
59         return 0;
60 }