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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 2 11:09:33 CET 2009


Author: felix
Date: 2009-03-02 11:09:31 +0100 (Mon, 02 Mar 2009)
New Revision: 2626

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/auth.c
   trunk/openvas-client/nessus/prefs_dialog/prefs_plugins.c
   trunk/openvas-client/nessus/prefs_dialog/prefs_plugins_tree.c
Log:
* nessus/auth.c, nessus/prefs_dialog/prefs_plugins.c,
nessus/prefs_dialog/prefs_plugins_tree.c: K&R style replacements, doc,
minor refomatting.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-02 09:54:53 UTC (rev 2625)
+++ trunk/openvas-client/ChangeLog	2009-03-02 10:09:31 UTC (rev 2626)
@@ -1,5 +1,11 @@
 2009-03-02  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	* nessus/auth.c, nessus/prefs_dialog/prefs_plugins.c,
+	nessus/prefs_dialog/prefs_plugins_tree.c: K&R style replacements, doc,
+	minor refomatting.
+
+2009-03-02  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	In filter module, added GPL header from implementation file to the
 	header file.
 

Modified: trunk/openvas-client/nessus/auth.c
===================================================================
--- trunk/openvas-client/nessus/auth.c	2009-03-02 09:54:53 UTC (rev 2625)
+++ trunk/openvas-client/nessus/auth.c	2009-03-02 10:09:31 UTC (rev 2626)
@@ -24,12 +24,13 @@
  * this file, you may extend this exception to your version of the
  * file, but you are not obligated to do so.  If you do not wish to
  * do so, delete this exception statement from your version.
- *
- * This is the Authentication Manager
- *
  */
 
+/** @file
+ * This is the Authentication Manager.
+ */
 
+
 #include <includes.h>
 #include <stdarg.h>
 #include "comm.h"
@@ -37,19 +38,18 @@
 #include "sighand.h"
 
 /**
- * Sends the login and password to the OpenVAS
- * daemon.
+ * @brief Sends the login and password to the OpenVAS daemon.
  *
+ * Note : this function does NOT check if the login/password are valid.
+ *
  * @param user     Login users name.
  * @param password Login users password.
  *
  * @returns 0 if the login informations were sent successfully,
  *          -1 if a problem occured.
- * 
- * Note : this function does NOT check if the login/password are
- * valid.
  */
-int auth_login(int soc, const char *user, const char* password)
+int
+auth_login (int soc, const char *user, const char* password)
 {
   char * buf = emalloc(255);
 
@@ -57,12 +57,14 @@
 
   /* Note: even if we use SSLv3 authentication, we ask for a password anyway */
   network_gets(soc, buf, 7);
-  if(strncmp(buf, "User : ", strlen(buf)))return(-1);
+  if(strncmp(buf, "User : ", strlen(buf)))
+    return(-1);
   network_printf(soc, "%s\n", user);
-  
+
   bzero(buf, 255);
-  network_gets(soc, buf,11);
-  if(strncmp(buf, "Password : ", strlen(buf)))return(-1);
+  network_gets (soc, buf, 11);
+  if(strncmp(buf, "Password : ", strlen(buf)))
+    return(-1);
   network_printf(soc, "%s\n", password);
   efree(&buf);
   return(0);
@@ -70,11 +72,13 @@
 
 
 /**
- * This function sends a string to the server using a printf syntax.
- * In the future, it will have to encrypt the string
- * but I have not implemented this feature right now
+ * @brief This function sends a string to the server using a printf syntax.
+ * 
+ * @param soc  Socket over which to send data.
+ * @param data Format string in printf fashion.
  */
-void network_printf(int soc, char * data, ...)
+void
+network_printf (int soc, char * data, ...)
 {
   va_list param;
   int r, s = 16384;
@@ -117,23 +121,26 @@
   signal(SIGPIPE, SIG_IGN);
   va_end(param);
   efree(&buffer);
-}                    
+}
 
+
 /**
- * Reads data sent by the server
+ * @brief Reads data sent by the server into the provided buffer.
+ * 
+ * @param[out] s Buffer to read data into, will always be nul- terminated.
+ * 
  * @return >0 is the amount of data placed in s
  *         <0 means there was an error.
  */
-int network_gets(soc, s, size)
-     int   soc;
-     char * s;
-     size_t size;
+int
+network_gets (int soc, char* s, size_t size)
 {
   int n;
 
-  if ( soc <= 0 ) soc = Context->socket;
+  if ( soc <= 0 )
+    soc = Context->socket;
 
-  if(  soc <= 0 )
+  if ( soc <= 0 )
     return 0;
 
 
@@ -142,7 +149,7 @@
    * (socket close?)
    * Also, recv_line will return 0 on error.
    */
-  n = recv_line(soc, s, size); 
+  n = recv_line(soc, s, size);
   if (n > 0)
     return n;
   else
@@ -156,15 +163,15 @@
  * Reads maximal size bytes from the socket soc into s and returns it.
  * Stops reading at '\0' and '\n' characters, and appends a 
  * terminating '\0' to s.
- * @param soc The socket.
- * @param s Pointer to the string (will not be set to NULL if NULL returned!).
+ * 
+ * @param soc  The socket.
+ * @param s    Pointer to the string (will not be set to NULL if NULL returned!).
  * @param size Number of bytes to maximally read from socket.
+ * 
  * @return The '\0' terminated string s or NULL if an error occured.
  */
-char * network_gets_raw(soc, s, size)
-     int    soc;
-     char * s;
-     size_t size;
+char*
+network_gets_raw (int soc, char* s, size_t size)
 {
   int n = 0, processed ;
 

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_plugins.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_plugins.c	2009-03-02 09:54:53 UTC (rev 2625)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_plugins.c	2009-03-02 10:09:31 UTC (rev 2626)
@@ -218,14 +218,19 @@
 }
   
 /**
- * @brief plugin_list_setup
+ * @brief Builds up the plugin area with plugin tree, buttons and preferences.
  *
- * Draws the main window showing informations
- * about the plugins of the server
+ * Draws the main window showing informations about the plugins of the server.
+ * This includes the list to en/disable NVTs and groups of NVTs, some
+ * convenient buttons like "Enable all" and the preferences hooks for dependency
+ * activation, dependency silencing and automatic enabling for new plugins.
+ * 
+ * @param context Context of interest.
+ * 
+ * @return Arglist with the GUI widgets hooked into.
  */
 struct arglist *
-prefs_dialog_plugins(context)
-  struct context *context;
+prefs_dialog_plugins (struct context *context)
 {
   struct arglist *ctrls = emalloc(sizeof(struct arglist));
   GtkWidget *frame;
@@ -350,8 +355,7 @@
   gtk_widget_show(button);
   arg_add_value(ctrls, "ENABLE_DEPS_AT_RUNTIME", ARG_PTR, -1, button);
 
-  button =
-      gtk_check_button_new_with_label(_("Silent"));
+  button = gtk_check_button_new_with_label (_("Silent"));
   gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0);
   gtk_widget_show(button);
   arg_add_value(ctrls, "SILENT_DEPS", ARG_PTR, -1, button);

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_plugins_tree.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_plugins_tree.c	2009-03-02 09:54:53 UTC (rev 2625)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_plugins_tree.c	2009-03-02 10:09:31 UTC (rev 2626)
@@ -104,6 +104,7 @@
 
 /**
  * @brief Handler for the tree model's "row-changed" signal.
+ * 
  * Emit the "statistics-changed" signal on the tree model.
  */
 static void
@@ -118,6 +119,7 @@
 
 /**
  * @brief Handler for the tree model's "row-deleted" signal.
+ * 
  * Emit the "statistics-changed" signal on the tree model.
  */
 static void
@@ -216,9 +218,7 @@
  * model doesn't send any signals.
  */
 static void
-trigger_row_update(model, iter)
-  GtkTreeModel *model;
-  GtkTreeIter *iter;
+trigger_row_update (GtkTreeModel *model, GtkTreeIter *iter)
 {
   GtkTreePath *path = gtk_tree_model_get_path(model, iter);
 
@@ -249,10 +249,7 @@
  * parent family.
  */
 static void
-active_toggled(cell, path_str, data)
-  GtkCellRendererToggle *cell;
-  gchar                 *path_str;
-  gpointer               data;
+active_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
 {
   GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(data));
   GtkTreeIter iter;
@@ -340,10 +337,8 @@
  * all other cases.
  */
 static gboolean
-button_press_event(tree, event, user_data)
-  GtkTreeView *tree;
-  GdkEventButton *event;
-  gpointer user_data;
+button_press_event (GtkTreeView *tree, GdkEventButton *event,
+                    gpointer user_data)
 {
   GtkTreePath * path;
   GtkTreeViewColumn *column;
@@ -379,12 +374,8 @@
  * @brief Set the "active" property of the toggle cell renderer.
  */
 static void
-active_data_func(tree_column, cell, model, iter, data)
-  GtkTreeViewColumn *tree_column;
-  GtkCellRenderer *cell;
-  GtkTreeModel *model;
-  GtkTreeIter *iter;
-  gpointer data;
+active_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell,
+                  GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
 {
   struct nessus_plugin *plugin;
   gboolean is_active = FALSE;
@@ -440,16 +431,14 @@
  * @brief Create a new plugin tree and model.
  */
 GtkWidget *
-prefs_create_plugins_tree(context, ctrls)
-  struct context *context;
-  struct arglist *ctrls;
+prefs_create_plugins_tree (struct context *context, struct arglist* ctrls)
 {
   GtkWidget *tree;
   GtkTreeSelection *selection;
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
 
-  /* make sure the "statistics-changed" signal exists */
+  /* Make sure the "statistics-changed" signal exists */
   create_statistics_changed_signal();
 
   /* Create the tree and its columns*/
@@ -498,9 +487,7 @@
  *        from ctrls if one is set.
  */
 static void
-fill_plugin_tree_store(context, ctrls)
-  struct context *context;
-  struct arglist *ctrls;
+fill_plugin_tree_store (struct context *context,   struct arglist *ctrls)
 {
   struct nessus_plugin *plugs = context->plugins;
   GtkTreeModel *store = GTK_TREE_MODEL(context->plugin_tree_store);
@@ -508,7 +495,7 @@
   GHashTable* family_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
       NULL, (GDestroyNotify)gtk_tree_path_free);
   
-  /* add the plugins and families.  The family nodes are created when
+  /* Add the plugins and families.  The family nodes are created when
    * the first plugin of that family is encountered */
   while(plugs != NULL )
   {
@@ -535,6 +522,7 @@
       g_hash_table_insert(family_hash, plug_family, family_path);
       gtk_tree_store_set(GTK_TREE_STORE(store), &family_iter,
 	  COL_NAME, plug_family, COL_PLUGIN, NULL, -1);
+      
     }
     else
     {
@@ -567,21 +555,20 @@
  * statistics_changed signal.
  */
 void
-prefs_plugin_tree_context_changed(context, ctrls, force_rebuild)
-  struct context *context;
-  struct arglist *ctrls;
-  gboolean force_rebuild;
+prefs_plugin_tree_context_changed (struct context *context,
+                                   struct arglist *ctrls,
+                                   gboolean force_rebuild)
 {
   GtkTreeView *tree_view = arg_get_value(ctrls, "PLUGINS_TREE_VIEW");
   GtkTreeModel *model = context->plugin_tree_model;
   GtkTreeModel *old_model = gtk_tree_view_get_model(tree_view);
 
-  /* if the caller wants, force a rebuild of the store by deleting the
+  /* If the caller wants, force a rebuild of the store by deleting the
    * old one */
   if (force_rebuild)
     context_reset_plugin_tree(context);
 
-  /* if the context doesn't have a tree store yet, create it together
+  /* If the context doesn't have a tree store yet, create it together
    * with the sort model and fill it */
   if (context->plugin_tree_store == NULL)
   {
@@ -628,9 +615,7 @@
  * @brief Enable/Disable all plugins in the tree.
  */
 void
-prefs_plugin_tree_enable_all(tree, enable)
-  GtkTreeView *tree;
-  int enable;
+prefs_plugin_tree_enable_all (GtkTreeView *tree, int enable)
 {
   GtkTreeModel *model = gtk_tree_view_get_model(tree);
   GtkTreeIter iter, child_iter;
@@ -666,12 +651,15 @@
  *
  * The function determines the total number of plugins and the number of
  * active plugins and stores these values is *total and *enabled.
+ * 
+ * @param tree_view    The treeview for which to count nvts.
+ * @param[out] total   Will contain the total number of NVTs in the tree
+ *                     model of the tree view tree_view.
+ * @param[out] enabled Will contain the number of enabled NVTs in the tree model
+ *                     of the tree view tree_view.
  */
 void
-prefs_plugin_tree_statistics(tree_view, total, enabled)
-  GtkTreeView *tree_view;
-  int *total;
-  int *enabled;
+prefs_plugin_tree_statistics (GtkTreeView *tree_view, int *total, int *enabled)
 {
   GtkTreeModel *tree_model = gtk_tree_view_get_model(tree_view);
   GtkTreeModel *real_model = gtk_tree_model_sort_get_model(
@@ -697,7 +685,7 @@
  *        "active" tflag.
  */
 void
-prefs_plugin_tree_read_only(GtkTreeView* tree_view, gboolean readonly)
+prefs_plugin_tree_read_only (GtkTreeView* tree_view, gboolean readonly)
 {
   g_object_set_data(G_OBJECT(tree_view), "read-only",
       GINT_TO_POINTER(readonly));



More information about the Openvas-commits mailing list