Added long options to all tools.
Tools exit if format is not "cue" or "toc".
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "cuefile.h"
|
||||
|
||||
char *progname;
|
||||
@@ -16,17 +16,16 @@ char *progname;
|
||||
void usage (int status)
|
||||
{
|
||||
if (0 == status) {
|
||||
fprintf(stdout, "%s: usage: cueconvert [-h] [-i cue|toc] [-o cue|toc] [infile [outfile]]\n", progname);
|
||||
fprintf(stdout, "%s: usage: cueconvert [option...] [infile [outfile]]\n", progname);
|
||||
fputs("\
|
||||
\n\
|
||||
OPTIONS\n\
|
||||
-h print usage\n\
|
||||
-i cue|toc set format of input file\n\
|
||||
-o cue|toc set format of output file\n\
|
||||
-h, --help print usage\n\
|
||||
-i, --input-format cue|toc set format of input file\n\
|
||||
-o, --output-format cue|toc set format of output file\n\
|
||||
", stdout);
|
||||
} else {
|
||||
fprintf(stderr, "%s: syntax error\n", progname);
|
||||
fprintf(stderr, "run `%s -h' for usage\n", progname);
|
||||
fprintf(stderr, "run `%s --help' for usage\n", progname);
|
||||
}
|
||||
|
||||
exit (status);
|
||||
@@ -65,13 +64,20 @@ int main (int argc, char **argv)
|
||||
int oformat = UNKNOWN;
|
||||
/* option variables */
|
||||
char c;
|
||||
/* getopt() variables */
|
||||
/* getopt_long() variables */
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
static struct option longopts[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"input-format", required_argument, NULL, 'i'},
|
||||
{"output-format", required_argument, NULL, 'o'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
progname = *argv;
|
||||
|
||||
while (-1 != (c = getopt(argc, argv, "hi:o:"))) {
|
||||
while (-1 != (c = getopt_long(argc, argv, "hi:o:", longopts, NULL))) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage(0);
|
||||
@@ -81,12 +87,18 @@ int main (int argc, char **argv)
|
||||
iformat = CUE;
|
||||
else if (0 == strcmp("toc", optarg))
|
||||
iformat = TOC;
|
||||
else
|
||||
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
|
||||
usage(1);
|
||||
break;
|
||||
case 'o':
|
||||
if (0 == strcmp("cue", optarg))
|
||||
oformat = CUE;
|
||||
else if (0 == strcmp("toc", optarg))
|
||||
oformat = TOC;
|
||||
else
|
||||
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
|
||||
usage(1);
|
||||
break;
|
||||
default:
|
||||
usage(1);
|
||||
|
||||
Reference in New Issue
Block a user