| 47 | } |
| 48 | |
| 49 | static const char* get_conf_file(int argc, char *argv[]) |
| 50 | { |
| 51 | if (argc < 3) { |
| 52 | std::cerr << "\n\tPlease specify a config file\n\n"; |
| 53 | usage(); |
| 54 | exit(0); |
| 55 | } |
| 56 | |
| 57 | const char* conf_file; |
| 58 | bool conf_file_set=0; |
| 59 | |
| 60 | if (argc >= 3 && (strcmp(argv[1], "-conf") == 0 || strcmp(argv[1], "-config") == 0 || strcmp(argv[1], "--config") == 0 || strcmp(argv[1], "--conf") == 0)) { |
| 61 | conf_file = argv[2]; |
| 62 | conf_file_set=1; |
| 63 | } else { |
| 64 | if (argc >= 5 && (strcmp(argv[3], "-conf") == 0 || strcmp(argv[3], "-config") == 0 || strcmp(argv[3], "--config") == 0 || strcmp(argv[3], "--conf") == 0)) { |
| 65 | conf_file = argv[4]; |
| 66 | conf_file_set=1; |
| 67 | } else { |
| 68 | if (argc >= 7 && (strcmp(argv[5], "-conf") == 0 || strcmp(argv[5], "-config") == 0 || strcmp(argv[5], "--config") == 0 || strcmp(argv[5], "--conf") == 0)) { |
| 69 | conf_file = argv[6]; |
| 70 | conf_file_set=1; |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if(!conf_file_set) { |
| 76 | usage(); |
| 77 | exit(0); |
| 78 | } |
| 79 | |
| 80 | ifstream ifile(conf_file); |
| 81 | |
| 82 | if (!ifile) { |
| 83 | std::cerr << "\n\tCould not find your config file.. Please, check the existance of "<< conf_file <<"\n\n"; |
| 84 | usage(); |
| 85 | exit(-1); |
| 86 | } |
| 87 | |
| 88 | return conf_file; |
| 89 | } |
| 90 | |
| 91 | |
| 92 | |