diff options
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 28 |
1 files changed, 15 insertions, 13 deletions
@@ -5,15 +5,17 @@ | |||
5 | 5 | ||
6 | #include "gzguts.h" | 6 | #include "gzguts.h" |
7 | 7 | ||
8 | #if defined(_WIN32) && !defined(__BORLANDC__) | 8 | #if defined(UNDER_CE) |
9 | # define LSEEK _wcelseek | ||
10 | #elif defined(__DJGPP__) | ||
11 | # define LSEEK llseek | ||
12 | #elif defined(_WIN32) && !defined(__BORLANDC__) | ||
9 | # define LSEEK _lseeki64 | 13 | # define LSEEK _lseeki64 |
10 | #else | 14 | #elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 |
11 | #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 | ||
12 | # define LSEEK lseek64 | 15 | # define LSEEK lseek64 |
13 | #else | 16 | #else |
14 | # define LSEEK lseek | 17 | # define LSEEK lseek |
15 | #endif | 18 | #endif |
16 | #endif | ||
17 | 19 | ||
18 | #if defined UNDER_CE | 20 | #if defined UNDER_CE |
19 | 21 | ||
@@ -52,8 +54,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { | |||
52 | msgbuf[chars] = 0; | 54 | msgbuf[chars] = 0; |
53 | } | 55 | } |
54 | 56 | ||
55 | z_size_t len; | 57 | wcstombs(buf, msgbuf, chars + 1); // assumes buf is big enough |
56 | wcstombs_s(&len, buf, sizeof(buf), msgbuf, chars + 1); | ||
57 | LocalFree(msgbuf); | 58 | LocalFree(msgbuf); |
58 | } | 59 | } |
59 | else { | 60 | else { |
@@ -180,10 +181,8 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { | |||
180 | 181 | ||
181 | /* save the path name for error messages */ | 182 | /* save the path name for error messages */ |
182 | #ifdef WIDECHAR | 183 | #ifdef WIDECHAR |
183 | if (fd == -2) { | 184 | if (fd == -2) |
184 | if (wcstombs_s(&len, NULL, 0, path, 0) != 0) | 185 | len = wcstombs(NULL, path, 0); |
185 | len = 0; | ||
186 | } | ||
187 | else | 186 | else |
188 | #endif | 187 | #endif |
189 | len = strlen((const char *)path); | 188 | len = strlen((const char *)path); |
@@ -193,18 +192,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { | |||
193 | return NULL; | 192 | return NULL; |
194 | } | 193 | } |
195 | #ifdef WIDECHAR | 194 | #ifdef WIDECHAR |
196 | if (fd == -2) | 195 | if (fd == -2) { |
197 | if (len) | 196 | if (len) |
198 | wcstombs_s(&len, state->path, len + 1, path, len + 1); | 197 | wcstombs(state->path, path, len + 1); |
199 | else | 198 | else |
200 | *(state->path) = 0; | 199 | *(state->path) = 0; |
200 | } | ||
201 | else | 201 | else |
202 | #endif | 202 | #endif |
203 | { | ||
203 | #if !defined(NO_snprintf) && !defined(NO_vsnprintf) | 204 | #if !defined(NO_snprintf) && !defined(NO_vsnprintf) |
204 | (void)snprintf(state->path, len + 1, "%s", (const char *)path); | 205 | (void)snprintf(state->path, len + 1, "%s", (const char *)path); |
205 | #else | 206 | #else |
206 | strcpy(state->path, path); | 207 | strcpy(state->path, path); |
207 | #endif | 208 | #endif |
209 | } | ||
208 | 210 | ||
209 | /* compute the flags for open() */ | 211 | /* compute the flags for open() */ |
210 | oflag = | 212 | oflag = |
@@ -232,7 +234,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { | |||
232 | state->fd = open((const char *)path, oflag, 0666); | 234 | state->fd = open((const char *)path, oflag, 0666); |
233 | #ifdef WIDECHAR | 235 | #ifdef WIDECHAR |
234 | else if (fd == -2) | 236 | else if (fd == -2) |
235 | _wsopen_s(&state->fd, path, oflag, _SH_DENYNO, _S_IREAD | _S_IWRITE); | 237 | state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE); |
236 | #endif | 238 | #endif |
237 | else | 239 | else |
238 | state->fd = fd; | 240 | state->fd = fd; |