Program won't start up without a config
This commit is contained in:
5
config.c
5
config.c
@@ -5,14 +5,15 @@
|
|||||||
config_t cfg;
|
config_t cfg;
|
||||||
const config_setting_t *setting;
|
const config_setting_t *setting;
|
||||||
|
|
||||||
void cfginit(void) {
|
int cfginit(void) {
|
||||||
|
|
||||||
config_init(&cfg);
|
config_init(&cfg);
|
||||||
if (!config_read_file(&cfg, "csoundbox.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));
|
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
//return(EXIT_FAILURE);
|
return 0;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfgdestroy(void) {
|
void cfgdestroy(void) {
|
||||||
|
2
config.h
2
config.h
@@ -4,7 +4,7 @@ typedef struct {
|
|||||||
char *key[50];
|
char *key[50];
|
||||||
} sounds;
|
} sounds;
|
||||||
|
|
||||||
void cfginit(void);
|
int cfginit(void);
|
||||||
void cfgdestroy(void);
|
void cfgdestroy(void);
|
||||||
void cfgreinit(void);
|
void cfgreinit(void);
|
||||||
const char *lookupSounds(char input);
|
const char *lookupSounds(char input);
|
||||||
|
@@ -22,7 +22,10 @@ int main(int argc, char *argv[]) {
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
//initialize libconfig
|
//initialize libconfig
|
||||||
cfginit();
|
if (!cfginit()) {
|
||||||
|
printf("Failed to initialize csoundbox.cfg. Does it exist?\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ao_initialize();
|
ao_initialize();
|
||||||
|
|
||||||
while ( (c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1 ) {
|
while ( (c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1 ) {
|
||||||
|
Reference in New Issue
Block a user