2 * Definitions for print streams.
4 * Gilbert Ramirez <gram@alumni.rice.edu>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __PRINT_STREAM_H__
14 #define __PRINT_STREAM_H__
16 #include "ws_symbol_export.h"
18 #include <wsutil/color.h>
22 #endif /* __cplusplus */
25 * Print stream code; this provides a "print stream" class with subclasses
26 * of various sorts. Additional subclasses might be implemented elsewhere.
30 typedef struct print_stream_ops {
31 gboolean (*print_preamble)(struct print_stream *self, gchar *filename, const char *version_string);
32 gboolean (*print_line)(struct print_stream *self, int indent,
34 gboolean (*print_bookmark)(struct print_stream *self,
35 const gchar *name, const gchar *title);
36 gboolean (*new_page)(struct print_stream *self);
37 gboolean (*print_finale)(struct print_stream *self);
38 gboolean (*destroy)(struct print_stream *self);
39 gboolean (*print_line_color)(struct print_stream *self, int indent, const char *line, const color_t *fg, const color_t *bg);
42 typedef struct print_stream {
43 const print_stream_ops_t *ops;
45 const char *to_codeset;
48 unsigned short csb_attrs; // WORD
52 WS_DLL_PUBLIC print_stream_t *print_stream_text_new(gboolean to_file, const char *dest);
53 WS_DLL_PUBLIC print_stream_t *print_stream_text_stdio_new(FILE *fh);
54 WS_DLL_PUBLIC print_stream_t *print_stream_ps_new(gboolean to_file, const char *dest);
55 WS_DLL_PUBLIC print_stream_t *print_stream_ps_stdio_new(FILE *fh);
57 WS_DLL_PUBLIC gboolean print_preamble(print_stream_t *self, gchar *filename, const char *version_string);
58 WS_DLL_PUBLIC gboolean print_line(print_stream_t *self, int indent, const char *line);
59 WS_DLL_PUBLIC gboolean print_bookmark(print_stream_t *self, const gchar *name,
61 WS_DLL_PUBLIC gboolean new_page(print_stream_t *self);
62 WS_DLL_PUBLIC gboolean print_finale(print_stream_t *self);
63 WS_DLL_PUBLIC gboolean destroy_print_stream(print_stream_t *self);
66 * equivalent to print_line(), but if the stream supports text coloring then
67 * the output text will also be colored with the given foreground and
70 * returns TRUE if the print was successful, FALSE otherwise
72 WS_DLL_PUBLIC gboolean print_line_color(print_stream_t *self, int indent, const char *line, const color_t *fg, const color_t *bg);
76 #endif /* __cplusplus */
78 #endif /* print_stream.h */