aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-08 17:42:20 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-08 17:42:20 +0000
commitde938dddceccb5f4c1da64924a758c2d214912dc (patch)
treea2a34bec98f260a54b513942ad4857382dd886e9
parentda3f7673db4f9adad7721c0ca05406d18cc24cf2 (diff)
Just make the fh member of a wtap_dumper_t a void * for now, and, in all
calls that use it, cast it to whatever it's supposed to be. Making it a gzFile means you can't use any stdio macros that reach inside the structure; making it a FILE *, as it used to be, amounts to trying to use a FILE * as a void * if we're writing a compressed file out. svn path=/trunk/; revision=36521
-rw-r--r--wiretap/file_access.c18
-rw-r--r--wiretap/wtap-int.h8
2 files changed, 14 insertions, 12 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 9ac254a27f..9a2f469096 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -921,7 +921,7 @@ static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int filetype, gboolean c
if(compressed) {
cant_seek = TRUE;
} else {
- fd = fileno(wdh->fh);
+ fd = fileno((FILE *)wdh->fh);
if (lseek(fd, 1, SEEK_CUR) == -1)
cant_seek = TRUE;
else {
@@ -949,11 +949,11 @@ void wtap_dump_flush(wtap_dumper *wdh)
{
#ifdef HAVE_LIBZ
if(wdh->compressed) {
- gzflush(wdh->fh, Z_SYNC_FLUSH); /* XXX - is Z_SYNC_FLUSH the right one? */
+ gzflush((gzFile)wdh->fh, Z_SYNC_FLUSH); /* XXX - is Z_SYNC_FLUSH the right one? */
} else
#endif
{
- fflush(wdh->fh);
+ fflush((FILE *)wdh->fh);
}
}
@@ -1053,14 +1053,14 @@ gboolean wtap_dump_file_write(wtap_dumper *wdh, const void *buf, size_t bufsize,
#ifdef HAVE_LIBZ
if (wdh->compressed) {
- nwritten = gzwrite(wdh->fh, buf, (unsigned) bufsize);
+ nwritten = gzwrite((gzFile)wdh->fh, buf, (unsigned) bufsize);
/*
* At least according to zlib.h, gzwrite returns 0
* on error; that appears to be the case in libz
* 1.2.5.
*/
if (nwritten == 0) {
- gzerror(wdh->fh, &errnum);
+ gzerror((gzFile)wdh->fh, &errnum);
if (errnum == Z_ERRNO)
*err = errno;
else {
@@ -1075,13 +1075,13 @@ gboolean wtap_dump_file_write(wtap_dumper *wdh, const void *buf, size_t bufsize,
} else
#endif
{
- nwritten = fwrite(buf, 1, bufsize, wdh->fh);
+ nwritten = fwrite(buf, 1, bufsize, (FILE *)wdh->fh);
/*
* At least according to the Mac OS X man page,
* this can return a short count on an error.
*/
if (nwritten != bufsize) {
- if (ferror(wdh->fh))
+ if (ferror((FILE *)wdh->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_WRITE;
@@ -1096,10 +1096,10 @@ static int wtap_dump_file_close(wtap_dumper *wdh)
{
#ifdef HAVE_LIBZ
if(wdh->compressed) {
- return gzclose(wdh->fh);
+ return gzclose((gzFile)wdh->fh);
} else
#endif
{
- return fclose(wdh->fh);
+ return fclose((FILE *)wdh->fh);
}
}
diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h
index feab2df258..6c020fd7ec 100644
--- a/wiretap/wtap-int.h
+++ b/wiretap/wtap-int.h
@@ -37,9 +37,6 @@
#ifdef HAVE_LIBZ
#include <zlib.h>
-#define WFILE_T gzFile
-#else /* No zLib */
-#define WFILE_T FILE *
#endif /* HAVE_LIBZ */
typedef struct {
@@ -104,6 +101,11 @@ struct wtap {
struct wtap_dumper;
+/*
+ * This could either be a FILE * or a gzFile.
+ */
+typedef void *WFILE_T;
+
typedef gboolean (*subtype_write_func)(struct wtap_dumper*,
const struct wtap_pkthdr*, const union wtap_pseudo_header*,
const guchar*, int*);