[Automatic manuf and enterprise-numbers update for 2010-04-04]
[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_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
38 #define file_close gzclose
39 #define file_getc gzgetc
40 #define file_gets(buf, len, file) gzgets((file), (buf), (len))
41 #define file_eof gzeof
42
43 #else /* No zLib */
44
45 #define file_open(path, mode) ws_fopen(path, mode)
46 #define filed_open fdopen
47 /* XX: file_read and file_write defined to return number of *bytes* to be consistent with gzread & gzwrite */
48 #define file_read(buf, bsize, count, file) ((bsize) * fread((buf), (bsize), (count), (file)))
49 #define file_write(buf, bsize, count, file) ((bsize) * fwrite((buf), (bsize), (count), (file)))
50 #define file_close fclose
51 #define file_getc fgetc
52 #define file_gets fgets
53 #define file_eof feof
54
55 #endif /* HAVE_LIBZ */
56
57 #endif /* __FILE_H__ */