diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-06-29 09:45:06 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-06-29 09:45:06 +0000 |
commit | 7dc9756921325232a4eb99837bebbdfa4cd2689d (patch) | |
tree | aa8897ea19a81bdeee140299bffdbd5e5733990c | |
parent | 6b2bdd3a6ef97b19ac83e816c38da0fd36cf213f (diff) |
Have "print_line()" take an indentation argument, and do blank
padding when printing text and use "putline" when printing PostScript.
Eliminate "hexdump", as it's just a special case of "putline".
Have "proto_tree_print_node()" just call "print_line()".
Get rid of "print_ps_hex()" - the font used for the hex dump and the
protocol tree are the same, so there's no need to switch fonts.
svn path=/trunk/; revision=5798
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | print.c | 79 | ||||
-rw-r--r-- | print.h | 4 | ||||
-rw-r--r-- | print.ps | 48 | ||||
-rw-r--r-- | rdps.c | 14 |
5 files changed, 57 insertions, 96 deletions
@@ -1,7 +1,7 @@ /* file.c * File I/O routines * - * $Id: file.c,v 1.279 2002/06/22 01:52:27 guy Exp $ + * $Id: file.c,v 1.280 2002/06/29 09:45:06 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1138,7 +1138,7 @@ print_packets(capture_file *cf, print_args_t *print_args) *cp++ = ' '; } *cp = '\0'; - print_line(cf->print_fh, print_args->format, line_buf); + print_line(cf->print_fh, 0, print_args->format, line_buf); } print_separator = FALSE; @@ -1224,10 +1224,10 @@ print_packets(capture_file *cf, print_args_t *print_args) *cp++ = ' '; } *cp = '\0'; - print_line(cf->print_fh, print_args->format, line_buf); + print_line(cf->print_fh, 0, print_args->format, line_buf); } else { if (print_separator) - print_line(cf->print_fh, print_args->format, ""); + print_line(cf->print_fh, 0, print_args->format, ""); /* Create the logical protocol tree, complete with the display representation of the items; we don't need the columns here, @@ -1,7 +1,7 @@ /* print.c * Routines for printing packet analysis trees. * - * $Id: print.c,v 1.54 2002/06/23 23:43:32 guy Exp $ + * $Id: print.c,v 1.55 2002/06/29 09:45:06 guy Exp $ * * Gilbert Ramirez <gram@alumni.rice.edu> * @@ -83,18 +83,6 @@ void close_print_dest(int to_file, FILE *fh) pclose(fh); } -void print_preamble(FILE *fh, gint format) -{ - if (format == PR_FMT_PS) - print_ps_preamble(fh); -} - -void print_finale(FILE *fh, gint format) -{ - if (format == PR_FMT_PS) - print_ps_finale(fh); -} - void proto_tree_print(print_args_t *print_args, epan_dissect_t *edt, FILE *fh) { @@ -150,13 +138,9 @@ void proto_tree_print_node(GNode *node, gpointer data) { field_info *fi = PITEM_FINFO(node); print_data *pdata = (print_data*) data; - int i; - int num_spaces; - char space[MAX_INDENT+1]; const guint8 *pd; gchar label_str[ITEM_LABEL_LENGTH]; gchar *label_ptr; - char psbuffer[MAX_PS_LINE_LENGTH]; /* static sized buffer! */ /* Don't print invisible entries. */ if (!fi->visible) @@ -171,25 +155,7 @@ void proto_tree_print_node(GNode *node, gpointer data) proto_item_fill_label(fi, label_str); } - if (pdata->format == PR_FMT_PS) { - /* Print the text, as PostScript */ - ps_clean_string(psbuffer, label_ptr, MAX_PS_LINE_LENGTH); - fprintf(pdata->fh, "%d (%s) putline\n", pdata->level, psbuffer); - } else { - /* Prepare the tabs for printing, depending on tree level */ - num_spaces = pdata->level * 4; - if (num_spaces > MAX_INDENT) { - num_spaces = MAX_INDENT; - } - for (i = 0; i < num_spaces; i++) { - space[i] = ' '; - } - /* The string is NUL-terminated */ - space[num_spaces] = '\0'; - - /* Print the text */ - fprintf(pdata->fh, "%s%s\n", space, label_ptr); - } + print_line(pdata->fh, pdata->level, pdata->format, label_ptr); /* If it's uninterpreted data, dump it (unless our caller will be printing the entire packet in hex). */ @@ -242,11 +208,11 @@ void print_hex_data(FILE *fh, gint format, epan_dissect_t *edt) tvb = src->tvb; if (multiple_sources) { name = src->name; - print_line(fh, format, ""); + print_line(fh, 0, format, ""); line = g_malloc(strlen(name) + 2); /* <name>:\0 */ strcpy(line, name); strcat(line, ":"); - print_line(fh, format, line); + print_line(fh, 0, format, line); g_free(line); } length = tvb_length(tvb); @@ -290,9 +256,7 @@ print_hex_data_buffer(FILE *fh, register const u_char *cp, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - if (format == PR_FMT_PS) - print_ps_hex(fh); - print_line(fh, format, ""); + print_line(fh, 0, format, ""); /* * How many of the leading digits of the offset will we supply? @@ -353,7 +317,7 @@ print_hex_data_buffer(FILE *fh, register const u_char *cp, * and advance the offset. */ line[k] = '\0'; - print_line(fh, format, line); + print_line(fh, 0, format, line); ad += 16; } } @@ -387,14 +351,41 @@ void ps_clean_string(unsigned char *out, const unsigned char *in, } } -void print_line(FILE *fh, gint format, char *line) +void print_preamble(FILE *fh, gint format) +{ + if (format == PR_FMT_PS) + print_ps_preamble(fh); +} + +void print_finale(FILE *fh, gint format) +{ + if (format == PR_FMT_PS) + print_ps_finale(fh); +} + +void print_line(FILE *fh, int indent, gint format, char *line) { + char space[MAX_INDENT+1]; + int i; + int num_spaces; char psbuffer[MAX_PS_LINE_LENGTH]; /* static sized buffer! */ if (format == PR_FMT_PS) { ps_clean_string(psbuffer, line, MAX_PS_LINE_LENGTH); - fprintf(fh, "(%s) hexdump\n", psbuffer); + fprintf(fh, "%d (%s) putline\n", indent, psbuffer); } else { + /* Prepare the tabs for printing, depending on tree level */ + num_spaces = indent * 4; + if (num_spaces > MAX_INDENT) { + num_spaces = MAX_INDENT; + } + for (i = 0; i < num_spaces; i++) { + space[i] = ' '; + } + /* The string is NUL-terminated */ + space[num_spaces] = '\0'; + + fputs(space, fh); fputs(line, fh); putc('\n', fh); } @@ -1,7 +1,7 @@ /* print.h * Definitions for printing packet analysis trees. * - * $Id: print.h,v 1.27 2002/06/04 07:03:47 guy Exp $ + * $Id: print.h,v 1.28 2002/06/29 09:45:06 guy Exp $ * * Gilbert Ramirez <gram@alumni.rice.edu> * @@ -59,6 +59,6 @@ void print_finale(FILE *fh, gint 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, gint format, char *line); +void print_line(FILE *fh, int indent, gint format, char *line); #endif /* print.h */ @@ -56,23 +56,6 @@ pop pop % junk if % then formfeed and start at top } def -% A putline with no indenting -/hexdump { - lmargin % X - vpos % Y - moveto - show - - /vpos vpos 10 sub def - - vpos bmargin le % is vpos <= bottom margin? - { - printpagenum showpage - /vpos tmargin def - } - if % then formfeed and start at top -} def - % A put line with smaller spacing and no formfeed /titleline { lmargin % X @@ -123,24 +106,19 @@ pop pop % junk 1 (Type: IP \(0x0800\)) putline 0 (Source: 00:c0:4f:c7:eb:c0) putline -% ---- ethereal hex start ---- % -% Set the font to 10 point -/Courier findfont 10 scalefont setfont -% ---- ethereal hex end ---- % - -() hexdump -(0000 cc 00 00 00 00 00 07 02 00 00 00 00 00 00 00 00 ................ ) hexdump -(0010 00 00 bd 0e fe 16 01 00 3e 00 03 08 58 4c 20 38 ........>...XL 8 ) hexdump -(0020 30 20 49 4d 33 00 16 01 00 34 00 16 01 01 35 00 0 IM3....4....5. ) hexdump -(0030 16 01 02 36 00 16 01 03 6e 00 16 01 ff 6f 00 16 ...6....n....o.. ) hexdump -(0040 01 ff 70 00 16 01 ff 71 00 16 01 ff 48 00 01 04 ..p....q....H... ) hexdump -(0050 ff 03 07 00 24 00 01 01 05 25 00 01 01 05 26 00 ....$....%....&. ) hexdump -(0060 01 01 05 27 00 01 01 05 6a 00 01 01 00 6b 00 01 ...'....j....k.. ) hexdump -(0070 01 00 6c 00 01 01 00 6d 00 01 01 00 3d 00 01 02 ..l....m....=... ) hexdump -(0080 02 00 c0 00 03 08 80 00 00 00 00 00 00 00 b4 00 ................ ) hexdump -(0090 01 04 c0 a8 42 ef 39 00 16 08 05 05 05 05 00 00 ....B.9......... ) hexdump -(00a0 00 00 00 03 20 36 41 20 52 69 6e 67 00 00 00 00 .... 6A Ring.... ) hexdump -(00b0 00 00 00 00 00 00 ...... ) hexdump +0 () putline +0 (0000 cc 00 00 00 00 00 07 02 00 00 00 00 00 00 00 00 ................ ) putline +0 (0010 00 00 bd 0e fe 16 01 00 3e 00 03 08 58 4c 20 38 ........>...XL 8 ) putline +0 (0020 30 20 49 4d 33 00 16 01 00 34 00 16 01 01 35 00 0 IM3....4....5. ) putline +0 (0030 16 01 02 36 00 16 01 03 6e 00 16 01 ff 6f 00 16 ...6....n....o.. ) putline +0 (0040 01 ff 70 00 16 01 ff 71 00 16 01 ff 48 00 01 04 ..p....q....H... ) putline +0 (0050 ff 03 07 00 24 00 01 01 05 25 00 01 01 05 26 00 ....$....%....&. ) putline +0 (0060 01 01 05 27 00 01 01 05 6a 00 01 01 00 6b 00 01 ...'....j....k.. ) putline +0 (0070 01 00 6c 00 01 01 00 6d 00 01 01 00 3d 00 01 02 ..l....m....=... ) putline +0 (0080 02 00 c0 00 03 08 80 00 00 00 00 00 00 00 b4 00 ................ ) putline +0 (0090 01 04 c0 a8 42 ef 39 00 16 08 05 05 05 05 00 00 ....B.9......... ) putline +0 (00a0 00 00 00 03 20 36 41 20 52 69 6e 67 00 00 00 00 .... 6A Ring.... ) putline +0 (00b0 00 00 00 00 00 00 ...... ) putline % ---- ethereal finale start ---- % % If this is not the first page, then print the page number @@ -1,11 +1,9 @@ /* rdps.c * - * - * $Id: rdps.c,v 1.3 1999/07/21 17:40:34 gram Exp $ + * $Id: rdps.c,v 1.4 2002/06/29 09:45:06 guy Exp $ * Ethereal - Network traffic analyzer - * By Gerald Combs <gerald@zing.org> + * By Gerald Combs <gerald@ethereal.com> * Copyright 1998 Gerald Combs - * * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,9 +22,8 @@ /* takes the file listed as the first argument and creates the file listed as the second argument. It takes a PostScript file and creates a C program -with 3 functions: +with 2 functions: print_ps_preamble() - print_ps_hex() print_ps_finale() */ @@ -83,11 +80,6 @@ int main(int argc, char **argv) start_code(output, "preamble"); continue; } - else if (strcmp(buf, "% ---- ethereal hex start ---- %\n") == 0) { - state = hex; - start_code(output, "hex"); - continue; - } else if (strcmp(buf, "% ---- ethereal finale start ---- %\n") == 0) { state = finale; start_code(output, "finale"); |