diff options
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | print.c | 14 | ||||
-rw-r--r-- | print.h | 4 | ||||
-rw-r--r-- | print.ps | 77 | ||||
-rw-r--r-- | tethereal.c | 4 |
5 files changed, 72 insertions, 35 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.375 2004/04/16 20:20:54 guy Exp $ + * $Id: file.c,v 1.376 2004/04/20 22:34:08 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1609,7 +1609,7 @@ print_packets(capture_file *cf, print_args_t *print_args) if (callback_args.print_fh == NULL) return PP_OPEN_ERROR; /* attempt to open destination failed */ - print_preamble(callback_args.print_fh, print_args->format); + print_preamble(callback_args.print_fh, print_args->format, cf->filename); if (ferror(callback_args.print_fh)) { close_print_dest(print_args->to_file, callback_args.print_fh); return PP_WRITE_ERROR; @@ -1662,9 +1662,9 @@ print_packets(capture_file *cf, print_args_t *print_args) } /* Right-justify the packet number column. */ - if (cf->cinfo.col_fmt[i] == COL_NUMBER) +/* if (cf->cinfo.col_fmt[i] == COL_NUMBER) sprintf(cp, "%*s", callback_args.col_widths[i], cf->cinfo.col_title[i]); - else + else*/ sprintf(cp, "%-*s", callback_args.col_widths[i], cf->cinfo.col_title[i]); cp += column_len; if (i != cf->cinfo.num_cols - 1) @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.76 2004/04/17 11:50:13 ulfl Exp $ + * $Id: print.c,v 1.77 2004/04/20 22:34:08 ulfl Exp $ * * Gilbert Ramirez <gram@alumni.rice.edu> * @@ -704,14 +704,24 @@ 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) +print_preamble(FILE *fh, gint format, gchar *filename) { + char psbuffer[MAX_PS_LINE_LENGTH]; /* static sized buffer! */ + + switch(format) { case(PR_FMT_TEXT): /* do nothing */ break; case(PR_FMT_PS): print_ps_preamble(fh); + fputs("%% Set the font to 8 point\n", fh); + fputs("/Courier findfont 8 scalefont setfont\n", fh); + fputs("\n", fh); + fputs("%% the page title\n", fh); + ps_clean_string(psbuffer, filename, MAX_PS_LINE_LENGTH); + fprintf(fh, "/eth_pagetitle (%s - Ethereal) def\n", psbuffer); + fputs("\n", fh); break; case(PR_FMT_PDML): fputs("<?xml version=\"1.0\"?>\n", fh); @@ -1,7 +1,7 @@ /* print.h * Definitions for printing packet analysis trees. * - * $Id: print.h,v 1.39 2004/04/17 11:50:14 ulfl Exp $ + * $Id: print.h,v 1.40 2004/04/20 22:34:08 ulfl Exp $ * * Gilbert Ramirez <gram@alumni.rice.edu> * @@ -68,7 +68,7 @@ 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); +void print_preamble(FILE *fh, gint format, gchar *filename); void print_finale(FILE *fh, gint format); void proto_tree_print(print_args_t *print_args, epan_dissect_t *edt, FILE *fh); @@ -27,10 +27,16 @@ clippath pathbbox pop pop % junk % 1-inch margins -/lmargin 72 def -/tmargin vmax 72 sub def -/bmargin 72 def -/pagenumtab hmax 72 sub def +%/lmargin 72 def +%/tmargin vmax 72 sub def +%/bmargin 72 def +%/pagenumtab hmax 72 sub def + +% 1/2-inch margins +/lmargin 36 def +/tmargin vmax 56 sub def +/bmargin 36 def +/pagenumtab hmax 36 sub def % Counters /vpos vmax 40 sub def @@ -39,8 +45,9 @@ pop pop % junk % Strings /pagenostr 7 string def + % Prints text with possible indenting -/putline { +/putline_single { exch 10 mul lmargin add % X vpos % Y moveto @@ -50,30 +57,52 @@ pop pop % junk vpos bmargin le % is vpos <= bottom margin? { - printpagenum showpage + printpageheader + showpage /vpos tmargin def } if % then formfeed and start at top } def -% A put line with smaller spacing and no formfeed -/titleline { - lmargin % X - vpos % Y - moveto - show - /vpos vpos 8 sub def +% Prints text with possible indenting and line wrap +/putline { + /text exch def + /indent exch def + + % wrapat = width / sizeof font (remember: monospaced font) + /pagewidth pagenumtab bmargin sub def + /cwidth (A) stringwidth pop def + /wrapat pagewidth cwidth div cvi def + + text length wrapat le { + % print line + indent text 0 text length getinterval putline_single + }{ + % print the lines first part + indent text 0 wrapat getinterval putline_single + % print wrapped rest + indent text wrapat text length wrapat sub getinterval putline + } + ifelse } def + % Prints the page number at the top right -/printpagenum { +/printpageheader { gsave % Set the font to 8 point /Helvetica findfont 8 scalefont setfont - pagenumtab % X - vmax 40 sub % Y + % title + lmargin % X + vmax 36 sub % Y + moveto + eth_pagetitle show + + % this page number + pagenumtab (Page ) stringwidth pop sub thispagenum pagenostr cvs stringwidth pop sub % X + vmax 36 sub % Y moveto (Page ) show thispagenum pagenostr cvs show @@ -83,19 +112,17 @@ pop pop % junk grestore } def -% Set the font to 8 point -/Helvetica findfont 8 scalefont setfont - -% Create the title -(Ethereal) titleline - % Reset the vertical position /vpos tmargin def -% Set the font to 10 point -/Courier findfont 10 scalefont setfont % ---- ethereal preamble end ---- % +% Set the font to 8 point +/Courier findfont 8 scalefont setfont + +% the page title +/eth_pagetitle (Ethereal) def + % Display our output lines. 0 (Ethernet II \(98 on wire, 68 captured\)) putline 1 (Destination: 00:00:0c:36:00:2a) putline @@ -124,7 +151,7 @@ pop pop % junk % If this is not the first page, then print the page number thispagenum 1 gt % is thispagenum > 1 ? { - printpagenum + printpageheader } if diff --git a/tethereal.c b/tethereal.c index 32f1dc36c5..71ee487e1f 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.235 2004/04/16 23:16:28 guy Exp $ + * $Id: tethereal.c,v 1.236 2004/04/20 22:34:08 ulfl Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -2272,7 +2272,7 @@ load_cap_file(capture_file *cf, int out_file_type) success = wtap_loop(cf->wth, 0, wtap_dispatch_cb_write, (guchar *) &args, &err, &err_info); } else { - print_preamble(stdout, print_format); + print_preamble(stdout, print_format, cf->filename); if (ferror(stdout)) { err = errno; show_print_file_io_error(err); |