some code cleanup of the printing system
svn path=/trunk/; revision=10682
This commit is contained in:
parent
0c339ea7ae
commit
1531315c18
11
file.c
11
file.c
|
@ -1,7 +1,7 @@
|
|||
/* file.c
|
||||
* File I/O routines
|
||||
*
|
||||
* $Id: file.c,v 1.377 2004/04/22 17:03:20 ulfl Exp $
|
||||
* $Id: file.c,v 1.378 2004/04/24 23:13:45 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -131,15 +131,6 @@ static gboolean copy_binary_file(char *from_filename, char *to_filename);
|
|||
XXX - is this the right number? */
|
||||
#define FRAME_DATA_CHUNK_SIZE 1024
|
||||
|
||||
typedef struct {
|
||||
int level;
|
||||
FILE *fh;
|
||||
GSList *src_list;
|
||||
gboolean print_all_levels;
|
||||
gboolean print_hex_for_data;
|
||||
char_enc encoding;
|
||||
gint format; /* text or PostScript */
|
||||
} print_data;
|
||||
|
||||
int
|
||||
cf_open(char *fname, gboolean is_tempfile, capture_file *cf)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* print_dlg.c
|
||||
* Dialog boxes for printing
|
||||
*
|
||||
* $Id: print_dlg.c,v 1.70 2004/04/22 21:40:48 ulfl Exp $
|
||||
* $Id: print_dlg.c,v 1.71 2004/04/24 23:13:46 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -82,6 +82,8 @@ static gint print_format;
|
|||
static gchar * print_file;
|
||||
static gchar * print_cmd;
|
||||
|
||||
#define PRINT_RANGE_KEY "printer_range"
|
||||
|
||||
#define PRINT_PS_RB_KEY "printer_ps_radio_button"
|
||||
#define PRINT_PDML_RB_KEY "printer_pdml_radio_button"
|
||||
#define PRINT_PSML_RB_KEY "printer_psml_radio_button"
|
||||
|
@ -104,9 +106,6 @@ static gchar * print_cmd;
|
|||
*/
|
||||
static GtkWidget *print_w;
|
||||
|
||||
static packet_range_t range;
|
||||
|
||||
|
||||
|
||||
/* Print the capture */
|
||||
void
|
||||
|
@ -143,6 +142,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
|
||||
GtkTooltips *tooltips;
|
||||
|
||||
packet_range_t *range;
|
||||
|
||||
if (print_w != NULL) {
|
||||
/* There's already a "Print" dialog box; reactivate it. */
|
||||
|
@ -151,7 +151,8 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
}
|
||||
|
||||
/* init the packet range */
|
||||
packet_range_init(&range);
|
||||
range = g_malloc(sizeof(packet_range_t));
|
||||
packet_range_init(range);
|
||||
|
||||
/* get settings from preferences only once */
|
||||
if(print_prefs_init == FALSE) {
|
||||
|
@ -304,7 +305,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
gtk_box_pack_start(GTK_BOX(packet_hb), range_fr, FALSE, FALSE, 0);
|
||||
gtk_widget_show(range_fr);
|
||||
|
||||
range_tb = range_new(&range
|
||||
range_tb = range_new(range
|
||||
#if GTK_MAJOR_VERSION < 2
|
||||
, accel_group
|
||||
#endif
|
||||
|
@ -327,7 +328,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
summary_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet summary line", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(summary_cb), FALSE);
|
||||
SIGNAL_CONNECT(summary_cb, "clicked", print_cmd_toggle_detail, print_w);
|
||||
gtk_tooltips_set_tip (tooltips, summary_cb, ("Print a packet summary line, like in the packet list"), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, summary_cb, ("Output of a packet summary line, like in the packet list"), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(format_vb), summary_cb);
|
||||
gtk_widget_show(summary_cb);
|
||||
|
||||
|
@ -336,7 +337,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
details_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet details:", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(details_cb), TRUE);
|
||||
SIGNAL_CONNECT(details_cb, "clicked", print_cmd_toggle_detail, print_w);
|
||||
gtk_tooltips_set_tip (tooltips, details_cb, ("Print the selected packet details (protocol tree)."), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, details_cb, ("Output format of the selected packet details (protocol tree)."), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(format_vb), details_cb);
|
||||
gtk_widget_show(details_cb);
|
||||
|
||||
|
@ -359,19 +360,19 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
/* "All collapsed"/"As displayed"/"All Expanded" radio buttons */
|
||||
collapse_all_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(NULL, "All co_llapsed", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(collapse_all_rb), FALSE);
|
||||
gtk_tooltips_set_tip (tooltips, collapse_all_rb, ("Print packet details tree \"collapsed\""), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, collapse_all_rb, ("Output of the packet details tree \"collapsed\""), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(details_vb), collapse_all_rb);
|
||||
gtk_widget_show(collapse_all_rb);
|
||||
|
||||
as_displayed_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(collapse_all_rb, "As displa_yed", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(as_displayed_rb), TRUE);
|
||||
gtk_tooltips_set_tip (tooltips, as_displayed_rb, ("Print packet details tree \"as displayed\""), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, as_displayed_rb, ("Output of the packet details tree \"as displayed\""), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(details_vb), as_displayed_rb);
|
||||
gtk_widget_show(as_displayed_rb);
|
||||
|
||||
expand_all_rb = RADIO_BUTTON_NEW_WITH_MNEMONIC(collapse_all_rb, "All e_xpanded", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(expand_all_rb), FALSE);
|
||||
gtk_tooltips_set_tip (tooltips, expand_all_rb, ("Print packet details tree \"expanded\""), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, expand_all_rb, ("Output of the packet details tree \"expanded\""), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(details_vb), expand_all_rb);
|
||||
gtk_widget_show(expand_all_rb);
|
||||
|
||||
|
@ -379,7 +380,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
hex_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Packet bytes", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(hex_cb), FALSE);
|
||||
SIGNAL_CONNECT(hex_cb, "clicked", print_cmd_toggle_detail, print_w);
|
||||
gtk_tooltips_set_tip (tooltips, hex_cb, ("Add hexdump of packet data"), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, hex_cb, ("Add a hexdump of the packet data"), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(format_vb), hex_cb);
|
||||
gtk_widget_show(hex_cb);
|
||||
|
||||
|
@ -391,8 +392,8 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
/* "Each packet on a new page" check button. */
|
||||
formfeed_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Each packet on a new page", accel_group);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(formfeed_cb), FALSE);
|
||||
gtk_tooltips_set_tip (tooltips, formfeed_cb, ("When checked, a new page will be used for each packet printed. "
|
||||
"This is done by adding a formfeed (or similar) between the packet printouts."), NULL);
|
||||
gtk_tooltips_set_tip (tooltips, formfeed_cb, ("When checked, a new page will be used for each packet. "
|
||||
"This is done by adding a formfeed (or similar) between the packet outputs."), NULL);
|
||||
gtk_container_add(GTK_CONTAINER(format_vb), formfeed_cb);
|
||||
gtk_widget_show(formfeed_cb);
|
||||
|
||||
|
@ -424,6 +425,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
OBJECT_SET_DATA(ok_bt, PRINT_CMD_TE_KEY, cmd_te);
|
||||
#endif
|
||||
|
||||
OBJECT_SET_DATA(ok_bt, PRINT_RANGE_KEY, range);
|
||||
OBJECT_SET_DATA(ok_bt, PRINT_FILE_TE_KEY, file_te);
|
||||
OBJECT_SET_DATA(ok_bt, PRINT_SUMMARY_CB_KEY, summary_cb);
|
||||
OBJECT_SET_DATA(ok_bt, PRINT_DETAILS_CB_KEY, details_cb);
|
||||
|
@ -433,6 +435,7 @@ file_print_cmd_cb(GtkWidget *widget _U_, gpointer data _U_)
|
|||
OBJECT_SET_DATA(ok_bt, PRINT_HEX_CB_KEY, hex_cb);
|
||||
OBJECT_SET_DATA(ok_bt, PRINT_FORMFEED_CB_KEY, formfeed_cb);
|
||||
SIGNAL_CONNECT(ok_bt, "clicked", print_ok_cb, print_w);
|
||||
gtk_tooltips_set_tip (tooltips, ok_bt, ("Start printing"), NULL);
|
||||
gtk_widget_grab_default(ok_bt);
|
||||
|
||||
cancel_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
|
||||
|
@ -621,7 +624,8 @@ print_ok_cb(GtkWidget *ok_bt, gpointer parent_w)
|
|||
button = (GtkWidget *)OBJECT_GET_DATA(ok_bt, PRINT_FORMFEED_CB_KEY);
|
||||
print_args.print_formfeed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (button));
|
||||
|
||||
print_args.range = range;
|
||||
|
||||
print_args.range = *((packet_range_t *)OBJECT_GET_DATA(ok_bt, PRINT_RANGE_KEY));
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(parent_w));
|
||||
|
||||
|
@ -671,6 +675,7 @@ static void
|
|||
print_destroy_cb(GtkWidget *win, gpointer user_data _U_)
|
||||
{
|
||||
GtkWidget *fs;
|
||||
gpointer range;
|
||||
|
||||
/* Is there a file selection dialog associated with this
|
||||
Print File dialog? */
|
||||
|
@ -681,6 +686,9 @@ print_destroy_cb(GtkWidget *win, gpointer user_data _U_)
|
|||
gtk_widget_destroy(fs);
|
||||
}
|
||||
|
||||
range = OBJECT_GET_DATA(win, PRINT_RANGE_KEY);
|
||||
g_free(range);
|
||||
|
||||
/* Note that we no longer have a "Print" dialog box. */
|
||||
print_w = NULL;
|
||||
}
|
||||
|
|
18
print.c
18
print.c
|
@ -1,7 +1,7 @@
|
|||
/* print.c
|
||||
* Routines for printing packet analysis trees.
|
||||
*
|
||||
* $Id: print.c,v 1.78 2004/04/22 17:03:20 ulfl Exp $
|
||||
* $Id: print.c,v 1.79 2004/04/24 23:13:46 ulfl Exp $
|
||||
*
|
||||
* Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
|
@ -49,7 +49,7 @@
|
|||
static void proto_tree_print_node(proto_node *node, gpointer data);
|
||||
static void proto_tree_print_node_pdml(proto_node *node, gpointer data);
|
||||
static void print_hex_data_buffer(FILE *fh, register const guchar *cp,
|
||||
register guint length, char_enc encoding, gint format);
|
||||
register guint length, char_enc encoding, print_format_e format);
|
||||
static void ps_clean_string(unsigned char *out, const unsigned char *in,
|
||||
int outbuf_size);
|
||||
static void print_escaped_xml(FILE *fh, char *unescaped_string);
|
||||
|
@ -534,7 +534,7 @@ print_pdml_geninfo(proto_tree *tree, print_data *pdata)
|
|||
}
|
||||
|
||||
|
||||
void print_hex_data(FILE *fh, gint format, epan_dissect_t *edt)
|
||||
void print_hex_data(FILE *fh, print_format_e format, epan_dissect_t *edt)
|
||||
{
|
||||
gboolean multiple_sources;
|
||||
GSList *src_le;
|
||||
|
@ -597,7 +597,7 @@ void print_hex_data(FILE *fh, gint format, epan_dissect_t *edt)
|
|||
|
||||
static void
|
||||
print_hex_data_buffer(FILE *fh, register const guchar *cp,
|
||||
register guint length, char_enc encoding, gint format)
|
||||
register guint length, char_enc encoding, print_format_e format)
|
||||
{
|
||||
register unsigned int ad, i, j, k, l;
|
||||
guchar c;
|
||||
|
@ -704,7 +704,7 @@ void ps_clean_string(unsigned char *out, const unsigned char *in,
|
|||
|
||||
/* Some formats need stuff at the beginning of the output */
|
||||
void
|
||||
print_preamble(FILE *fh, gint format, gchar *filename)
|
||||
print_preamble(FILE *fh, print_format_e format, gchar *filename)
|
||||
{
|
||||
char psbuffer[MAX_PS_LINE_LENGTH]; /* static sized buffer! */
|
||||
|
||||
|
@ -740,7 +740,7 @@ print_preamble(FILE *fh, gint format, gchar *filename)
|
|||
}
|
||||
|
||||
void
|
||||
print_packet_header(FILE *fh, gint format, guint32 number, gchar *summary) {
|
||||
print_packet_header(FILE *fh, print_format_e format, guint32 number, gchar *summary) {
|
||||
char psbuffer[MAX_PS_LINE_LENGTH]; /* static sized buffer! */
|
||||
|
||||
|
||||
|
@ -767,7 +767,7 @@ print_packet_header(FILE *fh, gint format, guint32 number, gchar *summary) {
|
|||
}
|
||||
|
||||
void
|
||||
print_formfeed(FILE *fh, gint format) {
|
||||
print_formfeed(FILE *fh, print_format_e format) {
|
||||
switch(format) {
|
||||
case(PR_FMT_TEXT):
|
||||
fputs("\f", fh);
|
||||
|
@ -788,7 +788,7 @@ print_formfeed(FILE *fh, gint format) {
|
|||
|
||||
/* Some formats need stuff at the end of the output */
|
||||
void
|
||||
print_finale(FILE *fh, gint format)
|
||||
print_finale(FILE *fh, print_format_e format)
|
||||
{
|
||||
switch(format) {
|
||||
case(PR_FMT_TEXT):
|
||||
|
@ -809,7 +809,7 @@ print_finale(FILE *fh, gint format)
|
|||
}
|
||||
|
||||
void
|
||||
print_line(FILE *fh, int indent, gint format, char *line)
|
||||
print_line(FILE *fh, int indent, print_format_e format, char *line)
|
||||
{
|
||||
char space[MAX_INDENT+1];
|
||||
int i;
|
||||
|
|
28
print.h
28
print.h
|
@ -1,7 +1,7 @@
|
|||
/* print.h
|
||||
* Definitions for printing packet analysis trees.
|
||||
*
|
||||
* $Id: print.h,v 1.41 2004/04/22 17:03:20 ulfl Exp $
|
||||
* $Id: print.h,v 1.42 2004/04/24 23:13:46 ulfl Exp $
|
||||
*
|
||||
* Gilbert Ramirez <gram@alumni.rice.edu>
|
||||
*
|
||||
|
@ -29,10 +29,14 @@
|
|||
|
||||
#include <epan/packet.h>
|
||||
|
||||
#define PR_FMT_TEXT 0
|
||||
#define PR_FMT_PS 1
|
||||
#define PR_FMT_PDML 2
|
||||
#define PR_FMT_PSML 3
|
||||
|
||||
/* print output format */
|
||||
typedef enum {
|
||||
PR_FMT_TEXT, /* plain text */
|
||||
PR_FMT_PS, /* postscript */
|
||||
PR_FMT_PSML, /* packet summary markup language */
|
||||
PR_FMT_PDML /* packet data markup language */
|
||||
} print_format_e;
|
||||
|
||||
/* print_range, enum which frames should be printed */
|
||||
typedef enum {
|
||||
|
@ -51,7 +55,7 @@ typedef enum {
|
|||
} print_dissections_e;
|
||||
|
||||
typedef struct {
|
||||
gint format; /* plain text, PostScript or PDML */
|
||||
print_format_e format; /* plain text, PostScript, PDML, ... */
|
||||
gboolean to_file; /* TRUE if we're printing to a file */
|
||||
char *dest; /* if printing to file, pathname;
|
||||
if not, command string */
|
||||
|
@ -70,13 +74,13 @@ typedef struct {
|
|||
|
||||
FILE *open_print_dest(int to_file, const char *dest);
|
||||
gboolean close_print_dest(int to_file, FILE *fh);
|
||||
void print_preamble(FILE *fh, gint format, gchar *filename);
|
||||
void print_packet_header(FILE *fh, gint format, guint32 number, gchar *summary);
|
||||
void print_formfeed(FILE *fh, gint format);
|
||||
void print_finale(FILE *fh, gint format);
|
||||
void print_preamble(FILE *fh, print_format_e format, gchar *filename);
|
||||
void print_packet_header(FILE *fh, print_format_e format, guint32 number, gchar *summary);
|
||||
void print_formfeed(FILE *fh, print_format_e format);
|
||||
void print_finale(FILE *fh, print_format_e format);
|
||||
void proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
|
||||
FILE *fh);
|
||||
void print_hex_data(FILE *fh, gint format, epan_dissect_t *edt);
|
||||
void print_line(FILE *fh, int indent, gint format, char *line);
|
||||
void print_hex_data(FILE *fh, print_format_e format, epan_dissect_t *edt);
|
||||
void print_line(FILE *fh, int indent, print_format_e format, char *line);
|
||||
|
||||
#endif /* print.h */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* tethereal.c
|
||||
*
|
||||
* $Id: tethereal.c,v 1.237 2004/04/22 17:03:20 ulfl Exp $
|
||||
* $Id: tethereal.c,v 1.238 2004/04/24 23:13:46 ulfl Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -121,7 +121,7 @@ static gboolean verbose;
|
|||
static gboolean print_hex;
|
||||
static gboolean line_buffered;
|
||||
static guint32 cum_bytes = 0;
|
||||
static int print_format;
|
||||
static print_format_e print_format;
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
typedef struct _loop_data {
|
||||
|
|
Loading…
Reference in New Issue