a51d7220564a9532115cda5b76296e6a19a6042e
[obnox/wireshark/wip.git] / wiretap / file_wrappers.h
1 /* file_wrappers.h
2  *
3  * $Id$
4  *
5  * Wiretap Library
6  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  */
23
24 #ifndef __FILE_H__
25 #define __FILE_H__
26
27 extern gint64 file_seek(void *stream, gint64 offset, int whence, int *err);
28 extern gint64 file_tell(void *stream);
29 extern int file_error(void *fh);
30
31 #ifdef HAVE_LIBZ
32
33 extern FILE_T file_open(const char *path, const char *mode);
34 #define filed_open gzdopen
35 /* XX: gzread and gzwrite return number of *bytes* (not number of elements) */
36 #define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize)))
37 #define file_close gzclose
38 #define file_getc gzgetc
39 #define file_gets(buf, len, file) gzgets((file), (buf), (len))
40 #define file_eof gzeof
41
42 #else /* No zLib */
43
44 #define file_open(path, mode) ws_fopen(path, mode)
45 #define filed_open fdopen
46 /* XX: file_read defined to return number of *bytes* to be consistent with gzread */
47 #define file_read(buf, bsize, count, file) ((bsize) * fread((buf), (bsize), (count), (file)))
48 #define file_close fclose
49 #define file_getc fgetc
50 #define file_gets fgets
51 #define file_eof feof
52
53 #endif /* HAVE_LIBZ */
54
55 #endif /* __FILE_H__ */