checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / epan / print_stream.h
1 /* print_stream.h
2  * Definitions for print streams.
3  *
4  * Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12
13 #ifndef __PRINT_STREAM_H__
14 #define __PRINT_STREAM_H__
15
16 #include "ws_symbol_export.h"
17
18 #include <wsutil/color.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23
24 /*
25  * Print stream code; this provides a "print stream" class with subclasses
26  * of various sorts.  Additional subclasses might be implemented elsewhere.
27  */
28 struct print_stream;
29
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,
33             const char *line);
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);
40 } print_stream_ops_t;
41
42 typedef struct print_stream {
43         const print_stream_ops_t *ops;
44         gboolean isatty;
45         const char *to_codeset;
46         void *data;
47 #ifdef _WIN32
48         unsigned short csb_attrs; // WORD
49 #endif
50 } print_stream_t;
51
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);
56
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,
60     const gchar *title);
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);
64
65 /*
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
68  * background
69  *
70  * returns TRUE if the print was successful, FALSE otherwise
71  */
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);
73
74 #ifdef __cplusplus
75 }
76 #endif /* __cplusplus */
77
78 #endif /* print_stream.h */