Nmap Development mailing list archives
[NmapFE PATCH] Use spin button for verbosity/debugging levels
From: Kris Katterjohn <kjak () ispwest com>
Date: Mon, 25 Sep 2006 00:06:48 -0500
The attached patch uses a spin button for selecting the verbosity and debugging levels instead of the...limited...way that's used now. I like the debug info! :) Verbose goes from 0-2 and debugging goes from 0-9. "-v" and "-vv" are used for verbose; "-d" and "-d[2-9]" are used for debugging. I don't know a lot of GTK, so I mostly copied from other portions of the code. When I tested it everything worked great, though :) It's a diff against 4.20ALPHA7. 'opt.uid' is used in this patch, so if you apply my other patch that uses 'opt.isr00t' instead, these need to be changed also. *yawn* time for bed Thanks, Kris Katterjohn
--- x/nmapfe/nmapfe.c 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe.c 2006-09-24 23:50:56.000000000 -0500 @@ -234,15 +234,6 @@ static gchar *protportEntries[] = { NULL }; -static gchar *verboseEntries[] = { - "Quiet", - "Verbose", - "Very Verbose", - "Debug", - "Verbose Debug", - NULL -}; - static gchar *outputFormatEntries[] = { "Normal", "grep-able", @@ -433,7 +424,6 @@ GtkAdjustment *adjust; opt.throttleValue = NORMAL_THROTTLE; opt.resolveValue = DEFAULT_RESOLVE; opt.protportValue = DEFAULT_PROTPORT; - opt.verboseValue = QUIET_VERBOSE; opt.outputFormatValue = NORMAL_OUTPUT; #ifdef WIN32 @@ -1213,29 +1203,52 @@ GtkAdjustment *adjust; gtk_widget_show_all(frame); } - /* Verbosity frame */ - { - gint i; - - frame = gtk_frame_new("Verbosity"); - gtk_table_attach_defaults(GTK_TABLE(nbpage), frame, 0, 1, 1, 2); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); - gtk_container_add(GTK_CONTAINER(frame), vbox); - - opt.verboseType = gtk_combo_box_new_text(); + /* Verbosity & Debugging frame */ + frame = gtk_frame_new("Verbosity & Debugging Levels"); + gtk_table_attach_defaults(GTK_TABLE(nbpage), frame, 0, 1, 1, 2); - for (i = 0; verboseEntries[i]; i++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(opt.verboseType), verboseEntries[i]); - } + table = gtk_table_new(2, 2, FALSE); + gtk_container_set_border_width(GTK_CONTAINER(table), 5); + gtk_container_add(GTK_CONTAINER(frame), table); - g_signal_connect(G_OBJECT(opt.verboseType), "changed", - G_CALLBACK (verboseType_cb), NULL); + opt.verbose = gtk_check_button_new_with_label("Verbosity"); + if (opt.uid != 0) + gtk_widget_set_sensitive(GTK_WIDGET(opt.verbose), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.verbose, 0, 1, 0, 1); + gtk_widget_show(opt.verbose); + + adjust = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 2.0, 1.0, 10.0, 10.0); + opt.verboseValue = gtk_spin_button_new(adjust, 1.0, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(opt.verboseValue), TRUE); + g_signal_connect(GTK_OBJECT(opt.verbose), "released", + GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.verboseValue); + g_signal_connect(GTK_OBJECT(opt.verboseValue), "changed", + GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); + if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.verbose)->active)) + gtk_widget_set_sensitive(GTK_WIDGET(opt.verboseValue), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.verboseValue, 1, 2, 0, 1); + gtk_widget_show(opt.verboseValue); + + opt.debug = gtk_check_button_new_with_label("Debugging"); + if (opt.uid != 0) + gtk_widget_set_sensitive(GTK_WIDGET(opt.debug), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.debug, 0, 1, 1, 2); + gtk_widget_show(opt.debug); + + adjust = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.0, 9.0, 1.0, 10.0, 10.0); + opt.debugValue = gtk_spin_button_new(adjust, 1.0, 0); + gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(opt.debugValue), TRUE); + g_signal_connect(GTK_OBJECT(opt.debug), "released", + GTK_SIGNAL_FUNC(toggle_button_set_sensitive_cb), opt.debugValue); + g_signal_connect(GTK_OBJECT(opt.debugValue), "changed", + GTK_SIGNAL_FUNC(display_nmap_command_cb), NULL); + if ((opt.uid != 0) || (! GTK_TOGGLE_BUTTON(opt.debug)->active)) + gtk_widget_set_sensitive(GTK_WIDGET(opt.debugValue), FALSE); + gtk_table_attach_defaults(GTK_TABLE(table), opt.debugValue, 1, 2, 1, 2); + gtk_widget_show(opt.debugValue); - gtk_box_pack_start(GTK_BOX(vbox), opt.verboseType, TRUE, FALSE, 0); - gtk_widget_show_all (frame); - } + gtk_widget_show(table); + gtk_widget_show(frame); frame = gtk_frame_new("Source"); @@ -1455,7 +1468,6 @@ GtkAdjustment *adjust; gtk_combo_box_set_active(GTK_COMBO_BOX (opt.outputFormatType), opt.outputFormatValue); /* Fifth Notebook - Options */ gtk_combo_box_set_active(GTK_COMBO_BOX (opt.resolveType), opt.resolveValue); - gtk_combo_box_set_active(GTK_COMBO_BOX (opt.verboseType), opt.verboseValue); display_nmap_command(); --- x/nmapfe/nmapfe.h 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe.h 2006-09-24 23:50:56.000000000 -0500 @@ -292,9 +292,11 @@ struct NmapFEoptions { /* DNS options */ GtkWidget *resolveType; guint resolveValue; - /* verbosity options */ - GtkWidget *verboseType; - guint verboseValue; + /* verbosity/debugging options */ + GtkWidget *verbose; + GtkWidget *verboseValue; + GtkWidget *debug; + GtkWidget *debugValue; /* source options */ GtkWidget *useSourceDevice; GtkWidget *SourceDevice; --- x/nmapfe/nmapfe_sig.c 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe_sig.c 2006-09-24 23:51:52.000000000 -0500 @@ -577,6 +577,28 @@ static int command_size = 0; else if (opt.resolveValue == NEVER_RESOLVE) strcat(command, "-n "); + if (GTK_TOGGLE_BUTTON(opt.verbose)->active) { + int val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(opt.verboseValue)); + + if (val == 1) + strcat(command, "-v "); + else if (val == 2) + strcat(command, "-vv "); + } + + if (GTK_TOGGLE_BUTTON(opt.debug)->active) { + int val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(opt.debugValue)); + + if (val > 0) { + strcat(command, "-d"); + + if (val > 1) + sprintf(command+strlen(command), "%d", val); + + strcat(command, " "); + } + } + if (GTK_WIDGET_SENSITIVE(opt.useDecoy) && GTK_TOGGLE_BUTTON(opt.useDecoy)->active) { const char *val = gtk_entry_get_text(GTK_ENTRY(opt.Decoy)); @@ -667,15 +689,6 @@ static int command_size = 0; } } - if (opt.verboseValue == V1_VERBOSE) - strcat(command, "-v "); - else if (opt.verboseValue == V2_VERBOSE) - strcat(command, "-vv "); - else if (opt.verboseValue == D1_VERBOSE) - strcat(command, "-d "); - else if (opt.verboseValue == D2_VERBOSE) - strcat(command, "-d2 "); - strcat(command, gtk_entry_get_text(GTK_ENTRY(opt.targetHost))); return(command); @@ -863,14 +876,6 @@ void protportType_cb(GtkComboBox *w, gpo /* callback for factory generated menu items: set variable to action */ -void verboseType_cb(GtkComboBox *w, gpointer d) -{ - opt.verboseValue = gtk_combo_box_get_active(w); - display_nmap_command(); -} - - -/* callback for factory generated menu items: set variable to action */ void outputFormatType_cb(GtkComboBox *w, gpointer d) { opt.outputFormatValue = gtk_combo_box_get_active(w); --- x/nmapfe/nmapfe_sig.h 2006-08-24 20:47:59.000000000 -0500 +++ y/nmapfe/nmapfe_sig.h 2006-09-24 23:50:56.000000000 -0500 @@ -132,7 +132,6 @@ void mainMenu_fcb(int *variable, guint a void throttleType_cb (GtkComboBox *, gpointer); void resolveType_cb (GtkComboBox *, gpointer); void protportType_cb (GtkComboBox *, gpointer); -void verboseType_cb (GtkComboBox *, gpointer); void outputFormatType_cb (GtkComboBox *, gpointer); void pingButton_toggled_cb(GtkWidget *ping_button, void *ignored);
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 24)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 24)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Fyodor (Sep 25)
- Re: [NmapFE PATCH] Use spin button for verbosity/debugging levels Kris Katterjohn (Sep 25)