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
This commit is contained in:
Guy Harris 2011-04-08 17:42:20 +00:00
parent da3f7673db
commit de938dddce
2 changed files with 14 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -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*);