You need to sign in before continuing.
Commit e0d2e93cfb3dd5980f71259faede4505a1eb4788
1 parent
04d68733
Default config file location
Showing
1 changed file
with
10 additions
and
3 deletions
mainapp.cpp
| ... | ... | @@ -211,7 +211,7 @@ void MainApp::doHelp(const char *arg) |
| 211 | 211 | printf("Usage: %s [options]\n", arg); |
| 212 | 212 | puts(""); |
| 213 | 213 | puts(" -h, --help Print help"); |
| 214 | - puts(" -c, --config-file <flashmq.conf> Configuration file."); | |
| 214 | + puts(" -c, --config-file <flashmq.conf> Configuration file. Default '/etc/flashmq/flashmq.conf'."); | |
| 215 | 215 | puts(" -t, --test-config Test configuration file."); |
| 216 | 216 | #ifndef NDEBUG |
| 217 | 217 | puts(" -z, --fuzz-file <inputdata.dat> For fuzzing, provides the bytes that would be sent by a client."); |
| ... | ... | @@ -369,7 +369,14 @@ void MainApp::initMainApp(int argc, char *argv[]) |
| 369 | 369 | {nullptr, 0, nullptr, 0} |
| 370 | 370 | }; |
| 371 | 371 | |
| 372 | + const std::string defaultConfigFile = "/etc/flashmq/flashmq.conf"; | |
| 372 | 373 | std::string configFile; |
| 374 | + | |
| 375 | + if (access(defaultConfigFile.c_str(), R_OK) == 0) | |
| 376 | + { | |
| 377 | + configFile = defaultConfigFile; | |
| 378 | + } | |
| 379 | + | |
| 373 | 380 | std::string fuzzFile; |
| 374 | 381 | |
| 375 | 382 | int option_index = 0; |
| ... | ... | @@ -409,14 +416,14 @@ void MainApp::initMainApp(int argc, char *argv[]) |
| 409 | 416 | { |
| 410 | 417 | if (configFile.empty()) |
| 411 | 418 | { |
| 412 | - std::cerr << "No config specified." << std::endl; | |
| 419 | + std::cerr << "No config specified (with -c) and the default " << defaultConfigFile << " not found." << std::endl << std::endl; | |
| 413 | 420 | MainApp::doHelp(argv[0]); |
| 414 | 421 | exit(1); |
| 415 | 422 | } |
| 416 | 423 | |
| 417 | 424 | ConfigFileParser c(configFile); |
| 418 | 425 | c.loadFile(true); |
| 419 | - puts("Config OK"); | |
| 426 | + printf("Config '%s' OK\n", configFile.c_str()); | |
| 420 | 427 | exit(0); |
| 421 | 428 | } |
| 422 | 429 | catch (ConfigFileException &ex) | ... | ... |