Program won't start up without a config

This commit is contained in:
2018-02-11 18:57:42 +01:00
parent 9ac911b882
commit aa0ca9db87
3 changed files with 8 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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 ) {