| 327 | } |
| 328 | |
| 329 | void |
| 330 | ParseCommandLine(int argc, char **argv, CommandLineOptions &options, |
| 331 | ConfigData &config) |
| 332 | { |
| 333 | bool use_config_file = true; |
| 334 | |
| 335 | // First pass: handle command line options |
| 336 | OptionParser parser(option_defs, argc, argv); |
| 337 | while (auto o = parser.Next()) { |
| 338 | switch (Option(o.index)) { |
| 339 | case OPTION_KILL: |
| 340 | options.kill = true; |
| 341 | break; |
| 342 | |
| 343 | case OPTION_NO_CONFIG: |
| 344 | use_config_file = false; |
| 345 | break; |
| 346 | |
| 347 | case OPTION_NO_DAEMON: |
| 348 | #ifdef ENABLE_DAEMON |
| 349 | options.daemon = false; |
| 350 | #endif |
| 351 | break; |
| 352 | |
| 353 | #ifdef __linux__ |
| 354 | case OPTION_SYSTEMD: |
| 355 | #ifdef ENABLE_DAEMON |
| 356 | options.daemon = false; |
| 357 | #endif |
| 358 | options.systemd = true; |
| 359 | break; |
| 360 | #endif |
| 361 | |
| 362 | case OPTION_STDOUT: |
| 363 | case OPTION_STDERR: |
| 364 | options.log_stderr = true; |
| 365 | break; |
| 366 | |
| 367 | case OPTION_VERBOSE: |
| 368 | options.verbose = true; |
| 369 | break; |
| 370 | |
| 371 | case OPTION_VERSION: |
| 372 | version(); |
| 373 | |
| 374 | case OPTION_HELP: |
| 375 | case OPTION_HELP2: |
| 376 | help(); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /* initialize the logging library, so the configuration file |
| 381 | parser can use it already */ |
| 382 | log_early_init(options.verbose); |
| 383 | |
| 384 | if (!use_config_file) { |
| 385 | LogDebug(cmdline_domain, |
| 386 | "Ignoring config, using daemon defaults"); |
no test coverage detected