7 enum { OPT_SIZE, OPT_HELP };
9 static struct optcfg_option options[] = {
10 {'s', "size", OPT_SIZE, "rendering resolution (WxH)"},
11 {'h', "help", OPT_HELP, "print usage and exit"},
15 static int opt_handler(struct optcfg *o, int opt, void *cls);
17 int init_options(int argc, char **argv)
19 struct optcfg *optcfg;
24 optcfg = optcfg_init(options);
25 optcfg_set_opt_callback(optcfg, opt_handler, argv[0]);
26 optcfg_parse_config_file(optcfg, "cyberay.conf");
27 if(optcfg_parse_args(optcfg, argc, argv) == -1) {
31 optcfg_destroy(optcfg);
35 static int opt_handler(struct optcfg *o, int optid, void *cls)
41 if(!(val = optcfg_next_value(o)) || sscanf(val, "%dx%d", &opt.width, &opt.height) != 2) {
42 fprintf(stderr, "size: expected <width>x<height>\n");
48 printf("Usage: %s [options]\n", (char*)cls);
50 optcfg_print_options(o);