/* * Mike Slemmer * CS326A - Project * main.cc * * This is the main file which creates all the requisite objects and * implements the path planner. */ #include #include #include #include #include "global.h" #define DEBUG_LEVEL 5 ErrorHandler *err; /* Main * * The main here makes sure that a filename was given as input. */ main(int argc, char **argv) { char *filename; char *output_filename; Trifixion *planner; struct stat buf; FILE *input, *output; err = new ErrorHandler(DEBUG_LEVEL); if (argc < 2) { filename = argv[1]; } else { filename = NULL; } if (filename) { if (stat(filename, &buf) < 0) { fprintf(stderr, "Input File %s does not exist or is inaccessible.\n", filename); exit(1); } } if (argc > 2) output_filename = argv[2]; else output_filename = NULL; if (output_filename) { if(stat(output_filename, &buf) >= 0) { fprintf(stderr, "Output File %s exists.\n", output_filename); exit(1); } } planner = new Trifixion(); if (filename) { input = fopen(filename, "r"); if (!input) { fprintf(stderr, "Error opening input file %s\n", filename); exit(1); } } else { input = stdin; } if (output_filename) { output = fopen(output_filename, "w"); if (!output) { fprintf(stderr, "Error opening output file %s\n", output_filename); fclose(input); exit(1); } } else output = stdout; planner->Start(input, output); fclose(input); if (output != stdout) fclose(output); }