Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
file_compressed.h
1/* file_compressed.h
2 * Declarations for writing compressed files.
3 *
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
7 *
8 * Derived from code in the Wiretap Library
9 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14#ifndef __WSUTIL_FILE_COMPRESSED_H__
15#define __WSUTIL_FILE_COMPRESSED_H__
16
17#include <wireshark.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif /* __cplusplus */
22
26typedef enum {
27 WS_FILE_UNCOMPRESSED,
28 WS_FILE_GZIP_COMPRESSED,
29 WS_FILE_ZSTD_COMPRESSED,
30 WS_FILE_LZ4_COMPRESSED,
31 WS_FILE_UNKNOWN_COMPRESSION,
32} ws_compression_type;
33
40WS_DLL_PUBLIC ws_compression_type
41ws_name_to_compression_type(const char *name);
42
43WS_DLL_PUBLIC ws_compression_type
44
51ws_extension_to_compression_type(const char *ext);
52
59WS_DLL_PUBLIC bool
60ws_can_write_compression_type(ws_compression_type compression_type);
61
68WS_DLL_PUBLIC const char *
69ws_compression_type_description(ws_compression_type compression_type);
70
77WS_DLL_PUBLIC const char *
78ws_compression_type_extension(ws_compression_type compression_type);
79
86WS_DLL_PUBLIC const char *
87ws_compression_type_name(ws_compression_type compression_type);
88
97WS_DLL_PUBLIC GSList *
98ws_get_all_compression_type_extensions_list(void);
99
108WS_DLL_PUBLIC GSList *
109ws_get_all_output_compression_type_names_list(void);
110
111/*
112 * (Possibly) compressed writable stream.
113 * Data is written to the stream using one of the above compression
114 * types, if the type supports writing.
115 *
116 * One of those types is WS_FILE_UNCOMPRESSED, which is why it's
117 * *possibly* compressed.
118 */
119typedef struct ws_cwstream ws_cwstream;
120
129WS_DLL_PUBLIC ws_cwstream*
130ws_cwstream_open(const char *filename, ws_compression_type ctype, int *err);
131
140WS_DLL_PUBLIC ws_cwstream*
141ws_cwstream_fdopen(int fd, ws_compression_type ctype, int *err);
142
150WS_DLL_PUBLIC ws_cwstream*
151ws_cwstream_open_stdout(ws_compression_type ctype, int *err);
152
153/* Write to file */
164WS_DLL_PUBLIC bool
165ws_cwstream_write(ws_cwstream* pfile, const uint8_t* data, size_t data_length,
166 uint64_t *bytes_written, int *err);
167
175WS_DLL_PUBLIC bool
176ws_cwstream_flush(ws_cwstream* pfile, int *err);
177
190WS_DLL_PUBLIC bool
191ws_cwstream_close(ws_cwstream* pfile, int *err);
192
204WS_DLL_PUBLIC void
205ws_cwstream_close_after_error(ws_cwstream* pfile);
206
207#if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
208
209typedef struct gzip_writer *GZWFILE_T;
210
211WS_DLL_PUBLIC GZWFILE_T gzwfile_open(const char *path);
212WS_DLL_PUBLIC GZWFILE_T gzwfile_fdopen(int fd);
213WS_DLL_PUBLIC unsigned gzwfile_write(GZWFILE_T state, const void *buf, unsigned len);
214WS_DLL_PUBLIC int gzwfile_flush(GZWFILE_T state);
215WS_DLL_PUBLIC int gzwfile_close(GZWFILE_T state);
216WS_DLL_PUBLIC void gzwfile_close_after_error(GZWFILE_T state);
217WS_DLL_PUBLIC int gzwfile_geterr(GZWFILE_T state);
218#endif /* HAVE_ZLIB */
219
220#ifdef HAVE_LZ4
221typedef struct lz4_writer *LZ4WFILE_T;
222
223WS_DLL_PUBLIC LZ4WFILE_T lz4wfile_open(const char *path);
224WS_DLL_PUBLIC LZ4WFILE_T lz4wfile_fdopen(int fd);
225WS_DLL_PUBLIC size_t lz4wfile_write(LZ4WFILE_T state, const void *buf, size_t len);
226WS_DLL_PUBLIC int lz4wfile_flush(LZ4WFILE_T state);
227WS_DLL_PUBLIC int lz4wfile_close(LZ4WFILE_T state);
228WS_DLL_PUBLIC void lz4wfile_close_after_error(LZ4WFILE_T state);
229WS_DLL_PUBLIC int lz4wfile_geterr(LZ4WFILE_T state);
230#endif
231
232#ifdef __cplusplus
233}
234#endif /* __cplusplus */
235
236#endif /* __WSUTIL_FILE_COMPRESSED_H__ */
Definition file_compressed.c:150