argparsing working
[mc1516pa.git] / modelchecker / main.c
1 #include <stdio.h>
2 #include <stdbool.h>
3 #include <ctype.h>
4
5 #include <sylvan.h>
6 #include "mc.h"
7
8 //#include <sokoban.h>
9 //#include <object.h>
10 //#include <coord.h>
11
12 bool DEBUG = false;
13
14 void usage(char *prg){
15 fprintf(stderr,
16 "Usage:\n"
17 "\t%s [opts] [FILE [FILE [...]]]\n"
18 "\n"
19 "Options:\n"
20 "\tAll strategies are mutually exclusive\n"
21 "\t-c coordinate based strategy\n"
22 "\t-o object based strategy\n"
23 "\t-y hybrid strategy\n"
24 // "\t-l LURD lURD verification strategy\n"
25 // "\t-r show all positions that are a valid solution\n"
26 "\n"
27 "\t-d enable verbose debug output\n"
28 "\t-h show this help\n"
29 "\n"
30 "Positional arguments:\n"
31 "\tFILE zero or more sokoban screens\n"
32 "\t when no file is specified stdin will be used\n", prg);
33 }
34
35 void solve(FILE *inputstream){
36 int buffer;
37 while((buffer = fgetc(inputstream)) != EOF){
38 printf("%c", buffer);
39 }
40 // Alex:
41 // Screen reading
42 // - Removing outside walls
43 // - Bucket fill
44 // - [tile]
45 // - tile = structure {int, int, enumtile}
46
47 // Both: Encoding in both schemes
48
49 // Future: SMC
50 }
51
52 int main(int argc, char **argv){
53 strategy strat = HYBRID;
54 int optchar;
55
56 while((optchar = getopt(argc, argv, "cdhoy")) != -1){
57 switch(optchar){
58 case 'c':
59 strat = COORD;
60 if(DEBUG) fprintf(stderr, "Strategy changed to Coordinate based\n");
61 break;
62 case 'd':
63 DEBUG = true;
64 if(DEBUG) fprintf(stderr, "Debug enabled\n");
65 break;
66 case 'h':
67 usage(argv[0]);
68 return 0;
69 case 'o':
70 strat = OBJECT;
71 if(DEBUG) fprintf(stderr, "Strategy changed to Object based\n");
72 break;
73 case 'y':
74 strat = HYBRID;
75 if(DEBUG) fprintf(stderr, "Strategy changed to Hybrid\n");
76 break;
77 case '?':
78 if(isprint(optopt)){
79 fprintf(stderr, "Unknown option `-%c'.\n", optopt);
80 } else {
81 fprintf(stderr, "Unknown option char `-\\x%x'.\n", optopt);
82 }
83 return 2;
84 default:
85 break;
86 }
87 }
88
89 if(optind == argc){
90 fprintf(stderr, "You have not specified a file, reading from stdin\n");
91 solve(stdin);
92 }
93
94 for(int filepathindex = optind; filepathindex < argc; filepathindex++){
95 char *currentfilepath = argv[filepathindex];
96 fprintf(stderr, "Processing: %s\n", currentfilepath);
97 if(DEBUG) fprintf(stderr, "Strategy: %d\n", strat);
98 FILE *currentfile = fopen(currentfilepath, "r");
99 if(DEBUG) fprintf(stderr, "Opening file\n");
100 solve(currentfile);
101 if(DEBUG) fprintf(stderr, "Closing file\n");
102 fclose(currentfile);
103 }
104 return 0;
105 }