| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include "server.h" | ||
| 5 | #include "config.h" | ||
| 6 | #include "log.h" | ||
| 7 | |||
| 8 | 8 | int main(int argc, char **argv) { | |
| 9 | ServerConfig config; | ||
| 10 | 8 | char *config_path = "config.yaml"; | |
| 11 | |||
| 12 | // allow --config <file> | ||
| 13 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
|
16 | for (int i = 1; i < argc; i++) { |
| 14 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
|
8 | if (strcmp(argv[i], "--config") == 0 && i + 1 < argc) { |
| 15 | 8 | config_path = argv[++i]; | |
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (load_config(&config, config_path) != 0) { |
| 20 | ✗ | fprintf(stderr, "Error loading configuration from %s\n", config_path); | |
| 21 | ✗ | return 1; | |
| 22 | } | ||
| 23 | |||
| 24 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (log_init(&config.logging) != 0) { |
| 25 | ✗ | fprintf(stderr, "Error initializing logging"); | |
| 26 | ✗ | exit(EXIT_FAILURE); | |
| 27 | } | ||
| 28 | |||
| 29 | 8 | log_message(LOG_LEVEL_INFO, "Starting server on port %d (max_connections=%d)", | |
| 30 | config.port, config.max_connections); | ||
| 31 | |||
| 32 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (start_server(&config) != 0) { |
| 33 | ✗ | log_message(LOG_LEVEL_ERROR, "Error starting server"); | |
| 34 | ✗ | log_shutdown(); | |
| 35 | ✗ | exit(EXIT_FAILURE); | |
| 36 | } | ||
| 37 | |||
| 38 | 8 | log_shutdown(); | |
| 39 | 8 | return EXIT_SUCCESS; | |
| 40 | } | ||
| 41 |