2 * "THE BEER-WARE LICENSE" (Revision 42):
3 * <tobias.rehbein@web.de> wrote this file. As long as you retain this notice
4 * you can do whatever you want with this stuff. If we meet some day, and you
5 * think this stuff is worth it, you can buy me a beer in return.
25 static const char *VERSION
= "v1.0.0";
26 static const char *OGG123
= "/usr/local/bin/ogg123";
27 static const char *OGG123_OPTIONS
= "";
29 void init_options(struct opts_options
*opts
);
30 static void print_usage(void);
33 init_options(struct opts_options
*opts
)
38 opts
->choices
= CHOICES
;
39 opts
->players
= PLAYERS
;
40 opts
->ogg123
= OGG123
;
41 opts
->ogg123_options
= OGG123_OPTIONS
;
45 opts_parse_options(struct opts_options
*opts
, int argc
, char **argv
)
53 struct option longopts
[] = {
54 {"time", required_argument
, NULL
, 't'},
55 {"choices", required_argument
, NULL
, 'c'},
56 {"players", required_argument
, NULL
, 'p'},
57 {"ogg123", required_argument
, NULL
, 'O'},
58 {"ogg123-options", required_argument
, NULL
, 'o'},
59 {"help", no_argument
, NULL
, 'h'}
64 while ((ch
= getopt_long(argc
, argv
, "t:c:p:o:e:h", longopts
, NULL
)) != -1)
67 opts
->time
= (int)strtol(optarg
, (char **)NULL
, 10);
70 opts
->choices
= (int)strtol(optarg
, (char **)NULL
, 10);
71 if (opts
->choices
< 1 || opts
->choices
> CHOICES
)
72 errx(EX_USAGE
, "choices must not exceed %d", CHOICES
);
75 opts
->players
= (int)strtol(optarg
, (char **)NULL
, 10);
76 if (opts
->players
< 1 || opts
->players
> PLAYERS
)
77 errx(EX_USAGE
, "players must not exceed %d", PLAYERS
);
80 opts
->ogg123
= optarg
;
83 opts
->ogg123_options
= optarg
;
97 printf("This is oggquiz %s\n\n", VERSION
);
98 printf("oggquiz [-t | --time seconds] [-c | --choices choices] [-p | --players players]\n");
99 printf(" [-o | --ogg123-options options] [-O | --ogg123 command]\n\n");
100 printf("oggquiz {-h | --help}\n");