diff options
-rw-r--r-- | 19.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -2,6 +2,7 @@ #include <regex.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> @@ -181,13 +182,18 @@ int main(int argc, char ** argv) { int rounds = 24; + char const * build = "basic"; int i; regex_t reblueprint; char buf[BUFSIZ]; - while ((i = getopt(argc, argv, "r:")) != -1) + while ((i = getopt(argc, argv, "b:r:")) != -1) { switch (i) { + case 'b': + build = optarg; + break; + case 'r': rounds = atoi(optarg); break; @@ -229,7 +235,14 @@ main(int argc, char ** argv) inventory_init(&i); - inventory_build_basic(&i, &b, rounds); + if (strcmp(build, "basic") == 0) { + inventory_build_basic(&i, &b, rounds); + } + else { + fprintf(stderr, "Unknown build strategy: %s\n", build); + regfree(&reblueprint); + return -1; + } printf("Blueprint %d geodes = %ld\n", b.id, i.geod.amount); } |