diff options
author | marha <marha@users.sourceforge.net> | 2012-06-22 15:53:45 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-06-22 15:54:13 +0200 |
commit | 7baa3d795c87c11550f1686488c968320428cbf9 (patch) | |
tree | 4c932d59c53a0d358916a7c66af5103b8bf22813 /zlib/examples/zpipe.c | |
parent | e1a407256a5c1571d8f4871fd981a51cfbd46e37 (diff) | |
download | vcxsrv-7baa3d795c87c11550f1686488c968320428cbf9.tar.gz vcxsrv-7baa3d795c87c11550f1686488c968320428cbf9.tar.bz2 vcxsrv-7baa3d795c87c11550f1686488c968320428cbf9.zip |
Switch to zlib 1.2.7
Diffstat (limited to 'zlib/examples/zpipe.c')
-rw-r--r-- | zlib/examples/zpipe.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/zlib/examples/zpipe.c b/zlib/examples/zpipe.c index 26abb56a9..83535d169 100644 --- a/zlib/examples/zpipe.c +++ b/zlib/examples/zpipe.c @@ -1,6 +1,6 @@ /* zpipe.c: example of proper use of zlib's inflate() and deflate() Not copyrighted -- provided to the public domain - Version 1.2 9 November 2004 Mark Adler */ + Version 1.4 11 December 2005 Mark Adler */ /* Version history: 1.0 30 Oct 2004 First version @@ -8,6 +8,8 @@ Use switch statement for inflate() return values 1.2 9 Nov 2004 Add assertions to document zlib guarantees 1.3 6 Apr 2005 Remove incorrect assertion in inf() + 1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions + Avoid some compiler warnings for input and output buffers */ #include <stdio.h> @@ -15,6 +17,14 @@ #include <assert.h> #include "zlib.h" +#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 + #define CHUNK 16384 /* Compress from file source to file dest until EOF on source. @@ -28,8 +38,8 @@ int def(FILE *source, FILE *dest, int level) int ret, flush; unsigned have; z_stream strm; - char in[CHUNK]; - char out[CHUNK]; + unsigned char in[CHUNK]; + unsigned char out[CHUNK]; /* allocate deflate state */ strm.zalloc = Z_NULL; @@ -84,8 +94,8 @@ int inf(FILE *source, FILE *dest) int ret; unsigned have; z_stream strm; - char in[CHUNK]; - char out[CHUNK]; + unsigned char in[CHUNK]; + unsigned char out[CHUNK]; /* allocate inflate state */ strm.zalloc = Z_NULL; @@ -167,6 +177,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); |