Ethereal-dev: Re: [ethereal-dev] No ZLIB and latest CVS sources

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxx>
Date: Wed, 26 Jan 2000 14:30:09 -0800 (PST)
> I haven't seen the change in CVS yet

	RCS file: /usr/local/cvsroot/ethereal/wiretap/file_wrappers.c,v
	Working file: file_wrappers.c
	head: 1.5
	branch:
	locks: strict
	access list:
	symbolic names:
	        release-0-8-2: 1.4
	keyword substitution: kv
	total revisions: 5;     selected revisions: 5
	description:
	----------------------------
	revision 1.5
	date: 2000/01/26 19:22:04;  author: guy;  state: Exp;  lines: +10 -11
	Always declare, and define, "file_seek()" to return a "long", as it's
	supposed to look like "ftell()".
 
	If you don't have zlib, just define "file_seek" as an alias for "fseek",
	rather than defining it as a routine.

		...

	RCS file: /usr/local/cvsroot/ethereal/wiretap/file_wrappers.h,v
	Working file: file_wrappers.h
	head: 1.4
	branch:
	locks: strict
	access list:
	symbolic names:
	        release-0-8-2: 1.3
	keyword substitution: kv
	total revisions: 4;     selected revisions: 4
	description:
	----------------------------
	revision 1.4
	date: 2000/01/26 19:22:04;  author: guy;  state: Exp;  lines: +3 -3
	Always declare, and define, "file_seek()" to return a "long", as it's
	supposed to look like "ftell()".
 
	If you don't have zlib, just define "file_seek" as an alias for "fseek",
	rather than defining it as a routine.

> and there was no patch attached :(

Attached (with the RCS ID changes removed).
Index: file_wrappers.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/wiretap/file_wrappers.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** file_wrappers.c	2000/01/25 04:49:55	1.4
--- file_wrappers.c	2000/01/26 19:22:04	1.5
***************
*** 56,66 ****
   * in the first place, so we don't know whether to include "zlib.h"
   * until we include "config.h"....
   *
   * So what we do is *undefine* HAVE_UNISTD_H before including "wtap.h"
   * (we need "wtap.h" to get the WTAP_ERR_ZLIB values, and it also includes
!  * "zlib.h" if HAVE_ZLIB" is defined), and make "file_seek()" a subroutine,
!  * so that the only call to "gzseek()" is in this file, which, by dint of
!  * the hackery described above, manages to correctly declare "gzseek()".
   *
   * DO NOT, UNDER ANY CIRCUMSTANCES, REMOVE THE FOLLOWING LINE, OR MOVE
   * IT AFTER THE INCLUDE OF "wtap.h"!  Doing so will cause any program
--- 56,71 ----
   * in the first place, so we don't know whether to include "zlib.h"
   * until we include "config.h"....
   *
+  * A similar problem appears to occur with "gztell()", at least on
+  * NetBSD.
+  *
   * So what we do is *undefine* HAVE_UNISTD_H before including "wtap.h"
   * (we need "wtap.h" to get the WTAP_ERR_ZLIB values, and it also includes
!  * "zlib.h" if HAVE_ZLIB" is defined), and, if we have zlib, make
!  * "file_seek()" and "file_tell()" subroutines, so that the only calls to
!  * "gzseek()" and "gztell()" are in this file, which, by dint of the
!  * hackery described above, manages to correctly declare "gzseek()" and
!  * "gztell()".
   *
   * DO NOT, UNDER ANY CIRCUMSTANCES, REMOVE THE FOLLOWING LINE, OR MOVE
   * IT AFTER THE INCLUDE OF "wtap.h"!  Doing so will cause any program
***************
*** 81,87 ****
  #include "file_wrappers.h"
  
  #ifdef HAVE_LIBZ
! int
  file_seek(void *stream, long offset, int whence)
  {
  	return gzseek(stream, (z_off_t)offset, whence);
--- 86,92 ----
  #include "file_wrappers.h"
  
  #ifdef HAVE_LIBZ
! long
  file_seek(void *stream, long offset, int whence)
  {
  	return gzseek(stream, (z_off_t)offset, whence);
***************
*** 91,102 ****
  file_tell(void *stream)
  {
  	return (long)gztell(stream);
- }
- #else /* HAVE_LIBZ */
- long
- file_seek(FILE *stream, long offset, int whence)
- {
- 	return fseek(stream, offset, whence);
  }
  #endif /* HAVE_LIBZ */
  
--- 96,101 ----

Index: file_wrappers.h
===================================================================
RCS file: /usr/local/cvsroot/ethereal/wiretap/file_wrappers.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -c -r1.3 -r1.4
*** file_wrappers.h	2000/01/25 04:49:55	1.3
--- file_wrappers.h	2000/01/26 19:22:04	1.4
***************
*** 27,33 ****
  #ifdef HAVE_LIBZ
  #define file_open gzopen
  #define filed_open gzdopen
! extern int file_seek(void *stream, long offset, int whence);
  #define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize)))
  #define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
  #define file_close gzclose
--- 27,33 ----
  #ifdef HAVE_LIBZ
  #define file_open gzopen
  #define filed_open gzdopen
! extern long file_seek(void *stream, long offset, int whence);
  #define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize)))
  #define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
  #define file_close gzclose
***************
*** 39,45 ****
  #else /* No zLib */
  #define file_open fopen
  #define filed_open fdopen
! extern int file_seek(FILE *stream, long offset, int whence);
  #define file_read fread
  #define file_write fwrite
  #define file_close fclose
--- 39,45 ----
  #else /* No zLib */
  #define file_open fopen
  #define filed_open fdopen
! #define file_seek fseek
  #define file_read fread
  #define file_write fwrite
  #define file_close fclose