aboutsummaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-30 06:42:10 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>1999-10-30 06:42:10 +0000
commit79f17949d5857fd03d72926cb7b4c4fc8236abb2 (patch)
treefefb90235a5e34b5424173c72d207d276840161e /print.c
parentdad66e20a7506b040f9cedc658dcade529746ce3 (diff)
Warren Young's patch to add a "Print" button to the "Follow TCP Stream"
data window. Some (belated) man page updates. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@950 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'print.c')
-rw-r--r--print.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/print.c b/print.c
index fd89b2c267..8d6c40ac87 100644
--- a/print.c
+++ b/print.c
@@ -1,7 +1,7 @@
/* print.c
* Routines for printing packet analysis trees.
*
- * $Id: print.c,v 1.21 1999/09/29 22:19:13 guy Exp $
+ * $Id: print.c,v 1.22 1999/10/30 06:41:36 guy Exp $
*
* Gilbert Ramirez <gram@verdict.uthscsa.edu>
*
@@ -47,6 +47,8 @@ static void proto_tree_print_node_ps(GNode *node, gpointer data);
static void ps_clean_string(unsigned char *out, const unsigned char *in,
int outbuf_size);
static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length);
+static void print_ps_file(FILE* target_fh, FILE* source_fh);
+static void print_text_file(FILE* target_fh, FILE* source_fh);
extern int proto_data; /* in packet-data.c */
@@ -93,6 +95,20 @@ void print_finale(FILE *fh)
print_ps_finale(fh);
}
+void print_file(FILE* fh, const char* filename)
+{
+ FILE* fh2 = fopen(filename, "r");
+ if (fh2 == NULL) {
+ fprintf(stderr, "Could not open file %s for reading.\n", filename);
+ return;
+ }
+
+ if (prefs.pr_format == PR_FMT_PS)
+ print_ps_file(fh, fh2);
+ else
+ print_text_file(fh, fh2);
+}
+
void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh)
{
@@ -317,3 +333,25 @@ void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int lengt
return;
}
+
+static
+void print_text_file(FILE* target_fh, FILE* source_fh)
+{
+ gchar buffer[MAX_LINE_LENGTH];
+ while (fgets(buffer, sizeof(buffer), source_fh) != NULL) {
+ fputs(buffer, target_fh);
+ }
+}
+
+static
+void print_ps_file(FILE* target_fh, FILE* source_fh)
+{
+ gchar buffer[MAX_LINE_LENGTH];
+ gchar ps_buffer[MAX_LINE_LENGTH];
+
+ while (fgets(buffer, sizeof(buffer), source_fh) != NULL) {
+ ps_clean_string(ps_buffer, buffer, MAX_LINE_LENGTH);
+ fputs(ps_buffer, target_fh);
+ }
+}
+