Wireshark 4.7.2
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
json_dumper.h
Go to the documentation of this file.
1
12
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
54
56#define JSON_DUMPER_MAX_DEPTH 1100
60typedef struct json_dumper {
62 GString *output_string;
63#define JSON_DUMPER_FLAGS_PRETTY_PRINT (1 << 0)
64#define JSON_DUMPER_DOT_TO_UNDERSCORE (1 << 1)
65#define JSON_DUMPER_FLAGS_NO_DEBUG (1 << 17)
66 int flags;
67 /* For internal use; initialize with zeroes. */
68 unsigned current_depth;
72 /* Internal write buffer */
73#define JD_BUF_SIZE 8192
74 char buf[JD_BUF_SIZE];
75 size_t buf_pos;
77
85WS_DLL_PUBLIC void
87
96WS_DLL_PUBLIC void
97json_dumper_set_member_name(json_dumper *dumper, const char *name);
98
99WS_DLL_PUBLIC void
100json_dumper_set_member_name_noesc(json_dumper *dumper, const char *name, size_t len);
101
109#define json_dumper_set_member_name_const(dumper, literal) \
110 json_dumper_set_member_name_noesc(dumper, literal, sizeof(literal) - 1)
111
119WS_DLL_PUBLIC void
121
129WS_DLL_PUBLIC void
131
139WS_DLL_PUBLIC void
141
150WS_DLL_PUBLIC void
151json_dumper_value_string(json_dumper *dumper, const char *value);
152
163WS_DLL_PUBLIC void
164json_dumper_value_string_noesc(json_dumper *dumper, const char *value, size_t len);
165
174WS_DLL_PUBLIC void
175json_dumper_value_double(json_dumper *dumper, double value);
176
186WS_DLL_PUBLIC void
187json_dumper_value_anyf(json_dumper *dumper, const char *format, ...)
188G_GNUC_PRINTF(2, 3);
189
201WS_DLL_PUBLIC void
202json_dumper_value_va_list(json_dumper *dumper, const char *format, va_list ap);
203
210WS_DLL_PUBLIC void
211json_dumper_value_int(json_dumper *dumper, int64_t value);
212
219WS_DLL_PUBLIC void
220json_dumper_value_uint(json_dumper *dumper, uint64_t value);
221
229WS_DLL_PUBLIC void
230json_dumper_begin_base64(json_dumper *dumper);
231
239WS_DLL_PUBLIC void
240json_dumper_end_base64(json_dumper *dumper);
241
251WS_DLL_PUBLIC void
252json_dumper_write_base64(json_dumper *dumper, const unsigned char *data, size_t len);
253
262WS_DLL_PUBLIC bool
263json_dumper_finish(json_dumper *dumper);
264
265#ifdef __cplusplus
266}
267#endif
268
269#endif /* __JSON_DUMPER_H__ */
270
271/*
272 * Editor modelines - https://www.wireshark.org/tools/modelines.html
273 *
274 * Local variables:
275 * c-basic-offset: 4
276 * tab-width: 8
277 * indent-tabs-mode: nil
278 * End:
279 *
280 * vi: set shiftwidth=4 tabstop=8 expandtab:
281 * :indentSize=4:tabSize=8:noTabs=true:
282 */
WS_DLL_PUBLIC void json_dumper_set_member_name_noesc(json_dumper *dumper, const char *name, size_t len)
Definition json_dumper.c:557
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:725
WS_DLL_PUBLIC void json_dumper_value_string_noesc(json_dumper *dumper, const char *value, size_t len)
Writes a string value that is known to not require JSON escaping.
Definition json_dumper.c:707
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:527
#define JSON_DUMPER_MAX_DEPTH
Definition json_dumper.h:56
WS_DLL_PUBLIC void json_dumper_end_object(json_dumper *dumper)
Ends the current JSON object.
Definition json_dumper.c:587
WS_DLL_PUBLIC void json_dumper_end_array(json_dumper *dumper)
Ends the current JSON array.
Definition json_dumper.c:599
WS_DLL_PUBLIC void json_dumper_begin_object(json_dumper *dumper)
Begins a new JSON object.
Definition json_dumper.c:521
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:691
WS_DLL_PUBLIC void json_dumper_value_anyf(json_dumper *dumper, const char *format,...)
Writes a formatted literal value to the JSON output.
Definition json_dumper.c:764
WS_DLL_PUBLIC void json_dumper_begin_array(json_dumper *dumper)
Begins a new JSON array.
Definition json_dumper.c:593
State and configuration for incrementally writing JSON output to a file or string.
Definition json_dumper.h:60
char buf[8192]
Definition json_dumper.h:74
int base64_save
Definition json_dumper.h:70
int base64_state
Definition json_dumper.h:69
FILE * output_file
Definition json_dumper.h:61
int flags
Definition json_dumper.h:66
uint8_t state[1100]
Definition json_dumper.h:71
unsigned current_depth
Definition json_dumper.h:68
size_t buf_pos
Definition json_dumper.h:75
GString * output_string
Definition json_dumper.h:62