]> git.ozlabs.org Git - petitboot/blob - devices/parser-test.c
4b134d0e5bd4eba470322a83eaa6c3f94c5a2b81
[petitboot] / devices / parser-test.c
1
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <stdarg.h>
5 #include <unistd.h>
6
7 #include "parser.h"
8
9 void pb_log(const char *fmt, ...)
10 {
11         va_list ap;
12
13         va_start(ap, fmt);
14         vfprintf(stderr, fmt, ap);
15         va_end(ap);
16 }
17
18
19 int mount_device(const char *dev_path, char *mount_path)
20 {
21         pb_log("attempt to mount device (%s) not supported\n", dev_path);
22         return -1;
23 }
24
25 int add_device(const struct device *dev)
26 {
27         printf("device added:\n");
28         printf("\tid: %s\n", dev->id);
29         printf("\tname: %s\n", dev->name);
30         printf("\tdescription: %s\n", dev->description);
31         printf("\tboot_image: %s\n", dev->icon_file);
32         return 0;
33 }
34
35 int add_boot_option(const struct boot_option *opt)
36 {
37         printf("option added:\n");
38         printf("\tname: %s\n", opt->name);
39         printf("\tdescription: %s\n", opt->description);
40         printf("\tboot_image: %s\n", opt->boot_image_file);
41         printf("\tinitrd: %s\n", opt->initrd_file);
42         printf("\tboot_args: %s\n", opt->boot_args);
43         return 0;
44 }
45
46 enum generic_icon_type guess_device_type(void)
47 {
48         return ICON_TYPE_UNKNOWN;
49 }
50
51 int main(int argc, char **argv)
52 {
53         const char *dev = "/dev/null";
54
55         if (argc != 2) {
56                 fprintf(stderr, "usage: %s <fake-mountpoint>\n", argv[0]);
57                 return EXIT_FAILURE;
58         }
59
60         iterate_parsers(dev, argv[1]);
61
62         return EXIT_SUCCESS;
63 }