Wireshark 4.7.0
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 <[email protected]>
6 * Copyright 1998 Gerald Combs
7 *
8 * Derived from code in the Wiretap Library
9 * Copyright (c) 1998 by Gilbert Ramirez <[email protected]>
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#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/*
22 * Types of compression for a file, including "none".
23 */
24typedef enum {
25 WS_FILE_UNCOMPRESSED,
26 WS_FILE_GZIP_COMPRESSED,
27 WS_FILE_ZSTD_COMPRESSED,
28 WS_FILE_LZ4_COMPRESSED,
29 WS_FILE_UNKNOWN_COMPRESSION,
30} ws_compression_type;
31
38WS_DLL_PUBLIC ws_compression_type
39ws_name_to_compression_type(const char *name);
40
41WS_DLL_PUBLIC ws_compression_type
42
49ws_extension_to_compression_type(const char *ext);
50
57WS_DLL_PUBLIC bool
58ws_can_write_compression_type(ws_compression_type compression_type);
59
66WS_DLL_PUBLIC const char *
67ws_compression_type_description(ws_compression_type compression_type);
68
75WS_DLL_PUBLIC const char *
76ws_compression_type_extension(ws_compression_type compression_type);
77
84WS_DLL_PUBLIC const char *
85ws_compression_type_name(ws_compression_type compression_type);
86
95WS_DLL_PUBLIC GSList *
96ws_get_all_compression_type_extensions_list(void);
97
106WS_DLL_PUBLIC GSList *
107ws_get_all_output_compression_type_names_list(void);
108
109/*
110 * (Possibly) compressed writable stream.
111 * Data is written to the stream using one of the above compression
112 * types, if the type supports writing.
113 *
114 * One of those types is WS_FILE_UNCOMPRESSED, which is why it's
115 * *possibly* compressed.
116 */
117typedef struct ws_cwstream ws_cwstream;
118
127WS_DLL_PUBLIC ws_cwstream*
128ws_cwstream_open(const char *filename, ws_compression_type ctype, int *err);
129
138WS_DLL_PUBLIC ws_cwstream*
139ws_cwstream_fdopen(int fd, ws_compression_type ctype, int *err);
140
148WS_DLL_PUBLIC ws_cwstream*
149ws_cwstream_open_stdout(ws_compression_type ctype, int *err);
150
151/* Write to file */
162WS_DLL_PUBLIC bool
163ws_cwstream_write(ws_cwstream* pfile, const uint8_t* data, size_t data_length,
164 uint64_t *bytes_written, int *err);
165
173WS_DLL_PUBLIC bool
174ws_cwstream_flush(ws_cwstream* pfile, int *err);
175
188WS_DLL_PUBLIC bool
189ws_cwstream_close(ws_cwstream* pfile, int *err);
190
191#if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
192
193typedef struct gzip_writer *GZWFILE_T;
194
195WS_DLL_PUBLIC GZWFILE_T gzwfile_open(const char *path);
196WS_DLL_PUBLIC GZWFILE_T gzwfile_fdopen(int fd);
197WS_DLL_PUBLIC unsigned gzwfile_write(GZWFILE_T state, const void *buf, unsigned len);
198WS_DLL_PUBLIC int gzwfile_flush(GZWFILE_T state);
199WS_DLL_PUBLIC int gzwfile_close(GZWFILE_T state);
200WS_DLL_PUBLIC int gzwfile_geterr(GZWFILE_T state);
201#endif /* HAVE_ZLIB */
202
203#ifdef HAVE_LZ4
204typedef struct lz4_writer *LZ4WFILE_T;
205
206WS_DLL_PUBLIC LZ4WFILE_T lz4wfile_open(const char *path);
207WS_DLL_PUBLIC LZ4WFILE_T lz4wfile_fdopen(int fd);
208WS_DLL_PUBLIC size_t lz4wfile_write(LZ4WFILE_T state, const void *buf, size_t len);
209WS_DLL_PUBLIC int lz4wfile_flush(LZ4WFILE_T state);
210WS_DLL_PUBLIC int lz4wfile_close(LZ4WFILE_T state);
211WS_DLL_PUBLIC int lz4wfile_geterr(LZ4WFILE_T state);
212#endif
213
214#ifdef __cplusplus
215}
216#endif /* __cplusplus */
217
218#endif /* __WSUTIL_FILE_COMPRESSED_H__ */
Definition file_compressed.c:152