2 |
2 |
3 #include "../iniparser/iniparser.h" |
3 #include "../iniparser/iniparser.h" |
4 #include "../iniparser/dictionary.h" |
4 #include "../iniparser/dictionary.h" |
5 #include "../ini/inihelper.h" |
5 #include "../ini/inihelper.h" |
6 #include "../logging.h" |
6 #include "../logging.h" |
|
7 #include "../util.h" |
7 |
8 |
8 #include <stdio.h> |
9 #include <stdio.h> |
9 |
10 |
10 static void freeCfgMeta(flib_cfg_meta *cfg) { |
11 static void freeCfgMeta(flib_cfg_meta *cfg) { |
11 if(cfg) { |
12 if(cfg) { |
54 if(!sectionName) { |
55 if(!sectionName) { |
55 goto handleError; |
56 goto handleError; |
56 } |
57 } |
57 |
58 |
58 bool error = false; |
59 bool error = false; |
59 result->settings[i].iniName = inihelper_strdupnull(sectionName); |
60 result->settings[i].iniName = flib_strdupnull(sectionName); |
60 result->settings[i].title = inihelper_getstringdup(settingfile, &error, sectionName, "title"); |
61 result->settings[i].title = inihelper_getstringdup(settingfile, &error, sectionName, "title"); |
61 result->settings[i].engineCommand = inihelper_getstringdup(settingfile, &error, sectionName, "command"); |
62 result->settings[i].engineCommand = inihelper_getstringdup(settingfile, &error, sectionName, "command"); |
62 result->settings[i].image = inihelper_getstringdup(settingfile, &error, sectionName, "image"); |
63 result->settings[i].image = inihelper_getstringdup(settingfile, &error, sectionName, "image"); |
63 result->settings[i].checkOverMax = inihelper_getbool(settingfile, &error, sectionName, "checkOverMax"); |
64 result->settings[i].checkOverMax = inihelper_getbool(settingfile, &error, sectionName, "checkOverMax"); |
64 result->settings[i].times1000 = inihelper_getbool(settingfile, &error, sectionName, "times1000"); |
65 result->settings[i].times1000 = inihelper_getbool(settingfile, &error, sectionName, "times1000"); |
76 if(!sectionName) { |
77 if(!sectionName) { |
77 goto handleError; |
78 goto handleError; |
78 } |
79 } |
79 |
80 |
80 bool error = false; |
81 bool error = false; |
81 result->mods[i].iniName = inihelper_strdupnull(sectionName); |
82 result->mods[i].iniName = flib_strdupnull(sectionName); |
82 result->mods[i].bitmaskIndex = inihelper_getint(modfile, &error, sectionName, "bitmaskIndex"); |
83 result->mods[i].bitmaskIndex = inihelper_getint(modfile, &error, sectionName, "bitmaskIndex"); |
83 if(error) { |
84 if(error) { |
84 flib_log_e("Missing or malformed ini parameter in file %s, section %s", modpath, sectionName); |
85 flib_log_e("Missing or malformed ini parameter in file %s, section %s", modpath, sectionName); |
85 goto handleError; |
86 goto handleError; |
86 } |
87 } |
107 return NULL; |
108 return NULL; |
108 } |
109 } |
109 |
110 |
110 result->modCount = meta->modCount; |
111 result->modCount = meta->modCount; |
111 result->settingCount = meta->settingCount; |
112 result->settingCount = meta->settingCount; |
112 result->schemeName = inihelper_strdupnull(schemeName); |
113 result->schemeName = flib_strdupnull(schemeName); |
113 result->mods = calloc(meta->modCount, sizeof(*result->mods)); |
114 result->mods = calloc(meta->modCount, sizeof(*result->mods)); |
114 result->settings = calloc(meta->settingCount, sizeof(*result->settings)); |
115 result->settings = calloc(meta->settingCount, sizeof(*result->settings)); |
115 |
116 |
116 if(!result->mods || !result->settings || !result->schemeName) { |
117 if(!result->mods || !result->settings || !result->schemeName) { |
117 flib_cfg_destroy(result); |
118 flib_cfg_destroy(result); |