[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvas-cvs
Subject:    [Openvas-commits] r3200 - in trunk/openvas-config-manager: . src
From:       scm-commit () wald ! intevation ! org
Date:       2009-04-27 12:03:55
Message-ID: 20090427120355.DFD5140844 () pyrosoma ! intevation ! org
[Download RAW message or body]

Author: mwiegand
Date: 2009-04-27 14:03:55 +0200 (Mon, 27 Apr 2009)
New Revision: 3200

Modified:
   trunk/openvas-config-manager/ChangeLog
   trunk/openvas-config-manager/src/openvascd.c
Log:
* src/openvascd.c (openvas_config_list_all_prefs): Changed config file
parsing to use g_key_file functionality provided by glib. Note that this
makes a slight change to the openvasd.conf necessary: A line containing
"[OpenVAS]" has to be inserted before any line containing preferences.

* ChangeLog: Fixed missing TLDs in mail addresses.


Modified: trunk/openvas-config-manager/ChangeLog
===================================================================
--- trunk/openvas-config-manager/ChangeLog	2009-04-26 22:37:29 UTC (rev 3199)
+++ trunk/openvas-config-manager/ChangeLog	2009-04-27 12:03:55 UTC (rev 3200)
@@ -1,5 +1,14 @@
-2009-04-24  Michael Wiegand <michael.wiegand@intevation>
+2009-04-24  Michael Wiegand <michael.wiegand@intevation.de>
 
+	* src/openvascd.c (openvas_config_list_all_prefs): Changed config file
+	parsing to use g_key_file functionality provided by glib. Note that this
+	make a slight change to the openvasd.conf necessary: A line containing
+	"[OpenVAS]" has to be inserted before any line containing preferences.
+
+	* ChangeLog: Fixed missing TLDs in mail addresses.
+
+2009-04-24  Michael Wiegand <michael.wiegand@intevation.de>
+
 	Added daemon functionality to openvascd. openvascd will now start as
 	GnuTLS server when started with the -d option.
 
@@ -15,7 +24,7 @@
 	OPENVAS_SERVER_KEY and OPENVAS_CA_CERTIFICATE are available when
 	compiling. Added link flag for GnuTLS.
 
-2009-04-22  Michael Wiegand <michael.wiegand@intevation>
+2009-04-22  Michael Wiegand <michael.wiegand@intevation.de>
 
 	Added support for retrieving server preferences (new command:
 	list_all_prefs).
@@ -34,7 +43,7 @@
 	* src/CMakeLists.txt: Use OPENVAS_CONFIG_FILE definition when compiling
 	openvascd.c.
 
-2009-04-22  Michael Wiegand <michael.wiegand@intevation>
+2009-04-22  Michael Wiegand <michael.wiegand@intevation.de>
 
 	Initial import of the openvas-configuration-manager module.
 

Modified: trunk/openvas-config-manager/src/openvascd.c
===================================================================
--- trunk/openvas-config-manager/src/openvascd.c	2009-04-26 22:37:29 UTC (rev 3199)
+++ trunk/openvas-config-manager/src/openvascd.c	2009-04-27 12:03:55 UTC (rev 3200)
@@ -400,39 +400,30 @@
 openvas_config_list_all_prefs (const gchar * config_file)
 {
   GError *error;
+  GKeyFile *config_key_file = g_key_file_new ();
+  gchar **config_keys = NULL;
 
-  gchar *config_file_contents = NULL;
-
-  if (g_file_get_contents (config_file, &config_file_contents, NULL, &error))
+  if (g_key_file_load_from_file (config_key_file, config_file, G_KEY_FILE_NONE, &error))
     {
-      int i;
       GHashTable *prefs = g_hash_table_new (NULL, NULL);
-      gchar **line = g_strsplit (config_file_contents, "\n", 0);
-      for (i = 0; i < g_strv_length (line); i++)
+      gsize len;
+      int i;
+
+      config_keys = g_key_file_get_keys (config_key_file, "OpenVAS", &len, &error);
+      for (i = 0; i < g_strv_length (config_keys); i++)
         {
-          if (line[i][0] != '\0' && line[i][0] != '#')
-            {
-              gchar **kv = g_strsplit (line[i], "=", 0);
-              if (g_strv_length (kv) == 2)
-                {
-                  g_hash_table_insert (prefs,
-                                       g_strdup (g_strstrip (kv[0])),
-                                       g_strdup (g_strstrip (kv[1])));
-                }
-              else
-                {
-                  g_debug ("Malformed preference %s detected in %s.",
-                           line[i], config_file);
-                }
-              g_strfreev (kv);
-            }
+          g_hash_table_insert (prefs,
+                               g_strdup (config_keys[i]),
+                               g_key_file_get_value (config_key_file, "OpenVAS",
+                                                     config_keys[i], &error));
         }
-      g_strfreev (line);
+      g_strfreev (config_keys);
+      g_key_file_free (config_key_file);
       return prefs;
     }
   else
     {
-      g_debug ("g_file_get_contents failed!");
+      g_debug ("%s", error->message);
       return NULL;
     }
 }

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic