diff --git a/cpukit/zlib/examples/zlib_how.html b/cpukit/zlib/examples/zlib_how.html index 40998dbf08..444ff1c9a3 100644 --- a/cpukit/zlib/examples/zlib_how.html +++ b/cpukit/zlib/examples/zlib_how.html @@ -4,7 +4,7 @@
+#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) +# include <fcntl.h> +# include <io.h> +# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif +CHUNK is simply the buffer size for feeding data to and pulling data from the zlib routines. Larger buffer sizes would be more efficient, especially for inflate(). If the memory is available, buffers sizes @@ -80,8 +98,8 @@ is used to pass information to and from the zlib routines, and to maint int ret, flush; unsigned have; z_stream strm; - char in[CHUNK]; - char out[CHUNK]; + unsigned char in[CHUNK]; + unsigned char out[CHUNK]; The first thing we do is to initialize the zlib state for compression using deflateInit(). This must be done before the first use of deflate(). @@ -313,8 +331,8 @@ can tell from the zlib stream itself when the stream is complete. int ret; unsigned have; z_stream strm; - char in[CHUNK]; - char out[CHUNK]; + unsigned char in[CHUNK]; + unsigned char out[CHUNK]; The initialization of the state is the same, except that there is no compression level, of course, and two more elements of the structure are initialized. avail_in @@ -494,6 +512,10 @@ int main(int argc, char **argv) { int ret; + /* avoid end-of-line conversions */ + SET_BINARY_MODE(stdin); + SET_BINARY_MODE(stdout); + /* do compression if no arguments */ if (argc == 1) { ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION); @@ -518,6 +540,6 @@ int main(int argc, char **argv) }