Changeset 95819 in vbox
- Timestamp:
- Jul 25, 2022 2:49:09 PM (3 years ago)
- Location:
- trunk/src/libs/zlib-1.2.12
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/zlib-1.2.12/Makefile.kmk
r76178 r95819 45 45 VBox-zlib-static_TEMPLATE = VBoxR3StaticNonPedantic 46 46 VBox-zlib-static_DEFS = $(VBox-zlib_DEFS) 47 ifdef VBOX_WITH_NOCRT_STATIC 48 VBox-zlib-static_DEFS += IPRT_NO_CRT_FOR_3RD_PARTY 49 endif 47 50 VBox-zlib-static_SOURCES = $(VBox-zlib_SOURCES) 48 51 -
trunk/src/libs/zlib-1.2.12/gzguts.h
r95239 r95819 19 19 #endif 20 20 21 #ifndef IPRT_NO_CRT /* VBox */ 21 22 #include <stdio.h> 23 #endif /* VBox */ 22 24 #include "zlib.h" 23 25 #ifdef STDC … … 30 32 # define _POSIX_SOURCE 31 33 #endif 34 #ifndef IPRT_NO_CRT /* VBox */ 32 35 #include <fcntl.h> 33 36 #endif 37 /* VBox */ 34 38 #ifdef _WIN32 35 39 # include <stddef.h> 36 40 #endif 37 41 42 #ifndef IPRT_NO_CRT /* VBox */ 38 43 #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) 39 44 # include <io.h> 40 45 #endif 41 46 #else /* VBox */ 47 # include <iprt/file.h> /* VBox */ 48 # include <iprt/errcore.h> /* VBox */ 49 #endif /* VBox */ 50 51 #ifndef IPRT_NO_CRT /* VBox */ 42 52 #if defined(_WIN32) 43 53 # define WIDECHAR 54 #endif /* VBox */ 44 55 #endif 45 56 … … 54 65 # define NO_GZCOMPRESS 55 66 #endif 67 68 #ifdef IPRT_NO_CRT /* VBox */ 69 # include <iprt/string.h> /* VBox */ 70 # define HAVE_VSNPRINTF /* VBox */ 71 # define snprintf RTStrPrintf /* VBox */ 72 # define vsnprintf RTStrPrintfV /* VBox */ 73 #else /* !IPRT_NO_CRT */ /* VBox */ 56 74 57 75 #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) … … 110 128 # define snprintf _snprintf 111 129 #endif 130 /* VBox */ 131 #endif /* !IPRT_NO_CRT */ /* VBox */ 112 132 113 133 #ifndef local … … 125 145 126 146 /* get errno and strerror definition */ 127 #if defined UNDER_CE 147 #if defined UNDER_CE || (defined(IPRT_NO_CRT) && defined(RT_OS_WINDOWS)) 128 148 # include <windows.h> 129 149 # define zstrerror() gz_strwinerror((DWORD)GetLastError()) … … 176 196 /* used for both reading and writing */ 177 197 int mode; /* see gzip modes above */ 198 #ifndef IPRT_NO_CRT 178 199 int fd; /* file descriptor */ 200 #else 201 RTFILE fd; /* file descriptor */ 202 #endif 179 203 char *path; /* path or fd for error messages */ 180 204 unsigned size; /* buffer size, zero if not allocated yet */ … … 205 229 /* shared functions */ 206 230 void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 207 #if defined UNDER_CE 231 #if defined UNDER_CE || (defined(IPRT_NO_CRT) && defined(RT_OS_WINDOWS)) 208 232 char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 209 233 #endif -
trunk/src/libs/zlib-1.2.12/gzlib.c
r95239 r95819 98 98 gz_statep state; 99 99 z_size_t len; 100 #ifndef IPRT_NO_CRT /* VBox */ 100 101 int oflag; 102 #else /* VBox */ 103 uint64_t fOpen; /* VBox */ 104 int rc; /* VBox */ 105 # define O_CLOEXEC /* VBox */ 106 # define O_EXCL /* VBox */ 107 #endif /* VBox */ 101 108 #ifdef O_CLOEXEC 102 109 int cloexec = 0; … … 220 227 221 228 /* compute the flags for open() */ 229 #ifndef IPRT_NO_CRT /* VBox */ 222 230 oflag = 223 231 #ifdef O_LARGEFILE … … 239 247 O_TRUNC : 240 248 O_APPEND))); 249 #else /* IPRT_NO_CRT */ /* VBox */ 250 fOpen = RTFILE_O_DENY_NONE /* VBox */ 251 | (0666 << RTFILE_O_CREATE_MODE_SHIFT) /* VBox */ 252 | (cloexec ? 0 : RTFILE_O_INHERIT) /* VBox */ 253 | (state->mode == GZ_READ /* VBox */ 254 ? RTFILE_O_READ | RTFILE_O_OPEN /* VBox */ 255 : RTFILE_O_WRITE /* VBox */ 256 | (exclusive /* VBox */ 257 ? RTFILE_O_CREATE /* VBox */ 258 : state->mode == GZ_WRITE /* VBox */ 259 ? RTFILE_O_CREATE_REPLACE /* VBox */ 260 : RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND) /* VBox */ 261 ); /* VBox */ 262 #endif /* IPRT_NO_CRT */ /* VBox */ 241 263 242 264 /* open the file with the appropriate flags (or just use fd) */ 265 #ifndef IPRT_NO_CRT /* VBox */ 243 266 state->fd = fd > -1 ? fd : ( 244 267 #ifdef WIDECHAR … … 247 270 open((const char *)path, oflag, 0666)); 248 271 if (state->fd == -1) { 272 #else /* IPRT_NO_CRT */ 273 rc = RTFileOpen(&state->fd, path, fOpen); 274 if (RT_FAILURE(rc)) { 275 #endif /* IPRT_NO_CRT */ 249 276 free(state->path); 250 277 free(state); … … 252 279 } 253 280 if (state->mode == GZ_APPEND) { 281 #ifndef IPRT_NO_CRT /* VBox */ 254 282 LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ 283 #else 284 RTFileSeek(state->fd, 0, RTFILE_SEEK_END, NULL); 285 #endif 255 286 state->mode = GZ_WRITE; /* simplify later checks */ 256 287 } … … 258 289 /* save the current position for rewinding (only if reading) */ 259 290 if (state->mode == GZ_READ) { 291 #ifndef IPRT_NO_CRT /* VBox */ 260 292 state->start = LSEEK(state->fd, 0, SEEK_CUR); 293 #else 294 state->start = RTFileTell(state->fd); 295 #endif 261 296 if (state->start == -1) state->start = 0; 262 297 } … … 359 394 360 395 /* back up and start over */ 396 #ifndef IPRT_NO_CRT /* VBox */ 361 397 if (LSEEK(state->fd, state->start, SEEK_SET) == -1) 398 #else 399 if (RT_FAILURE(RTFileSeek(state->fd, state->start, RTFILE_SEEK_CURRENT, NULL))) 400 #endif 362 401 return -1; 363 402 gz_reset(state); … … 400 439 if (state->mode == GZ_READ && state->how == COPY && 401 440 state->x.pos + offset >= 0) { 441 #ifndef IPRT_NO_CRT /* VBox */ 402 442 ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); 403 443 if (ret == -1) 444 #else 445 ret = RTFileSeek(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR, NULL); 446 if (RT_FAILURE(ret)) 447 #endif 404 448 return -1; 405 449 state->x.have = 0; … … 496 540 497 541 /* compute and return effective offset in file */ 542 #ifndef IPRT_NO_CRT /* VBox */ 498 543 offset = LSEEK(state->fd, 0, SEEK_CUR); 499 544 if (offset == -1) 545 #else 546 offset = RTFileTell(state->fd); 547 if ((uint64_t)offset == UINT64_MAX) 548 #endif 500 549 return -1; 501 550 if (state->mode == GZ_READ) /* reading */ -
trunk/src/libs/zlib-1.2.12/gzread.c
r95239 r95819 33 33 if (get > max) 34 34 get = max; 35 #ifndef IPRT_NO_CRT /* VBox */ 35 36 ret = read(state->fd, buf + *have, get); 36 37 if (ret <= 0) 37 38 break; 39 #else /* VBox */ 40 { /* VBox */ 41 size_t cbRead; /* VBox */ 42 ret = RTFileRead(state->fd, buf + *have, get, &cbRead); /* VBox */ 43 if (RT_SUCCESS(ret)) /* VBox */ 44 ret = (int)cbRead; /* VBox */ 45 else /* VBox */ 46 { /* VBox */ 47 char szDefine[80]; /* VBox */ 48 RTErrQueryDefine(ret, szDefine, sizeof(szDefine), false); /* VBox */ 49 gz_error(state, Z_ERRNO, szDefine); /* VBox */ 50 return -1; /* VBox */ 51 } /* VBox */ 52 } /* VBox */ 53 #endif /* VBox */ 38 54 *have += (unsigned)ret; 39 55 } while (*have < len); 56 #ifndef IPRT_NO_CRT /* VBox */ 40 57 if (ret < 0) { 41 58 gz_error(state, Z_ERRNO, zstrerror()); 42 59 return -1; 43 60 } 61 #endif /* VBox */ 44 62 if (ret == 0) 45 63 state->eof = 1; … … 647 665 gz_error(state, Z_OK, NULL); 648 666 free(state->path); 667 #ifndef IPRT_NO_CRT /* VBox */ 649 668 ret = close(state->fd); 669 #else /* VBox */ 670 ret = RTFileClose(state->fd); /* VBox */ 671 if (RT_SUCCESS(ret)) /* VBox */ 672 ret = 0; /* VBox */ 673 #endif /* VBox */ 650 674 free(state); 651 675 return ret ? Z_ERRNO : err; -
trunk/src/libs/zlib-1.2.12/gzwrite.c
r95239 r95819 65 65 } 66 66 67 #ifdef IPRT_NO_CRT /* VBox */ 68 DECLINLINE(int) gz_write_wrap(gz_statep state, void const *pvSrc, size_t cbToWrite) /* VBox */ 69 { /* VBox */ 70 size_t cbWritten; /* VBox */ 71 int ret = RTFileWrite(state->fd, pvSrc, cbToWrite, &cbWritten); /* VBox */ 72 if (RT_SUCCESS(ret)) /* VBox */ 73 ret = (int)cbWritten; /* VBox */ 74 else { /* VBox */ 75 char szDefine[80]; /* VBox */ 76 RTErrQueryDefine(ret, szDefine, sizeof(szDefine), false); /* VBox */ 77 gz_error(state, Z_ERRNO, szDefine); /* VBox */ 78 ret = -1; /* VBox */ 79 } /* VBox */ 80 return ret; /* VBox */ 81 } /* VBox */ 82 #endif /* IPRT_NO_CRT */ /* VBox */ 83 67 84 /* Compress whatever is at avail_in and next_in and write to the output file. 68 85 Return -1 if there is an error writing to the output file or if gz_init() … … 87 104 while (strm->avail_in) { 88 105 put = strm->avail_in > max ? max : strm->avail_in; 106 #ifndef IPRT_NO_CRT /* VBox */ 89 107 writ = write(state->fd, strm->next_in, put); 90 108 if (writ < 0) { … … 92 110 return -1; 93 111 } 112 #else /* VBox */ 113 writ = gz_write_wrap(state, strm->next_in, put); /* VBox */ 114 if (writ < 0) /* VBox */ 115 return -1; /* VBox */ 116 #endif /* VBox */ 94 117 strm->avail_in -= (unsigned)writ; 95 118 strm->next_in += writ; … … 117 140 put = strm->next_out - state->x.next > (int)max ? max : 118 141 (unsigned)(strm->next_out - state->x.next); 142 #ifndef IPRT_NO_CRT /* VBox */ 119 143 writ = write(state->fd, state->x.next, put); 120 144 if (writ < 0) { … … 122 146 return -1; 123 147 } 148 #else /* VBox */ 149 writ = gz_write_wrap(state, state->x.next, put); /* VBox */ 150 if (writ < 0) /* VBox */ 151 return -1; /* VBox */ 152 #endif /* VBox */ 124 153 state->x.next += writ; 125 154 } … … 671 700 gz_error(state, Z_OK, NULL); 672 701 free(state->path); 702 #ifndef IPRT_NO_CRT /* VBox */ 673 703 if (close(state->fd) == -1) 704 #else /* VBox */ 705 if (RT_FAILURE(RTFileClose(state->fd))) /* VBox */ 706 #endif /* VBox */ 674 707 ret = Z_ERRNO; 675 708 free(state); -
trunk/src/libs/zlib-1.2.12/zutil.h
r95239 r95819 257 257 #endif 258 258 259 #ifdef IPRT_NO_CRT /* VBox */ 260 # undef Assert /* VBox */ 261 # include <iprt/assert.h> /* VBox */ 262 # undef Assert /* VBox */ 263 # ifdef ZLIB_DEBUG /* VBox */ 264 # define Assert(cond, msg) AssertMsg(cond, (msg)) /* VBox */ 265 # else /* VBox */ 266 # define Assert(cond, msg) do {} while (0) /* VBox */ 267 # endif /* VBox */ 268 #endif /* VBox */ 269 259 270 #ifndef Z_SOLO 260 271 voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
Note:
See TracChangeset
for help on using the changeset viewer.