aboutsummaryrefslogtreecommitdiffstats
path: root/print.h
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-07-25 08:53:38 +0000
committerGuy Harris <guy@alum.mit.edu>2004-07-25 08:53:38 +0000
commit5a3ab160c1f0d7c54b27bf339d0a0e99fecb4878 (patch)
treebd82ff9fdbe1928ad507cefd67b92ce2816e2b92 /print.h
parent809bd53e813b4cae8c1d9120618a894fd50a25f9 (diff)
Make some generic print routines that take, as an argument, a pointer to
a structure containing a pointer to print operations for that object and a pointer to the private subclass-dependent data for that object, with subclasses for text and PostScript, and use those rather than the old scheme where a print format was passed as an argument - or where (as in the case of printing summary information in Tethereal) we just printed as text even if "-T ps" was selected. Check whether those routines succeed or get an I/O error writing output. Clean up indentation. svn path=/trunk/; revision=11514
Diffstat (limited to 'print.h')
-rw-r--r--print.h49
1 files changed, 38 insertions, 11 deletions
diff --git a/print.h b/print.h
index 848608ffd4..d131f18f91 100644
--- a/print.h
+++ b/print.h
@@ -52,7 +52,7 @@ typedef enum {
} print_dissections_e;
typedef struct {
- print_format_e format; /* plain text, PostScript, PDML, ... */
+ print_format_e format; /* plain text or PostScript */
gboolean to_file; /* TRUE if we're printing to a file */
char *file; /* file output pathname */
char *cmd; /* print command string (not win32) */
@@ -69,21 +69,48 @@ typedef struct {
/* Functions in print.h */
-extern FILE *open_print_dest(int to_file, const char *dest);
-extern gboolean close_print_dest(int to_file, FILE *fh);
-extern void print_preamble(FILE *fh, print_format_e format, gchar *filename);
-extern void print_packet_header(FILE *fh, print_format_e format, guint32 number, gchar *summary);
-extern void print_formfeed(FILE *fh, print_format_e format);
-extern void print_finale(FILE *fh, print_format_e format);
-extern void proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
- FILE *fh);
extern void write_pdml_preamble(FILE *fh);
extern void proto_tree_write_pdml(epan_dissect_t *edt, FILE *fh);
extern void write_pdml_finale(FILE *fh);
+
extern void write_psml_preamble(FILE *fh);
extern void proto_tree_write_psml(epan_dissect_t *edt, FILE *fh);
extern void write_psml_finale(FILE *fh);
-extern void print_hex_data(FILE *fh, print_format_e format, epan_dissect_t *edt);
-extern void print_line(FILE *fh, int indent, print_format_e format, char *line);
+
+struct print_stream;
+
+typedef struct print_stream_ops {
+ gboolean (*print_preamble)(struct print_stream *self, gchar *filename);
+ gboolean (*print_line)(struct print_stream *self, int indent,
+ const char *line);
+ gboolean (*print_bookmark)(struct print_stream *self,
+ const gchar *name, const gchar *title);
+ gboolean (*new_page)(struct print_stream *self);
+ gboolean (*print_finale)(struct print_stream *self);
+ gboolean (*destroy)(struct print_stream *self);
+} print_stream_ops_t;
+
+typedef struct print_stream {
+ const print_stream_ops_t *ops;
+ void *data;
+} print_stream_t;
+
+extern gboolean proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
+ print_stream_t *stream);
+extern gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt);
+extern void print_packet_header(FILE *fh, print_format_e format, guint32 number, gchar *summary);
+
+extern print_stream_t *print_stream_text_new(int to_file, const char *dest);
+extern print_stream_t *print_stream_text_stdio_new(FILE *fh);
+extern print_stream_t *print_stream_ps_new(int to_file, const char *dest);
+extern print_stream_t *print_stream_ps_stdio_new(FILE *fh);
+
+extern gboolean print_preamble(print_stream_t *self, gchar *filename);
+extern gboolean print_line(print_stream_t *self, int indent, const char *line);
+extern gboolean print_bookmark(print_stream_t *self, const gchar *name,
+ const gchar *title);
+extern gboolean new_page(print_stream_t *self);
+extern gboolean print_finale(print_stream_t *self);
+extern gboolean destroy_print_stream(print_stream_t *self);
#endif /* print.h */