4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
6 * SPDX-License-Identifier: GPL-2.0-or-later
9 #ifndef __WTAP_FILE_WRAPPERS_H__
10 #define __WTAP_FILE_WRAPPERS_H__
12 #include <wireshark.h>
14 #include <wsutil/file_util.h>
16 extern FILE_T
file_open(const char *path
);
17 extern FILE_T
file_fdopen(int fildes
);
18 extern void file_set_random_access(FILE_T stream
, bool random_flag
, GPtrArray
*seek
);
19 WS_DLL_PUBLIC
int64_t file_seek(FILE_T stream
, int64_t offset
, int whence
, int *err
);
20 WS_DLL_PUBLIC
int64_t file_tell(FILE_T stream
);
21 extern int64_t file_tell_raw(FILE_T stream
);
22 extern int file_fstat(FILE_T stream
, ws_statb64
*statb
, int *err
);
23 WS_DLL_PUBLIC
bool file_iscompressed(FILE_T stream
);
24 WS_DLL_PUBLIC
int file_read(void *buf
, unsigned int count
, FILE_T file
);
25 WS_DLL_PUBLIC
int file_peekc(FILE_T stream
);
26 WS_DLL_PUBLIC
int file_getc(FILE_T stream
);
27 WS_DLL_PUBLIC
char *file_gets(char *buf
, int len
, FILE_T stream
);
28 WS_DLL_PUBLIC
char *file_getsp(char *buf
, int len
, FILE_T stream
);
29 WS_DLL_PUBLIC
int file_eof(FILE_T stream
);
30 WS_DLL_PUBLIC
int file_error(FILE_T fh
, char **err_info
);
31 extern void file_clearerr(FILE_T stream
);
32 extern void file_fdclose(FILE_T file
);
33 extern bool file_fdreopen(FILE_T file
, const char *path
);
34 extern void file_close(FILE_T file
);
36 #if defined (HAVE_ZLIB) || defined (HAVE_ZLIBNG)
37 typedef struct wtap_writer
*GZWFILE_T
;
39 extern GZWFILE_T
gzwfile_open(const char *path
);
40 extern GZWFILE_T
gzwfile_fdopen(int fd
);
41 extern unsigned gzwfile_write(GZWFILE_T state
, const void *buf
, unsigned len
);
42 extern int gzwfile_flush(GZWFILE_T state
);
43 extern int gzwfile_close(GZWFILE_T state
);
44 extern int gzwfile_geterr(GZWFILE_T state
);
45 #endif /* HAVE_ZLIB */
48 typedef struct lz4_writer
*LZ4WFILE_T
;
50 extern LZ4WFILE_T
lz4wfile_open(const char *path
);
51 extern LZ4WFILE_T
lz4wfile_fdopen(int fd
);
52 extern size_t lz4wfile_write(LZ4WFILE_T state
, const void *buf
, size_t len
);
53 extern int lz4wfile_flush(LZ4WFILE_T state
);
54 extern int lz4wfile_close(LZ4WFILE_T state
);
55 extern int lz4wfile_geterr(LZ4WFILE_T state
);
58 #endif /* __FILE_H__ */