Wireshark  4.3.0
The Wireshark network protocol analyzer
print_stream.h
Go to the documentation of this file.
1 
13 #ifndef __PRINT_STREAM_H__
14 #define __PRINT_STREAM_H__
15 
16 #include "ws_symbol_export.h"
17 
18 #include <wsutil/color.h>
19 #include <wsutil/str_util.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 /*
26  * Print stream code; this provides a "print stream" class with subclasses
27  * of various sorts. Additional subclasses might be implemented elsewhere.
28  */
29 struct print_stream;
30 
31 typedef struct print_stream_ops {
32  bool (*print_preamble)(struct print_stream *self, char *filename, const char *version_string);
33  bool (*print_line)(struct print_stream *self, int indent,
34  const char *line);
35  bool (*print_line_color)(struct print_stream *self, int indent, const char *line, const color_t *fg, const color_t *bg);
36  bool (*print_bookmark)(struct print_stream *self,
37  const char *name, const char *title);
38  bool (*new_page)(struct print_stream *self);
39  bool (*print_finale)(struct print_stream *self);
40  bool (*destroy)(struct print_stream *self);
42 
43 typedef struct print_stream {
44  const print_stream_ops_t *ops;
45  void *data;
47 
48 /*
49  * These return a print_stream_t * on success and NULL on failure.
50  */
51 WS_DLL_PUBLIC print_stream_t *print_stream_text_new(bool to_file, const char *dest);
52 WS_DLL_PUBLIC print_stream_t *print_stream_text_stdio_new(FILE *fh);
53 WS_DLL_PUBLIC print_stream_t *print_stream_ps_new(bool to_file, const char *dest);
54 WS_DLL_PUBLIC print_stream_t *print_stream_ps_stdio_new(FILE *fh);
55 
56 /*
57  * These return true if the print was successful, false otherwise.
58  */
59 WS_DLL_PUBLIC bool print_preamble(print_stream_t *self, char *filename, const char *version_string);
60 WS_DLL_PUBLIC bool print_line(print_stream_t *self, int indent, const char *line);
61 
62 /*
63  * equivalent to print_line(), but if the stream supports text coloring then
64  * the output text will also be colored with the given foreground and
65  * background
66  */
67 WS_DLL_PUBLIC bool print_line_color(print_stream_t *self, int indent, const char *line, const color_t *fg, const color_t *bg);
68 WS_DLL_PUBLIC bool print_bookmark(print_stream_t *self, const char *name,
69  const char *title);
70 WS_DLL_PUBLIC bool new_page(print_stream_t *self);
71 WS_DLL_PUBLIC bool print_finale(print_stream_t *self);
72 WS_DLL_PUBLIC bool destroy_print_stream(print_stream_t *self);
73 
74 #ifdef __cplusplus
75 }
76 #endif /* __cplusplus */
77 
78 #endif /* print_stream.h */
Definition: color.h:23
Definition: print_stream.h:31
Definition: print_stream.h:43