-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
48 lines (44 loc) · 1.26 KB
/
main.cpp
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
#include <stdio.h> /* for printf */
#include <stdlib.h> /* for exit */
#include <unistd.h> /* for getopt */
#include "compiler.h"
int main(int argc, char **argv) {
int c;
char * source = 0;
char * output_dir = 0;
char * header = 0;
bool t = false;
bool v = false;
while ((c = getopt(argc, argv, "vto:h:")) != -1) {
int this_option_optind = optind ? optind : 1;
switch (c) {
case 'o':
printf("option o with value '%s'\n", optarg);
output_dir = optarg;
break;
case 'h':
printf("option h with value '%s'\n", optarg);
header = optarg;
break;
case 't':
t = true;
break;
case 'v':
v = true;
break;
case '?':
break;
default:
printf("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc) {
source = argv[optind++];
/*printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");*/
}
compile(source, output_dir, header, t, v);
exit(0);
}