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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 17 09:26:47 CET 2009


Author: felix
Date: 2009-02-17 09:26:46 +0100 (Tue, 17 Feb 2009)
New Revision: 2500

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/plugin_infos.c
Log:
Partly repaired timeout- functionality on client- side.

* nessus/plugin_infos.c (do_set_timeout): Changed signature, no reason
to use arglists here, treat OID as a string and not as an int.

* nessus/plugin_infos.c (set_timeout_build_window): Use arguments
directly, not nested in an argument (matches new do_set_timeout
signature). Renamed local variables, indicate thet timeout unit is
seconds, use gtks show_all() instead of multiple show()s.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-02-17 07:58:22 UTC (rev 2499)
+++ trunk/openvas-client/ChangeLog	2009-02-17 08:26:46 UTC (rev 2500)
@@ -1,5 +1,17 @@
 2009-02-17  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Partly repaired timeout- functionality on client- side.
+
+	* nessus/plugin_infos.c (do_set_timeout): Changed signature, no reason
+	to use arglists here, treat OID as a string and not as an int.
+	
+	* nessus/plugin_infos.c (set_timeout_build_window): Use arguments
+	directly, not nested in an argument (matches new do_set_timeout
+	signature). Renamed local variables, indicate thet timeout unit is
+	seconds, use gtks show_all() instead of multiple show()s.
+
+2009-02-17  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Minor reformatting and documentation.
 
 	* nessus/plugin_infos.c: Minor reformatting and documentation.

Modified: trunk/openvas-client/nessus/plugin_infos.c
===================================================================
--- trunk/openvas-client/nessus/plugin_infos.c	2009-02-17 07:58:22 UTC (rev 2499)
+++ trunk/openvas-client/nessus/plugin_infos.c	2009-02-17 08:26:46 UTC (rev 2500)
@@ -150,30 +150,26 @@
  * A timeout value is a key/value ['timeout.OID'/'5'] pair.
  */
 static void 
-do_set_timeout (struct arglist * ctrls)
+do_set_timeout (char* oid, const char* timeout)
 {
- struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
- GtkWidget * w      = arg_get_value(ctrls, "ENTRY");
- char * to;
- int id;
- char * pref;
- int type;
- 
- id  = GPOINTER_TO_SIZE(arg_get_value(ctrls, "OID"));
- 
- to = (char*)gtk_entry_get_text(GTK_ENTRY(w));
- pref = emalloc(40);
- 
- sprintf(pref, "timeout.%d", id);
- if((type = arg_get_type(serv_prefs, pref)) >= 0)
- {
-  char * old = arg_get_value(serv_prefs, pref);
-  if(type == ARG_STRING)efree(&old);
-  arg_set_type(serv_prefs, pref, ARG_STRING);
-  arg_set_value(serv_prefs, pref, sizeof(int), estrdup(to));
- }
- else
-  arg_add_value(serv_prefs, pref, ARG_STRING, sizeof(int), estrdup(to));
+  struct arglist * serv_prefs = arg_get_value(Context->prefs, "SERVER_PREFS");
+  char * pref;
+  int type;
+
+  pref = emalloc(40);
+
+  sprintf(pref, "timeout.%s", oid);
+  printf("BUGME: %s\n", oid);
+  if ((type = arg_get_type(serv_prefs, pref)) >= 0)
+    {
+      char * old = arg_get_value(serv_prefs, pref);
+      if (type == ARG_STRING)
+        efree(&old);
+      arg_set_type (serv_prefs, pref, ARG_STRING);
+      arg_set_value (serv_prefs, pref, sizeof(int), estrdup(timeout));
+    }
+  else
+    arg_add_value(serv_prefs, pref, ARG_STRING, sizeof(int), estrdup(timeout));
 }
 
 
@@ -187,8 +183,8 @@
   GtkWidget * dialog;
   GtkWidget * vbox;
   GtkWidget * hbox;
-  GtkWidget * w;
-  struct arglist * ctrls = emalloc(sizeof(*ctrls));
+  GtkWidget * label;
+  GtkWidget * entry;
 
   dialog = gtk_dialog_new_with_buttons(_("Set plugin timeout..."), window,
                                        GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -207,28 +203,24 @@
   gtk_widget_show(hbox);
 
   /* The label for the entry field */
-  w = gtk_label_new(_("Set plugin timeout:"));
-  gtk_box_pack_start(GTK_BOX(hbox), w, TRUE, TRUE, 10);
-  gtk_misc_set_alignment((GtkMisc *)w, 0, 1);
-  gtk_widget_show(w);
+  label = gtk_label_new (_("Set plugin timeout in seconds:"));
+  gtk_box_pack_start (GTK_BOX(hbox), label, TRUE, TRUE, 10);
+  gtk_misc_set_alignment ((GtkMisc *) label, 0, 1);
 
   /* Then entry field for the timeout */
-  w = gtk_entry_new();
-  gtk_box_pack_start(GTK_BOX(hbox),w, TRUE, TRUE, 10);
-  gtk_widget_show(w);
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX(hbox), entry, TRUE, TRUE, 10);
   if(!def_to)
-    gtk_entry_set_text(GTK_ENTRY(w), cur_to);
+    gtk_entry_set_text (GTK_ENTRY(entry), cur_to);
 
-  arg_add_value(ctrls, "WINDOW", ARG_PTR, -1, window);
-  arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, w);
-  arg_add_value(ctrls, "OID", ARG_STRING, strlen(oid), estrdup(oid));
+  gtk_widget_show_all (dialog);
 
   /* execute and later remove the dialog */
   switch (gtk_dialog_run(GTK_DIALOG(dialog)))
   {
     // TODO allow only numbers in text entry
     case GTK_RESPONSE_OK:
-      do_set_timeout(ctrls);
+      do_set_timeout (estrdup(oid), gtk_entry_get_text (GTK_ENTRY(entry)));
       break;
   }
   gtk_widget_destroy(dialog);
@@ -387,7 +379,7 @@
  * @param name The plugins name.
  */
 void 
-plugin_info_window_setup (struct nessus_plugin * res, char * pluginname)
+plugin_info_window_setup (struct nessus_plugin * res, char* pluginname)
 {
   GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
   GtkWidget * dialog;



More information about the Openvas-commits mailing list