[Openvas-commits] r2705 - in trunk/openvas-client: . nessus/prefs_dialog

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 9 09:53:43 CET 2009


Author: felix
Date: 2009-03-09 09:53:41 +0100 (Mon, 09 Mar 2009)
New Revision: 2705

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c
Log:
Include the number of log messages in the count-cache file (.cnt) that
is used to fill the table of reports (left side in GUI), cosmetics.

* nessus/prefs_dialog/prefs_scope_tree.c: Documentation and whites
spaces added.

* nessus/prefs_dialog/prefs_scope_tree.c
(scopetreestore_counters_update): Documentation added, use of
g_strdup_printf and gfree instead of snprintf etc. Renamed local
variables h,w,n,f,l to highs,warnings... etc, included nr of log
messages into the cnt file.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-08 14:05:20 UTC (rev 2704)
+++ trunk/openvas-client/ChangeLog	2009-03-09 08:53:41 UTC (rev 2705)
@@ -1,3 +1,17 @@
+2009-03-09  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+	Include the number of log messages in the count-cache file (.cnt) that
+	is used to fill the table of reports (left side in GUI), cosmetics.
+
+	* nessus/prefs_dialog/prefs_scope_tree.c: Documentation and whites
+	spaces added.
+	
+	* nessus/prefs_dialog/prefs_scope_tree.c
+	(scopetreestore_counters_update): Documentation added, use of
+	g_strdup_printf and gfree instead of snprintf etc. Renamed local
+	variables h,w,n,f,l to highs,warnings... etc, included nr of log
+	messages into the cnt file.
+
 2009-03-07  Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
 
 	* src/gui/priofiltermngr_dlg.c (priorityfiltermanager_dialog):

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c	2009-03-08 14:05:20 UTC (rev 2704)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c	2009-03-09 08:53:41 UTC (rev 2705)
@@ -45,6 +45,11 @@
  * The scope- tree also acts as a table, allowing an overview over how many
  * security notes, warnings, holes and false positives were reported in a
  * "report"- scope.
+ * 
+ * The counted numbers for warnings, holes etc are stored in a separate .cnt
+ * file to avoid recounting.
+ * The cnt file is placed next to the location of the .nbe backend file (usually
+ * in the contexts directory).
  */
 
 /**
@@ -76,6 +81,7 @@
   context->treerowref = gtk_tree_row_reference_new(model, path);
 }
 
+
 void
 scope_move_menuitem_enable (struct context *context, gboolean enable)
 {
@@ -559,65 +565,74 @@
 }
 
 
+/**
+ * @brief Set table values for statistics (e.g. nr. of warnings) in the
+ * @brief treestore. Values are read from or written to a .cnt file.
+ * 
+ * @param treestore Treestore to manipulate.
+ * @param be        Backend index, will be converted (backend_convert) if file
+ *                  does not exist.
+ * @param fname     Path to .cnt file.
+ */
 void
 scopetreestore_counters_update (GtkTreeStore* treestore, GtkTreeIter iter,
                                 int be, char * fname)
 {
   struct arglist *hosts;
-  char cached_counters[1024];
+  gchar* cached_counters = NULL;
   FILE * fp;
-  int    h = 0, w = 0, n = 0, f = 0, l = 0;
+  int    highs = 0, warns = 0, notes = 0, falsepos = 0, logs = 0;
 
-  /*
-   * Cache the results in a '.cnt' file to avoid recounting 
-   * each .nbe file on startup
-   */
-  if ( fname != NULL )
-	{
-  	snprintf(cached_counters, sizeof(cached_counters), "%s.cnt", fname);
-	fp = fopen(cached_counters, "r");
-	}
+  /* Cache the results in a '.cnt' file to avoid recounting 
+   * each .nbe file on startup */
+  if (fname != NULL)
+    {
+      cached_counters = g_strdup_printf ("%s.cnt", fname);
+      fp = fopen (cached_counters, "r");
+    }
   else
-	fp = NULL;
+    fp = NULL;
 
-  if ( fp == NULL )
+  if (fp == NULL)
   {
      hosts = backend_convert(be);
-     h = number_of_holes(hosts);
-     w = number_of_warnings(hosts);
-     n = number_of_notes(hosts);
-     f = number_of_false_positives(hosts);
-     l = number_of_log_messages(hosts);
+     highs = number_of_holes(hosts);
+     warns = number_of_warnings(hosts);
+     notes = number_of_notes(hosts);
+     falsepos = number_of_false_positives(hosts);
+     logs = number_of_log_messages(hosts);
      if(hosts) arg_free_all(hosts);
      if ( fname != NULL )
-     	fp = fopen(cached_counters, "w");
+       fp = fopen (cached_counters, "w");
      else
 	fp = NULL;
 
      if ( fp != NULL )
       {
-       fprintf(fp, "%d %d %d %d\n", h, w, n, f);
+       fprintf(fp, "%d %d %d %d %d\n", highs, warns, notes, falsepos, logs);
        fclose(fp);
       }
       else if ( fname != NULL ) perror("open ");
   }
   else
   {
-    fscanf(fp, "%d %d %d %d", &h, &w, &n, &f);
+    fscanf(fp, "%d %d %d %d %d", &highs, &warns, &notes, &falsepos, &logs);
     fclose(fp);
   }
 
 
   /* XXX: add these to scopes and tasks? */
   gtk_tree_store_set (treestore, &iter,
-                      COL_NOTE, n,
-                      COL_WARN, w,
-                      COL_HOLE, h,
-                      COL_FALSE, f,
-                      COL_LOG, l,
+                      COL_NOTE, notes,
+                      COL_WARN, warns,
+                      COL_HOLE, highs,
+                      COL_FALSE, falsepos,
+                      COL_LOG, logs,
                       -1);
+  if (cached_counters) g_free (cached_counters);
 }
 
+
 void
 scopetreeview_counters_update (struct context *context, int be, char * fname)
 {
@@ -634,6 +649,7 @@
   gtk_tree_path_free(path);
 }
 
+
 void
 scopetreeview_connected_update (struct context *context)
 {
@@ -648,11 +664,12 @@
   gtk_tree_path_free(path);
 }
 
+
 /**
  * @brief Set the pixbuf of the cell according to the state of the context or
  *        the row.
  *
- * The data parameter should be the tree-view widget.
+ * @param data The tree-view widget.
  */
 static void
 connected_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
@@ -861,8 +878,7 @@
   GtkTreeStore *treestore;
   GtkTreeIter global, task, scope, report;
   /* TODO currently unused:
-   * GtkTreeIter hostgroup, host;
-   */
+   * GtkTreeIter hostgroup, host; */
   struct context *tasks, *scopes, *reports;
 
   treestore = gtk_tree_store_new (NUM_COLS,



More information about the Openvas-commits mailing list