1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/* main.c - handle command line arguments
* Copyright (C) 2004 Matthias Czapla <dermatsch@gmx.de>
*
* This file is part of cue2toc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "cue2toc.h"
#include "error.h"
#include "conf.h"
#include "convert.h"
void usage(void);
int
main(int argc, char *argv[])
{
char *outfile = NULL;
char *infile = NULL;
int c;
struct cuesheet *cs;
prog = argv[0];
opterr = 0; /* we do error msgs ourselves */
config(); /* Read configuration file */
while ((c = getopt(argc, argv, ":dhno:qv")) != -1)
switch (c) {
case 'd': debug = 1; break;
case 'h':
usage();
exit(EXIT_SUCCESS);
break;
case 'n': cdtext = 0; break; /* for compatibility */
case 'o':
if (strcmp(optarg, "-") == 0)
outfile = NULL; /* use stdout */
else
outfile = optarg;
break;
case 'q': quiet = 1; break;
case 'v':
printf("%s\n", PACKAGE_STRING);
printf("Report bugs to <%s>\n", PACKAGE_BUGREPORT);
exit(EXIT_SUCCESS);
break;
case ':': err_quit("Options requires argument -- %c", optopt);
case '?': err_quit("Illegal option -- %c", optopt);
default: err_quit("Unhandled command line option. D'oh!");
}
switch(argc - optind) {
case 0:
infile = NULL; /* use stdin */
break;
case 1:
if (strcmp(argv[optind], "-") == 0)
infile = NULL; /* use stdin */
else
infile = argv[optind];
break;
default:
err_quit("Too many arguments");
}
cs = read_cue(infile);
if (convert)
convert_files(cs->tracklist);
write_toc(outfile, cs);
return EXIT_SUCCESS;
}
void
usage(void)
{
printf("Usage: %s [-dhqv] [-o tocfile] [cuefile]\n",
prog);
printf(" -d\t\tprint debugging info\n");
printf(" -h\t\tdisplay this help message\n");
printf(" -o tocfile\twrite output to tocfile\n");
printf(" -q\t\tbe quiet\n");
printf(" -v\t\tdisplay version information\n");
}
|