diff options
| author | arf20 <aruizfernandez05@gmail.com> | 2025-11-10 23:50:02 +0100 |
|---|---|---|
| committer | arf20 <aruizfernandez05@gmail.com> | 2025-11-10 23:50:02 +0100 |
| commit | 6bf70db630afa19d0407d6468df8de307bccfecd (patch) | |
| tree | 6f33f87121d6b00424fb3bec4230e8ac9feefc8c /config.c | |
| parent | 26aedc1555186b3be00cf719c2376585035b86af (diff) | |
| download | arfnet2-status-6bf70db630afa19d0407d6468df8de307bccfecd.tar.gz arfnet2-status-6bf70db630afa19d0407d6468df8de307bccfecd.zip | |
fix config
Diffstat (limited to 'config.c')
| -rw-r--r-- | config.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -5,8 +5,9 @@ #include <string.h> #include <errno.h> -unsigned short port = DEFAULT_PORT; -char *log_path = DEFAULT_LOG_PATH; +unsigned short port = 0; +char *tmpl_path = NULL; +char *log_path = NULL; monitor_config_t monitor_config = { .interval = DEFAULT_INTERVAL }; alert_config_t alert_config = { 0 }; @@ -60,6 +61,9 @@ config_load(const char *conf_path) fprintf(stderr, "[config] invalid interval: %s\n", line); return -1; } + } else if (strcmp(line, "interval") == 0) { + tmpl_path = strdup(value); + printf("\ttemplate: %s\n", tmpl_path); } else if (strcmp(line, "log") == 0) { value[strlen(value) - 1] = '\0'; log_path = strdup(value); @@ -97,6 +101,23 @@ config_load(const char *conf_path) fclose(cfgf); + if (port == 0) { + fprintf(stderr, "[config] W: no port, using default\n"); + port = DEFAULT_PORT; + } + + if (!tmpl_path) { + fprintf(stderr, "[config] W: no template file given, using default\n"); + tmpl_path = DEFAULT_TMPL_PATH; + } + + if (!log_path) { + fprintf(stderr, "[config] W: no template event log path given, " + "using default\n"); + log_path = DEFAULT_LOG_PATH; + } + + if (!alert_config.from || !alert_config.mail_server) fprintf(stderr, "[config] W: no mail\n"); |
