From aa0ca9db87637499754281b3872ea6d0ba95067d Mon Sep 17 00:00:00 2001 From: structix Date: Sun, 11 Feb 2018 18:57:42 +0100 Subject: [PATCH] Program won't start up without a config --- config.c | 5 +++-- config.h | 2 +- csoundbox.c | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 1034614..c5b0db9 100644 --- a/config.c +++ b/config.c @@ -5,14 +5,15 @@ config_t cfg; const config_setting_t *setting; -void cfginit(void) { +int cfginit(void) { config_init(&cfg); if (!config_read_file(&cfg, "csoundbox.cfg")) { fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg)); config_destroy(&cfg); - //return(EXIT_FAILURE); + return 0; } + return 1; } void cfgdestroy(void) { diff --git a/config.h b/config.h index 69a66bf..ec5f4ae 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ typedef struct { char *key[50]; } sounds; -void cfginit(void); +int cfginit(void); void cfgdestroy(void); void cfgreinit(void); const char *lookupSounds(char input); diff --git a/csoundbox.c b/csoundbox.c index d0ba1cc..6876d2f 100644 --- a/csoundbox.c +++ b/csoundbox.c @@ -22,7 +22,10 @@ int main(int argc, char *argv[]) { int c; //initialize libconfig - cfginit(); + if (!cfginit()) { + printf("Failed to initialize csoundbox.cfg. Does it exist?\n"); + return 0; + } ao_initialize(); while ( (c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1 ) {