* possible. If flushing, copy the remaining available input to next_out as
* stored blocks, if there is enough space.
*/
- unsigned len, left, have, last = 0;
+ int last = 0;
+ unsigned len, left, have;
unsigned used = s->strm->avail_in;
do {
/* Set len to the maximum size block that we can copy directly with the
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS
#endif
+#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
+# define _CRT_NONSTDC_NO_DEPRECATE
+#endif
#include <stdio.h>
#include "zlib.h"
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
# include <io.h>
-# include <share.h>
# include <sys/stat.h>
#endif
# define WIDECHAR
#endif
-#if defined(_WIN32) || defined(WINAPI_FAMILY)
-# define open _open
-# define read _read
-# define write _write
-# define close _close
-#endif
-
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
#include "gzguts.h"
-#if defined(_WIN32) && !defined(__BORLANDC__)
+#if defined(UNDER_CE)
+# define LSEEK _wcelseek
+#elif defined(__DJGPP__)
+# define LSEEK llseek
+#elif defined(_WIN32) && !defined(__BORLANDC__)
# define LSEEK _lseeki64
-#else
-#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define LSEEK lseek64
#else
# define LSEEK lseek
#endif
-#endif
#if defined UNDER_CE
msgbuf[chars] = 0;
}
- z_size_t len;
- wcstombs_s(&len, buf, sizeof(buf), msgbuf, chars + 1);
+ wcstombs(buf, msgbuf, chars + 1); // assumes buf is big enough
LocalFree(msgbuf);
}
else {
/* save the path name for error messages */
#ifdef WIDECHAR
- if (fd == -2) {
- if (wcstombs_s(&len, NULL, 0, path, 0) != 0)
- len = 0;
- }
+ if (fd == -2)
+ len = wcstombs(NULL, path, 0);
else
#endif
len = strlen((const char *)path);
return NULL;
}
#ifdef WIDECHAR
- if (fd == -2)
+ if (fd == -2) {
if (len)
- wcstombs_s(&len, state->path, len + 1, path, len + 1);
+ wcstombs(state->path, path, len + 1);
else
*(state->path) = 0;
+ }
else
#endif
+ {
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
strcpy(state->path, path);
#endif
+ }
/* compute the flags for open() */
oflag =
state->fd = open((const char *)path, oflag, 0666);
#ifdef WIDECHAR
else if (fd == -2)
- _wsopen_s(&state->fd, path, oflag, _SH_DENYNO, _S_IREAD | _S_IWRITE);
+ state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE);
#endif
else
state->fd = fd;