epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / print_stream.h
blob98f59ddb35c45195dd323519d049ed81a9d2c519
1 /** @file
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>
19 #include <wsutil/str_util.h>
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
26 * Print stream code; this provides a "print stream" class with subclasses
27 * of various sorts. Additional subclasses might be implemented elsewhere.
29 struct print_stream;
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);
41 } print_stream_ops_t;
43 typedef struct print_stream {
44 const print_stream_ops_t *ops;
45 void *data;
46 } print_stream_t;
49 * These return a print_stream_t * on success and NULL on failure.
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);
57 * These return true if the print was successful, false otherwise.
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);
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
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);
74 #ifdef __cplusplus
76 #endif /* __cplusplus */
78 #endif /* print_stream.h */