+
+/* internally open a file for writing (compressed or not) */
+static FILE *wtap_dump_file_open(wtap_dumper *wdh, const char *filename)
+{
+#ifdef HAVE_LIBZ
+ if(wdh->compressed) {
+ return gzopen(filename, "wb");
+ } else
+#endif
+ {
+ return eth_fopen(filename, "wb");
+ }
+}
+
+/* internally open a file for writing (compressed or not) */
+static FILE *wtap_dump_file_fdopen(wtap_dumper *wdh, int fd)
+{
+#ifdef HAVE_LIBZ
+ if(wdh->compressed) {
+ return gzdopen(fd, "wb");
+ } else
+#endif
+ {
+ return fdopen(fd, "wb");
+ }
+}
+
+/* internally writing raw bytes (compressed or not) */
+size_t wtap_dump_file_write(wtap_dumper *wdh, const void *buf, unsigned bufsize)
+{
+#ifdef HAVE_LIBZ
+ if(wdh->compressed) {
+ return gzwrite(wdh->fh, buf, bufsize);
+ } else
+#endif
+ {
+ return fwrite(buf, 1, bufsize, wdh->fh);
+ }
+}
+
+/* internally close a file for writing (compressed or not) */
+static int wtap_dump_file_close(wtap_dumper *wdh)
+{
+#ifdef HAVE_LIBZ
+ if(wdh->compressed) {
+ return gzclose(wdh->fh);
+ } else
+#endif
+ {
+ return fclose(wdh->fh);
+ }
+}
+
+int wtap_dump_file_ferror(wtap_dumper *wdh)
+{
+#ifdef HAVE_LIBZ
+ int errnum;
+
+ if(wdh->compressed) {
+ gzerror(wdh->fh, &errnum);
+
+ if(errnum == Z_ERRNO) {
+ return errno;
+ } else {
+ /* XXX - what to do with this zlib specific number? */
+ return errnum;
+ }
+ } else
+#endif
+ {
+ return ferror(wdh->fh);
+ }
+}
+