/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.90 1999/09/12 06:11:34 guy Exp $
+ * $Id: file.c,v 1.91 1999/09/12 20:23:31 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
dissect_packet(cf->pd, fd, protocol_tree);
/* Print the information in that tree. */
- proto_tree_print(FALSE, (GNode *)protocol_tree, cf->pd, fd, cf->print_fh);
+ proto_tree_print(FALSE, print_args->expand_all, (GNode *)protocol_tree,
+ cf->pd, fd, cf->print_fh);
proto_tree_free(protocol_tree);
}
}
+ if (col_widths != NULL)
+ g_free(col_widths);
+
#if 0
print_finale(cf->print_fh);
#endif
/* file.h
* Definitions for file structures and routines
*
- * $Id: file.h,v 1.43 1999/09/12 06:11:35 guy Exp $
+ * $Id: file.h,v 1.44 1999/09/12 20:23:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
if not, command string */
gboolean print_summary; /* TRUE if we should just print summary;
FALSE if we should print protocol tree. */
+ gboolean expand_all; /* TRUE if we should expand all levels;
+ FALSE if we should expand as displayed. */
} print_args_t;
int print_packets(capture_file *cf, print_args_t *print_args);
/* keys.h
* Key definitions for various objects
*
- * $Id: keys.h,v 1.3 1999/09/12 06:11:50 guy Exp $
+ * $Id: keys.h,v 1.4 1999/09/12 20:23:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
/* Keys for gtk_object_set_data */
-#define E_DFILTER_TE_KEY "display_filter_te"
-#define E_RFILTER_TE_KEY "read_filter_te"
+#define E_DFILTER_TE_KEY "display_filter_te"
+#define E_RFILTER_TE_KEY "read_filter_te"
-#define PRINT_CMD_LB_KEY "printer_command_label"
-#define PRINT_CMD_TE_KEY "printer_command_entry"
-#define PRINT_FILE_BT_KEY "printer_file_button"
-#define PRINT_FILE_TE_KEY "printer_file_entry"
-#define PRINT_DEST_RB_KEY "printer_destination_radio_button"
-#define PRINT_SUMMARY_RB_KEY "printer_summary_radio_button"
+#define PRINT_CMD_LB_KEY "printer_command_label"
+#define PRINT_CMD_TE_KEY "printer_command_entry"
+#define PRINT_FILE_BT_KEY "printer_file_button"
+#define PRINT_FILE_TE_KEY "printer_file_entry"
+#define PRINT_DEST_RB_KEY "printer_destination_radio_button"
+#define PRINT_SUMMARY_RB_KEY "printer_summary_radio_button"
+#define PRINT_EXPAND_ALL_RB_KEY "printer_expand_all_radio_button"
#endif
/* print_dlg.c
* Dialog boxes for printing
*
- * $Id: print_dlg.c,v 1.4 1999/09/12 06:11:51 guy Exp $
+ * $Id: print_dlg.c,v 1.5 1999/09/12 20:23:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
GtkWidget *cmd_lb, *cmd_te;
GtkWidget *file_bt_hb, *file_bt, *file_te;
GSList *dest_grp;
- GtkWidget *summary_rb, *detail_rb;
+ GtkWidget *options_hb;
+ GtkWidget *summary_vb, *summary_rb, *detail_rb;
GSList *summary_grp;
+ GtkWidget *expand_vb, *expand_all_rb, *as_displayed_rb;
+ GSList *expand_grp;
GtkWidget *bbox, *ok_bt, *cancel_bt;
/* XXX - don't pop up one if there's already one open; instead,
gtk_signal_connect(GTK_OBJECT(file_bt), "clicked",
GTK_SIGNAL_FUNC(print_file_cb), GTK_OBJECT(file_te));
+ /* Horizontal box into which to put two vertical boxes of option
+ buttons. */
+ options_hb = gtk_hbox_new(FALSE, 0);
+ gtk_container_border_width(GTK_CONTAINER(options_hb), 5);
+ gtk_container_add(GTK_CONTAINER(main_vb), options_hb);
+ gtk_widget_show(options_hb);
+
+ /* Vertical box into which to put the "Print summary"/"Print detail"
+ radio buttons. */
+ summary_vb = gtk_vbox_new(FALSE, 5);
+ gtk_container_border_width(GTK_CONTAINER(summary_vb), 5);
+ gtk_container_add(GTK_CONTAINER(options_hb), summary_vb);
+ gtk_widget_show(summary_vb);
+
/* "Print summary"/"Print detail" radio buttons */
summary_rb = gtk_radio_button_new_with_label(NULL, "Print summary");
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(summary_rb), FALSE);
summary_grp = gtk_radio_button_group(GTK_RADIO_BUTTON(summary_rb));
- gtk_container_add(GTK_CONTAINER(main_vb), summary_rb);
+ gtk_container_add(GTK_CONTAINER(summary_vb), summary_rb);
gtk_widget_show(summary_rb);
detail_rb = gtk_radio_button_new_with_label(summary_grp, "Print detail");
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(detail_rb), TRUE);
- gtk_container_add(GTK_CONTAINER(main_vb), detail_rb);
+ gtk_container_add(GTK_CONTAINER(summary_vb), detail_rb);
gtk_widget_show(detail_rb);
+ /* Vertical box into which to put the "Expand all levels"/"Print as displayed"
+ radio buttons. */
+ expand_vb = gtk_vbox_new(FALSE, 5);
+ gtk_container_border_width(GTK_CONTAINER(expand_vb), 5);
+ gtk_container_add(GTK_CONTAINER(options_hb), expand_vb);
+ gtk_widget_show(expand_vb);
+
+ /* "Expand all levels"/"Print as displayed" radio buttons */
+ expand_all_rb = gtk_radio_button_new_with_label(NULL, "Expand all levels");
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(expand_all_rb), TRUE);
+ expand_grp = gtk_radio_button_group(GTK_RADIO_BUTTON(expand_all_rb));
+ gtk_container_add(GTK_CONTAINER(expand_vb), expand_all_rb);
+ gtk_widget_show(expand_all_rb);
+ as_displayed_rb = gtk_radio_button_new_with_label(expand_grp, "Print as displayed");
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(as_displayed_rb), FALSE);
+ gtk_container_add(GTK_CONTAINER(expand_vb), as_displayed_rb);
+ gtk_widget_show(as_displayed_rb);
+
/* Button row: OK and Cancel buttons */
bbox = gtk_hbutton_box_new();
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END);
gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_CMD_TE_KEY, cmd_te);
gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_FILE_TE_KEY, file_te);
gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_SUMMARY_RB_KEY, summary_rb);
+ gtk_object_set_data(GTK_OBJECT(ok_bt), PRINT_EXPAND_ALL_RB_KEY, expand_all_rb);
gtk_signal_connect(GTK_OBJECT(ok_bt), "clicked",
GTK_SIGNAL_FUNC(print_ok_cb), GTK_OBJECT(print_w));
GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
PRINT_SUMMARY_RB_KEY);
print_args.print_summary = GTK_TOGGLE_BUTTON (button)->active;
+ button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(ok_bt),
+ PRINT_EXPAND_ALL_RB_KEY);
+ print_args.expand_all = GTK_TOGGLE_BUTTON (button)->active;
+
gtk_widget_destroy(GTK_WIDGET(parent_w));
#if 0
display_opt_window_active = FALSE;
}
print_preamble(fh);
- proto_tree_print(TRUE, (GNode*) cf.protocol_tree, cf.pd, cf.fd, fh);
+ proto_tree_print(TRUE, TRUE, (GNode*) cf.protocol_tree, cf.pd, cf.fd, fh);
print_finale(fh);
close_print_dest(prefs.pr_dest == PR_DEST_FILE, fh);
}
/* gtkpacket.c
* Routines for GTK+ packet display
*
- * $Id: proto_draw.c,v 1.2 1999/09/11 12:38:18 deniel Exp $
+ * $Id: proto_draw.c,v 1.3 1999/09/12 20:23:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
extern GtkWidget *byte_view;
extern GdkFont *m_r_font, *m_b_font;
-static gint tree_type[NUM_TREE_TYPES];
-
static void
proto_tree_draw_node(GNode *node, gpointer data);
void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view) {
int i;
for(i=0; i < NUM_TREE_TYPES; i++) {
- tree_type[i] = 1;
+ tree_is_expanded[i] = TRUE;
}
gtk_tree_clear_items(GTK_TREE(tree_view), 0, -1);
proto_tree_draw(protocol_tree, tree_view);
void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view) {
int i;
for(i=0; i < NUM_TREE_TYPES; i++) {
- tree_type[i] = 0;
+ tree_is_expanded[i] = FALSE;
}
gtk_tree_clear_items(GTK_TREE(tree_view), 0, -1);
proto_tree_draw(protocol_tree, tree_view);
static void
expand_tree(GtkWidget *w, gpointer data) {
- gint *val = (gint *) data;
- *val = 1;
+ gboolean *val = (gint *) data;
+ *val = TRUE;
}
static void
collapse_tree(GtkWidget *w, gpointer data) {
- gint *val = (gint *) data;
- *val = 0;
+ gboolean *val = (gint *) data;
+ *val = FALSE;
}
static void
if (g_node_n_children(node) > 0) {
subtree = gtk_tree_new();
gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), GTK_WIDGET(subtree));
- if (tree_type[fi->tree_type])
+ if (tree_is_expanded[fi->tree_type])
gtk_tree_item_expand(GTK_TREE_ITEM(ti));
gtk_signal_connect(GTK_OBJECT(ti), "expand", (GtkSignalFunc) expand_tree,
- (gpointer) &tree_type[fi->tree_type]);
+ (gpointer) &tree_is_expanded[fi->tree_type]);
gtk_signal_connect(GTK_OBJECT(ti), "collapse", (GtkSignalFunc) collapse_tree,
- (gpointer) &tree_type[fi->tree_type]);
+ (gpointer) &tree_is_expanded[fi->tree_type]);
g_node_children_foreach(node, G_TRAVERSE_ALL,
proto_tree_draw_node, subtree);
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.42 1999/09/12 06:11:36 guy Exp $
+ * $Id: packet.c,v 1.43 1999/09/12 20:23:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
extern capture_file cf;
+gboolean tree_is_expanded[NUM_TREE_TYPES];
+
int proto_frame = -1;
int hf_frame_arrival_time = -1;
int hf_frame_time_delta = -1;
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.97 1999/09/12 06:11:36 guy Exp $
+ * $Id: packet.h,v 1.98 1999/09/12 20:23:33 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
NUM_TREE_TYPES /* last item number plus one */
};
+/* TRUE if subtrees of an item of the specified type are to be expanded. */
+extern gboolean tree_is_expanded[NUM_TREE_TYPES];
/* Utility routines used by packet*.c */
gchar* ether_to_str(const guint8 *);
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.19 1999/09/12 06:11:37 guy Exp $
+ * $Id: print.c,v 1.20 1999/09/12 20:23:33 guy Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
int level;
FILE *fh;
const guint8 *pd;
+ gboolean print_all_levels;
} print_data;
FILE *open_print_dest(int to_file, const char *dest)
print_ps_finale(fh);
}
-void proto_tree_print(gboolean print_one, GNode *protocol_tree,
- const u_char *pd, frame_data *fd, FILE *fh)
+void proto_tree_print(gboolean print_one_packet, gboolean print_all_levels,
+ GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh)
{
print_data data;
data.level = 0;
data.fh = fh;
data.pd = pd;
+ data.print_all_levels = print_all_levels;
/* XXX - printing multiple frames in PostScript looks as if it's
tricky - you have to deal with page boundaries, I think -
and I'll have to spend some time learning enough about
PostScript to figure it out, so, for now, we only print
multiple frames as text. */
- if (prefs.pr_format == PR_FMT_TEXT || !print_one) {
+ if (prefs.pr_format == PR_FMT_TEXT || !print_one_packet) {
g_node_children_foreach((GNode*) protocol_tree, G_TRAVERSE_ALL,
proto_tree_print_node_text, &data);
} else {
field_info *fi = (field_info*) (node->data);
print_data *pdata = (print_data*) data;
int i;
- int num_spaces;
+ int num_spaces;
char space[41];
gchar label_str[ITEM_LABEL_LENGTH];
gchar *label_ptr;
+ /* Don't print invisible entries. */
if (!fi->visible)
return;
if (fi->hfinfo->id == proto_data)
dumpit(pdata->fh, &pdata->pd[fi->start], fi->length);
- /* Recurse into the subtree, if it exists */
- if (g_node_n_children(node) > 0) {
- pdata->level++;
- g_node_children_foreach(node, G_TRAVERSE_ALL,
- proto_tree_print_node_text, pdata);
- pdata->level--;
+ /* If we're printing all levels, or if this level is expanded,
+ recurse into the subtree, if it exists. */
+ if (pdata->print_all_levels || tree_is_expanded[fi->tree_type]) {
+ if (g_node_n_children(node) > 0) {
+ pdata->level++;
+ g_node_children_foreach(node, G_TRAVERSE_ALL,
+ proto_tree_print_node_text, pdata);
+ pdata->level--;
+ }
}
}
/* print.h
* Definitions for printing packet analysis trees.
*
- * $Id: print.h,v 1.11 1999/09/12 06:11:37 guy Exp $
+ * $Id: print.h,v 1.12 1999/09/12 20:23:34 guy Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
void close_print_dest(int to_file, FILE *fh);
void print_preamble(FILE *fh);
void print_finale(FILE *fh);
-void proto_tree_print(gboolean print_one, GNode *protocol_tree,
- const u_char *pd, frame_data *fd, FILE *fh);
+void proto_tree_print(gboolean print_one_packet, gboolean print_all_levels,
+ GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh);
#endif /* print.h */