-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
77 lines (63 loc) · 1.04 KB
/
main.c
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
#include <u.h>
#include <libc.h>
#include "cuefs.h"
char *fname = "<stdin>";
void
usage(void)
{
fprint(2, "usage: %s [-Dv] [-m mtpt] [-f outfmt] [-i index] file\n", argv0);
exits("usage");
}
int
fmtarg(char *fmt)
{
if(cistrcmp(fmt, "wave") == 0)
return WAVE;
if(cistrcmp(fmt, "flac") == 0)
return FLAC;
if(cistrcmp(fmt, "pcm") == 0)
return BINARY;
return UNKNOWN;
}
void
main(int argc, char **argv)
{
extern int chatty9p;
char *mtpt = "/mnt/cue";
int outfmt = -1, prefidx = 0;
ARGBEGIN {
case 'D':
chatty9p++;
break;
case 'm':
mtpt = EARGF(usage());
break;
case 'v':
verbosity++;
break;
case 'f':
if((outfmt = fmtarg(EARGF(usage()))) == UNKNOWN)
usage();
break;
case 'i':
prefidx = atoi(EARGF(usage()));
break;
default:
usage();
} ARGEND;
outfd = 1;
if(argc > 1)
usage();
if(argc == 1)
{
fname = argv[0];
if((infd = open(fname, OREAD)) < 0)
sysfatal("open: %r");
}
cursheet = newsheet();
yyparse();
if(infd != 0)
close(infd);
cuefsinit(cursheet, mtpt, outfmt, prefidx);
exits(0);
}