1 /* file_wrappers.h 2 * 3 * Wiretap Library 4 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu> 5 * 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 9 #ifndef __WTAP_FILE_WRAPPERS_H__ 10 #define __WTAP_FILE_WRAPPERS_H__ 11 12 #include <glib.h> 13 #include "wtap.h" 14 #include <wsutil/file_util.h> 15 #include "ws_symbol_export.h" 16 17 extern FILE_T file_open(const char *path); 18 extern FILE_T file_fdopen(int fildes); 19 extern void file_set_random_access(FILE_T stream, gboolean random_flag, GPtrArray *seek); 20 WS_DLL_PUBLIC gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err); 21 WS_DLL_PUBLIC gint64 file_tell(FILE_T stream); 22 extern gint64 file_tell_raw(FILE_T stream); 23 extern int file_fstat(FILE_T stream, ws_statb64 *statb, int *err); 24 WS_DLL_PUBLIC gboolean file_iscompressed(FILE_T stream); 25 WS_DLL_PUBLIC int file_read(void *buf, unsigned int count, FILE_T file); 26 WS_DLL_PUBLIC int file_peekc(FILE_T stream); 27 WS_DLL_PUBLIC int file_getc(FILE_T stream); 28 WS_DLL_PUBLIC char *file_gets(char *buf, int len, FILE_T stream); 29 WS_DLL_PUBLIC char *file_getsp(char *buf, int len, FILE_T stream); 30 WS_DLL_PUBLIC int file_eof(FILE_T stream); 31 WS_DLL_PUBLIC int file_error(FILE_T fh, gchar **err_info); 32 extern void file_clearerr(FILE_T stream); 33 extern void file_fdclose(FILE_T file); 34 extern int file_fdreopen(FILE_T file, const char *path); 35 extern void file_close(FILE_T file); 36 37 #ifdef HAVE_ZLIB 38 typedef struct wtap_writer *GZWFILE_T; 39 40 extern GZWFILE_T gzwfile_open(const char *path); 41 extern GZWFILE_T gzwfile_fdopen(int fd); 42 extern guint gzwfile_write(GZWFILE_T state, const void *buf, guint len); 43 extern int gzwfile_flush(GZWFILE_T state); 44 extern int gzwfile_close(GZWFILE_T state); 45 extern int gzwfile_geterr(GZWFILE_T state); 46 #endif /* HAVE_ZLIB */ 47 48 #endif /* __FILE_H__ */ 49