[PATCH 1/3] storage: add the capability to select list seperator when loading a key file

Tomasz Bursztyka tomasz.bursztyka at linux.intel.com
Wed Feb 15 07:04:58 PST 2012


---
 src/storage.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 75a1b0b..31699c6 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -38,7 +38,7 @@
 #define MODE		(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | \
 			S_IXGRP | S_IROTH | S_IXOTH)
 
-static GKeyFile *storage_load(const char *pathname)
+static GKeyFile *storage_load(const char *pathname, char sep)
 {
 	GKeyFile *keyfile = NULL;
 	GError *error = NULL;
@@ -47,6 +47,9 @@ static GKeyFile *storage_load(const char *pathname)
 
 	keyfile = g_key_file_new();
 
+	if (sep != 0)
+		g_key_file_set_list_separator(keyfile, sep);
+
 	if (!g_key_file_load_from_file(keyfile, pathname, 0, &error)) {
 		DBG("Unable to load %s: %s", pathname, error->message);
 		g_clear_error(&error);
@@ -91,7 +94,7 @@ GKeyFile *__connman_storage_load_global()
 	if(pathname == NULL)
 		return NULL;
 
-	keyfile = storage_load(pathname);
+	keyfile = storage_load(pathname, 0);
 
 	g_free(pathname);
 
@@ -133,7 +136,7 @@ GKeyFile *__connman_storage_load_config(const char *ident)
 	if(pathname == NULL)
 		return NULL;
 
-	keyfile = storage_load(pathname);
+	keyfile = storage_load(pathname, 0);
 
 	g_free(pathname);
 
@@ -173,7 +176,7 @@ GKeyFile *__connman_storage_open_service(const char *service_id)
 	if(pathname == NULL)
 		return NULL;
 
-	keyfile =  storage_load(pathname);
+	keyfile =  storage_load(pathname, 0);
 	if (keyfile) {
 		g_free(pathname);
 		return keyfile;
@@ -247,7 +250,7 @@ GKeyFile *connman_storage_load_service(const char *service_id)
 	if(pathname == NULL)
 		return NULL;
 
-	keyfile =  storage_load(pathname);
+	keyfile =  storage_load(pathname, 0);
 	g_free(pathname);
 	if (keyfile)
 		return keyfile;
@@ -256,7 +259,7 @@ GKeyFile *connman_storage_load_service(const char *service_id)
 	if(pathname == NULL)
 		return NULL;
 
-	keyfile =  storage_load(pathname);
+	keyfile =  storage_load(pathname, 0);
 
 	g_free(pathname);
 
@@ -300,7 +303,7 @@ GKeyFile *__connman_storage_load_provider(const char *identifier)
 	if (pathname == NULL)
 		return NULL;
 
-	keyfile = storage_load(pathname);
+	keyfile = storage_load(pathname, 0);
 	g_free(pathname);
 
 	return keyfile;
@@ -404,7 +407,7 @@ void __connman_storage_migrate()
 	keyfile = g_key_file_new();
 
 	/* If default.profile doesn't exists, create settings with defaults. */
-	keyfile_def = storage_load(pathname);
+	keyfile_def = storage_load(pathname, 0);
 	if (keyfile_def == NULL) {
 		g_key_file_set_boolean(keyfile, "global",
 					"OfflineMode", FALSE);
-- 
1.7.8.4




More information about the connman mailing list