MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / g_option_keyfile_parse

Function g_option_keyfile_parse

sqladvisor/main.cc:1265–1330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263 NULL }, { "verbose", 'v', 0, G_OPTION_ARG_INT, &(options.verbose),
1264 "1:output logs 0:output nothing", NULL }, { NULL } };
1265int g_option_keyfile_parse(GKeyFile *keyfile, const char *ini_group_name,
1266 GOptionEntry *entries) {
1267 GError *gerr = NULL;
1268 GOptionEntry *entry = NULL;
1269 int ret = 0;
1270 int i = 0, j = 0;
1271 if (keyfile == NULL) {
1272 return ret;
1273 }
1274 if (!g_key_file_has_group(keyfile, ini_group_name)) {
1275 return ret;
1276 }
1277 for (i = 0; entries[i].long_name; i++) {
1278 char *arg_string = NULL;
1279 char **arg_string_array = NULL;
1280 int arg_int = 0;
1281 gsize len = 0;
1282 entry = &(entries[i]);
1283 switch (entry->arg) {
1284 case G_OPTION_ARG_STRING: {
1285 g_clear_error(&gerr);
1286 if (entry->arg_data == NULL
1287 || *(gchar **) (entry->arg_data) != NULL) {
1288 break;
1289 }
1290 arg_string = g_key_file_get_string(keyfile, ini_group_name,
1291 entry->long_name, &gerr);
1292 if (!gerr) {
1293 *(gchar **) (entry->arg_data) = g_strchomp(arg_string);
1294 }
1295 break;
1296 }
1297 case G_OPTION_ARG_INT: {
1298 g_clear_error(&gerr);
1299 arg_int = g_key_file_get_integer(keyfile, ini_group_name,
1300 entry->long_name, &gerr);
1301 if (!gerr) {
1302 *(gint *) (entry->arg_data) = arg_int;
1303 }
1304 break;
1305 }
1306 case G_OPTION_ARG_STRING_ARRAY: {
1307 g_clear_error(&gerr);
1308 if (entry->arg_data == NULL
1309 || *(gchar **) (entry->arg_data) != NULL) {
1310 break;
1311 }
1312 arg_string_array = g_key_file_get_string_list(keyfile,
1313 ini_group_name, entry->long_name, &len, &gerr);
1314 if (!gerr) {
1315 for (j = 0; arg_string_array[j]; j++) {
1316 arg_string_array[j] = g_strstrip(arg_string_array[j]);
1317 }
1318 *(gchar ***) (entry->arg_data) = arg_string_array;
1319 }
1320 break;
1321 }
1322 default: {

Callers 1

mainFunction · 0.85

Calls 1

sql_print_errorFunction · 0.85

Tested by

no test coverage detected