1999-09-11 12:38:18 +00:00
|
|
|
/* main.c
|
1998-09-16 03:22:19 +00:00
|
|
|
*
|
2003-03-01 10:18:54 +00:00
|
|
|
* $Id: main.c,v 1.282 2003/03/01 10:18:54 guy Exp $
|
1998-09-16 02:39:15 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2001-01-10 10:11:27 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1998-09-16 02:39:15 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
1999-02-19 05:28:38 +00:00
|
|
|
* Richard Sharpe, 13-Feb-1999, added support for initializing structures
|
|
|
|
* needed by dissect routines
|
2001-03-23 14:44:04 +00:00
|
|
|
* Jeff Foster, 2001/03/12, added support tabbed hex display windowss
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1998-09-16 02:39:15 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* To do:
|
|
|
|
* - Graphs
|
|
|
|
* - Playback window
|
|
|
|
* - Multiple window support
|
|
|
|
* - Add cut/copy/paste
|
|
|
|
* - Create header parsing routines
|
|
|
|
* - Make byte view selections more fancy?
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
2001-12-04 07:32:05 +00:00
|
|
|
#include <ctype.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
|
2002-10-25 00:29:12 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2000-01-15 00:23:13 +00:00
|
|
|
#ifdef HAVE_IO_H
|
|
|
|
#include <io.h> /* open/close on win32 */
|
|
|
|
#endif
|
|
|
|
|
2001-01-28 23:56:29 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
#include <pcap.h>
|
|
|
|
#endif
|
|
|
|
|
2001-07-05 00:34:42 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
|
|
|
#include <zlib.h> /* to get the libz version number */
|
|
|
|
#endif
|
|
|
|
|
1999-01-04 07:39:14 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
2002-10-24 07:08:26 +00:00
|
|
|
#ifdef HAVE_SOME_SNMP
|
2002-10-25 03:13:11 +00:00
|
|
|
|
2002-10-24 07:08:26 +00:00
|
|
|
#ifdef HAVE_NET_SNMP
|
|
|
|
#include <net-snmp/version.h>
|
|
|
|
#endif /* HAVE_NET_SNMP */
|
2002-10-25 03:13:11 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UCD_SNMP
|
|
|
|
#include <ucd-snmp/version.h>
|
|
|
|
#endif /* HAVE_UCD_SNMP */
|
|
|
|
|
2002-10-24 07:08:26 +00:00
|
|
|
#endif /* HAVE_SOME_SNMP */
|
1999-11-29 03:07:19 +00:00
|
|
|
|
1999-06-14 21:46:36 +00:00
|
|
|
#ifdef NEED_STRERROR_H
|
|
|
|
#include "strerror.h"
|
|
|
|
#endif
|
|
|
|
|
2000-03-28 20:20:11 +00:00
|
|
|
#ifdef NEED_GETOPT_H
|
|
|
|
#include "getopt.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 04:09:37 +00:00
|
|
|
#ifdef WIN32 /* Needed for console I/O */
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#endif
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/epan.h>
|
2001-04-02 09:53:46 +00:00
|
|
|
#include <epan/filesystem.h>
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/epan_dissect.h>
|
2000-09-27 04:55:05 +00:00
|
|
|
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "main.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/timestamp.h>
|
|
|
|
#include <epan/packet.h>
|
1999-02-09 00:35:38 +00:00
|
|
|
#include "capture.h"
|
1999-06-22 22:02:39 +00:00
|
|
|
#include "summary.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "file.h"
|
2001-01-28 04:52:29 +00:00
|
|
|
#include "filters.h"
|
2002-01-11 07:40:32 +00:00
|
|
|
#include "prefs.h"
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "menu.h"
|
2000-01-25 17:32:52 +00:00
|
|
|
#include "../menu.h"
|
2000-11-21 23:54:10 +00:00
|
|
|
#include "color.h"
|
2003-01-08 01:59:42 +00:00
|
|
|
#include "color_filters.h"
|
2000-11-21 23:54:10 +00:00
|
|
|
#include "color_utils.h"
|
2000-02-12 06:46:54 +00:00
|
|
|
#include "filter_prefs.h"
|
2001-12-06 02:21:26 +00:00
|
|
|
#include "file_dlg.h"
|
1998-11-17 04:29:13 +00:00
|
|
|
#include "column.h"
|
1998-09-16 02:39:15 +00:00
|
|
|
#include "print.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/resolv.h>
|
2001-11-09 07:44:51 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
#include "pcap-util.h"
|
|
|
|
#endif
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
#include "statusbar.h"
|
2000-01-03 06:59:25 +00:00
|
|
|
#include "simple_dialog.h"
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "proto_draw.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/dfilter/dfilter.h>
|
1999-09-09 02:42:40 +00:00
|
|
|
#include "keys.h"
|
2000-02-29 06:24:41 +00:00
|
|
|
#include "packet_win.h"
|
1999-12-16 06:20:18 +00:00
|
|
|
#include "gtkglobals.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/plugins.h>
|
2000-10-20 04:26:40 +00:00
|
|
|
#include "colors.h"
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/strutil.h>
|
2001-04-02 00:38:36 +00:00
|
|
|
#include "register.h"
|
2001-12-04 08:26:00 +00:00
|
|
|
#include "ringbuffer.h"
|
2001-12-12 21:39:01 +00:00
|
|
|
#include "ui_util.h"
|
2002-12-19 02:58:53 +00:00
|
|
|
#include "../ui_util.h"
|
2001-10-21 16:15:21 +00:00
|
|
|
#include "image/clist_ascend.xpm"
|
|
|
|
#include "image/clist_descend.xpm"
|
2002-09-07 10:02:36 +00:00
|
|
|
#include "../tap.h"
|
2002-11-10 11:36:39 +00:00
|
|
|
#include "compat_macros.h"
|
1999-04-06 16:24:50 +00:00
|
|
|
|
2001-04-03 05:26:27 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#include "capture-wpcap.h"
|
|
|
|
#endif
|
|
|
|
|
2001-10-21 16:15:21 +00:00
|
|
|
typedef struct column_arrows {
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *ascend_pm;
|
|
|
|
GtkWidget *descend_pm;
|
|
|
|
} column_arrows;
|
2001-04-03 05:26:27 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
capture_file cfile;
|
2001-03-23 14:44:04 +00:00
|
|
|
GtkWidget *top_level, *packet_list, *tree_view, *byte_nb_ptr,
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
*tv_scrollw, *pkt_scrollw;
|
2002-02-18 01:08:44 +00:00
|
|
|
static GtkWidget *info_bar;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1998-09-16 02:39:15 +00:00
|
|
|
GdkFont *m_r_font, *m_b_font;
|
2002-11-03 17:38:45 +00:00
|
|
|
guint m_font_height, m_font_width;
|
|
|
|
#else
|
|
|
|
PangoFontDescription *m_r_font, *m_b_font;
|
|
|
|
#endif
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
static guint main_ctx, file_ctx, help_ctx;
|
2001-03-27 06:48:12 +00:00
|
|
|
static GString *comp_info_str;
|
1999-05-11 18:51:10 +00:00
|
|
|
gchar *ethereal_path = NULL;
|
1999-08-14 19:53:31 +00:00
|
|
|
gchar *last_open_dir = NULL;
|
2001-12-31 04:41:50 +00:00
|
|
|
gint root_x = G_MAXINT, root_y = G_MAXINT, top_width, top_height;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1998-09-27 22:12:47 +00:00
|
|
|
ts_type timestamp_type = RELATIVE;
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
1998-12-29 04:05:38 +00:00
|
|
|
GtkStyle *item_style;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1998-12-29 04:05:38 +00:00
|
|
|
|
1999-11-19 22:32:00 +00:00
|
|
|
/* Specifies the field currently selected in the GUI protocol tree */
|
|
|
|
field_info *finfo_selected = NULL;
|
1999-06-24 16:25:59 +00:00
|
|
|
|
2001-02-20 04:09:37 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
static gboolean has_no_console; /* TRUE if app has no console */
|
|
|
|
static gboolean console_was_created; /* TRUE if console was created */
|
|
|
|
static void create_console(void);
|
|
|
|
static void destroy_console(void);
|
|
|
|
static void console_log_handler(const char *log_domain,
|
|
|
|
GLogLevelFlags log_level, const char *message, gpointer user_data);
|
|
|
|
#endif
|
|
|
|
|
2000-01-15 12:54:24 +00:00
|
|
|
static void create_main_window(gint, gint, gint, e_prefs*);
|
1998-10-12 01:40:57 +00:00
|
|
|
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
#define E_DFILTER_CM_KEY "display_filter_combo"
|
|
|
|
#define E_DFILTER_FL_KEY "display_filter_list"
|
|
|
|
|
1998-10-16 01:18:35 +00:00
|
|
|
/* About Ethereal window */
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
about_ethereal( GtkWidget *w _U_, gpointer data _U_ ) {
|
1998-10-16 01:18:35 +00:00
|
|
|
simple_dialog(ESD_TYPE_INFO, NULL,
|
1999-12-16 04:11:33 +00:00
|
|
|
"Ethereal - Network Protocol Analyzer\n"
|
2002-10-23 18:24:09 +00:00
|
|
|
"Version " VERSION " (C) 1998-2002 Gerald Combs <gerald@ethereal.com>\n"
|
2001-03-27 06:48:12 +00:00
|
|
|
"Compiled %s\n\n"
|
1999-12-16 04:11:33 +00:00
|
|
|
|
|
|
|
"Check the man page for complete documentation and\n"
|
|
|
|
"for the list of contributors.\n"
|
|
|
|
|
2000-11-22 04:07:04 +00:00
|
|
|
"\nSee http://www.ethereal.com/ for more information.",
|
2001-03-27 06:48:12 +00:00
|
|
|
comp_info_str->str);
|
1998-10-16 01:18:35 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-03-02 23:10:12 +00:00
|
|
|
void
|
|
|
|
set_fonts(GdkFont *regular, GdkFont *bold)
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
void
|
|
|
|
set_fonts(PangoFontDescription *regular, PangoFontDescription *bold)
|
|
|
|
#endif
|
2001-03-02 23:10:12 +00:00
|
|
|
{
|
|
|
|
/* Yes, assert. The code that loads the font should check
|
|
|
|
* for NULL and provide its own error message. */
|
|
|
|
g_assert(m_r_font && m_b_font);
|
|
|
|
m_r_font = regular;
|
|
|
|
m_b_font = bold;
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2001-03-02 23:10:12 +00:00
|
|
|
m_font_height = m_r_font->ascent + m_r_font->descent;
|
|
|
|
m_font_width = gdk_string_width(m_r_font, "0");
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2001-03-02 23:10:12 +00:00
|
|
|
}
|
|
|
|
|
2002-12-19 02:58:53 +00:00
|
|
|
/*
|
|
|
|
* Go to frame specified by currently selected protocol tree item.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
|
|
|
|
{
|
|
|
|
if (finfo_selected) {
|
|
|
|
header_field_info *hfinfo;
|
|
|
|
guint32 framenum;
|
|
|
|
|
|
|
|
hfinfo = finfo_selected->hfinfo;
|
|
|
|
g_assert(hfinfo);
|
|
|
|
if (hfinfo->type == FT_FRAMENUM) {
|
2003-03-01 10:18:54 +00:00
|
|
|
framenum = fvalue_get_integer(finfo_selected->value);
|
|
|
|
if (framenum != 0) {
|
|
|
|
switch (goto_frame(&cfile, framenum)) {
|
|
|
|
|
|
|
|
case NO_SUCH_FRAME:
|
|
|
|
simple_dialog(ESD_TYPE_CRIT, NULL,
|
|
|
|
"There is no frame with that frame number.");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_NOT_DISPLAYED:
|
|
|
|
/* XXX - add it to the display filter? */
|
|
|
|
simple_dialog(ESD_TYPE_CRIT, NULL,
|
|
|
|
"The frame with that frame number is not currently being displayed.");
|
|
|
|
return;
|
|
|
|
|
|
|
|
case FOUND_FRAME:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-12-19 02:58:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-09-17 03:12:28 +00:00
|
|
|
|
1999-06-24 16:25:59 +00:00
|
|
|
/* Match selected byte pattern */
|
2002-04-08 20:30:56 +00:00
|
|
|
static void
|
2002-01-11 08:21:02 +00:00
|
|
|
match_selected_cb_do(gpointer data, int action, gchar *text)
|
1999-06-24 16:25:59 +00:00
|
|
|
{
|
1999-11-26 05:23:40 +00:00
|
|
|
GtkWidget *filter_te;
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
char *cur_filter, *new_filter;
|
1999-06-24 16:25:59 +00:00
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
if (!text)
|
|
|
|
return;
|
|
|
|
g_assert(data);
|
2002-11-10 11:36:39 +00:00
|
|
|
filter_te = OBJECT_GET_DATA(data, E_DFILTER_TE_KEY);
|
2002-01-11 08:21:02 +00:00
|
|
|
g_assert(filter_te);
|
1999-06-24 16:25:59 +00:00
|
|
|
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
cur_filter = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, -1);
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
switch (action&MATCH_SELECTED_MASK) {
|
|
|
|
|
|
|
|
case MATCH_SELECTED_REPLACE:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strdup(text);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MATCH_SELECTED_AND:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strdup(text);
|
2002-01-11 08:21:02 +00:00
|
|
|
else
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strconcat("(", cur_filter, ") && (", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MATCH_SELECTED_OR:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strdup(text);
|
2002-01-11 08:21:02 +00:00
|
|
|
else
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strconcat("(", cur_filter, ") || (", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MATCH_SELECTED_NOT:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MATCH_SELECTED_AND_NOT:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
else
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strconcat("(", cur_filter, ") && !(", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MATCH_SELECTED_OR_NOT:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if ((!cur_filter) || (0 == strlen(cur_filter)))
|
|
|
|
new_filter = g_strconcat("!(", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
else
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
new_filter = g_strconcat("(", cur_filter, ") || !(", text, ")", NULL);
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
g_assert_not_reached();
|
2002-05-03 03:30:15 +00:00
|
|
|
new_filter = NULL;
|
2002-01-11 08:21:02 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-06-24 16:25:59 +00:00
|
|
|
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
/* Free up the copy we got of the old filter text. */
|
|
|
|
g_free(cur_filter);
|
|
|
|
|
1999-06-24 16:25:59 +00:00
|
|
|
/* create a new one and set the display filter entry accordingly */
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_te), new_filter);
|
1999-11-26 05:23:40 +00:00
|
|
|
|
1999-07-31 18:26:07 +00:00
|
|
|
/* Run the display filter so it goes in effect. */
|
2002-01-11 08:21:02 +00:00
|
|
|
if (action&MATCH_SELECTED_APPLY_NOW)
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
filter_packets(&cfile, new_filter);
|
2002-01-11 08:21:02 +00:00
|
|
|
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
/* Free up the new filter text. */
|
|
|
|
g_free(new_filter);
|
|
|
|
|
|
|
|
/* Free up the generated text we were handed. */
|
2002-01-18 07:29:40 +00:00
|
|
|
g_free(text);
|
2002-01-11 08:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_replace_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_and_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_or_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_not_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_and_ptree_not(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_or_ptree_not(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_OR_NOT,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_replace_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_REPLACE,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_and_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_AND,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_or_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_OR,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_not_ptree(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_NOT,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
1999-11-19 22:32:00 +00:00
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_and_ptree_not(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_AND_NOT,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_or_ptree_not(GtkWidget *w, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
if (finfo_selected)
|
|
|
|
match_selected_cb_do((data ? data : w),
|
|
|
|
MATCH_SELECTED_OR_NOT,
|
|
|
|
proto_alloc_dfilter_string(finfo_selected, cfile.pd));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
get_text_from_packet_list(gpointer data)
|
|
|
|
{
|
2002-11-10 11:36:39 +00:00
|
|
|
gint row = (gint)OBJECT_GET_DATA(data, E_MPACKET_LIST_ROW_KEY);
|
|
|
|
gint column = (gint)OBJECT_GET_DATA(data, E_MPACKET_LIST_COL_KEY);
|
2002-01-11 08:21:02 +00:00
|
|
|
frame_data *fdata = (frame_data *)gtk_clist_get_row_data(GTK_CLIST(packet_list), row);
|
|
|
|
epan_dissect_t *edt;
|
|
|
|
gchar *buf=NULL;
|
|
|
|
int len;
|
2002-03-05 05:58:41 +00:00
|
|
|
int err;
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
if (fdata != NULL) {
|
2002-03-05 05:58:41 +00:00
|
|
|
/* XXX - do something with "err" */
|
2002-01-11 08:21:02 +00:00
|
|
|
wtap_seek_read(cfile.wth, fdata->file_off, &cfile.pseudo_header,
|
2002-03-05 05:58:41 +00:00
|
|
|
cfile.pd, fdata->cap_len, &err);
|
2002-01-11 08:21:02 +00:00
|
|
|
|
|
|
|
edt = epan_dissect_new(FALSE, FALSE);
|
|
|
|
epan_dissect_run(edt, &cfile.pseudo_header, cfile.pd, fdata,
|
|
|
|
&cfile.cinfo);
|
|
|
|
epan_dissect_fill_in_columns(edt);
|
|
|
|
|
|
|
|
if (strlen(cfile.cinfo.col_expr[column]) != 0 &&
|
|
|
|
strlen(cfile.cinfo.col_expr_val[column]) != 0) {
|
|
|
|
len = strlen(cfile.cinfo.col_expr[column]) +
|
|
|
|
strlen(cfile.cinfo.col_expr_val[column]) + 5;
|
|
|
|
buf = g_malloc0(len);
|
|
|
|
snprintf(buf, len, "%s == %s", cfile.cinfo.col_expr[column],
|
|
|
|
cfile.cinfo.col_expr_val[column]);
|
|
|
|
}
|
|
|
|
|
|
|
|
epan_dissect_free(edt);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_replace_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_REPLACE|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_and_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_AND|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_or_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_OR|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_not_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_NOT|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_and_plist_not(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_AND_NOT|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
match_selected_cb_or_plist_not(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_OR_NOT|MATCH_SELECTED_APPLY_NOW,
|
|
|
|
get_text_from_packet_list(data));
|
1999-11-19 22:32:00 +00:00
|
|
|
}
|
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_replace_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_REPLACE,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
1999-06-24 16:25:59 +00:00
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_and_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_AND,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_or_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_OR,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_not_plist(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_NOT,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_and_plist_not(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_AND_NOT,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-08-24 01:17:09 +00:00
|
|
|
prepare_selected_cb_or_plist_not(GtkWidget *w _U_, gpointer data)
|
2002-01-11 08:21:02 +00:00
|
|
|
{
|
|
|
|
match_selected_cb_do(data,
|
|
|
|
MATCH_SELECTED_OR_NOT,
|
|
|
|
get_text_from_packet_list(data));
|
|
|
|
}
|
1999-11-19 22:32:00 +00:00
|
|
|
|
1999-07-11 08:40:52 +00:00
|
|
|
/* Run the current display filter on the current packet set, and
|
|
|
|
redisplay. */
|
|
|
|
static void
|
1999-08-13 23:47:43 +00:00
|
|
|
filter_activate_cb(GtkWidget *w, gpointer data)
|
|
|
|
{
|
2002-11-10 11:36:39 +00:00
|
|
|
GtkCombo *filter_cm = OBJECT_GET_DATA(w, E_DFILTER_CM_KEY);
|
|
|
|
GList *filter_list = OBJECT_GET_DATA(filter_cm, E_DFILTER_FL_KEY);
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
GList *li;
|
1999-11-25 18:02:25 +00:00
|
|
|
gboolean add_filter = TRUE;
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
gboolean free_filter = TRUE;
|
|
|
|
char *s;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-01-11 08:21:02 +00:00
|
|
|
g_assert(data);
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
s = g_strdup(gtk_entry_get_text(GTK_ENTRY(data)));
|
2002-08-28 21:04:11 +00:00
|
|
|
|
1999-11-25 18:02:25 +00:00
|
|
|
/* GtkCombos don't let us get at their list contents easily, so we maintain
|
|
|
|
our own filter list, and feed it to gtk_combo_set_popdown_strings when
|
|
|
|
a new filter is added. */
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if (filter_packets(&cfile, s)) {
|
1999-11-25 18:02:25 +00:00
|
|
|
li = g_list_first(filter_list);
|
|
|
|
while (li) {
|
|
|
|
if (li->data && strcmp(s, li->data) == 0)
|
|
|
|
add_filter = FALSE;
|
|
|
|
li = li->next;
|
|
|
|
}
|
1999-08-13 23:47:43 +00:00
|
|
|
|
1999-11-25 18:02:25 +00:00
|
|
|
if (add_filter) {
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
free_filter = FALSE;
|
|
|
|
filter_list = g_list_append(filter_list, s);
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, filter_list);
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
gtk_combo_set_popdown_strings(filter_cm, filter_list);
|
1999-11-25 18:02:25 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_cm->entry), g_list_last(filter_list)->data);
|
|
|
|
}
|
|
|
|
}
|
Clean up the handling of filter strings:
have "filter_packets()" make a copy of the filter string handed
to it, as it may save the filter string in the "capture_file"
structure, and the caller of "filter_packets()" shouldn't have
to worry about the string it passed to "filter_packets()" being
stashed away somewhere so that it can't just free that string or
change it;
have callers of "filter_packets()" free up the string they
handed to it, if the string was allocated and they're done with
it;
plug some memory leaks in "match_selected_cb_do()".
Check for an illegal "action" argument being passed to
"match_selected_cb_do()".
Move some keys out of "keys.h" into "gtk/main.c", as they're only used
in "gtk/main.c".
Make the pointer to the filter list a data item for the combo box, as
it's a copy of the list of strings for the combo box, rather than
attaching it to the widgets that activate the filter (a pointer to the
combo box *itself* is a data item for those widgets).
In "filter_activate_cb()", make a copy of the text from the text entry
field as soon as we fetch it, and use that copy. Free that copy if
we didn't add the filter to the filter list.
Don't make a copy of the entire filter list and use that to set the
combo box's list of items - just use the list itself. Also, when the
list is changed, make the new value the data for the combo box (the list
pointer will actually not be changed, because we happen to be using
"g_list_append()", but let's not rely on that).
svn path=/trunk/; revision=5368
2002-05-03 03:24:47 +00:00
|
|
|
if (free_filter)
|
|
|
|
g_free(s);
|
1999-07-11 08:40:52 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 15:06:07 +00:00
|
|
|
/* redisplay with no display filter */
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
filter_reset_cb(GtkWidget *w, gpointer data _U_)
|
1999-11-21 15:06:07 +00:00
|
|
|
{
|
|
|
|
GtkWidget *filter_te = NULL;
|
|
|
|
|
2002-11-10 11:36:39 +00:00
|
|
|
if ((filter_te = OBJECT_GET_DATA(w, E_DFILTER_TE_KEY))) {
|
1999-11-21 15:06:07 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_te), "");
|
|
|
|
}
|
2000-06-27 04:36:03 +00:00
|
|
|
filter_packets(&cfile, NULL);
|
1999-11-21 15:06:07 +00:00
|
|
|
}
|
|
|
|
|
2000-05-10 06:00:22 +00:00
|
|
|
/* GTKClist compare routine, overrides default to allow numeric comparison */
|
|
|
|
static gint
|
|
|
|
packet_list_compare(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
|
|
|
|
{
|
|
|
|
/* Get row text strings */
|
2002-11-28 02:04:23 +00:00
|
|
|
char *text1 = GTK_CELL_TEXT (((const GtkCListRow *)ptr1)->cell[clist->sort_column])->text;
|
|
|
|
char *text2 = GTK_CELL_TEXT (((const GtkCListRow *)ptr2)->cell[clist->sort_column])->text;
|
2000-05-10 06:00:22 +00:00
|
|
|
|
|
|
|
/* Attempt to convert to numbers */
|
|
|
|
double num1 = atof(text1);
|
|
|
|
double num2 = atof(text2);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
gint col_fmt = cfile.cinfo.col_fmt[clist->sort_column];
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-05-10 06:00:22 +00:00
|
|
|
if ((col_fmt == COL_NUMBER) || (col_fmt == COL_REL_TIME) || (col_fmt == COL_DELTA_TIME) ||
|
|
|
|
((col_fmt == COL_CLS_TIME) && (timestamp_type == RELATIVE)) ||
|
|
|
|
((col_fmt == COL_CLS_TIME) && (timestamp_type == DELTA)) ||
|
|
|
|
(col_fmt == COL_UNRES_SRC_PORT) || (col_fmt == COL_UNRES_DST_PORT) ||
|
|
|
|
((num1 != 0) && (num2 != 0) && ((col_fmt == COL_DEF_SRC_PORT) || (col_fmt == COL_RES_SRC_PORT) ||
|
|
|
|
(col_fmt == COL_DEF_DST_PORT) || (col_fmt == COL_RES_DST_PORT))) ||
|
|
|
|
(col_fmt == COL_PACKET_LENGTH)) {
|
|
|
|
|
|
|
|
/* Compare numeric column */
|
|
|
|
|
|
|
|
if (num1 < num2)
|
|
|
|
return -1;
|
|
|
|
else if (num1 > num2)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-05-10 06:00:22 +00:00
|
|
|
else {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-05-10 06:00:22 +00:00
|
|
|
/* Compare text column */
|
|
|
|
if (!text2)
|
|
|
|
return (text1 != NULL);
|
|
|
|
|
|
|
|
if (!text1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return strcmp(text1, text2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* What to do when a column is clicked */
|
2002-08-28 21:04:11 +00:00
|
|
|
static void
|
2000-05-10 06:00:22 +00:00
|
|
|
packet_list_click_column_cb(GtkCList *clist, gint column, gpointer data)
|
|
|
|
{
|
2001-10-21 16:15:21 +00:00
|
|
|
column_arrows *col_arrows = (column_arrows *) data;
|
|
|
|
int i;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-10-21 16:15:21 +00:00
|
|
|
gtk_clist_freeze(clist);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-10-21 16:15:21 +00:00
|
|
|
for (i = 0; i < cfile.cinfo.num_cols; i++) {
|
|
|
|
gtk_widget_hide(col_arrows[i].ascend_pm);
|
|
|
|
gtk_widget_hide(col_arrows[i].descend_pm);
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-05-10 06:00:22 +00:00
|
|
|
if (column == clist->sort_column) {
|
2001-10-21 16:15:21 +00:00
|
|
|
if (clist->sort_type == GTK_SORT_ASCENDING) {
|
2000-05-10 06:00:22 +00:00
|
|
|
clist->sort_type = GTK_SORT_DESCENDING;
|
2001-10-21 16:15:21 +00:00
|
|
|
gtk_widget_show(col_arrows[column].descend_pm);
|
|
|
|
} else {
|
2000-05-10 06:00:22 +00:00
|
|
|
clist->sort_type = GTK_SORT_ASCENDING;
|
2001-10-21 16:15:21 +00:00
|
|
|
gtk_widget_show(col_arrows[column].ascend_pm);
|
|
|
|
}
|
2000-05-10 06:00:22 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
clist->sort_type = GTK_SORT_ASCENDING;
|
2001-10-21 16:15:21 +00:00
|
|
|
gtk_widget_show(col_arrows[column].ascend_pm);
|
2000-05-10 06:00:22 +00:00
|
|
|
gtk_clist_set_sort_column(clist, column);
|
|
|
|
}
|
2001-10-21 16:15:21 +00:00
|
|
|
gtk_clist_thaw(clist);
|
2000-05-10 06:00:22 +00:00
|
|
|
|
|
|
|
gtk_clist_sort(clist);
|
|
|
|
}
|
|
|
|
|
2000-08-21 19:36:19 +00:00
|
|
|
/* mark packets */
|
2002-08-28 21:04:11 +00:00
|
|
|
static void
|
2000-08-21 19:36:19 +00:00
|
|
|
set_frame_mark(gboolean set, frame_data *frame, gint row) {
|
2000-11-21 23:54:10 +00:00
|
|
|
GdkColor fg, bg;
|
|
|
|
|
2001-12-06 02:21:26 +00:00
|
|
|
if (row == -1)
|
|
|
|
return;
|
2000-11-21 23:54:10 +00:00
|
|
|
if (set) {
|
2001-12-06 02:21:26 +00:00
|
|
|
mark_frame(&cfile, frame);
|
2000-11-21 23:54:10 +00:00
|
|
|
color_t_to_gdkcolor(&fg, &prefs.gui_marked_fg);
|
|
|
|
color_t_to_gdkcolor(&bg, &prefs.gui_marked_bg);
|
2002-09-23 19:09:52 +00:00
|
|
|
gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg);
|
|
|
|
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg);
|
2000-11-21 23:54:10 +00:00
|
|
|
} else {
|
2001-12-06 02:21:26 +00:00
|
|
|
unmark_frame(&cfile, frame);
|
2002-09-23 19:09:52 +00:00
|
|
|
gtk_clist_set_background(GTK_CLIST(packet_list), row, NULL);
|
|
|
|
gtk_clist_set_foreground(GTK_CLIST(packet_list), row, NULL);
|
2000-11-21 23:54:10 +00:00
|
|
|
}
|
2001-12-06 02:21:26 +00:00
|
|
|
file_set_save_marked_sensitive();
|
2000-08-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-21 15:45:33 +00:00
|
|
|
static void
|
2002-11-03 17:38:45 +00:00
|
|
|
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
|
|
|
|
{
|
|
|
|
GdkEventButton *event_button = (GdkEventButton *)event;
|
|
|
|
gint row, column;
|
|
|
|
|
|
|
|
if (w == NULL || event == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event->type == GDK_BUTTON_PRESS && event_button->button == 2 &&
|
|
|
|
gtk_clist_get_selection_info(GTK_CLIST(w), event_button->x,
|
|
|
|
event_button->y, &row, &column)) {
|
|
|
|
frame_data *fdata = (frame_data *) gtk_clist_get_row_data(GTK_CLIST(w),
|
|
|
|
row);
|
|
|
|
set_frame_mark(!fdata->flags.marked, fdata, row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static gint
|
|
|
|
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
|
|
|
|
{
|
|
|
|
GdkEventButton *event_button = (GdkEventButton *)event;
|
|
|
|
gint row, column;
|
|
|
|
|
|
|
|
if (w == NULL || event == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (event->type == GDK_BUTTON_PRESS &&
|
|
|
|
gtk_clist_get_selection_info(GTK_CLIST(w), event_button->x,
|
|
|
|
event_button->y, &row, &column)) {
|
|
|
|
if (event_button->button == 2)
|
|
|
|
{
|
|
|
|
frame_data *fdata = (frame_data *)gtk_clist_get_row_data(GTK_CLIST(w), row);
|
|
|
|
set_frame_mark(!fdata->flags.marked, fdata, row);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (event_button->button == 1) {
|
|
|
|
gtk_clist_select_row(GTK_CLIST(w), row, column);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
2000-08-21 15:45:33 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-08-21 15:45:33 +00:00
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void mark_frame_cb(GtkWidget *w _U_, gpointer data _U_) {
|
2000-08-21 19:36:19 +00:00
|
|
|
if (cfile.current_frame) {
|
|
|
|
/* XXX hum, should better have a "cfile->current_row" here ... */
|
|
|
|
set_frame_mark(!cfile.current_frame->flags.marked,
|
2002-08-28 21:04:11 +00:00
|
|
|
cfile.current_frame,
|
|
|
|
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
|
2000-08-21 19:36:19 +00:00
|
|
|
cfile.current_frame));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mark_all_frames(gboolean set) {
|
|
|
|
frame_data *fdata;
|
|
|
|
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
|
|
|
|
set_frame_mark(set,
|
|
|
|
fdata,
|
2002-08-28 21:04:11 +00:00
|
|
|
gtk_clist_find_row_from_data(GTK_CLIST(packet_list), fdata));
|
2000-08-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-22 14:04:52 +00:00
|
|
|
void update_marked_frames(void) {
|
|
|
|
frame_data *fdata;
|
|
|
|
if (cfile.plist == NULL) return;
|
|
|
|
for (fdata = cfile.plist; fdata != NULL; fdata = fdata->next) {
|
|
|
|
if (fdata->flags.marked)
|
|
|
|
set_frame_mark(TRUE,
|
|
|
|
fdata,
|
|
|
|
gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
|
|
|
|
fdata));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
|
2000-08-21 19:36:19 +00:00
|
|
|
mark_all_frames(TRUE);
|
|
|
|
}
|
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_) {
|
2000-08-21 19:36:19 +00:00
|
|
|
mark_all_frames(FALSE);
|
|
|
|
}
|
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
/* What to do when a list item is selected/unselected */
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
packet_list_select_cb(GtkWidget *w _U_, gint row, gint col _U_, gpointer evt _U_) {
|
1998-10-16 01:18:35 +00:00
|
|
|
|
2001-03-23 14:44:04 +00:00
|
|
|
/* Remove the hex display tabbed pages */
|
|
|
|
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
|
|
|
|
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
|
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
select_packet(&cfile, row);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2001-03-23 14:44:04 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
packet_list_unselect_cb(GtkWidget *w _U_, gint row _U_, gint col _U_, gpointer evt _U_) {
|
2001-03-23 14:44:04 +00:00
|
|
|
|
2000-06-27 04:36:03 +00:00
|
|
|
unselect_packet(&cfile);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2001-03-23 14:44:04 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
static void
|
|
|
|
tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column _U_,
|
|
|
|
gpointer user_data _U_)
|
|
|
|
#else
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
static void
|
2002-11-03 17:38:45 +00:00
|
|
|
tree_view_selection_changed_cb(GtkTreeSelection *sel, gpointer user_data _U_)
|
|
|
|
#endif
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
field_info *finfo;
|
|
|
|
gchar *help_str = NULL;
|
|
|
|
gchar len_str[2+10+1+5+1]; /* ", {N} bytes\0",
|
|
|
|
N < 4294967296 */
|
|
|
|
gboolean has_blurb = FALSE;
|
|
|
|
guint length = 0, byte_len;
|
|
|
|
GtkWidget *byte_view;
|
|
|
|
const guint8 *byte_data;
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
#endif
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
/* if nothing is selected */
|
|
|
|
if (!gtk_tree_selection_get_selected(sel, &model, &iter))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Which byte view is displaying the current protocol tree
|
|
|
|
* row's data?
|
|
|
|
*/
|
|
|
|
byte_view = get_notebook_bv_ptr(byte_nb_ptr);
|
|
|
|
if (byte_view == NULL)
|
|
|
|
return; /* none */
|
|
|
|
|
|
|
|
byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
|
|
|
|
if (byte_data == NULL)
|
|
|
|
return; /* none */
|
|
|
|
|
|
|
|
unselect_field();
|
|
|
|
packet_hex_print(GTK_TEXT_VIEW(byte_view), byte_data,
|
|
|
|
cfile.current_frame, NULL, byte_len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
gtk_tree_model_get(model, &iter, 1, &finfo, -1);
|
|
|
|
#else
|
|
|
|
g_assert(node);
|
|
|
|
finfo = gtk_ctree_node_get_row_data( ctree, GTK_CTREE_NODE(node) );
|
|
|
|
#endif
|
|
|
|
if (!finfo) return;
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
set_notebook_page(byte_nb_ptr, finfo->ds_tvb);
|
2001-03-23 14:44:04 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
byte_view = get_notebook_bv_ptr(byte_nb_ptr);
|
|
|
|
byte_data = get_byte_view_data_and_length(byte_view, &byte_len);
|
|
|
|
g_assert(byte_data != NULL);
|
|
|
|
|
|
|
|
finfo_selected = finfo;
|
|
|
|
set_menus_for_selected_tree_row(TRUE);
|
|
|
|
|
|
|
|
if (finfo->hfinfo) {
|
|
|
|
if (finfo->hfinfo->blurb != NULL &&
|
|
|
|
finfo->hfinfo->blurb[0] != '\0') {
|
|
|
|
has_blurb = TRUE;
|
|
|
|
length = strlen(finfo->hfinfo->blurb);
|
|
|
|
} else {
|
|
|
|
length = strlen(finfo->hfinfo->name);
|
|
|
|
}
|
|
|
|
if (finfo->length == 0) {
|
|
|
|
len_str[0] = '\0';
|
|
|
|
} else if (finfo->length == 1) {
|
|
|
|
strcpy (len_str, ", 1 byte");
|
|
|
|
} else {
|
|
|
|
snprintf (len_str, sizeof len_str, ", %d bytes", finfo->length);
|
|
|
|
}
|
|
|
|
statusbar_pop_field_msg(); /* get rid of current help msg */
|
|
|
|
if (length) {
|
|
|
|
length += strlen(finfo->hfinfo->abbrev) + strlen(len_str) + 10;
|
|
|
|
help_str = g_malloc(sizeof(gchar) * length);
|
|
|
|
sprintf(help_str, "%s (%s)%s",
|
|
|
|
(has_blurb) ? finfo->hfinfo->blurb : finfo->hfinfo->name,
|
|
|
|
finfo->hfinfo->abbrev, len_str);
|
|
|
|
statusbar_push_field_msg(help_str);
|
|
|
|
g_free(help_str);
|
|
|
|
} else {
|
2001-04-19 23:06:23 +00:00
|
|
|
/*
|
2002-11-03 17:38:45 +00:00
|
|
|
* Don't show anything if the field name is zero-length;
|
|
|
|
* the pseudo-field for "proto_tree_add_text()" is such
|
|
|
|
* a field, and we don't want "Text (text)" showing up
|
|
|
|
* on the status line if you've selected such a field.
|
|
|
|
*
|
|
|
|
* XXX - there are zero-length fields for which we *do*
|
|
|
|
* want to show the field name.
|
|
|
|
*
|
|
|
|
* XXX - perhaps the name and abbrev field should be null
|
|
|
|
* pointers rather than null strings for that pseudo-field,
|
|
|
|
* but we'd have to add checks for null pointers in some
|
|
|
|
* places if we did that.
|
|
|
|
*
|
|
|
|
* Or perhaps protocol tree items added with
|
|
|
|
* "proto_tree_add_text()" should have -1 as the field index,
|
|
|
|
* with no pseudo-field being used, but that might also
|
|
|
|
* require special checks for -1 to be added.
|
|
|
|
*/
|
|
|
|
statusbar_push_field_msg("");
|
|
|
|
}
|
|
|
|
}
|
2000-08-22 19:40:09 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
packet_hex_print(GTK_TEXT(byte_view), byte_data, cfile.current_frame,
|
|
|
|
finfo, byte_len);
|
|
|
|
#else
|
|
|
|
packet_hex_print(GTK_TEXT_VIEW(byte_view), byte_data, cfile.current_frame,
|
|
|
|
finfo, byte_len);
|
|
|
|
#endif
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
static void
|
2002-11-03 17:38:45 +00:00
|
|
|
tree_view_unselect_row_cb(GtkCTree *ctree _U_, GList *node _U_, gint column _U_,
|
|
|
|
gpointer user_data _U_)
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
{
|
2001-03-23 14:44:04 +00:00
|
|
|
GtkWidget *byte_view;
|
2002-02-18 01:08:44 +00:00
|
|
|
const guint8 *data;
|
2002-08-28 21:04:11 +00:00
|
|
|
guint len;
|
2001-03-23 14:44:04 +00:00
|
|
|
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
/*
|
|
|
|
* Which byte view is displaying the current protocol tree
|
|
|
|
* row's data?
|
|
|
|
*/
|
2002-02-18 01:08:44 +00:00
|
|
|
byte_view = get_notebook_bv_ptr(byte_nb_ptr);
|
|
|
|
if (byte_view == NULL)
|
|
|
|
return; /* none */
|
|
|
|
|
|
|
|
data = get_byte_view_data_and_length(byte_view, &len);
|
|
|
|
if (data == NULL)
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
return; /* none */
|
2001-03-23 14:44:04 +00:00
|
|
|
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
unselect_field();
|
2001-03-23 14:44:04 +00:00
|
|
|
packet_hex_print(GTK_TEXT(byte_view), data, cfile.current_frame,
|
|
|
|
NULL, len);
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void collapse_all_cb(GtkWidget *widget _U_, gpointer data _U_) {
|
2001-12-06 04:25:09 +00:00
|
|
|
if (cfile.edt->tree)
|
|
|
|
collapse_all_tree(cfile.edt->tree, tree_view);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void expand_all_cb(GtkWidget *widget _U_, gpointer data _U_) {
|
2001-12-06 04:25:09 +00:00
|
|
|
if (cfile.edt->tree)
|
|
|
|
expand_all_tree(cfile.edt->tree, tree_view);
|
1999-09-11 12:38:18 +00:00
|
|
|
}
|
|
|
|
|
2002-03-05 11:56:00 +00:00
|
|
|
void resolve_name_cb(GtkWidget *widget _U_, gpointer data _U_) {
|
2001-12-06 04:25:09 +00:00
|
|
|
if (cfile.edt->tree) {
|
2002-01-13 20:35:12 +00:00
|
|
|
guint32 tmp = g_resolv_flags;
|
|
|
|
g_resolv_flags = RESOLV_ALL;
|
2001-12-06 04:25:09 +00:00
|
|
|
proto_tree_draw(cfile.edt->tree, tree_view);
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags = tmp;
|
2000-02-20 14:52:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-29 06:24:41 +00:00
|
|
|
/* Set the selection mode of the packet list window. */
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
void
|
|
|
|
set_plist_sel_browse(gboolean val)
|
|
|
|
{
|
2000-08-15 22:22:35 +00:00
|
|
|
gboolean old_val;
|
|
|
|
|
|
|
|
old_val =
|
|
|
|
(GTK_CLIST(packet_list)->selection_mode == GTK_SELECTION_SINGLE);
|
|
|
|
|
|
|
|
if (val == old_val) {
|
|
|
|
/*
|
|
|
|
* The mode isn't changing, so don't do anything.
|
|
|
|
* In particular, don't gratuitiously unselect the
|
|
|
|
* current packet.
|
|
|
|
*
|
|
|
|
* XXX - why do we have to unselect the current packet
|
|
|
|
* ourselves? The documentation for the GtkCList at
|
|
|
|
*
|
|
|
|
* http://developer.gnome.org/doc/API/gtk/gtkclist.html
|
|
|
|
*
|
|
|
|
* says "Note that setting the widget's selection mode to
|
|
|
|
* one of GTK_SELECTION_BROWSE or GTK_SELECTION_SINGLE will
|
|
|
|
* cause all the items in the GtkCList to become deselected."
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
if (finfo_selected)
|
2000-06-27 04:36:03 +00:00
|
|
|
unselect_packet(&cfile);
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
|
1999-12-30 19:53:11 +00:00
|
|
|
/* Yeah, GTK uses "browse" in the case where we do not, but oh well. I think
|
|
|
|
* "browse" in Ethereal makes more sense than "SINGLE" in GTK+ */
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
if (val) {
|
|
|
|
gtk_clist_set_selection_mode(GTK_CLIST(packet_list), GTK_SELECTION_SINGLE);
|
|
|
|
}
|
|
|
|
else {
|
1999-12-30 19:53:11 +00:00
|
|
|
gtk_clist_set_selection_mode(GTK_CLIST(packet_list), GTK_SELECTION_BROWSE);
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
/* Set the font of the packet list window. */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
void
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
set_plist_font(GdkFont *font)
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
void
|
|
|
|
set_plist_font(PangoFontDescription *font)
|
|
|
|
#endif
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
{
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
int i;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GtkStyle *style;
|
1999-12-16 06:20:18 +00:00
|
|
|
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
style = gtk_style_new();
|
|
|
|
gdk_font_unref(style->font);
|
|
|
|
style->font = font;
|
|
|
|
gdk_font_ref(font);
|
2000-02-29 06:24:41 +00:00
|
|
|
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
gtk_widget_set_style(packet_list, style);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
2003-02-17 07:50:49 +00:00
|
|
|
PangoLayout *layout;
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_modify_font(packet_list, font);
|
|
|
|
#endif
|
2000-02-29 06:24:41 +00:00
|
|
|
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
/* Compute static column sizes to use during a "-S" capture, so that
|
|
|
|
the columns don't resize during a live capture. */
|
|
|
|
for (i = 0; i < cfile.cinfo.num_cols; i++) {
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
cfile.cinfo.col_width[i] = gdk_string_width(font,
|
|
|
|
get_column_longest_string(get_column_format(i)));
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
2003-02-17 07:50:49 +00:00
|
|
|
layout = gtk_widget_create_pango_layout(packet_list,
|
|
|
|
get_column_longest_string(get_column_format(i)));
|
|
|
|
pango_layout_get_pixel_size(layout, &cfile.cinfo.col_width[i],
|
|
|
|
NULL);
|
|
|
|
g_object_unref(G_OBJECT(layout));
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
}
|
2000-02-29 06:24:41 +00:00
|
|
|
}
|
1999-12-30 23:02:56 +00:00
|
|
|
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
/*
|
|
|
|
* Push a message referring to file access onto the statusbar.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
statusbar_push_file_msg(gchar *msg)
|
|
|
|
{
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pop a message referring to file access off the statusbar.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
statusbar_pop_file_msg(void)
|
|
|
|
{
|
|
|
|
gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX - do we need multiple statusbar contexts?
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Push a message referring to the currently-selected field onto the statusbar.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
statusbar_push_field_msg(gchar *msg)
|
|
|
|
{
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(info_bar), help_ctx, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pop a message referring to the currently-selected field off the statusbar.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
statusbar_pop_field_msg(void)
|
|
|
|
{
|
|
|
|
gtk_statusbar_pop(GTK_STATUSBAR(info_bar), help_ctx);
|
|
|
|
}
|
|
|
|
|
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
2000-04-01 11:30:53 +00:00
|
|
|
static gboolean
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
do_quit(void)
|
2000-02-13 10:36:06 +00:00
|
|
|
{
|
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
2000-04-01 11:30:53 +00:00
|
|
|
/* XXX - should we check whether the capture file is an
|
|
|
|
unsaved temporary file for a live capture and, if so,
|
|
|
|
pop up a "do you want to exit without saving the capture
|
|
|
|
file?" dialog, and then just return, leaving said dialog
|
|
|
|
box to forcibly quit if the user clicks "OK"?
|
|
|
|
|
|
|
|
If so, note that this should be done in a subroutine that
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
returns TRUE if we do so, and FALSE otherwise, and if it
|
|
|
|
returns TRUE we should return TRUE without nuking anything.
|
|
|
|
|
|
|
|
Note that, if we do that, we might also want to check if
|
|
|
|
an "Update list of packets in real time" capture is in
|
|
|
|
progress and, if so, ask whether they want to terminate
|
|
|
|
the capture and discard it, and return TRUE, before nuking
|
|
|
|
any child capture, if they say they don't want to do so. */
|
|
|
|
|
2002-01-10 09:51:23 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
/* Nuke any child capture in progress. */
|
|
|
|
kill_capture_child();
|
2002-01-10 09:51:23 +00:00
|
|
|
#endif
|
There's no need to catch the "delete_event" signal on "Follow TCP
Stream" windows - the window should always be deleted in that situation,
so there's no need for a signal handler that might return TRUE (meaning
"don't delete the window"), and the "destroy" handler gets called when
the window actually gets destroyed, so there's no need to do any cleanup
in the "delete_event" handler.
Catch the "delete_event" signal on the main window in a routine with the
right signature, and that returns FALSE so that the window actually gets
deleted.
Call "close_cap_file()" in the callback for the "File:Quit" menu item
(which is also called by the "delete_event" handler for the main
window), rather than calling it after "gtk_main()" returns -
"close_cap_file()" manipulates stuff in the main window, and if we do so
after "gtk_main()" returns, it appears that the main window may have
disappeared (if we are exiting because the user deleted the main
window), in which case we can get crashes or other errors when
"close_cap_file()" tries to manipulate stuff in the main window.
There's no need to catch the "destroy" signal on the main window - we do
some of the cleanup in the handler for "delete_event" (we have to, for
reasons described above), and we do the rest of it after the main
routine returns.
svn path=/trunk/; revision=1773
2000-04-01 11:30:53 +00:00
|
|
|
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
/* Are we in the middle of reading a capture? */
|
|
|
|
if (cfile.state == FILE_READ_IN_PROGRESS) {
|
|
|
|
/* Yes, so we can't just close the file and quit, as
|
|
|
|
that may yank the rug out from under the read in
|
|
|
|
progress; instead, just set the state to
|
|
|
|
"FILE_READ_ABORTED" and return - the code doing the read
|
|
|
|
will check for that and, if it sees that, will clean
|
|
|
|
up and quit. */
|
|
|
|
cfile.state = FILE_READ_ABORTED;
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
|
|
|
|
/* Say that the window should *not* be deleted;
|
|
|
|
that'll be done by the code that cleans up. */
|
|
|
|
return TRUE;
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
} else {
|
|
|
|
/* Close any capture file we have open; on some OSes, you
|
|
|
|
can't unlink a temporary capture file if you have it
|
|
|
|
open.
|
|
|
|
"close_cap_file()" will unlink it after closing it if
|
|
|
|
it's a temporary file.
|
|
|
|
|
|
|
|
We do this here, rather than after the main loop returns,
|
|
|
|
as, after the main loop returns, the main window may have
|
|
|
|
been destroyed (if this is called due to a "destroy"
|
|
|
|
even on the main window rather than due to the user
|
|
|
|
selecting a menu item), and there may be a crash
|
|
|
|
or other problem when "close_cap_file()" tries to
|
|
|
|
clean up stuff in the main window.
|
|
|
|
|
|
|
|
XXX - is there a better place to put this?
|
|
|
|
Or should we have a routine that *just* closes the
|
|
|
|
capture file, and doesn't do anything with the UI,
|
|
|
|
which we'd call here, and another routine that
|
|
|
|
calls that routine and also cleans up the UI, which
|
|
|
|
we'd call elsewhere? */
|
Enable "Match Selected" only if there's a field selected *and* we can do
a "Match Selected" on it - we can't do a "Match Selected" if the field
has no value (e.g., FT_NULL) and has a length of 0.
If we unselect the current packet, we don't have a protocol tree, so we
don't have a currently selected field - clear the "Match Selected" menu
item and the display in the status line of information about the
currently selected field.
Move the low-level statusbar manipulation into "gtk/main.c", in routines
whose API doesn't expose anything GTK+-ish.
"close_cap_file()" calls one of those routines to clear out the status
bar, so it doesn't need to take a pointer to the statusbar widget as an
argument.
"clear_tree_and_hex_views()" is purely a display-manipulating routine;
move it to "gtk/proto_draw.c".
Extract from "tree_view_unselect_row_cb()" an "unselect_field()" routine
to do all the work that needs to be done if the currently selected
protocol tree row is unselected, and call it if the currently selected
packet list row is unselected (if it's unselected, there *is* no
protocol tree, so no row can be selected), as well as from
"tree_view_unselect_row_cb()".
Before pushing a new field-description message onto the statusbar, pop
the old one off.
Get rid of an unused variable (set, but not used).
svn path=/trunk/; revision=3513
2001-06-05 07:39:31 +00:00
|
|
|
close_cap_file(&cfile);
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
|
|
|
|
/* Exit by leaving the main loop, so that any quit functions
|
|
|
|
we registered get called. */
|
|
|
|
gtk_main_quit();
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
|
|
|
|
/* Say that the window should be deleted. */
|
|
|
|
return FALSE;
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
}
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
static gboolean
|
2002-03-05 11:56:00 +00:00
|
|
|
main_window_delete_event_cb(GtkWidget *widget _U_, GdkEvent *event _U_, gpointer data _U_)
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
{
|
|
|
|
gint desk_x, desk_y;
|
|
|
|
|
|
|
|
/* Try to grab our geometry */
|
|
|
|
gdk_window_get_root_origin(top_level->window, &root_x, &root_y);
|
|
|
|
if (gdk_window_get_deskrelative_origin(top_level->window,
|
|
|
|
&desk_x, &desk_y)) {
|
|
|
|
if (desk_x <= root_x && desk_y <= root_y) {
|
|
|
|
root_x = desk_x;
|
|
|
|
root_y = desk_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX - Is this the "approved" method? */
|
|
|
|
gdk_window_get_size(top_level->window, &top_width, &top_height);
|
|
|
|
|
|
|
|
/* "do_quit()" indicates whether the main window should be deleted. */
|
|
|
|
return do_quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
file_quit_cmd_cb (GtkWidget *widget _U_, gpointer data _U_)
|
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while
an "Update list of packets in real time" capture is in progress, we can
abort the capture.
Arrange that "fork_child" is -1 when there is no capture child, so said
routine knows when it can kill the child.
When we exit, kill off any capture child, using that routine, and, if
we're exiting due to a request to delete the main window and, if a read
is in progress (from an "Update list of packets in real time" capture),
don't delete the main window - just set the "Read aborted" flag, so that
the code doing the read will see that flag (it will be called because
the pipe to the capture child is closed due to the child exiting) will
see that and clean up and exit itself.
svn path=/trunk/; revision=4498
2002-01-08 09:32:15 +00:00
|
|
|
{
|
|
|
|
do_quit();
|
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void
|
2002-05-22 23:22:56 +00:00
|
|
|
print_usage(gboolean print_ver) {
|
1998-09-16 02:39:15 +00:00
|
|
|
|
2002-05-22 23:22:56 +00:00
|
|
|
if (print_ver) {
|
|
|
|
fprintf(stderr, "This is GNU " PACKAGE " " VERSION ", compiled %s\n",
|
2001-03-27 06:48:12 +00:00
|
|
|
comp_info_str->str);
|
2002-08-28 21:04:11 +00:00
|
|
|
}
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-05-22 23:22:56 +00:00
|
|
|
fprintf(stderr, "\n%s [ -vh ] [ -klpQS ] [ -a <capture autostop condition> ] ...\n",
|
1998-09-16 02:39:15 +00:00
|
|
|
PACKAGE);
|
2001-12-04 08:26:00 +00:00
|
|
|
fprintf(stderr, "\t[ -b <number of ringbuffer files> ] [ -B <byte view height> ]\n");
|
|
|
|
fprintf(stderr, "\t[ -c <count> ] [ -f <capture filter> ] [ -i <interface> ]\n");
|
|
|
|
fprintf(stderr, "\t[ -m <medium font> ] [ -n ] [ -N <resolving> ]\n");
|
2001-05-31 08:36:46 +00:00
|
|
|
fprintf(stderr, "\t[ -o <preference setting> ] ... [ -P <packet list height> ]\n");
|
|
|
|
fprintf(stderr, "\t[ -r <infile> ] [ -R <read filter> ] [ -s <snaplen> ] \n");
|
2001-11-24 08:46:13 +00:00
|
|
|
fprintf(stderr, "\t[ -t <time stamp format> ] [ -T <tree view height> ]\n");
|
|
|
|
fprintf(stderr, "\t[ -w <savefile> ] [ <infile> ]\n");
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
2002-05-22 23:22:56 +00:00
|
|
|
fprintf(stderr, "\n%s [ -vh ] [ -B <byte view height> ] [ -m <medium font> ]\n",
|
1999-12-07 07:12:49 +00:00
|
|
|
PACKAGE);
|
2001-06-27 08:36:08 +00:00
|
|
|
fprintf(stderr, "\t[ -n ] [ -N <resolving> ]\n");
|
2000-08-20 08:08:30 +00:00
|
|
|
fprintf(stderr, "\t[ -o <preference setting> ... [ -P <packet list height> ]\n");
|
2001-05-31 08:36:46 +00:00
|
|
|
fprintf(stderr, "\t[ -r <infile> ] [ -R <read filter> ] [ -t <time stamp format> ]\n");
|
2001-11-24 08:46:13 +00:00
|
|
|
fprintf(stderr, "\t[ -T <tree view height> ] [ <infile> ]\n");
|
1999-12-07 07:12:49 +00:00
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
static void
|
2001-02-20 04:09:37 +00:00
|
|
|
show_version(void)
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
create_console();
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 06:48:12 +00:00
|
|
|
printf("%s %s, %s\n", PACKAGE, VERSION, comp_info_str->str);
|
2001-02-20 04:09:37 +00:00
|
|
|
}
|
|
|
|
|
2001-12-04 07:32:05 +00:00
|
|
|
static int
|
2001-04-18 05:45:58 +00:00
|
|
|
get_positive_int(const char *string, const char *name)
|
|
|
|
{
|
|
|
|
long number;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
number = strtol(string, &p, 10);
|
|
|
|
if (p == string || *p != '\0') {
|
|
|
|
fprintf(stderr, "ethereal: The specified %s \"%s\" is not a decimal number\n",
|
|
|
|
name, string);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (number < 0) {
|
|
|
|
fprintf(stderr, "ethereal: The specified %s \"%s\" is a negative number\n",
|
|
|
|
name, string);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-02-24 06:01:03 +00:00
|
|
|
if (number == 0) {
|
|
|
|
fprintf(stderr, "ethereal: The specified %s \"%s\" is zero\n",
|
|
|
|
name, string);
|
|
|
|
exit(1);
|
|
|
|
}
|
2001-04-18 05:45:58 +00:00
|
|
|
if (number > INT_MAX) {
|
|
|
|
fprintf(stderr, "ethereal: The specified %s \"%s\" is too large (greater than %d)\n",
|
|
|
|
name, string, INT_MAX);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return number;
|
|
|
|
}
|
|
|
|
|
2002-01-10 09:51:23 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2001-12-04 07:32:05 +00:00
|
|
|
/*
|
|
|
|
* Given a string of the form "<autostop criterion>:<value>", as might appear
|
|
|
|
* as an argument to a "-a" option, parse it and set the criterion in
|
|
|
|
* question. Return an indication of whether it succeeded or failed
|
|
|
|
* in some fashion.
|
|
|
|
*/
|
|
|
|
static gboolean
|
|
|
|
set_autostop_criterion(const char *autostoparg)
|
|
|
|
{
|
2002-08-02 22:34:54 +00:00
|
|
|
guchar *p, *colonp;
|
2001-12-04 07:32:05 +00:00
|
|
|
|
|
|
|
colonp = strchr(autostoparg, ':');
|
|
|
|
if (colonp == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
p = colonp;
|
|
|
|
*p++ = '\0';
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Skip over any white space (there probably won't be any, but
|
|
|
|
* as we allow it in the preferences file, we might as well
|
|
|
|
* allow it here).
|
|
|
|
*/
|
|
|
|
while (isspace(*p))
|
|
|
|
p++;
|
|
|
|
if (*p == '\0') {
|
|
|
|
/*
|
|
|
|
* Put the colon back, so if our caller uses, in an
|
|
|
|
* error message, the string they passed us, the message
|
|
|
|
* looks correct.
|
|
|
|
*/
|
|
|
|
*colonp = ':';
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (strcmp(autostoparg,"duration") == 0) {
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.has_autostop_duration = TRUE;
|
|
|
|
capture_opts.autostop_duration = get_positive_int(p,"autostop duration");
|
2001-12-04 07:32:05 +00:00
|
|
|
} else if (strcmp(autostoparg,"filesize") == 0) {
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.has_autostop_filesize = TRUE;
|
|
|
|
capture_opts.autostop_filesize = get_positive_int(p,"autostop filesize");
|
2001-12-04 07:32:05 +00:00
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*colonp = ':'; /* put the colon back */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-01-10 09:51:23 +00:00
|
|
|
#endif
|
2001-12-04 07:32:05 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if defined WIN32 || GTK_MAJOR_VERSION < 2
|
2002-09-07 10:02:36 +00:00
|
|
|
/*
|
|
|
|
Once every 3 seconds we get a callback here which we use to update
|
|
|
|
the tap extensions. Since Gtk1 is single threaded we dont have to
|
|
|
|
worry about any locking or critical regions.
|
|
|
|
*/
|
|
|
|
static gint
|
|
|
|
update_cb(gpointer data _U_)
|
|
|
|
{
|
|
|
|
draw_tap_listeners(FALSE);
|
|
|
|
return 1;
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
/* if these three functions are copied to gtk1 ethereal, since gtk1 does not
|
|
|
|
use threads all updte_thread_mutex can be dropped and protect/unprotect
|
|
|
|
would just be empty functions.
|
|
|
|
|
|
|
|
This allows gtk2-rpcstat.c and friends to be copied unmodified to
|
|
|
|
gtk1-ethereal and it will just work.
|
|
|
|
*/
|
|
|
|
static GStaticMutex update_thread_mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
gpointer
|
|
|
|
update_thread(gpointer data _U_)
|
|
|
|
{
|
|
|
|
while(1){
|
|
|
|
GTimeVal tv1, tv2;
|
|
|
|
g_get_current_time(&tv1);
|
|
|
|
g_static_mutex_lock(&update_thread_mutex);
|
|
|
|
gdk_threads_enter();
|
|
|
|
draw_tap_listeners(FALSE);
|
|
|
|
gdk_threads_leave();
|
|
|
|
g_static_mutex_unlock(&update_thread_mutex);
|
|
|
|
g_thread_yield();
|
|
|
|
g_get_current_time(&tv2);
|
|
|
|
if( ((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) >
|
|
|
|
(tv2.tv_sec * 1000000 + tv2.tv_usec) ){
|
|
|
|
g_usleep(((tv1.tv_sec + 2) * 1000000 + tv1.tv_usec) -
|
|
|
|
(tv2.tv_sec * 1000000 + tv2.tv_usec));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-07 10:02:36 +00:00
|
|
|
void
|
|
|
|
protect_thread_critical_region(void)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
#if ! defined WIN32 && GTK_MAJOR_VERSION >= 2
|
|
|
|
g_static_mutex_lock(&update_thread_mutex);
|
|
|
|
#endif
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
unprotect_thread_critical_region(void)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
#if ! defined WIN32 && GTK_MAJOR_VERSION >= 2
|
|
|
|
g_static_mutex_unlock(&update_thread_mutex);
|
|
|
|
#endif
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
2002-11-06 10:53:36 +00:00
|
|
|
/* structure to keep track of what tap listeners have been registered.
|
|
|
|
*/
|
|
|
|
typedef struct _ethereal_tap_list {
|
|
|
|
struct _ethereal_tap_list *next;
|
|
|
|
char *cmd;
|
|
|
|
void (*func)(char *arg);
|
|
|
|
} ethereal_tap_list;
|
|
|
|
static ethereal_tap_list *tap_list=NULL;
|
|
|
|
|
|
|
|
void
|
|
|
|
register_ethereal_tap(char *cmd, void (*func)(char *arg), char *dummy _U_, void (*dummy2)(void) _U_)
|
|
|
|
{
|
|
|
|
ethereal_tap_list *newtl;
|
|
|
|
|
|
|
|
newtl=malloc(sizeof(ethereal_tap_list));
|
|
|
|
newtl->next=tap_list;
|
|
|
|
tap_list=newtl;
|
|
|
|
newtl->cmd=cmd;
|
|
|
|
newtl->func=func;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
/* And now our feature presentation... [ fade to music ] */
|
1998-09-16 02:39:15 +00:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
1999-10-21 21:47:08 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
char *command_name;
|
|
|
|
#endif
|
|
|
|
char *s;
|
1999-07-13 02:53:26 +00:00
|
|
|
int i;
|
|
|
|
int opt;
|
1998-09-16 02:39:15 +00:00
|
|
|
extern char *optarg;
|
1999-12-07 07:12:49 +00:00
|
|
|
gboolean arg_error = FALSE;
|
1999-11-04 21:04:35 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2001-07-27 07:10:13 +00:00
|
|
|
#ifdef HAVE_PCAP_VERSION
|
1999-12-07 07:12:49 +00:00
|
|
|
extern char pcap_version[];
|
2001-07-27 07:10:13 +00:00
|
|
|
#endif /* HAVE_PCAP_VERSION */
|
|
|
|
#endif /* HAVE_LIBPCAP */
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-10-27 17:19:23 +00:00
|
|
|
#ifdef WIN32
|
2002-08-28 21:04:11 +00:00
|
|
|
WSADATA wsaData;
|
2002-10-09 03:07:34 +00:00
|
|
|
#endif /* WIN32 */
|
2000-10-27 17:19:23 +00:00
|
|
|
|
2001-10-22 22:59:26 +00:00
|
|
|
char *gpf_path, *cf_path, *df_path;
|
2002-08-01 03:15:29 +00:00
|
|
|
char *pf_path;
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
int gpf_open_errno, pf_open_errno, cf_open_errno, df_open_errno;
|
1999-12-07 07:12:49 +00:00
|
|
|
int err;
|
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
1999-12-07 07:12:49 +00:00
|
|
|
gboolean start_capture = FALSE;
|
|
|
|
gchar *save_file = NULL;
|
2000-01-16 02:48:12 +00:00
|
|
|
GList *if_list;
|
2000-01-15 06:05:21 +00:00
|
|
|
gchar err_str[PCAP_ERRBUF_SIZE];
|
2001-02-11 09:28:17 +00:00
|
|
|
gboolean stats_known;
|
|
|
|
struct pcap_stat stats;
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
gboolean capture_option_specified = FALSE;
|
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
|
|
|
#endif
|
1998-11-18 03:01:44 +00:00
|
|
|
gint pl_size = 280, tv_size = 95, bv_size = 75;
|
1999-08-10 07:16:47 +00:00
|
|
|
gchar *rc_file, *cf_name = NULL, *rfilter = NULL;
|
2001-02-01 20:21:25 +00:00
|
|
|
dfilter_t *rfcode = NULL;
|
1999-08-15 19:18:46 +00:00
|
|
|
gboolean rfilter_parse_failed = FALSE;
|
1998-11-17 04:29:13 +00:00
|
|
|
e_prefs *prefs;
|
2001-05-31 08:36:46 +00:00
|
|
|
char badopt;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
char *bold_font_name;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2001-12-31 04:41:50 +00:00
|
|
|
gint desk_x, desk_y;
|
|
|
|
gboolean prefs_write_needed = FALSE;
|
2002-11-10 11:41:45 +00:00
|
|
|
ethereal_tap_list *tli = NULL;
|
2002-11-10 11:36:39 +00:00
|
|
|
gchar *tap_opt = NULL;
|
2001-12-31 04:41:50 +00:00
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
#define OPTSTRING_INIT "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:vz:"
|
2002-05-22 23:22:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
#ifdef WIN32
|
|
|
|
#define OPTSTRING_CHILD "W:Z:"
|
|
|
|
#else
|
|
|
|
#define OPTSTRING_CHILD "W:"
|
|
|
|
#endif /* WIN32 */
|
|
|
|
#else
|
|
|
|
#define OPTSTRING_CHILD ""
|
|
|
|
#endif /* HAVE_LIBPCAP */
|
|
|
|
|
|
|
|
char optstring[sizeof(OPTSTRING_INIT) + sizeof(OPTSTRING_CHILD) - 1] =
|
|
|
|
OPTSTRING_INIT;
|
1998-09-16 02:39:15 +00:00
|
|
|
|
1999-05-11 18:51:10 +00:00
|
|
|
ethereal_path = argv[0];
|
|
|
|
|
2001-02-20 04:09:37 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
/* Arrange that if we have no console window, and a GLib message logging
|
|
|
|
routine is called to log a message, we pop up a console window.
|
|
|
|
|
|
|
|
We do that by inserting our own handler for all messages logged
|
|
|
|
to the default domain; that handler pops up a console if necessary,
|
|
|
|
and then calls the default handler. */
|
|
|
|
g_log_set_handler(NULL,
|
|
|
|
G_LOG_LEVEL_ERROR|
|
|
|
|
G_LOG_LEVEL_CRITICAL|
|
|
|
|
G_LOG_LEVEL_WARNING|
|
|
|
|
G_LOG_LEVEL_MESSAGE|
|
|
|
|
G_LOG_LEVEL_INFO|
|
|
|
|
G_LOG_LEVEL_DEBUG|
|
|
|
|
G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION,
|
|
|
|
console_log_handler, NULL);
|
|
|
|
#endif
|
|
|
|
|
1999-10-21 21:47:08 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2000-01-25 04:44:33 +00:00
|
|
|
command_name = get_basename(ethereal_path);
|
1999-10-21 21:47:08 +00:00
|
|
|
/* Set "capture_child" to indicate whether this is going to be a child
|
|
|
|
process for a "-S" capture. */
|
|
|
|
capture_child = (strcmp(command_name, CHILD_NAME) == 0);
|
2002-05-22 23:22:56 +00:00
|
|
|
if (capture_child)
|
|
|
|
strcat(optstring, OPTSTRING_CHILD);
|
1999-10-21 21:47:08 +00:00
|
|
|
#endif
|
|
|
|
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
/* Register all dissectors; we must do this before checking for the
|
2002-05-14 10:15:12 +00:00
|
|
|
"-G" flag, as the "-G" flag dumps information registered by the
|
|
|
|
dissectors, and we must do it before we read the preferences, in
|
|
|
|
case any dissectors register preferences. */
|
2001-04-02 00:38:36 +00:00
|
|
|
epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs);
|
2002-11-06 10:53:36 +00:00
|
|
|
register_all_tap_listeners();
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
|
|
|
|
/* Now register the preferences for any non-dissector modules.
|
|
|
|
We must do that before we read the preferences as well. */
|
|
|
|
prefs_register_modules();
|
|
|
|
|
2002-05-14 10:15:12 +00:00
|
|
|
/* If invoked with the "-G" flag, we dump out information based on
|
|
|
|
the argument to the "-G" flag; if no argument is specified,
|
|
|
|
for backwards compatibility we dump out a glossary of display
|
|
|
|
filter symbols.
|
1999-10-21 21:47:08 +00:00
|
|
|
|
|
|
|
We must do this before calling "gtk_init()", because "gtk_init()"
|
|
|
|
tries to open an X display, and we don't want to have to do any X
|
|
|
|
stuff just to do a build.
|
|
|
|
|
|
|
|
Given that we call "gtk_init()" before doing the regular argument
|
|
|
|
list processing, so that it can handle X and GTK+ arguments and
|
|
|
|
remove them from the list at which we look, this means we must do
|
|
|
|
this before doing the regular argument list processing, as well.
|
|
|
|
|
|
|
|
This means that:
|
|
|
|
|
|
|
|
you must give the "-G" flag as the first flag on the command line;
|
|
|
|
|
|
|
|
you must give it as "-G", nothing more, nothing less;
|
|
|
|
|
2002-05-14 10:15:12 +00:00
|
|
|
the first argument after the "-G" flag, if present, will be used
|
|
|
|
to specify the information to dump;
|
|
|
|
|
|
|
|
arguments after that will not be used. */
|
1999-10-21 21:47:08 +00:00
|
|
|
if (argc >= 2 && strcmp(argv[1], "-G") == 0) {
|
2002-05-14 10:15:12 +00:00
|
|
|
if (argc == 2)
|
|
|
|
proto_registrar_dump_fields();
|
|
|
|
else {
|
|
|
|
if (strcmp(argv[2], "fields") == 0)
|
|
|
|
proto_registrar_dump_fields();
|
|
|
|
else if (strcmp(argv[2], "protocols") == 0)
|
|
|
|
proto_registrar_dump_protocols();
|
2002-05-14 18:27:28 +00:00
|
|
|
else {
|
|
|
|
fprintf(stderr, "tethereal: Invalid \"%s\" option for -G flag\n",
|
|
|
|
argv[2]);
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-05-14 10:15:12 +00:00
|
|
|
}
|
Have Ethereal, when invoked as "ethereal-dump-fields", dump out a
glossary of display filter symbols, just as it does with "-G", except
that, as it can discover that it was so invoked before even looking at
the command-line arguments, it needn't even bother calling "gtk_init()"
to process those command-line arguments GTK+ cares about, and thus
needn't do any X stuff at all when so invoked.
That allows Ethereal to be built in an environment where you don't have
an X server, and, if your connection to your X server is slow, allows
you to built it faster.
Get rid of the "-G" flag, as it had only a somewhat specialized use.
svn path=/trunk/; revision=444
1999-08-05 06:34:43 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* multithread support currently doesn't seem to work in win32 gtk2.0.6 */
|
|
|
|
#if ! defined WIN32 && GTK_MAJOR_VERSION >= 2 && defined G_THREADS_ENABLED
|
|
|
|
{
|
|
|
|
GThread *ut;
|
|
|
|
g_thread_init(NULL);
|
|
|
|
gdk_threads_init();
|
|
|
|
ut=g_thread_create(update_thread, NULL, FALSE, NULL);
|
|
|
|
g_thread_set_priority(ut, G_THREAD_PRIORITY_LOW);
|
|
|
|
}
|
|
|
|
#else /* WIN32 || GTK1.2 || !G_THREADS_ENABLED */
|
2002-09-07 10:02:36 +00:00
|
|
|
/* this is to keep tap extensions updating once every 3 seconds */
|
|
|
|
gtk_timeout_add(3000, (GtkFunction)update_cb,(gpointer)NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif /* !WIN32 && GTK2 && G_THREADS_ENABLED */
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Set the current locale according to the program environment.
|
2000-06-05 03:09:21 +00:00
|
|
|
* We haven't localized anything, but some GTK widgets are localized
|
2000-07-05 02:04:16 +00:00
|
|
|
* (the file selection dialogue, for example).
|
|
|
|
* This also sets the C-language locale to the native environment. */
|
2000-06-05 03:09:21 +00:00
|
|
|
gtk_set_locale();
|
|
|
|
|
1998-11-17 04:29:13 +00:00
|
|
|
/* Let GTK get its args */
|
|
|
|
gtk_init (&argc, &argv);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-01-28 04:52:29 +00:00
|
|
|
/* Read the preference files. */
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
prefs = read_prefs(&gpf_open_errno, &gpf_path, &pf_open_errno, &pf_path);
|
1999-08-14 19:53:31 +00:00
|
|
|
|
2001-06-19 08:47:48 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.has_snaplen = FALSE;
|
|
|
|
capture_opts.snaplen = MIN_PACKET_SIZE;
|
|
|
|
capture_opts.has_autostop_count = FALSE;
|
|
|
|
capture_opts.autostop_count = 1;
|
|
|
|
capture_opts.has_autostop_duration = FALSE;
|
|
|
|
capture_opts.autostop_duration = 1;
|
|
|
|
capture_opts.has_autostop_filesize = FALSE;
|
|
|
|
capture_opts.autostop_filesize = 1;
|
|
|
|
capture_opts.ringbuffer_on = FALSE;
|
|
|
|
capture_opts.ringbuffer_num_files = RINGBUFFER_MIN_NUM_FILES;
|
Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file. Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).
If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.
Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").
Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping. Also add units to the capture count option.
Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.
Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.
svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
|
|
|
|
2001-06-19 08:47:48 +00:00
|
|
|
/* If this is a capture child process, it should pay no attention
|
|
|
|
to the "prefs.capture_prom_mode" setting in the preferences file;
|
|
|
|
it should do what the parent process tells it to do, and if
|
|
|
|
the parent process wants it not to run in promiscuous mode, it'll
|
2002-01-10 11:05:50 +00:00
|
|
|
tell it so with a "-p" flag.
|
|
|
|
|
|
|
|
Otherwise, set promiscuous mode from the preferences setting. */
|
2001-06-19 08:47:48 +00:00
|
|
|
if (capture_child)
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.promisc_mode = TRUE;
|
2002-01-10 11:05:50 +00:00
|
|
|
else
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.promisc_mode = prefs->capture_prom_mode;
|
2002-01-10 11:05:50 +00:00
|
|
|
|
|
|
|
/* Set "Update list of packets in real time" mode from the preferences
|
|
|
|
setting. */
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.sync_mode = prefs->capture_real_time;
|
2002-01-10 11:05:50 +00:00
|
|
|
|
|
|
|
/* And do the same for "Automatic scrolling in live capture" mode. */
|
|
|
|
auto_scroll_live = prefs->capture_auto_scroll;
|
2001-06-19 08:47:48 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-13 20:35:12 +00:00
|
|
|
/* Set the name resolution code's flags from the preferences. */
|
|
|
|
g_resolv_flags = prefs->name_resolve;
|
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
/* Read the capture filter file. */
|
|
|
|
read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno);
|
|
|
|
|
|
|
|
/* Read the display filter file. */
|
|
|
|
read_filter_list(DFILTER_LIST, &df_path, &df_open_errno);
|
2001-01-28 04:52:29 +00:00
|
|
|
|
2002-09-06 22:45:44 +00:00
|
|
|
init_cap_file(&cfile);
|
1998-11-17 04:29:13 +00:00
|
|
|
|
1998-12-27 20:47:53 +00:00
|
|
|
/* Assemble the compile-time options */
|
2001-03-27 06:48:12 +00:00
|
|
|
comp_info_str = g_string_new("");
|
|
|
|
|
|
|
|
g_string_append(comp_info_str, "with ");
|
|
|
|
g_string_sprintfa(comp_info_str,
|
1998-12-27 20:47:53 +00:00
|
|
|
#ifdef GTK_MAJOR_VERSION
|
2002-11-03 17:38:45 +00:00
|
|
|
"GTK+ %d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION,
|
|
|
|
GTK_MICRO_VERSION);
|
2001-03-27 06:48:12 +00:00
|
|
|
#else
|
2002-11-03 17:38:45 +00:00
|
|
|
"GTK+ (version unknown)");
|
2001-03-27 06:48:12 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
g_string_append(comp_info_str, ", with ");
|
|
|
|
g_string_sprintfa(comp_info_str,
|
|
|
|
#ifdef GLIB_MAJOR_VERSION
|
2002-11-03 17:38:45 +00:00
|
|
|
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
|
|
|
|
GLIB_MICRO_VERSION);
|
1998-12-27 20:47:53 +00:00
|
|
|
#else
|
2002-11-03 17:38:45 +00:00
|
|
|
"GLib (version unknown)");
|
1999-07-09 04:18:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, ", with libpcap ");
|
2001-07-27 07:10:13 +00:00
|
|
|
#ifdef HAVE_PCAP_VERSION
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, pcap_version);
|
2001-07-27 07:10:13 +00:00
|
|
|
#else /* HAVE_PCAP_VERSION */
|
|
|
|
g_string_append(comp_info_str, "(version unknown)");
|
|
|
|
#endif /* HAVE_PCAP_VERSION */
|
|
|
|
#else /* HAVE_LIBPCAP */
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, ", without libpcap");
|
2001-07-27 07:10:13 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
1999-11-29 02:45:23 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBZ
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, ", with libz ");
|
1999-11-29 02:45:23 +00:00
|
|
|
#ifdef ZLIB_VERSION
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, ZLIB_VERSION);
|
1999-11-29 02:45:23 +00:00
|
|
|
#else /* ZLIB_VERSION */
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, "(version unknown)");
|
1999-11-29 02:45:23 +00:00
|
|
|
#endif /* ZLIB_VERSION */
|
|
|
|
#else /* HAVE_LIBZ */
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, ", without libz");
|
1999-11-29 02:45:23 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
1999-11-29 03:07:19 +00:00
|
|
|
|
2002-10-23 18:24:09 +00:00
|
|
|
/* Oh, this is pretty. */
|
|
|
|
/* Oh, ha. you think that was pretty. Try this:! --Wes */
|
|
|
|
#ifdef HAVE_SOME_SNMP
|
|
|
|
|
2002-03-12 10:37:04 +00:00
|
|
|
#ifdef HAVE_UCD_SNMP
|
2002-10-23 18:24:09 +00:00
|
|
|
g_string_append(comp_info_str, ", with UCD-SNMP ");
|
2001-03-27 06:48:12 +00:00
|
|
|
g_string_append(comp_info_str, VersionInfo);
|
2002-10-23 18:24:09 +00:00
|
|
|
#endif /* HAVE_UCD_SNMP */
|
|
|
|
|
|
|
|
#ifdef HAVE_NET_SNMP
|
|
|
|
g_string_append(comp_info_str, ", with Net-SNMP ");
|
|
|
|
g_string_append(comp_info_str, netsnmp_get_version());
|
|
|
|
#endif /* HAVE_NET_SNMP */
|
|
|
|
|
2002-03-10 23:19:44 +00:00
|
|
|
#else /* no SNMP library */
|
2002-10-23 18:24:09 +00:00
|
|
|
g_string_append(comp_info_str, ", without UCD-SNMP or Net-SNMP");
|
|
|
|
#endif /* HAVE_SOME_SNMP */
|
1998-12-27 20:47:53 +00:00
|
|
|
|
1998-09-16 02:39:15 +00:00
|
|
|
/* Now get our args */
|
2002-05-22 23:22:56 +00:00
|
|
|
while ((opt = getopt(argc, argv, optstring)) != -1) {
|
1998-09-16 02:39:15 +00:00
|
|
|
switch (opt) {
|
2001-12-04 07:32:05 +00:00
|
|
|
case 'a': /* autostop criteria */
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
if (set_autostop_criterion(optarg) == FALSE) {
|
|
|
|
fprintf(stderr, "ethereal: Invalid or unknown -a flag \"%s\"\n", optarg);
|
2002-08-28 21:04:11 +00:00
|
|
|
exit(1);
|
2001-12-04 07:32:05 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
2001-12-04 08:26:00 +00:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 'b': /* Ringbuffer option */
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.ringbuffer_on = TRUE;
|
|
|
|
capture_opts.ringbuffer_num_files =
|
|
|
|
get_positive_int(optarg, "number of ring buffer files");
|
2001-12-04 08:26:00 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
2001-12-04 07:32:05 +00:00
|
|
|
#endif
|
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'B': /* Byte view pane height */
|
2001-04-18 05:45:58 +00:00
|
|
|
bv_size = get_positive_int(optarg, "byte view pane height");
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
|
|
|
case 'c': /* Capture xxx packets */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.has_autostop_count = TRUE;
|
|
|
|
capture_opts.autostop_count = get_positive_int(optarg, "packet count");
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
1999-07-13 02:53:26 +00:00
|
|
|
case 'f':
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.cfilter)
|
|
|
|
g_free(cfile.cfilter);
|
|
|
|
cfile.cfilter = g_strdup(optarg);
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
1999-12-07 07:12:49 +00:00
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'h': /* Print help and exit */
|
2002-05-22 23:22:56 +00:00
|
|
|
print_usage(TRUE);
|
1998-09-16 02:39:15 +00:00
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case 'i': /* Use interface xxx */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.iface = g_strdup(optarg);
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 'k': /* Start capture immediately */
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
start_capture = TRUE;
|
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
2001-05-01 00:41:46 +00:00
|
|
|
case 'l': /* Automatic scrolling in live capture mode */
|
2002-01-10 11:05:50 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
auto_scroll_live = TRUE;
|
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
2001-05-01 00:41:46 +00:00
|
|
|
break;
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
case 'm': /* Fixed-width font for the display */
|
|
|
|
if (prefs->gui_font_name != NULL)
|
|
|
|
g_free(prefs->gui_font_name);
|
2001-05-31 08:36:46 +00:00
|
|
|
prefs->gui_font_name = g_strdup(optarg);
|
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'n': /* No name resolution */
|
2002-01-13 20:35:12 +00:00
|
|
|
g_resolv_flags = RESOLV_NONE;
|
2001-05-31 08:36:46 +00:00
|
|
|
break;
|
|
|
|
case 'N': /* Select what types of addresses/port #s to resolve */
|
2002-01-13 20:35:12 +00:00
|
|
|
if (g_resolv_flags == RESOLV_ALL)
|
|
|
|
g_resolv_flags = RESOLV_NONE;
|
|
|
|
badopt = string_to_name_resolve(optarg, &g_resolv_flags);
|
2001-05-31 08:36:46 +00:00
|
|
|
if (badopt != '\0') {
|
|
|
|
fprintf(stderr, "ethereal: -N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'\n",
|
|
|
|
badopt);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
case 'o': /* Override preference from command line */
|
|
|
|
switch (prefs_set_pref(optarg)) {
|
|
|
|
|
|
|
|
case PREFS_SET_SYNTAX_ERR:
|
|
|
|
fprintf(stderr, "ethereal: Invalid -o flag \"%s\"\n", optarg);
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PREFS_SET_NO_SUCH_PREF:
|
Allow a dissector to register preferences that it no longer supports as
obsolete; we silently ignore attempts to set those in a preferences
file, so that we don't spam the user with error messages caused by them
having saved preferences in an earlier release that contained those
preferences.
Make the Diameter and iSCSI dissectors register obsolete preferences.
Crash if some code tries to register a preferences module with a name
that contains something other than lower-case ASCII letters, numbers, or
underscores, or that has already been registered, or if some code tries
to register a preference with a name that contains something other than
lower-case ASCII letters, numbers, underscores, or periods, or that has
already been registered, so that we don't put code like that in a
release and have to shovel code into "prefs.c" to fix it up later. (The
problem with multiple modules or preferences with the same name should
be obvious; the problem with names with blanks, or upper-case letters,
or punctuation, is that they're a pain to type on the command line.)
svn path=/trunk/; revision=4148
2001-11-04 02:50:21 +00:00
|
|
|
case PREFS_SET_OBSOLETE:
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
fprintf(stderr, "ethereal: -o flag \"%s\" specifies unknown preference\n",
|
|
|
|
optarg);
|
|
|
|
exit(1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2000-09-15 05:32:49 +00:00
|
|
|
case 'p': /* Don't capture in promiscuous mode */
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.promisc_mode = FALSE;
|
2000-09-15 05:32:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'P': /* Packet list pane height */
|
2001-04-18 05:45:58 +00:00
|
|
|
pl_size = get_positive_int(optarg, "packet list pane height");
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
1999-05-11 18:51:10 +00:00
|
|
|
case 'Q': /* Quit after capture (just capture to file) */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
1999-05-11 18:51:10 +00:00
|
|
|
quit_after_cap = 1;
|
Add a new global flag "capture_child", which is TRUE if we're a child
process for a sync mode or fork mode capture.
Have that flag control whether we do things that *only* the parent or
*only* the child should do, rather than basing it solely on the setting
of "sync_mode" or "fork_mode" (or, in the case of stuff done in the
child process either in sync mode or fork mode, rather than basing it on
the setting of those flags at all).
Split "do_capture()" into a "run_capture()" routine that starts a
capture (possibly by forking off and execing a child process, if we're
supposed to do sync mode or fork mode captures), and that assumes the
file to which the capture is to write has already been opened and that
"cf.save_file_fd" is the file descriptor for that file, and a
"do_capture()" routine that creates a temporary file, getting an FD for
it, and calls "run_capture()".
Use "run_capture()", rather than "capture()", for "-k" captures, so that
it'll do the capture in a child process if "-S" or "-F" was specified
("do_capture()" won't do because "-k" captures should write to the file
specified by the "-w" flag, not some random temporary file).
For child process captures, however, just use "capture()" - the child
process shouldn't itself fork off a child if we're in sync or fork mode,
and should just write to the file whose file descriptor was specified by
the "-W" flag on the command line.
All this allows you to do "ethereal -S -w <file> -i <interface> -k" to
start a sync mode capture from the command line.
svn path=/trunk/; revision=740
1999-09-30 06:50:01 +00:00
|
|
|
start_capture = TRUE; /*** -Q implies -k !! ***/
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
1999-12-07 07:12:49 +00:00
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'r': /* Read capture file xxx */
|
1999-12-02 08:28:34 +00:00
|
|
|
/* We may set "last_open_dir" to "cf_name", and if we change
|
|
|
|
"last_open_dir" later, we free the old value, so we have to
|
|
|
|
set "cf_name" to something that's been allocated. */
|
Fix bug which occurs when running ethereal with "-r" to load a file, then
loading a new file from within ethereal.
In main(), cf_name was being set to optarg, without g_strdup()'ing it.
Later, in file_open_cmd_cb(), we try to g_free last_open_dir, which is
cf_name, so blammo! We try to g_free something that we can't.
So, in main(), be sure to set cf_name to a g_strdup() of optarg, not
just optarg.
(At home I'm using debug/development versions of glib/gtk, so maybe
that's why I saw the problem only now. I could have sworn that I
have done this sequence of events successfully before).
svn path=/trunk/; revision=1180
1999-12-02 05:25:59 +00:00
|
|
|
cf_name = g_strdup(optarg);
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
1999-08-08 01:29:24 +00:00
|
|
|
case 'R': /* Read file filter */
|
1999-08-15 19:18:46 +00:00
|
|
|
rfilter = optarg;
|
1999-08-08 01:29:24 +00:00
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 's': /* Set the snapshot (capture) length */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.has_snaplen = TRUE;
|
|
|
|
capture_opts.snaplen = get_positive_int(optarg, "snapshot length");
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
1999-05-11 18:51:10 +00:00
|
|
|
case 'S': /* "Sync" mode: used for following file ala tail -f */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.sync_mode = TRUE;
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
1999-12-07 07:12:49 +00:00
|
|
|
break;
|
1998-09-27 22:12:47 +00:00
|
|
|
case 't': /* Time stamp type */
|
|
|
|
if (strcmp(optarg, "r") == 0)
|
|
|
|
timestamp_type = RELATIVE;
|
|
|
|
else if (strcmp(optarg, "a") == 0)
|
|
|
|
timestamp_type = ABSOLUTE;
|
2000-11-01 08:31:36 +00:00
|
|
|
else if (strcmp(optarg, "ad") == 0)
|
|
|
|
timestamp_type = ABSOLUTE_WITH_DATE;
|
1998-09-27 22:12:47 +00:00
|
|
|
else if (strcmp(optarg, "d") == 0)
|
|
|
|
timestamp_type = DELTA;
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "ethereal: Invalid time stamp type \"%s\"\n",
|
|
|
|
optarg);
|
|
|
|
fprintf(stderr, "It must be \"r\" for relative, \"a\" for absolute,\n");
|
2000-11-01 08:31:36 +00:00
|
|
|
fprintf(stderr, "\"ad\" for absolute with date, or \"d\" for delta.\n");
|
1998-09-27 22:12:47 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
case 'T': /* Tree view pane height */
|
2001-04-18 05:45:58 +00:00
|
|
|
tv_size = get_positive_int(optarg, "tree view pane height");
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
|
|
|
case 'v': /* Show version and exit */
|
2001-02-20 04:09:37 +00:00
|
|
|
show_version();
|
|
|
|
#ifdef WIN32
|
|
|
|
if (console_was_created)
|
|
|
|
destroy_console();
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
exit(0);
|
|
|
|
break;
|
Add to Wiretap the ability to write capture files; for now, it can only
write them in "libpcap" format, but the mechanism can have other formats
added.
When creating the temporary file for a capture, use "create_tempfile()",
to close a security hole opened by the fact that "tempnam()" creates a
temporary file, but doesn't open it, and we open the file with the name
it gives us - somebody could remove the file and plant a link to some
file, and, if as may well be the case when Ethereal is capturing
packets, it's running as "root", that means we write a capture on top of
that file.... (The aforementioned changes to Wiretap let you open a
capture file for writing given an file descriptor, "fdopen()"-style,
which this change requires.)
svn path=/trunk/; revision=509
1999-08-18 04:17:38 +00:00
|
|
|
case 'w': /* Write to capture file xxx */
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
1999-10-02 06:26:53 +00:00
|
|
|
save_file = g_strdup(optarg);
|
1999-12-07 07:12:49 +00:00
|
|
|
#else
|
|
|
|
capture_option_specified = TRUE;
|
|
|
|
arg_error = TRUE;
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
break;
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-05-22 23:22:56 +00:00
|
|
|
/* This is a hidden option supporting Sync mode, so we don't set
|
|
|
|
* the error flags for the user in the non-libpcap case.
|
|
|
|
*/
|
|
|
|
case 'W': /* Write to capture file FD xxx */
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.save_file_fd = atoi(optarg);
|
1999-12-07 07:12:49 +00:00
|
|
|
break;
|
2002-05-22 23:22:56 +00:00
|
|
|
#endif
|
2002-11-06 10:53:36 +00:00
|
|
|
case 'z':
|
|
|
|
for(tli=tap_list;tli;tli=tli->next){
|
|
|
|
if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){
|
2002-11-10 11:36:39 +00:00
|
|
|
tap_opt = g_strdup(optarg);
|
2002-09-07 10:02:36 +00:00
|
|
|
break;
|
2002-11-06 10:53:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!tli){
|
|
|
|
fprintf(stderr,"ethereal: invalid -z argument.\n");
|
|
|
|
fprintf(stderr," -z argument must be one of :\n");
|
|
|
|
for(tli=tap_list;tli;tli=tli->next){
|
|
|
|
fprintf(stderr," %s\n",tli->cmd);
|
|
|
|
}
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
2000-06-15 08:02:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-05-22 23:22:56 +00:00
|
|
|
/* Hidden option supporting Sync mode */
|
|
|
|
case 'Z': /* Write to pipe FD XXX */
|
2000-06-15 08:02:43 +00:00
|
|
|
/* associate stdout with pipe */
|
|
|
|
i = atoi(optarg);
|
|
|
|
if (dup2(i, 1) < 0) {
|
|
|
|
fprintf(stderr, "Unable to dup pipe handle\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
break;
|
2002-05-22 23:22:56 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
2000-06-15 08:02:43 +00:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
1999-12-07 07:12:49 +00:00
|
|
|
default:
|
1999-10-02 20:00:46 +00:00
|
|
|
case '?': /* Bad flag - print usage message */
|
1999-12-07 07:12:49 +00:00
|
|
|
arg_error = TRUE;
|
1999-10-02 20:00:46 +00:00
|
|
|
break;
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-24 08:46:13 +00:00
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
if (argc >= 1) {
|
|
|
|
if (cf_name != NULL) {
|
|
|
|
/*
|
|
|
|
* Input file name specified with "-r" *and* specified as a regular
|
|
|
|
* command-line argument.
|
|
|
|
*/
|
|
|
|
arg_error = TRUE;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Input file name not specified with "-r", and a command-line argument
|
|
|
|
* was specified; treat it as the input file name.
|
|
|
|
*
|
|
|
|
* Yes, this is different from tethereal, where non-flag command-line
|
|
|
|
* arguments are a filter, but this works better on GUI desktops
|
|
|
|
* where a command can be specified to be run to open a particular
|
|
|
|
* file - yes, you could have "-r" as the last part of the command,
|
|
|
|
* but that's a bit ugly.
|
|
|
|
*/
|
|
|
|
cf_name = g_strdup(argv[0]);
|
|
|
|
}
|
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc != 0) {
|
|
|
|
/*
|
|
|
|
* Extra command line arguments were specified; complain.
|
|
|
|
*/
|
2002-05-22 23:22:56 +00:00
|
|
|
fprintf(stderr, "Invalid argument: %s\n", argv[0]);
|
2001-11-24 08:46:13 +00:00
|
|
|
arg_error = TRUE;
|
|
|
|
}
|
2002-05-22 23:22:56 +00:00
|
|
|
if (arg_error) {
|
|
|
|
print_usage(FALSE);
|
|
|
|
exit(1);
|
|
|
|
}
|
1998-12-29 04:05:38 +00:00
|
|
|
|
2002-01-10 09:51:23 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
if (capture_opts.ringbuffer_on) {
|
2001-12-21 20:33:47 +00:00
|
|
|
/* Ring buffer works only under certain conditions:
|
|
|
|
a) ring buffer does not work with temporary files;
|
2002-02-24 09:25:36 +00:00
|
|
|
b) sync_mode and capture_opts.ringbuffer_on are mutually exclusive -
|
2002-01-10 11:05:50 +00:00
|
|
|
sync_mode takes precedence;
|
2001-12-21 20:33:47 +00:00
|
|
|
c) it makes no sense to enable the ring buffer if the maximum
|
|
|
|
file size is set to "infinite". */
|
2002-09-09 20:39:01 +00:00
|
|
|
if (save_file == NULL) {
|
2001-12-21 20:33:47 +00:00
|
|
|
fprintf(stderr, "ethereal: Ring buffer requested, but capture isn't being saved to a permanent file.\n");
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.ringbuffer_on = FALSE;
|
2001-12-21 20:33:47 +00:00
|
|
|
}
|
2002-02-24 09:25:36 +00:00
|
|
|
if (capture_opts.sync_mode) {
|
2001-12-21 20:33:47 +00:00
|
|
|
fprintf(stderr, "ethereal: Ring buffer requested, but an \"Update list of packets in real time\" capture is being done.\n");
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.ringbuffer_on = FALSE;
|
2001-12-21 20:33:47 +00:00
|
|
|
}
|
2002-02-24 09:25:36 +00:00
|
|
|
if (!capture_opts.has_autostop_filesize) {
|
2001-12-21 20:33:47 +00:00
|
|
|
fprintf(stderr, "ethereal: Ring buffer requested, but no maximum capture file size was specified.\n");
|
2002-02-24 09:25:36 +00:00
|
|
|
capture_opts.ringbuffer_on = FALSE;
|
2001-12-21 20:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-10 09:51:23 +00:00
|
|
|
#endif
|
2001-12-21 20:33:47 +00:00
|
|
|
|
2000-09-14 22:59:08 +00:00
|
|
|
#ifdef WIN32
|
2001-04-03 05:26:27 +00:00
|
|
|
/* Load wpcap if possible */
|
|
|
|
load_wpcap();
|
|
|
|
|
2000-09-14 22:59:08 +00:00
|
|
|
/* Start windows sockets */
|
|
|
|
WSAStartup( MAKEWORD( 1, 1 ), &wsaData );
|
2002-10-09 03:07:34 +00:00
|
|
|
#endif /* WIN32 */
|
2000-09-14 22:59:08 +00:00
|
|
|
|
2000-07-09 03:29:42 +00:00
|
|
|
/* Notify all registered modules that have had any of their preferences
|
|
|
|
changed either from one of the preferences file or from the command
|
2002-07-07 21:52:51 +00:00
|
|
|
line that their preferences have changed. */
|
2000-07-09 03:29:42 +00:00
|
|
|
prefs_apply_all();
|
|
|
|
|
1999-12-07 07:12:49 +00:00
|
|
|
#ifndef HAVE_LIBPCAP
|
|
|
|
if (capture_option_specified)
|
|
|
|
fprintf(stderr, "This version of Ethereal was not built with support for capturing packets.\n");
|
|
|
|
#endif
|
1999-10-02 19:33:14 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
1999-06-15 03:46:46 +00:00
|
|
|
if (start_capture) {
|
2000-01-15 06:05:21 +00:00
|
|
|
/* We're supposed to do a live capture; did the user specify an interface
|
|
|
|
to use? */
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.iface == NULL) {
|
2002-05-22 23:22:56 +00:00
|
|
|
/* No - is a default specified in the preferences file? */
|
|
|
|
if (prefs->capture_device != NULL) {
|
|
|
|
/* Yes - use it. */
|
|
|
|
cfile.iface = g_strdup(prefs->capture_device);
|
|
|
|
} else {
|
|
|
|
/* No - pick the first one from the list of interfaces. */
|
|
|
|
if_list = get_interface_list(&err, err_str);
|
|
|
|
if (if_list == NULL) {
|
|
|
|
switch (err) {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-05-22 23:22:56 +00:00
|
|
|
case CANT_GET_INTERFACE_LIST:
|
|
|
|
fprintf(stderr, "ethereal: Can't get list of interfaces: %s\n",
|
|
|
|
err_str);
|
|
|
|
break;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-05-22 23:22:56 +00:00
|
|
|
case NO_INTERFACES_FOUND:
|
|
|
|
fprintf(stderr, "ethereal: There are no interfaces on which a capture can be done\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
exit(2);
|
2000-01-16 02:48:12 +00:00
|
|
|
}
|
2002-05-22 23:22:56 +00:00
|
|
|
cfile.iface = g_strdup(if_list->data); /* first interface */
|
|
|
|
free_interface_list(if_list);
|
2000-01-15 06:05:21 +00:00
|
|
|
}
|
1999-06-15 03:46:46 +00:00
|
|
|
}
|
1999-10-02 06:00:07 +00:00
|
|
|
}
|
|
|
|
if (capture_child) {
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.save_file_fd == -1) {
|
1999-10-02 06:00:07 +00:00
|
|
|
/* XXX - send this to the standard output as something our parent
|
|
|
|
should put in an error message box? */
|
|
|
|
fprintf(stderr, "%s: \"-W\" flag not specified\n", CHILD_NAME);
|
|
|
|
exit(1);
|
Add to Wiretap the ability to write capture files; for now, it can only
write them in "libpcap" format, but the mechanism can have other formats
added.
When creating the temporary file for a capture, use "create_tempfile()",
to close a security hole opened by the fact that "tempnam()" creates a
temporary file, but doesn't open it, and we open the file with the name
it gives us - somebody could remove the file and plant a link to some
file, and, if as may well be the case when Ethereal is capturing
packets, it's running as "root", that means we write a capture on top of
that file.... (The aforementioned changes to Wiretap let you open a
capture file for writing given an file descriptor, "fdopen()"-style,
which this change requires.)
svn path=/trunk/; revision=509
1999-08-18 04:17:38 +00:00
|
|
|
}
|
1999-06-15 03:46:46 +00:00
|
|
|
}
|
1999-10-02 06:00:07 +00:00
|
|
|
#endif
|
1999-06-15 03:46:46 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Build the column format array */
|
2002-07-07 21:52:51 +00:00
|
|
|
col_init(&cfile.cinfo, prefs->num_cols);
|
2000-06-27 04:36:03 +00:00
|
|
|
for (i = 0; i < cfile.cinfo.num_cols; i++) {
|
|
|
|
cfile.cinfo.col_fmt[i] = get_column_format(i);
|
|
|
|
cfile.cinfo.col_title[i] = g_strdup(get_column_title(i));
|
|
|
|
cfile.cinfo.fmt_matx[i] = (gboolean *) g_malloc0(sizeof(gboolean) *
|
1998-12-29 04:05:38 +00:00
|
|
|
NUM_COL_FMTS);
|
2000-06-27 04:36:03 +00:00
|
|
|
get_column_format_matches(cfile.cinfo.fmt_matx[i], cfile.cinfo.col_fmt[i]);
|
2000-11-19 08:54:37 +00:00
|
|
|
cfile.cinfo.col_data[i] = NULL;
|
2000-06-27 04:36:03 +00:00
|
|
|
if (cfile.cinfo.col_fmt[i] == COL_INFO)
|
2000-11-19 08:54:37 +00:00
|
|
|
cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
|
1999-10-15 20:33:06 +00:00
|
|
|
else
|
2000-11-19 08:54:37 +00:00
|
|
|
cfile.cinfo.col_buf[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
2002-01-11 08:21:02 +00:00
|
|
|
cfile.cinfo.col_expr[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
|
|
|
cfile.cinfo.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
|
1998-12-29 04:05:38 +00:00
|
|
|
}
|
|
|
|
|
2002-01-10 09:51:23 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2002-02-24 09:25:36 +00:00
|
|
|
if (capture_opts.has_snaplen) {
|
|
|
|
if (capture_opts.snaplen < 1)
|
|
|
|
capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
|
|
|
|
else if (capture_opts.snaplen < MIN_PACKET_SIZE)
|
|
|
|
capture_opts.snaplen = MIN_PACKET_SIZE;
|
Have Wiretap set the snapshot length to 0 if it can't be derived from
reading the capture file. Have callers of "wtap_snapshot_length()"
treat a value of 0 as "unknown", and default to WTAP_MAX_PACKET_SIZE (so
that, when writing a capture file in a format that *does* store the
snapshot length, we can at least put *something* in the file).
If we don't know the snapshot length of the current capture file, don't
display a value in the summary window.
Don't use "cfile.snap" as the snapshot length option when capturing -
doing so causes Ethereal to default, when capturing, to the snapshot
length of the last capture file that you read in, rather than to the
snapshot length of the last capture you did (or the initial default of
"no snapshot length").
Redo the "Capture Options" dialog box to group options into sections
with frames around them, and add units to the snapshot length, maximum
file size, and capture duration options, as per a suggestion by Ulf
Lamping. Also add units to the capture count option.
Make the snapshot length, capture count, maximum file size, and capture
duration options into a combination of a check box and a spin button.
If the check box is not checked, the limit in question is inactive
(snapshot length of 65535, no max packet count, no max file size, no max
capture duration); if it's checked, the spinbox specifies the limit.
Default all of the check boxes to "not checked" and all of the spin
boxes to small values.
Use "gtk_toggle_button_get_active()" rather than directly fetching the
state of a check box.
svn path=/trunk/; revision=4709
2002-02-08 10:07:41 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-04 08:26:00 +00:00
|
|
|
/* Check the value range of the ringbuffer_num_files parameter */
|
2002-02-24 09:25:36 +00:00
|
|
|
if (capture_opts.ringbuffer_num_files < RINGBUFFER_MIN_NUM_FILES)
|
|
|
|
capture_opts.ringbuffer_num_files = RINGBUFFER_MIN_NUM_FILES;
|
|
|
|
else if (capture_opts.ringbuffer_num_files > RINGBUFFER_MAX_NUM_FILES)
|
|
|
|
capture_opts.ringbuffer_num_files = RINGBUFFER_MAX_NUM_FILES;
|
2002-01-10 09:51:23 +00:00
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-10-24 07:18:39 +00:00
|
|
|
rc_file = get_persconffile_path(RC_FILE, FALSE);
|
1998-09-16 02:39:15 +00:00
|
|
|
gtk_rc_parse(rc_file);
|
|
|
|
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
/* Try to load the regular and boldface fixed-width fonts */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
bold_font_name = boldify(prefs->gui_font_name);
|
|
|
|
m_r_font = gdk_font_load(prefs->gui_font_name);
|
|
|
|
m_b_font = gdk_font_load(bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
m_r_font = pango_font_description_from_string(prefs->gui_font_name);
|
|
|
|
m_b_font = pango_font_description_copy(m_r_font);
|
|
|
|
pango_font_description_set_weight(m_b_font, PANGO_WEIGHT_BOLD);
|
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
if (m_r_font == NULL || m_b_font == NULL) {
|
2000-08-20 15:38:50 +00:00
|
|
|
/* XXX - pop this up as a dialog box? no */
|
|
|
|
if (m_r_font == NULL) {
|
2000-08-21 01:52:57 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
if (!capture_child)
|
|
|
|
#endif
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-20 15:38:50 +00:00
|
|
|
fprintf(stderr, "ethereal: Warning: font %s not found - defaulting to 6x13 and 6x13bold\n",
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
fprintf(stderr, "ethereal: Warning: font %s not found - defaulting to Monospace 9\n",
|
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
prefs->gui_font_name);
|
2000-08-20 15:38:50 +00:00
|
|
|
} else {
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
gdk_font_unref(m_r_font);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
pango_font_description_free(m_r_font);
|
|
|
|
#endif
|
2000-08-20 15:38:50 +00:00
|
|
|
}
|
|
|
|
if (m_b_font == NULL) {
|
2000-08-21 01:52:57 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2000-08-20 15:38:50 +00:00
|
|
|
if (!capture_child)
|
2000-08-21 01:52:57 +00:00
|
|
|
#endif
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-20 15:38:50 +00:00
|
|
|
fprintf(stderr, "ethereal: Warning: font %s not found - defaulting to 6x13 and 6x13bold\n",
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
fprintf(stderr, "ethereal: Warning: bold font %s not found - defaulting"
|
|
|
|
" to Monospace 9\n", prefs->gui_font_name);
|
|
|
|
#endif
|
2000-08-20 15:38:50 +00:00
|
|
|
} else {
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
gdk_font_unref(m_b_font);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
pango_font_description_free(m_b_font);
|
|
|
|
#endif
|
2000-08-20 15:38:50 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
g_free(bold_font_name);
|
|
|
|
if ((m_r_font = gdk_font_load("6x13")) == NULL) {
|
|
|
|
fprintf(stderr, "ethereal: Error: font 6x13 not found\n");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
if ((m_r_font = pango_font_description_from_string("Monospace 9")) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "ethereal: Error: font Monospace 9 not found\n");
|
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
if ((m_b_font = gdk_font_load("6x13bold")) == NULL) {
|
2000-08-20 15:38:50 +00:00
|
|
|
fprintf(stderr, "ethereal: Error: font 6x13bold not found\n");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
if ((m_b_font = pango_font_description_copy(m_r_font)) == NULL) {
|
|
|
|
fprintf(stderr, "ethereal: Error: font Monospace 9 bold not found\n");
|
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2000-08-23 21:05:11 +00:00
|
|
|
g_free(prefs->gui_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-23 21:05:11 +00:00
|
|
|
prefs->gui_font_name = g_strdup("6x13");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
pango_font_description_set_weight(m_b_font, PANGO_WEIGHT_BOLD);
|
|
|
|
prefs->gui_font_name = g_strdup("Monospace 9");
|
|
|
|
#endif
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
|
|
|
|
2001-03-02 23:10:12 +00:00
|
|
|
/* Call this for the side-effects that set_fonts() produces */
|
|
|
|
set_fonts(m_r_font, m_b_font);
|
|
|
|
|
2000-01-15 12:54:24 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
/* Is this a "child" ethereal, which is only supposed to pop up a
|
|
|
|
capture box to let us stop the capture, and run a capture
|
|
|
|
to a file that our parent will read? */
|
|
|
|
if (!capture_child) {
|
|
|
|
#endif
|
|
|
|
/* No. Pop up the main window, and read in a capture file if
|
|
|
|
we were told to. */
|
|
|
|
|
2001-03-02 17:44:07 +00:00
|
|
|
create_main_window(pl_size, tv_size, bv_size, prefs);
|
2000-01-25 13:44:39 +00:00
|
|
|
set_menus_for_capture_file(FALSE);
|
2000-01-15 12:54:24 +00:00
|
|
|
|
2002-11-10 11:36:39 +00:00
|
|
|
/* open tap windows after creating the main window to avoid GTK warnings */
|
2002-11-10 11:41:45 +00:00
|
|
|
if (tap_opt && tli) {
|
|
|
|
(*tli->func)(tap_opt);
|
2002-11-10 11:36:39 +00:00
|
|
|
g_free(tap_opt);
|
|
|
|
}
|
|
|
|
|
2003-01-08 01:59:42 +00:00
|
|
|
colors_init();
|
2002-05-27 22:00:37 +00:00
|
|
|
colfilter_init();
|
2000-01-15 12:54:24 +00:00
|
|
|
|
|
|
|
/* If we were given the name of a capture file, read it in now;
|
|
|
|
we defer it until now, so that, if we can't open it, and pop
|
|
|
|
up an alert box, the alert box is more likely to come up on
|
|
|
|
top of the main window - but before the preference-file-error
|
|
|
|
alert box, so, if we get one of those, it's more likely to come
|
|
|
|
up on top of us. */
|
|
|
|
if (cf_name) {
|
|
|
|
if (rfilter != NULL) {
|
2001-02-01 20:21:25 +00:00
|
|
|
if (!dfilter_compile(rfilter, &rfcode)) {
|
2000-07-20 05:10:02 +00:00
|
|
|
simple_dialog(ESD_TYPE_CRIT, NULL, dfilter_error_msg);
|
2000-01-15 12:54:24 +00:00
|
|
|
rfilter_parse_failed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!rfilter_parse_failed) {
|
2000-06-27 04:36:03 +00:00
|
|
|
if ((err = open_cap_file(cf_name, FALSE, &cfile)) == 0) {
|
2000-01-15 12:54:24 +00:00
|
|
|
/* "open_cap_file()" succeeded, so it closed the previous
|
|
|
|
capture file, and thus destroyed any previous read filter
|
|
|
|
attached to "cf". */
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.rfcode = rfcode;
|
Add routines to Wiretap to allow a client of Wiretap to get:
a pointer to the "wtap_pkthdr" structure for an open capture
file;
a pointer to the "wtap_pseudo_header" union for an open capture
file;
a pointer to the packet buffer for an open capture file;
so that a program using "wtap_read()" in a loop can get at those items.
Keep, in a "capture_file" structure, an indicator of whether:
no file is open;
a file is open, and being read;
a file is open, and is being read, but the user tried to quit
out of reading the file (e.g., by doing "File/Quit");
a file is open, and has been completely read.
Abort if we try to close a capture that's being read if the user hasn't
tried to quit out of the read.
Have "File/Quit" check if a file is being read; if so, just set the
state indicator to "user tried to quit out of it", so that the code
reading the file can do what's appropriate to clean up, rather than
closing the file out from under that code and causing crashes.
Have "read_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
close the capture and return an indication that the read was aborted by
the user. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "continue_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
return an indication that the read was aborted by the user if that
happened. Otherwise, return an indication of whether the read
completely succeeded or failed in the middle (and, if it failed, return
the error code through a pointer).
Have "finish_tail_cap_file()" read the capture file with a loop using
"wtap_read()", rather than by using "wtap_loop()"; have it check after
reading each packet whether the user tried to abort the read and, if so,
quit the loop, and after the loop finishes (even if it read no packets),
close the capture and return an indication that the read was aborted by
the user if that happened. Otherwise, return an indication of whether
the read completely succeeded or failed in the middle (and, if it
failed, return the error code through a pointer).
Have their callers check whether the read was aborted or not and, if it
was, bail out in the appropriate fashion (exit if it's reading a file
specified by "-r" on the command line; exit the main loop if it's
reading a file specified with File->Open; kill the capture child if it's
"continue_tail_cap_file()"; exit the main loop if it's
"finish_tail_cap_file()".
svn path=/trunk/; revision=2095
2000-06-27 07:13:42 +00:00
|
|
|
switch (read_cap_file(&cfile, &err)) {
|
|
|
|
|
|
|
|
case READ_SUCCESS:
|
|
|
|
case READ_ERROR:
|
|
|
|
/* Just because we got an error, that doesn't mean we were unable
|
|
|
|
to read any of the file; we handle what we could get from the
|
|
|
|
file. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case READ_ABORTED:
|
|
|
|
/* Exit now. */
|
|
|
|
gtk_exit(0);
|
|
|
|
break;
|
|
|
|
}
|
2000-01-25 05:48:47 +00:00
|
|
|
/* Save the name of the containing directory specified in the
|
|
|
|
path name, if any; we can write over cf_name, which is a
|
|
|
|
good thing, given that "get_dirname()" does write over its
|
|
|
|
argument. */
|
|
|
|
s = get_dirname(cf_name);
|
2001-04-09 22:35:23 +00:00
|
|
|
set_last_open_dir(s);
|
2002-09-09 20:39:01 +00:00
|
|
|
g_free(cf_name);
|
|
|
|
cf_name = NULL;
|
2000-01-15 12:54:24 +00:00
|
|
|
} else {
|
2001-02-08 03:55:45 +00:00
|
|
|
if (rfcode != NULL)
|
|
|
|
dfilter_free(rfcode);
|
2000-06-27 04:36:03 +00:00
|
|
|
cfile.rfcode = NULL;
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
/* If the global preferences file exists but we failed to open it,
|
|
|
|
pop up an alert box; we defer that until now, so that the alert
|
|
|
|
box is more likely to come up on top of the main window. */
|
|
|
|
if (gpf_path != NULL) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, NULL,
|
|
|
|
"Could not open global preferences file\n\"%s\": %s.", gpf_path,
|
|
|
|
strerror(gpf_open_errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the user's preferences file exists but we failed to open it,
|
|
|
|
pop up an alert box; we defer that until now, so that the alert
|
|
|
|
box is more likely to come up on top of the main window. */
|
2000-01-15 12:54:24 +00:00
|
|
|
if (pf_path != NULL) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, NULL,
|
Add support for a global "ethereal.conf" preferences file, stored in the
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most
likely).
Add a mechanism to allow modules (e.g., dissectors) to register
preference values, which:
can be put into the global or the user's preference file;
can be set from the command line, with arguments to the "-o"
flag;
can be set from tabs in the "Preferences" dialog box.
Use that mechanism to register the "Decode IPv4 TOS field as DiffServ
field" variable for IP as a preference.
Stuff that still needs to be done:
documenting the API for registering preferences;
documenting the "-o" values in the man page (probably needs a
flag similar to "-G", and a Perl script to turn the output into
documentation as is done with the list of field);
handling error checking for numeric values (range checking,
making sure that if the user changes the variable from the GUI
they change it to a valid numeric value);
using the callbacks to, for example, update the display when
preferences are changed (could be expensive);
panic if the user specifies a numeric value with a base other
than 10, 8, or 16.
We may also want to clean up the existing wired-in preferences not to
take effect the instant you tweak the widget, and to add an "Apply"
button to the "Preferences" dialog.
svn path=/trunk/; revision=2117
2000-07-05 09:41:07 +00:00
|
|
|
"Could not open your preferences file\n\"%s\": %s.", pf_path,
|
2000-01-15 12:54:24 +00:00
|
|
|
strerror(pf_open_errno));
|
2002-08-01 03:15:29 +00:00
|
|
|
g_free(pf_path);
|
|
|
|
pf_path = NULL;
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
|
|
|
|
Have separate capture and display filter lists; some filter dialog boxes
use the capture filter lists, and others use the display filter list, as
appropriate.
Have separate menu items for editing the capture and display filter
lists.
Have separate "~/.ethereal/cfilters" and "~/.ethereal/dfilters" files
for the two lists; if either of those files isn't found, we try
"~/.ethereal/filters", which means that you will start out with two
identical lists holding all your filters - if certain filters belong
only in one list, you'll have to delete them by hand from the other
list.
Do I/O error checking when reading and writing filter lists; when
writing a filter list, write it to a new file, and then rename the new
file on top of the old file, so that you don't lose your old filter list
if, for example, you run out of disk space or disk quota.
svn path=/trunk/; revision=2948
2001-01-28 09:13:10 +00:00
|
|
|
/* If the user's capture filter file exists but we failed to open it,
|
|
|
|
pop up an alert box; we defer that until now, so that the alert
|
|
|
|
box is more likely to come up on top of the main window. */
|
|
|
|
if (cf_path != NULL) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, NULL,
|
|
|
|
"Could not open your capture filter file\n\"%s\": %s.", cf_path,
|
|
|
|
strerror(cf_open_errno));
|
|
|
|
g_free(cf_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the user's display filter file exists but we failed to open it,
|
|
|
|
pop up an alert box; we defer that until now, so that the alert
|
|
|
|
box is more likely to come up on top of the main window. */
|
|
|
|
if (df_path != NULL) {
|
|
|
|
simple_dialog(ESD_TYPE_WARN, NULL,
|
|
|
|
"Could not open your display filter file\n\"%s\": %s.", df_path,
|
|
|
|
strerror(df_open_errno));
|
|
|
|
g_free(df_path);
|
|
|
|
}
|
|
|
|
|
2000-01-15 12:54:24 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
if (capture_child) {
|
|
|
|
/* This is the child process for a sync mode or fork mode capture,
|
|
|
|
so just do the low-level work of a capture - don't create
|
|
|
|
a temporary file and fork off *another* child process (so don't
|
|
|
|
call "do_capture()"). */
|
|
|
|
|
2001-02-11 09:28:17 +00:00
|
|
|
/* XXX - hand these stats to the parent process */
|
|
|
|
capture(&stats_known, &stats);
|
2000-01-15 12:54:24 +00:00
|
|
|
|
|
|
|
/* The capture is done; there's nothing more for us to do. */
|
|
|
|
gtk_exit(0);
|
|
|
|
} else {
|
|
|
|
if (start_capture) {
|
|
|
|
/* "-k" was specified; start a capture. */
|
|
|
|
do_capture(save_file);
|
2002-09-09 20:39:01 +00:00
|
|
|
if (save_file != NULL) {
|
|
|
|
/* Save the directory name for future file dialogs. */
|
|
|
|
s = get_dirname(save_file); /* Overwrites save_file */
|
|
|
|
set_last_open_dir(s);
|
|
|
|
g_free(save_file);
|
|
|
|
save_file = NULL;
|
|
|
|
}
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
2000-01-25 13:44:39 +00:00
|
|
|
else {
|
Exit from Ethereal by making the main loop exit, so that any quit
routines we register get called.
Register the "follow TCP stream" windows with "gtk_quit_add_destroy()",
so that, when Ethereal exits, they all get destroyed; this means that
their destroy callbacks get called, which means that they get to delete
their temporary files, so that, if you exit Ethereal without manually
closing the "follow TCP stream" windows, the temporary files don't get
left around.
Exit from Ethereal's "main()" function by calling "gtk_exit()", rather
than "exit()", so that we do whatever cleanup GTK+ requires. (We used
to call "gtk_exit()" in the callback for the "File:Quit" menu item and
the "delete" callback for the main window, but we now just call
"gtk_main_quit()" so that we exit from the main loop.)
svn path=/trunk/; revision=1772
2000-04-01 10:23:01 +00:00
|
|
|
set_menus_for_capture_in_progress(FALSE);
|
2000-01-25 13:44:39 +00:00
|
|
|
}
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
2000-01-25 17:57:31 +00:00
|
|
|
#else
|
|
|
|
set_menus_for_capture_in_progress(FALSE);
|
2000-01-15 12:54:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gtk_main();
|
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
/* Try to save our geometry. GTK+ provides two routines to get a
|
|
|
|
window's position relative to the X root window. If I understand the
|
|
|
|
documentation correctly, gdk_window_get_deskrelative_origin applies
|
|
|
|
mainly to Enlightenment and gdk_window_get_root_origin applies for
|
|
|
|
all other WMs.
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
The code below tries both routines, and picks the one that returns
|
|
|
|
the upper-left-most coordinates.
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
More info at:
|
|
|
|
|
|
|
|
http://mail.gnome.org/archives/gtk-devel-list/2001-March/msg00289.html
|
|
|
|
http://www.gtk.org/faq/#AEN600 */
|
|
|
|
|
|
|
|
/* Re-read our saved preferences. */
|
|
|
|
/* XXX - Move all of this into a separate function? */
|
|
|
|
prefs = read_prefs(&gpf_open_errno, &gpf_path, &pf_open_errno, &pf_path);
|
|
|
|
|
|
|
|
if (pf_path == NULL) {
|
|
|
|
if (prefs->gui_geometry_save_position) {
|
|
|
|
if (top_level->window != NULL) {
|
|
|
|
gdk_window_get_root_origin(top_level->window, &root_x, &root_y);
|
|
|
|
if (gdk_window_get_deskrelative_origin(top_level->window,
|
|
|
|
&desk_x, &desk_y)) {
|
|
|
|
if (desk_x <= root_x && desk_y <= root_y) {
|
|
|
|
root_x = desk_x;
|
|
|
|
root_y = desk_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (prefs->gui_geometry_main_x != root_x) {
|
|
|
|
prefs->gui_geometry_main_x = root_x;
|
|
|
|
prefs_write_needed = TRUE;
|
|
|
|
}
|
|
|
|
if (prefs->gui_geometry_main_y != root_y) {
|
|
|
|
prefs->gui_geometry_main_y = root_y;
|
|
|
|
prefs_write_needed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
if (prefs->gui_geometry_save_size) {
|
|
|
|
if (top_level->window != NULL) {
|
|
|
|
/* XXX - Is this the "approved" method? */
|
|
|
|
gdk_window_get_size(top_level->window, &top_width, &top_height);
|
|
|
|
}
|
|
|
|
if (prefs->gui_geometry_main_width != top_width) {
|
|
|
|
prefs->gui_geometry_main_width = top_width;
|
|
|
|
prefs_write_needed = TRUE;
|
|
|
|
}
|
|
|
|
if (prefs->gui_geometry_main_height != top_height) {
|
|
|
|
prefs->gui_geometry_main_height = top_height;
|
|
|
|
prefs_write_needed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
if (prefs_write_needed) {
|
|
|
|
write_prefs(&pf_path);
|
|
|
|
}
|
2002-08-01 03:15:29 +00:00
|
|
|
} else {
|
|
|
|
/* Ignore errors silently */
|
|
|
|
g_free(pf_path);
|
2001-12-31 04:41:50 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-09-27 04:55:05 +00:00
|
|
|
epan_cleanup();
|
2000-01-15 12:54:24 +00:00
|
|
|
g_free(rc_file);
|
|
|
|
|
2000-09-14 22:59:08 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
/* Shutdown windows sockets */
|
|
|
|
WSACleanup();
|
2001-02-20 04:09:37 +00:00
|
|
|
|
|
|
|
/* For some unknown reason, the "atexit()" call in "create_console()"
|
|
|
|
doesn't arrange that "destroy_console()" be called when we exit,
|
|
|
|
so we call it here if a console was created. */
|
|
|
|
if (console_was_created)
|
|
|
|
destroy_console();
|
2000-09-14 22:59:08 +00:00
|
|
|
#endif
|
|
|
|
|
Exit from Ethereal by making the main loop exit, so that any quit
routines we register get called.
Register the "follow TCP stream" windows with "gtk_quit_add_destroy()",
so that, when Ethereal exits, they all get destroyed; this means that
their destroy callbacks get called, which means that they get to delete
their temporary files, so that, if you exit Ethereal without manually
closing the "follow TCP stream" windows, the temporary files don't get
left around.
Exit from Ethereal's "main()" function by calling "gtk_exit()", rather
than "exit()", so that we do whatever cleanup GTK+ requires. (We used
to call "gtk_exit()" in the callback for the "File:Quit" menu item and
the "delete" callback for the main window, but we now just call
"gtk_main_quit()" so that we exit from the main loop.)
svn path=/trunk/; revision=1772
2000-04-01 10:23:01 +00:00
|
|
|
gtk_exit(0);
|
|
|
|
|
|
|
|
/* This isn't reached, but we need it to keep GCC from complaining
|
|
|
|
that "main()" returns without returning a value - it knows that
|
|
|
|
"exit()" never returns, but it doesn't know that "gtk_exit()"
|
|
|
|
doesn't, as GTK+ doesn't declare it with the attribute
|
|
|
|
"noreturn". */
|
|
|
|
return 0; /* not reached */
|
2000-01-15 12:54:24 +00:00
|
|
|
}
|
|
|
|
|
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
/* We build this as a GUI subsystem application on Win32, so
|
|
|
|
"WinMain()", not "main()", gets called.
|
|
|
|
|
|
|
|
Hack shamelessly stolen from the Win32 port of the GIMP. */
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define _stdcall __attribute__((stdcall))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int _stdcall
|
|
|
|
WinMain (struct HINSTANCE__ *hInstance,
|
|
|
|
struct HINSTANCE__ *hPrevInstance,
|
|
|
|
char *lpszCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
2001-02-20 04:09:37 +00:00
|
|
|
has_no_console = TRUE;
|
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
|
|
|
return main (__argc, __argv);
|
|
|
|
}
|
|
|
|
|
2001-02-20 04:09:37 +00:00
|
|
|
/*
|
|
|
|
* If this application has no console window to which its standard output
|
|
|
|
* would go, create one.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
create_console(void)
|
|
|
|
{
|
|
|
|
if (has_no_console) {
|
|
|
|
/* We have no console to which to print the version string, so
|
|
|
|
create one and make it the standard input, output, and error. */
|
|
|
|
if (!AllocConsole())
|
|
|
|
return; /* couldn't create console */
|
|
|
|
freopen("CONIN$", "r", stdin);
|
|
|
|
freopen("CONOUT$", "w", stdout);
|
|
|
|
freopen("CONOUT$", "w", stderr);
|
|
|
|
|
|
|
|
/* Well, we have a console now. */
|
|
|
|
has_no_console = FALSE;
|
|
|
|
console_was_created = TRUE;
|
|
|
|
|
|
|
|
/* Now register "destroy_console()" as a routine to be called just
|
|
|
|
before the application exits, so that we can destroy the console
|
|
|
|
after the user has typed a key (so that the console doesn't just
|
|
|
|
disappear out from under them, giving the user no chance to see
|
|
|
|
the message(s) we put in there). */
|
|
|
|
atexit(destroy_console);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_console(void)
|
|
|
|
{
|
|
|
|
printf("\n\nPress any key to exit\n");
|
|
|
|
_getch();
|
|
|
|
FreeConsole();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This routine should not be necessary, at least as I read the GLib
|
|
|
|
source code, as it looks as if GLib is, on Win32, *supposed* to
|
|
|
|
create a console window into which to display its output.
|
|
|
|
|
|
|
|
That doesn't happen, however. I suspect there's something completely
|
|
|
|
broken about that code in GLib-for-Win32, and that it may be related
|
|
|
|
to the breakage that forces us to just call "printf()" on the message
|
|
|
|
rather than passing the message on to "g_log_default_handler()"
|
|
|
|
(which is the routine that does the aforementioned non-functional
|
|
|
|
console window creation). */
|
|
|
|
static void
|
|
|
|
console_log_handler(const char *log_domain, GLogLevelFlags log_level,
|
|
|
|
const char *message, gpointer user_data)
|
|
|
|
{
|
|
|
|
create_console();
|
|
|
|
if (console_was_created) {
|
|
|
|
/* For some unknown reason, the above doesn't appear to actually cause
|
|
|
|
anything to be sent to the standard output, so we'll just splat the
|
|
|
|
message out directly, just to make sure it gets out. */
|
|
|
|
printf("%s\n", message);
|
|
|
|
} else
|
|
|
|
g_log_default_handler(log_domain, log_level, message, user_data);
|
|
|
|
}
|
On Win32, build Ethereal as a Windows-subsystem program rather than a
console-subsystem program, so that when not run from a shell window it
doesn't cause a shell window to be popped up. (Yes, this means that any
messages it prints, when not popped up from a shell window, get lost,
but the same is true of Ethereal on UNIX/X.) Trick for doing this
shamelessly stolen from the Win32 port of the GIMP.
We do not want to build Tethereal or editcap as Windows-subsystem
programs, however, so we take the "/SUBSYSTEM" flag out of LDFLAGS and
put it into the link commands for Ethereal, Tethereal, and editcap.
svn path=/trunk/; revision=1857
2000-04-14 09:00:25 +00:00
|
|
|
#endif
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
/* Given a font name, construct the name of the next heavier version of
|
|
|
|
that font. */
|
|
|
|
|
|
|
|
#define XLFD_WEIGHT 3 /* index of the "weight" field */
|
|
|
|
|
|
|
|
/* Map from a given weight to the appropriate weight for the "bold"
|
|
|
|
version of a font.
|
|
|
|
XXX - the XLFD says these strings shouldn't be used for font matching;
|
|
|
|
can we get the weight, as a number, from GDK, and ask GDK to find us
|
|
|
|
a font just like the given font, but with the appropriate higher
|
|
|
|
weight? */
|
|
|
|
static const struct {
|
|
|
|
char *light;
|
|
|
|
char *heavier;
|
|
|
|
} weight_map[] = {
|
|
|
|
{ "ultralight", "light" },
|
|
|
|
{ "extralight", "semilight" },
|
|
|
|
{ "light", "medium" },
|
|
|
|
{ "semilight", "semibold" },
|
|
|
|
{ "medium", "bold" },
|
2000-08-20 09:02:29 +00:00
|
|
|
{ "normal", "bold" },
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
{ "semibold", "extrabold" },
|
|
|
|
{ "bold", "ultrabold" }
|
|
|
|
};
|
|
|
|
#define N_WEIGHTS (sizeof weight_map / sizeof weight_map[0])
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-09-08 10:59:21 +00:00
|
|
|
char *
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
boldify(const char *font_name)
|
|
|
|
{
|
|
|
|
char *bold_font_name;
|
|
|
|
gchar **xlfd_tokens;
|
2001-04-24 00:28:21 +00:00
|
|
|
unsigned int i;
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
/* Is this an XLFD font? If it begins with "-", yes, otherwise no. */
|
|
|
|
if (font_name[0] == '-') {
|
|
|
|
xlfd_tokens = g_strsplit(font_name, "-", XLFD_WEIGHT+1);
|
2002-05-30 00:44:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we *have* a weight (this might not be a valid
|
|
|
|
* XLFD font name).
|
|
|
|
*/
|
|
|
|
for (i = 0; i < XLFD_WEIGHT+1; i++) {
|
|
|
|
if (xlfd_tokens[i] == NULL) {
|
|
|
|
/*
|
|
|
|
* We don't, so treat this as a non-XLFD
|
|
|
|
* font name.
|
|
|
|
*/
|
|
|
|
goto not_xlfd;
|
|
|
|
}
|
|
|
|
}
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
for (i = 0; i < N_WEIGHTS; i++) {
|
|
|
|
if (strcmp(xlfd_tokens[XLFD_WEIGHT],
|
|
|
|
weight_map[i].light) == 0) {
|
|
|
|
g_free(xlfd_tokens[XLFD_WEIGHT]);
|
|
|
|
xlfd_tokens[XLFD_WEIGHT] =
|
|
|
|
g_strdup(weight_map[i].heavier);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bold_font_name = g_strjoinv("-", xlfd_tokens);
|
|
|
|
g_strfreev(xlfd_tokens);
|
2002-05-30 00:44:50 +00:00
|
|
|
return bold_font_name;
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
}
|
2002-05-30 00:44:50 +00:00
|
|
|
|
|
|
|
not_xlfd:
|
|
|
|
/*
|
|
|
|
* This isn't an XLFD font name; just append "bold" to the name
|
|
|
|
* of the font.
|
|
|
|
*/
|
|
|
|
bold_font_name = g_strconcat(font_name, "bold", NULL);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
return bold_font_name;
|
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2001-03-02 23:10:12 +00:00
|
|
|
|
2000-01-15 12:54:24 +00:00
|
|
|
static void
|
|
|
|
create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_vbox, *menubar, *u_pane, *l_pane,
|
|
|
|
*stat_hbox, *column_lb,
|
|
|
|
*filter_bt, *filter_cm, *filter_te,
|
|
|
|
*filter_apply,
|
|
|
|
*filter_reset;
|
|
|
|
GList *filter_list = NULL;
|
|
|
|
GtkAccelGroup *accel;
|
|
|
|
GtkStyle *win_style;
|
|
|
|
GdkBitmap *ascend_bm, *descend_bm;
|
|
|
|
GdkPixmap *ascend_pm, *descend_pm;
|
|
|
|
column_arrows *col_arrows;
|
|
|
|
int i;
|
|
|
|
/* Display filter construct dialog has an Apply button, and "OK" not
|
|
|
|
only sets our text widget, it activates it (i.e., it causes us to
|
|
|
|
filter the capture). */
|
|
|
|
static construct_args_t args = {
|
|
|
|
"Ethereal: Display Filter",
|
|
|
|
TRUE,
|
|
|
|
TRUE
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Main window */
|
|
|
|
top_level = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_widget_set_name(top_level, "main window");
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(top_level, "delete_event", main_window_delete_event_cb,
|
|
|
|
NULL);
|
|
|
|
SIGNAL_CONNECT(top_level, "realize", window_icon_realize_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(top_level), "The Ethereal Network Analyzer");
|
|
|
|
if (prefs->gui_geometry_save_position) {
|
|
|
|
gtk_widget_set_uposition(GTK_WIDGET(top_level),
|
|
|
|
prefs->gui_geometry_main_x,
|
|
|
|
prefs->gui_geometry_main_y);
|
|
|
|
}
|
|
|
|
if (prefs->gui_geometry_save_size) {
|
2002-11-10 11:36:39 +00:00
|
|
|
WIDGET_SET_SIZE(top_level, prefs->gui_geometry_main_width,
|
|
|
|
prefs->gui_geometry_main_height);
|
2002-11-03 17:38:45 +00:00
|
|
|
} else {
|
2002-11-10 11:36:39 +00:00
|
|
|
WIDGET_SET_SIZE(top_level, DEF_WIDTH, -1);
|
2002-11-03 17:38:45 +00:00
|
|
|
}
|
|
|
|
gtk_window_set_policy(GTK_WINDOW(top_level), TRUE, TRUE, FALSE);
|
|
|
|
|
|
|
|
/* Container for menu bar, paned windows and progress/info box */
|
|
|
|
main_vbox = gtk_vbox_new(FALSE, 1);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vbox), 1);
|
|
|
|
gtk_container_add(GTK_CONTAINER(top_level), main_vbox);
|
|
|
|
gtk_widget_show(main_vbox);
|
|
|
|
|
|
|
|
/* Menu bar */
|
|
|
|
get_main_menu(&menubar, &accel);
|
|
|
|
gtk_window_add_accel_group(GTK_WINDOW(top_level), accel);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), menubar, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(menubar);
|
|
|
|
|
|
|
|
/* Panes for the packet list, tree, and byte view */
|
|
|
|
u_pane = gtk_vpaned_new();
|
|
|
|
gtk_paned_gutter_size(GTK_PANED(u_pane), (GTK_PANED(u_pane))->handle_size);
|
|
|
|
l_pane = gtk_vpaned_new();
|
|
|
|
gtk_paned_gutter_size(GTK_PANED(l_pane), (GTK_PANED(l_pane))->handle_size);
|
|
|
|
gtk_container_add(GTK_CONTAINER(main_vbox), u_pane);
|
|
|
|
gtk_widget_show(l_pane);
|
|
|
|
gtk_paned_add2(GTK_PANED(u_pane), l_pane);
|
|
|
|
gtk_widget_show(u_pane);
|
|
|
|
|
|
|
|
/* Packet list */
|
|
|
|
pkt_scrollw = scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(pkt_scrollw),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_widget_show(pkt_scrollw);
|
|
|
|
gtk_paned_add1(GTK_PANED(u_pane), pkt_scrollw);
|
|
|
|
|
|
|
|
packet_list = gtk_clist_new(cfile.cinfo.num_cols);
|
|
|
|
/* Column titles are filled in below */
|
|
|
|
gtk_container_add(GTK_CONTAINER(pkt_scrollw), packet_list);
|
|
|
|
|
|
|
|
col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) *
|
|
|
|
cfile.cinfo.num_cols);
|
|
|
|
|
|
|
|
set_plist_sel_browse(prefs->gui_plist_sel_browse);
|
|
|
|
set_plist_font(m_r_font);
|
|
|
|
gtk_widget_set_name(packet_list, "packet list");
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(packet_list, "click-column", packet_list_click_column_cb,
|
|
|
|
col_arrows);
|
|
|
|
SIGNAL_CONNECT(packet_list, "select-row", packet_list_select_cb, NULL);
|
|
|
|
SIGNAL_CONNECT(packet_list, "unselect-row", packet_list_unselect_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
for (i = 0; i < cfile.cinfo.num_cols; i++) {
|
|
|
|
if (get_column_resize_type(cfile.cinfo.col_fmt[i]) != RESIZE_MANUAL)
|
|
|
|
gtk_clist_set_column_auto_resize(GTK_CLIST(packet_list), i, TRUE);
|
|
|
|
|
|
|
|
/* Right-justify the packet number column. */
|
|
|
|
if (cfile.cinfo.col_fmt[i] == COL_NUMBER)
|
|
|
|
gtk_clist_set_column_justification(GTK_CLIST(packet_list), i,
|
|
|
|
GTK_JUSTIFY_RIGHT);
|
|
|
|
}
|
2002-11-10 11:36:39 +00:00
|
|
|
WIDGET_SET_SIZE(packet_list, -1, pl_size);
|
|
|
|
SIGNAL_CONNECT(packet_list, "button_press_event", popup_menu_handler,
|
|
|
|
OBJECT_GET_DATA(popup_menu_object, PM_PACKET_LIST_KEY));
|
|
|
|
SIGNAL_CONNECT(packet_list, "button_press_event",
|
|
|
|
packet_list_button_pressed_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_clist_set_compare_func(GTK_CLIST(packet_list), packet_list_compare);
|
|
|
|
gtk_widget_show(packet_list);
|
|
|
|
|
|
|
|
/* Tree view */
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
item_style = gtk_style_new();
|
|
|
|
gdk_font_unref(item_style->font);
|
|
|
|
item_style->font = m_r_font;
|
|
|
|
#endif
|
|
|
|
create_tree_view(tv_size, prefs, l_pane, &tv_scrollw, &tree_view);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(tree_view, "tree-select-row", tree_view_select_row_cb, NULL);
|
|
|
|
SIGNAL_CONNECT(tree_view, "tree-unselect-row", tree_view_unselect_row_cb,
|
|
|
|
NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)),
|
|
|
|
"changed", tree_view_selection_changed_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(tree_view, "button_press_event", popup_menu_handler,
|
|
|
|
OBJECT_GET_DATA(popup_menu_object, PM_TREE_VIEW_KEY));
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(tree_view);
|
1999-07-28 03:29:02 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* Byte view. */
|
|
|
|
byte_nb_ptr = create_byte_view(bv_size, l_pane);
|
|
|
|
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(byte_nb_ptr, "button_press_event", popup_menu_handler,
|
|
|
|
OBJECT_GET_DATA(popup_menu_object, PM_HEXDUMP_KEY));
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Filter/info box */
|
|
|
|
stat_hbox = gtk_hbox_new(FALSE, 1);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(stat_hbox), 0);
|
|
|
|
gtk_box_pack_start(GTK_BOX(main_vbox), stat_hbox, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(stat_hbox);
|
|
|
|
|
|
|
|
filter_bt = gtk_button_new_with_label("Filter:");
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(filter_bt, "clicked", display_filter_construct_cb, &args);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_bt, FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show(filter_bt);
|
|
|
|
|
|
|
|
filter_cm = gtk_combo_new();
|
|
|
|
filter_list = g_list_append (filter_list, "");
|
|
|
|
gtk_combo_set_popdown_strings(GTK_COMBO(filter_cm), filter_list);
|
|
|
|
gtk_combo_disable_activate(GTK_COMBO(filter_cm));
|
|
|
|
gtk_combo_set_case_sensitive(GTK_COMBO(filter_cm), TRUE);
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(filter_cm, E_DFILTER_FL_KEY, filter_list);
|
2002-11-03 17:38:45 +00:00
|
|
|
filter_te = GTK_COMBO(filter_cm)->entry;
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_te);
|
|
|
|
OBJECT_SET_DATA(filter_te, E_DFILTER_CM_KEY, filter_cm);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_cm, TRUE, TRUE, 3);
|
2002-11-10 11:36:39 +00:00
|
|
|
SIGNAL_CONNECT(filter_te, "activate", filter_activate_cb, filter_te);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_widget_show(filter_cm);
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
filter_reset = gtk_button_new_with_label("Reset");
|
|
|
|
#else
|
|
|
|
filter_reset = gtk_button_new_from_stock(GTK_STOCK_CLEAR);
|
|
|
|
#endif
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(filter_reset, E_DFILTER_TE_KEY, filter_te);
|
|
|
|
SIGNAL_CONNECT(filter_reset, "clicked", filter_reset_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_reset, FALSE, TRUE, 1);
|
|
|
|
gtk_widget_show(filter_reset);
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
filter_apply = gtk_button_new_with_label("Apply");
|
|
|
|
#else
|
|
|
|
filter_apply = gtk_button_new_from_stock(GTK_STOCK_APPLY);
|
|
|
|
#endif
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(filter_apply, E_DFILTER_CM_KEY, filter_cm);
|
|
|
|
SIGNAL_CONNECT(filter_apply, "clicked", filter_activate_cb, filter_te);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(stat_hbox), filter_apply, FALSE, TRUE, 1);
|
|
|
|
gtk_widget_show(filter_apply);
|
|
|
|
|
|
|
|
/* Sets the text entry widget pointer as the E_DILTER_TE_KEY data
|
|
|
|
* of any widget that ends up calling a callback which needs
|
|
|
|
* that text entry pointer */
|
|
|
|
set_menu_object_data("/File/Open...", E_DFILTER_TE_KEY, filter_te);
|
|
|
|
set_menu_object_data("/File/Reload", E_DFILTER_TE_KEY, filter_te);
|
|
|
|
set_menu_object_data("/Edit/Filters...", E_FILT_TE_PTR_KEY, filter_te);
|
|
|
|
set_menu_object_data("/Tools/Follow TCP Stream", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/And Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/Or Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/And Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Match/Or Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/And Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/Or Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/And Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
|
|
|
set_menu_object_data("/Display/Prepare/Or Not Selected", E_DFILTER_TE_KEY,
|
|
|
|
filter_te);
|
2002-11-10 11:36:39 +00:00
|
|
|
OBJECT_SET_DATA(popup_menu_object, E_DFILTER_TE_KEY, filter_te);
|
|
|
|
OBJECT_SET_DATA(popup_menu_object, E_MPACKET_LIST_KEY, packet_list);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
info_bar = gtk_statusbar_new();
|
|
|
|
main_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "main");
|
|
|
|
file_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "file");
|
|
|
|
help_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(info_bar), "help");
|
|
|
|
gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, DEF_READY_MESSAGE);
|
|
|
|
gtk_box_pack_start(GTK_BOX(stat_hbox), info_bar, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(info_bar);
|
|
|
|
|
|
|
|
gtk_widget_show(top_level);
|
|
|
|
|
|
|
|
/* Fill in column titles. This must be done after the top level window
|
|
|
|
is displayed. */
|
|
|
|
win_style = gtk_widget_get_style(top_level);
|
|
|
|
ascend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &ascend_bm,
|
|
|
|
&win_style->bg[GTK_STATE_NORMAL],
|
|
|
|
(gchar **)clist_ascend_xpm);
|
|
|
|
descend_pm = gdk_pixmap_create_from_xpm_d(top_level->window, &descend_bm,
|
|
|
|
&win_style->bg[GTK_STATE_NORMAL],
|
|
|
|
(gchar **)clist_descend_xpm);
|
|
|
|
for (i = 0; i < cfile.cinfo.num_cols; i++) {
|
|
|
|
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
|
|
|
|
column_lb = gtk_label_new(cfile.cinfo.col_title[i]);
|
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2,
|
|
|
|
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show(column_lb);
|
|
|
|
col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
|
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
|
|
|
|
col_arrows[i].ascend_pm,
|
|
|
|
1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
if (i == 0) {
|
|
|
|
gtk_widget_show(col_arrows[i].ascend_pm);
|
|
|
|
}
|
|
|
|
col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
|
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table),
|
|
|
|
col_arrows[i].descend_pm,
|
|
|
|
1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_clist_set_column_widget(GTK_CLIST(packet_list), i,
|
|
|
|
col_arrows[i].table);
|
|
|
|
gtk_widget_show(col_arrows[i].table);
|
2001-10-21 16:15:21 +00:00
|
|
|
}
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(packet_list));
|
1998-09-16 02:39:15 +00:00
|
|
|
}
|
2001-03-02 23:10:12 +00:00
|
|
|
|
2001-04-09 22:35:23 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
set_last_open_dir(char *dirname)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (last_open_dir) {
|
|
|
|
g_free(last_open_dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dirname) {
|
|
|
|
len = strlen(dirname);
|
2002-09-09 20:39:01 +00:00
|
|
|
if (dirname[len-1] == G_DIR_SEPARATOR) {
|
|
|
|
last_open_dir = g_strconcat(dirname, NULL);
|
|
|
|
}
|
|
|
|
else {
|
2001-04-10 12:07:40 +00:00
|
|
|
last_open_dir = g_strconcat(dirname, G_DIR_SEPARATOR_S,
|
|
|
|
NULL);
|
2001-04-09 22:35:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
last_open_dir = NULL;
|
|
|
|
}
|
|
|
|
}
|