diff options
Diffstat (limited to 'sd.c')
-rw-r--r-- | sd.c | 22 |
1 files changed, 6 insertions, 16 deletions
@@ -2,31 +2,21 @@ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <time.h> -#include <getopt.h> #include <sqlite3.h> #include "segmenttree.h" -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { char *file = "cards"; bool verbose = false; bool noninteractive = false; /* Proccess args */ - static struct option long_options[] = { - {"file", required_argument, NULL, 'f'}, - {"verbose", no_argument, NULL, 'v'}, - {"noninteractive", no_argument, NULL, 'n'} - }; - while (true) { - int c = getopt_long(argc, argv, "f:vn", long_options, NULL); - if (c == -1) break; - switch (c) { - case 'f': file = optarg; break; - case 'v': verbose = true; break; - case 'n': noninteractive = true; break; - default: abort(); - } + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-v") == 0) verbose = true; + else if (strcmp(argv[i], "-n") == 0) noninteractive = true; + else file = argv[i]; } /* Seed the RNG */ |