[Openvas-commits] r5456 - in trunk/openvas-client: . openvas

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 9 11:57:51 CEST 2009


Author: felix
Date: 2009-10-09 11:57:51 +0200 (Fri, 09 Oct 2009)
New Revision: 5456

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/openvas/preferences.c
Log:
2009-10-09  Felix Wolfsteller <felix.wolfsteller at intevation.de>

* openvas/preferences.c (preferences_init): Reformatted.
(preferences_get_filename): Reformatted, doc.
(prefs_add_subcategory): Reformatted, added todo about possible memleak.
(prefs_get_pluginset): Reformatted.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-10-09 09:51:29 UTC (rev 5455)
+++ trunk/openvas-client/ChangeLog	2009-10-09 09:57:51 UTC (rev 5456)
@@ -1,3 +1,10 @@
+2009-10-09  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+	* openvas/preferences.c (preferences_init): Reformatted.
+	(preferences_get_filename): Reformatted, doc.
+	(prefs_add_subcategory): Reformatted, added todo about possible memleak.
+	(prefs_get_pluginset): Reformatted.	
+
 2009-10-09  Michael Wiegand <michael.wiegand at greenbone.net>
 
 	* openvas/preferences.c (prefs_buffer_parse): Don't drop

Modified: trunk/openvas-client/openvas/preferences.c
===================================================================
--- trunk/openvas-client/openvas/preferences.c	2009-10-09 09:51:29 UTC (rev 5455)
+++ trunk/openvas-client/openvas/preferences.c	2009-10-09 09:57:51 UTC (rev 5456)
@@ -48,10 +48,11 @@
 {
   int result;
 
-  context->prefs = emalloc(sizeof(struct arglist));
-  result = preferences_process(context);
-  if(result && getenv("OPENVASHOME") == 0)
-    show_error_and_wait(CANNOT_SET_HOMEVAR);
+  context->prefs = emalloc (sizeof (struct arglist));
+  result = preferences_process (context);
+  if (result && getenv ("OPENVASHOME") == 0)
+    show_error_and_wait (CANNOT_SET_HOMEVAR);
+
   return (result);
 }
 
@@ -65,28 +66,28 @@
  *
  * @param context Context of interest.
  *
- * @return The location of the contexts openvasrc.
+ * @return The location of the contexts openvasrc, to be freed by caller with
+ *         g_free.
  */
 gchar *
 preferences_get_filename (struct context * context)
 {
   gchar * openvasrc;
 
-  if(context->dir)
-  {
-    openvasrc = g_build_filename(context->dir, "openvasrc", NULL);
-  }
-  else
-  {
-    if(Alt_rcfile)
-      openvasrc = estrdup(Alt_rcfile);
-    else
+  if (context->dir)
     {
-      gchar *home = prefs_get_openvashome();
-
-      openvasrc = g_build_filename (home, ".openvasrc", NULL);
+      openvasrc = g_build_filename (context->dir, "openvasrc", NULL);
     }
-  }
+  else // e.g. global context
+    {
+      if (Alt_rcfile)
+        openvasrc = estrdup (Alt_rcfile);
+      else
+        {
+          gchar *home = prefs_get_openvashome();
+          openvasrc = g_build_filename (home, ".openvasrc", NULL);
+        }
+    }
   return openvasrc;
 }
 
@@ -271,20 +272,21 @@
 static int
 prefs_add_subcategory (struct arglist *arglist, FILE *fd, int keep_order)
 {
-  char *buffer = emalloc(4096);
+  char *buffer = emalloc (4096);
   int flag = 0;
 
-  while(!flag && !feof(fd) && fgets(buffer, 4096, fd))
-  {
-    if(!strlen(buffer))
-      return (1);
-    if((!strcmp(buffer, "end\n")) || (!strncmp(buffer, "end(", 4)))
-      flag = 1;
-    else
-      prefs_buffer_parse(buffer, arglist, keep_order);
-    bzero(buffer, 255);
-  }
-  efree(&buffer);
+  while (!flag && !feof (fd) && fgets (buffer, 4096, fd))
+    {
+      /** @todo Evaluate if memleak. */
+      if (!strlen (buffer))
+        return (1);
+      if ((!strcmp (buffer, "end\n")) || (!strncmp (buffer, "end(", 4)))
+        flag = 1;
+      else
+        prefs_buffer_parse (buffer, arglist, keep_order);
+      bzero (buffer, 255);
+    }
+  efree (&buffer);
   return (0);
 }
 
@@ -397,14 +399,14 @@
 prefs_get_pluginset (struct context *context, char *name,
                      struct openvas_plugin *plugins)
 {
-  struct arglist *plugin_set = arg_get_value(context->prefs, name);
+  struct arglist *plugin_set = arg_get_value (context->prefs, name);
 
-  if(!plugin_set)
-  {
-    plugin_set = emalloc(sizeof(struct arglist));
-    arg_add_value(context->prefs, name, ARG_ARGLIST, -1, plugin_set);
-    new_pluginset(plugin_set, plugins);
-  }
+  if (!plugin_set)
+    {
+      plugin_set = emalloc (sizeof (struct arglist));
+      arg_add_value (context->prefs, name, ARG_ARGLIST, -1, plugin_set);
+      new_pluginset (plugin_set, plugins);
+    }
   return plugin_set;
 }
 



More information about the Openvas-commits mailing list