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