[Openvas-commits] r5445 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 8 22:14:44 CEST 2009


Author: mattm
Date: 2009-10-08 22:14:43 +0200 (Thu, 08 Oct 2009)
New Revision: 5445

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.c
Log:
	* src/manage.c (preference_value): New function.  Handles radio
	preference type parsing.
	(send_config_preferences): Get actual value of preference with
	preference_value.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-10-08 18:56:02 UTC (rev 5444)
+++ trunk/openvas-manager/ChangeLog	2009-10-08 20:14:43 UTC (rev 5445)
@@ -1,5 +1,12 @@
 2009-10-08  Matthew Mundell <matthew.mundell at intevation.de>
 
+	* src/manage.c (preference_value): New function.  Handles radio
+	preference type parsing.
+	(send_config_preferences): Get actual value of preference with
+	preference_value.
+
+2009-10-08  Matthew Mundell <matthew.mundell at intevation.de>
+
 	* src/tasks_sql.h (set_task_parameter): Free rc on fail.  Moving setting
 	the task description and targets to precede filling the config, as
 	insert_rc_into_config modifies its rc argument.

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2009-10-08 18:56:02 UTC (rev 5444)
+++ trunk/openvas-manager/src/manage.c	2009-10-08 20:14:43 UTC (rev 5445)
@@ -487,6 +487,29 @@
 }
 
 /**
+ * @brief Return the real value of a preference.
+ *
+ * Take care of radio button options.
+ *
+ * @param[in]  name        Name of preference.
+ * @param[in]  full_value  Entire value of preference.
+ *
+ * @return Real value of the preference.
+ */
+static gchar*
+preference_value (const char* name, const char* full_value)
+{
+  char *bracket = strchr (name, '[');
+  if (bracket && strncmp (bracket, "[radio]:", strlen ("[radio]:")) == 0)
+    {
+      char *semicolon = strchr (full_value, ';');
+      if (semicolon)
+        return g_strndup (full_value, semicolon - full_value);
+    }
+  return g_strdup (full_value);
+}
+
+/**
  * @brief Send the preferences from a config to the scanner.
  *
  * @param[in]  task  Task.
@@ -502,7 +525,10 @@
   init_preference_iterator (&prefs, config, name);
   while (next (&prefs))
     {
-      if (send_to_server (preference_iterator_name (&prefs)))
+      const char *name = preference_iterator_name (&prefs);
+      char *value;
+
+      if (send_to_server (name))
         {
           cleanup_iterator (&prefs);
           return -1;
@@ -514,11 +540,14 @@
           return -1;
         }
 
-      if (send_to_server (preference_iterator_value (&prefs)))
+      value = preference_value (name, preference_iterator_value (&prefs));
+      if (send_to_server (value))
         {
+          g_free (value);
           cleanup_iterator (&prefs);
           return -1;
         }
+      g_free (value);
 
       if (sendn_to_server ("\n", 1))
         {



More information about the Openvas-commits mailing list