diff options
author | Cara Salter <cara@devcara.com> | 2023-02-16 09:20:25 -0500 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2023-02-16 09:20:25 -0500 |
commit | 9ae99ae2949716cb05cd8fee618cb4ce67fff4a5 (patch) | |
tree | 53ed1b21667e524674deb69dc6f416c8bef9dcd1 /src/main.c | |
parent | 085ca0d6ca31223b14855525dc82bcdae93cf7f7 (diff) | |
download | cmud-9ae99ae2949716cb05cd8fee618cb4ce67fff4a5.tar.gz cmud-9ae99ae2949716cb05cd8fee618cb4ce67fff4a5.zip |
Work on configuration
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -5,6 +5,9 @@ #include "log.h" #include <stdlib.h> #include <stdio.h> +#include <libconfig.h> + +config_t cfg; /** * Server entrypoint @@ -12,6 +15,24 @@ * sets up everything needed to handle sockets and connections * */ int main() { + + debug("Initializing config..."); + config_init(&cfg); + if (config_read_file(&cfg, "config.cfg") != CONFIG_TRUE) { + error("Could not read config:"); + printf("%s (%d): %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); + + exit(-1); + } + debug("Done"); + + const char* name; + if (!config_lookup_string(&cfg, "name", &name)) { + error("Invalid config"); + exit(-1); + } + + info("Starting up %s game server", name); int err = 0; server_t server = {0}; err = server_listen(&server); |