From 143ef96a6fcd70d7e461882f9dcdf97b18694940 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Mon, 25 Feb 2013 14:11:08 +0200 Subject: [PATCH] config: Make load service from each keyfile group as a function --- src/config.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/config.c b/src/config.c index cefe3c9..098ef61 100644 --- a/src/config.c +++ b/src/config.c @@ -714,15 +714,33 @@ err: return FALSE; } +static connman_bool_t load_service_from_keyfile(GKeyFile *keyfile, + struct connman_config *config) +{ + connman_bool_t found = FALSE; + char **groups; + int i; + + groups = g_key_file_get_groups(keyfile, NULL); + + for (i = 0; groups[i] != NULL; i++) { + if (g_str_has_prefix(groups[i], "service_") == FALSE) + continue; + if (load_service(keyfile, groups[i], config) == TRUE) + found = TRUE; + } + + g_strfreev(groups); + + return found; +} + static int load_config(struct connman_config *config) { - GKeyFile *keyfile; GError *error = NULL; - gsize length; - char **groups; + gboolean protected; + GKeyFile *keyfile; char *str; - gboolean protected, found = FALSE; - int i; DBG("config %p", config); @@ -753,22 +771,11 @@ static int load_config(struct connman_config *config) config->protected = TRUE; g_clear_error(&error); - groups = g_key_file_get_groups(keyfile, &length); - - for (i = 0; groups[i] != NULL; i++) { - if (g_str_has_prefix(groups[i], "service_") == TRUE) { - if (load_service(keyfile, groups[i], config) == TRUE) - found = TRUE; - } - } - - if (found == FALSE) + if (load_service_from_keyfile(keyfile, config) == FALSE) connman_warn("Config file %s/%s.config does not contain any " "configuration that can be provisioned!", STORAGEDIR, config->ident); - g_strfreev(groups); - g_key_file_free(keyfile); return 0; -- 2.7.4