summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2013-02-25 14:11:08 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2013-02-26 12:47:32 +0200
commit143ef96a6fcd70d7e461882f9dcdf97b18694940 (patch)
treeb846d2267f6dae884d0147469c764f3b7301ccec
parent585c7ec677471745ab2668cb047b31eb9007dd82 (diff)
downloadconnman-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.c41
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;