diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2013-02-25 14:11:08 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-02-26 12:47:32 +0200 |
commit | 143ef96a6fcd70d7e461882f9dcdf97b18694940 (patch) | |
tree | b846d2267f6dae884d0147469c764f3b7301ccec | |
parent | 585c7ec677471745ab2668cb047b31eb9007dd82 (diff) | |
download | connman-143ef96a6fcd70d7e461882f9dcdf97b18694940.tar.gz connman-143ef96a6fcd70d7e461882f9dcdf97b18694940.tar.bz2 connman-143ef96a6fcd70d7e461882f9dcdf97b18694940.zip |
config: Make load service from each keyfile group as a function
-rw-r--r-- | src/config.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/config.c b/src/config.c index cefe3c98..098ef610 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; |