11 #include <pb-config/pb-config.h>
12 #include <types/types.h>
13 #include <waiter/waiter.h>
14 #include <process/process.h>
15 #include <talloc/talloc.h>
17 extern struct config *config_get(void);
18 extern int platform_init(void);
20 static const struct option options[] = {
28 static void usage(const char *progname)
30 fprintf(stderr, "Usage:\t%1$s <var>\n"
31 "\t%1$s --list\n", progname);
34 static void print_one_config(void *ctx, const char *req, const char *name,
37 bool use_prefix = !req;
41 if (req && strcmp(req, name))
45 val = talloc_vasprintf(ctx, fmt, ap);
48 if (!strcmp(val, "(null)")) {
52 val = talloc_strdup(ctx, "");
55 sep = use_prefix ? ": " : "";
57 printf("%s%s%s\n", use_prefix ? name : "", sep, val);
62 static void print_config(void *ctx, struct config *config, const char *var)
64 print_one_config(ctx, var, "bootdev", "%s", config->boot_device);
65 print_one_config(ctx, var, "autoboot", "%s",
66 config->autoboot_enabled ? "enabled" : "disabled");
67 print_one_config(ctx, var, "timeout", "%d",
68 config->autoboot_timeout_sec);
69 print_one_config(ctx, var, "safe-mode", "%s",
70 config->safe_mode ? "enabled" : "disabled");
71 print_one_config(ctx, var, "debug", "%s",
72 config->debug ? "enabled" : "disabled");
75 int main(int argc, char **argv)
77 struct waitset *waitset;
78 struct config *config;
85 int opt = getopt_long(argc, argv, "l", options, NULL);
99 ctx = talloc_new(NULL);
101 waitset = waitset_create(ctx);
103 process_init(ctx, waitset, false);
109 config = config_get();
112 print_config(ctx, config, NULL);
116 for (i = optind; i < argc; i++)
117 print_config(ctx, config, argv[i]);