void ConfigLoad(Config *config, const char *filename) { // Load default values first ConfigLoadDefault(config); int configVersion = -1; FILE *f = fopen(filename, "r"); if (f == NULL) { printf("Error loading config '%s'\n", filename); return; } configVersion = ConfigGetVersion(f); fclose(f); switch (configVersion) { case 0: ConfigLoadOld(config, filename); break; case 1: case 2: case 3: case 4: ConfigLoadJSON(config, filename); break; default: printf("Unknown config version\n"); break; } }
Config ConfigLoad(const char *filename) { // Load default values first Config c = ConfigDefault(); if (filename == NULL) { // This is equivalent to loading nothing; just exit return c; } FILE *f = fopen(filename, "r"); if (f == NULL) { printf("Error loading config '%s'\n", filename); return c; } const int configVersion = ConfigGetVersion(f); fclose(f); switch (configVersion) { case 0: printf("Classic config is no longer supported\n"); break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: ConfigLoadJSON(&c, filename); break; default: LOG(LM_MAIN, LL_ERROR, "Unknown config version"); break; } ConfigSetChanged(&c); return c; }