summaryrefslogtreecommitdiffstats
path: root/ui/test/pb-test.c
blob: 5f021ff7e73d73f6455c8855f5500a40f31a34ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

#include <stdio.h>

#include "ui/common/discover-client.h"

static int print_device_add(struct device *device)
{
	struct boot_option *opt;

	printf("new device:\n");
	printf("\tid:   %s\n", device->id);
	printf("\tname: %s\n", device->name);
	printf("\tdesc: %s\n", device->description);
	printf("\ticon: %s\n", device->icon_file);

	printf("\tboot options:\n");
	list_for_each_entry(&device->boot_options, opt, list) {
		printf("\t\tid:   %s\n", opt->id);
		printf("\t\tname: %s\n", opt->name);
		printf("\t\tdesc: %s\n", opt->description);
		printf("\t\ticon: %s\n", opt->icon_file);
		printf("\t\tboot: %s\n", opt->boot_image_file);
		printf("\t\tinit: %s\n", opt->initrd_file);
		printf("\t\targs: %s\n", opt->boot_args);
	}

	return 0;
}

static void print_device_remove(char *dev_id)
{
	printf("removed device:\n");
	printf("\tid:   %s\n", dev_id);
}

struct discover_client_ops client_ops = {
	.add_device = print_device_add,
	.remove_device = print_device_remove,
};

int main(void)
{
	struct discover_client *client;

	client = discover_client_init(&client_ops);
	if (!client)
		return -1;

	for (;;) {
		int rc;

		rc = discover_client_process(client);
		if (rc)
			break;
	}

	return 0;
}
OpenPOWER on IntegriCloud