| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
json_dumper.h
Go to the documentation of this file.
1
13#ifndef __JSON_DUMPER_H__
14#define __JSON_DUMPER_H__
15
16#include "ws_symbol_export.h"
17
18#include <inttypes.h>
19#include <stdbool.h>
20#include <stdio.h>
21
22#include <glib.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
56#define JSON_DUMPER_MAX_DEPTH 1100
57 typedef struct json_dumper {
58 FILE *output_file;
59 GString *output_string;
60#define JSON_DUMPER_FLAGS_PRETTY_PRINT (1 << 0) /* Enable pretty printing. */
61#define JSON_DUMPER_DOT_TO_UNDERSCORE (1 << 1) /* Convert dots to underscores in keys */
62#define JSON_DUMPER_FLAGS_NO_DEBUG (1 << 17) /* Disable fatal ws_error messages on error(intended for speeding up fuzzing). */
63 int flags;
64 /* for internal use, initialize with zeroes. */
65 unsigned current_depth;
66 int base64_state;
67 int base64_save;
68 uint8_t state[JSON_DUMPER_MAX_DEPTH];
69} json_dumper;
70
78WS_DLL_PUBLIC void
79 json_dumper_begin_object(json_dumper *dumper);
80
89WS_DLL_PUBLIC void
90 json_dumper_set_member_name(json_dumper *dumper, const char *name);
91
99WS_DLL_PUBLIC void
100 json_dumper_end_object(json_dumper *dumper);
101
109WS_DLL_PUBLIC void
110 json_dumper_begin_array(json_dumper *dumper);
111
119WS_DLL_PUBLIC void
120 json_dumper_end_array(json_dumper *dumper);
121
130WS_DLL_PUBLIC void
131 json_dumper_value_string(json_dumper *dumper, const char *value);
132
141WS_DLL_PUBLIC void
142 json_dumper_value_double(json_dumper *dumper, double value);
143
153WS_DLL_PUBLIC void
154json_dumper_value_anyf(json_dumper *dumper, const char *format, ...)
155G_GNUC_PRINTF(2, 3);
156
168WS_DLL_PUBLIC void
169 json_dumper_value_va_list(json_dumper *dumper, const char *format, va_list ap);
170
178WS_DLL_PUBLIC void
179 json_dumper_begin_base64(json_dumper *dumper);
180
188WS_DLL_PUBLIC void
189 json_dumper_end_base64(json_dumper *dumper);
190
200WS_DLL_PUBLIC void
201 json_dumper_write_base64(json_dumper *dumper, const unsigned char *data, size_t len);
202
211WS_DLL_PUBLIC bool
212 json_dumper_finish(json_dumper *dumper);
213
214#ifdef __cplusplus
215}
216#endif
217
218#endif /* __JSON_DUMPER_H__ */
219
220/*
221 * Editor modelines - https://www.wireshark.org/tools/modelines.html
222 *
223 * Local variables:
224 * c-basic-offset: 4
225 * tab-width: 8
226 * indent-tabs-mode: nil
227 * End:
228 *
229 * vi: set shiftwidth=4 tabstop=8 expandtab:
230 * :indentSize=4:tabSize=8:noTabs=true:
231 */
json_dumper_value_double
WS_DLL_PUBLIC void json_dumper_value_double(json_dumper *dumper, double value)
Writes a double-precision numeric value to the JSON output.
Definition json_dumper.c:588
json_dumper_set_member_name
WS_DLL_PUBLIC void json_dumper_set_member_name(json_dumper *dumper, const char *name)
Sets the name of the next member in a JSON object.
Definition json_dumper.c:438
json_dumper_begin_base64
WS_DLL_PUBLIC void json_dumper_begin_base64(json_dumper *dumper)
Begins a base64-encoded data block.
Definition json_dumper.c:654
json_dumper_value_va_list
WS_DLL_PUBLIC void WS_DLL_PUBLIC void json_dumper_value_va_list(json_dumper *dumper, const char *format, va_list ap)
Writes a formatted literal value using a va_list.
Definition json_dumper.c:610
JSON_DUMPER_MAX_DEPTH
#define JSON_DUMPER_MAX_DEPTH
Definition json_dumper.h:56
json_dumper_end_object
WS_DLL_PUBLIC void json_dumper_end_object(json_dumper *dumper)
Ends the current JSON object.
Definition json_dumper.c:468
json_dumper_finish
WS_DLL_PUBLIC bool json_dumper_finish(json_dumper *dumper)
Finalizes the JSON output.
Definition json_dumper.c:637
json_dumper_value_anyf
WS_DLL_PUBLIC void json_dumper_value_anyf(json_dumper *dumper, const char *format,...) G_GNUC_PRINTF(2
Writes a formatted literal value to the JSON output.
json_dumper_end_array
WS_DLL_PUBLIC void json_dumper_end_array(json_dumper *dumper)
Ends the current JSON array.
Definition json_dumper.c:480
json_dumper_end_base64
WS_DLL_PUBLIC void json_dumper_end_base64(json_dumper *dumper)
Ends a base64-encoded data block.
Definition json_dumper.c:688
json_dumper_begin_object
WS_DLL_PUBLIC void json_dumper_begin_object(json_dumper *dumper)
Begins a new JSON object.
Definition json_dumper.c:432
json_dumper_value_string
WS_DLL_PUBLIC void json_dumper_value_string(json_dumper *dumper, const char *value)
Writes a string value to the JSON output.
Definition json_dumper.c:572
json_dumper_begin_array
WS_DLL_PUBLIC void json_dumper_begin_array(json_dumper *dumper)
Begins a new JSON array.
Definition json_dumper.c:474
json_dumper_write_base64
WS_DLL_PUBLIC void json_dumper_write_base64(json_dumper *dumper, const unsigned char *data, size_t len)
Writes binary data in base64 format.
Definition json_dumper.c:660
json_dumper
Definition json_dumper.h:57
json_dumper::output_file
FILE * output_file
Definition json_dumper.h:58
json_dumper::output_string
GString * output_string
Definition json_dumper.h:59