+/**
+ * @function HandleArguments
+ * @purpose Fill the "options" variable by parsing command line arguments
+ * @param argc - Number of arguments
+ * @param argv - Argument strings
+ */
+void HandleArguments(int argc, char ** argv)
+{
+ for (unsigned i = 1; i < argc; ++i) //For all arguments
+ {
+ if (argv[i][0] != '-') //If the argument is not a switch value...
+ {
+ //Interpret first non switch as input file, and second as output file.
+ //If there are too many non switch arguments, give an error.
+ if (options.input == NULL)
+ options.input = argv[i];
+ else if (options.output == NULL)
+ options.output = argv[i];
+ else
+ {
+ fprintf(stderr,"Usage: %s [OPTIONS] field [output]\n", argv[0]);
+ fprintf(stderr," (You provided too many file names)\n");
+ exit(EXIT_FAILURE);
+ }
+ continue;
+ }
+ switch (argv[i][1]) //The argument is a switch if we get here
+ {
+ case 'n': //Number of threads switch
+ UnsignedArgument(&i, argc, argv, &(options.num_threads), &(options.nested_threads));
+ #ifdef SINGLE_THREADED
+ fprintf(stderr, "Warning: -%c switch has no effect in the single-threaded program.\n", argv[i][1]);
+
+ #endif //SINGLE_THREADED
+ break;
+ case 's': //Number of steps switch
+ UnsignedArgument(&i, argc, argv, &(options.num_steps), NULL);
+ break;
+ case 't': //Timeout switch (in seconds)
+ UnsignedArgument(&i, argc, argv, &(options.timeout), NULL);
+ break;
+ case 'g': //Graphics switch
+ options.draw_graphics = !options.draw_graphics;
+ break;
+ case 'v': //Verbosity switch
+ UnsignedArgument(&i, argc, argv, &(options.verbosity), NULL);
+ break;