18 static optcfg_option options[] = {
19 // short, long, id, desc
20 {'s', "size", OPT_SIZE, "window size (WxH)"},
21 {0, "vr", OPT_VR, "enable VR mode"},
22 {0, "srgb", OPT_SRGB, "use linear color space"},
23 {'f', "fullscreen", OPT_FULLSCREEN, "run in fullscreen mode"},
24 {'w', "windowed", OPT_WINDOWED, "run in windowed mode"},
25 {'h', "help", OPT_HELP, "print usage and exit"},
29 static int opt_handler(optcfg *oc, int opt, void *cls);
31 bool init_options(int argc, char **argv, const char *cfgfile)
34 memset(&opt, 0, sizeof opt);
39 optcfg *oc = optcfg_init(options);
40 optcfg_set_opt_callback(oc, opt_handler, 0);
43 optcfg_parse_config_file(oc, cfgfile);
46 if(argv && optcfg_parse_args(oc, argc, argv) == -1) {
47 fprintf(stderr, "invalid option\n");
56 static bool is_enabled(optcfg *oc)
59 optcfg_enabled_value(oc, &res);
63 static int opt_handler(optcfg *oc, int optid, void *cls)
68 char *valstr = optcfg_next_value(oc);
69 if(!valstr || sscanf(valstr, "%dx%d", &opt.width, &opt.height) != 2) {
70 fprintf(stderr, "size must be in the form: WIDTHxHEIGHT\n");
77 opt.vr = is_enabled(oc);
81 opt.srgb = is_enabled(oc);
85 opt.fullscreen = is_enabled(oc);
89 opt.fullscreen = !is_enabled(oc);
93 printf("Usage: vrfileman [options]\nOptions:\n");
94 optcfg_print_options(oc);