aboutsummaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>1999-07-23 08:29:24 +0000
committerGuy Harris <guy@alum.mit.edu>1999-07-23 08:29:24 +0000
commit356a07b384d1b3ff58ccf8a5f01b76f879055baf (patch)
tree5546665a4b2e1fa09c5d4a74623c5c860cf70b03 /print.c
parentde459d1426cc27341dcf681cf5b35c27c9a5732a (diff)
Add a "File/Print" menu item, which prints *all* the packets in the
capture to a file or printer. This should eventually get the ability to print either all the packets or only the packets selected by the display filter, and possibly also the ability to print only packets M through N. Get rid of "cur" member of "capture_file" structure; nobody used it. There's no need to pass a pointer to a "dialog_button" variable to "simple_dialog()" for the error boxes displayed if a file copy or move fails; that dialog box is just a message box and has only an "OK" button. Put the declaration of "prefs" into "prefs.h". svn path=/trunk/; revision=378
Diffstat (limited to 'print.c')
-rw-r--r--print.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/print.c b/print.c
index 68ba00762f..41e294a790 100644
--- a/print.c
+++ b/print.c
@@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.13 1999/07/15 15:32:43 gram Exp $
+ * $Id: print.c,v 1.14 1999/07/23 08:29:22 guy Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@@ -56,7 +56,6 @@ static void ps_clean_string(unsigned char *out, const unsigned char *in,
int outbuf_size);
static void dumpit_ps (FILE *fh, register const u_char *cp, register u_int length);
-extern e_prefs prefs;
extern int proto_data; /* in packet-data.c */
/* #include "ps.c" */
@@ -262,26 +261,34 @@ typedef struct {
const guint8 *pd;
} print_data;
-void proto_tree_print(GNode *protocol_tree, const u_char *pd, frame_data *fd)
+FILE *open_print_dest(int to_file, const char *dest)
{
FILE *fh;
char *out;
- print_data data;
/* Open the file or command for output */
- if (prefs.pr_dest == PR_DEST_CMD) {
- out = prefs.pr_cmd;
+ out = dest;
+ if (to_file)
+ fh = fopen(dest, "w");
+ else
fh = popen(prefs.pr_cmd, "w");
- }
- else {
- out = prefs.pr_file;
- fh = fopen(prefs.pr_file, "w");
- }
- if (!fh) {
- g_error("Cannot open %s for output.\n", out);
- return;
- }
+ return fh;
+}
+
+void close_print_dest(int to_file, FILE *fh)
+{
+ /* Close the file or command */
+ if (to_file)
+ fclose(fh);
+ else
+ pclose(fh);
+}
+
+void proto_tree_print(GNode *protocol_tree, const u_char *pd, frame_data *fd,
+ FILE *fh)
+{
+ print_data data;
/* Create the output */
data.level = 0;
@@ -296,14 +303,6 @@ void proto_tree_print(GNode *protocol_tree, const u_char *pd, frame_data *fd)
proto_tree_print_node_ps, &data);
print_ps_finale(fh);
}
-
- /* Close the file or command */
- if (prefs.pr_dest == PR_DEST_CMD) {
- pclose(fh);
- }
- else {
- fclose(fh);
- }
}
/* Print a tree's data, and any child nodes, in plain text */