📄 zlib.diff
字号:
diff -acr zlib/deflate.c zlibce/deflate.c
*** zlib/deflate.c Tue Mar 12 00:00:39 2002
--- zlibce/deflate.c Tue Mar 19 21:09:08 2002
***************
*** 921,926 ****
--- 921,930 ----
#endif /* ASMV */
#ifdef DEBUG
+ #ifdef _WIN32_WCE
+ /* Windows CE is not support DEBUG version's zlib */
+ # define check_match(s, start, match, length)
+ #else
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
***************
*** 944,949 ****
--- 948,954 ----
do { putc(s->window[start++], stderr); } while (--length != 0);
}
}
+ #endif
#else
# define check_match(s, start, match, length)
#endif
diff -acr zlib/example.c zlibce/example.c
*** zlib/example.c Mon Mar 11 22:16:01 2002
--- zlibce/example.c Thu Jul 27 12:04:46 2000
***************
*** 1,11 ****
/* example.c -- usage example of the zlib compression library
! * Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: zlib.diff,v 1.1.1.1 2006/12/05 17:55:44 gazza Exp $ */
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
--- 1,19 ----
/* example.c -- usage example of the zlib compression library
! * Copyright (C) 1995-1998 Jean-loup Gailly.
! * Copyright (C) 2000 Tenik Co.,Ltd.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: zlib.diff,v 1.1.1.1 2006/12/05 17:55:44 gazza Exp $ */
+ #if defined(_WIN32_WCE)
+ #if _WIN32_WCE < 211
+ #error (f|w)printf functions is not support old WindowsCE.
+ #endif
+ #include <windows.h>
+ #else
#include <stdio.h>
+ #endif
#include "zlib.h"
#ifdef STDC
***************
*** 21,26 ****
--- 29,43 ----
# define TESTFILE "foo.gz"
#endif
+ #if defined(_WIN32_WCE)
+ #define calloc(x,y) malloc((x)*(y))
+ #undef stderr
+ #define stderr stdout
+ #define F_NULL INVALID_HANDLE_VALUE
+ #else
+ #define F_NULL NULL
+ #endif
+
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
***************
*** 96,102 ****
z_off_t pos;
file = gzopen(out, "wb");
! if (file == NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
--- 113,119 ----
z_off_t pos;
file = gzopen(out, "wb");
! if (file == F_NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
***************
*** 113,119 ****
gzclose(file);
file = gzopen(in, "rb");
! if (file == NULL) {
fprintf(stderr, "gzopen error\n");
}
strcpy((char*)uncompr, "garbage");
--- 130,136 ----
gzclose(file);
file = gzopen(in, "rb");
! if (file == F_NULL) {
fprintf(stderr, "gzopen error\n");
}
strcpy((char*)uncompr, "garbage");
diff -acr zlib/gzio.c zlibce/gzio.c
*** zlib/gzio.c Mon Mar 11 22:16:01 2002
--- zlibce/gzio.c Fri Jul 05 17:29:28 2002
***************
*** 1,5 ****
--- 1,6 ----
/* gzio.c -- IO on .gz files
* Copyright (C) 1995-2002 Jean-loup Gailly.
+ * Copyright (C) 2000-2002 Tenik Co.,Ltd.(for WindowsCE)
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Compile this file with -DNO_DEFLATE to avoid the compression code.
***************
*** 7,13 ****
--- 8,18 ----
/* @(#) $Id: zlib.diff,v 1.1.1.1 2006/12/05 17:55:44 gazza Exp $ */
+ #ifdef _WIN32_WCE
+ #include <windows.h>
+ #else
#include <stdio.h>
+ #endif
#include "zutil.h"
***************
*** 41,47 ****
--- 46,56 ----
z_stream stream;
int z_err; /* error code for last stream operation */
int z_eof; /* set if end of input file */
+ #ifdef _WIN32_WCE
+ HANDLE file; /* .gz file */
+ #else
FILE *file; /* .gz file */
+ #endif
Byte *inbuf; /* input buffer */
Byte *outbuf; /* output buffer */
uLong crc; /* crc32 of uncompressed data */
***************
*** 58,64 ****
--- 67,77 ----
local int get_byte OF((gz_stream *s));
local void check_header OF((gz_stream *s));
local int destroy OF((gz_stream *s));
+ #ifdef _WIN32_WCE
+ local void putLong OF((HANDLE file, uLong x));
+ #else
local void putLong OF((FILE *file, uLong x));
+ #endif
local uLong getLong OF((gz_stream *s));
/* ===========================================================================
***************
*** 82,87 ****
--- 95,105 ----
gz_stream *s;
char fmode[80]; /* copy of mode, without the compression level */
char *m = fmode;
+ #ifdef _WIN32_WCE
+ char cbuff[10];
+ DWORD size;
+ TCHAR file[MAX_PATH];
+ #endif
if (!path || !mode) return Z_NULL;
***************
*** 94,100 ****
--- 112,122 ----
s->stream.next_in = s->inbuf = Z_NULL;
s->stream.next_out = s->outbuf = Z_NULL;
s->stream.avail_in = s->stream.avail_out = 0;
+ #ifdef _WIN32_WCE
+ s->file = INVALID_HANDLE_VALUE;
+ #else
s->file = NULL;
+ #endif
s->z_err = Z_OK;
s->z_eof = 0;
s->crc = crc32(0L, Z_NULL, 0);
***************
*** 152,168 ****
--- 174,218 ----
}
s->stream.avail_out = Z_BUFSIZE;
+ #ifdef _WIN32_WCE
+ SetLastError(NO_ERROR);
+ if ((HANDLE)fd == INVALID_HANDLE_VALUE) {
+ MultiByteToWideChar(CP_ACP, 0, path, -1, file, MAX_PATH);
+ s->file = CreateFile(file, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
+ } else {
+ s->file = (HANDLE)fd;
+ }
+ #else
errno = 0;
s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
+ #endif
+ #ifdef _WIN32_WCE
+ if (s->file == INVALID_HANDLE_VALUE) {
+ #else
if (s->file == NULL) {
+ #endif
return destroy(s), (gzFile)Z_NULL;
}
if (s->mode == 'w') {
/* Write a very simple .gz header:
*/
+ #ifdef _WIN32_WCE
+ cbuff[0] = gz_magic[0];
+ cbuff[1] = gz_magic[1];
+ cbuff[2] = Z_DEFLATED;
+ cbuff[3] = 0; /*flags*/
+ cbuff[4] = 0;
+ cbuff[5] = 0;
+ cbuff[6] = 0;
+ cbuff[7] = 0; /*time*/;
+ cbuff[8] = 0; /*xflags*/;
+ cbuff[9] = OS_CODE;
+ WriteFile(s->file, cbuff, 10, &size, NULL);
+ #else
fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
+ #endif
s->startpos = 10L;
/* We use 10L instead of ftell(s->file) to because ftell causes an
* fflush on some systems. This version of the library doesn't use
***************
*** 171,177 ****
--- 221,231 ----
*/
} else {
check_header(s); /* skip the .gz header */
+ #ifdef _WIN32_WCE
+ s->startpos = (SetFilePointer(s->file, 0, NULL, FILE_CURRENT) - s->stream.avail_in);
+ #else
s->startpos = (ftell(s->file) - s->stream.avail_in);
+ #endif
}
return (gzFile)s;
***************
*** 197,204 ****
--- 251,263 ----
{
char name[20];
+ #ifdef _WIN32_WCE
+ if ((HANDLE)fd == INVALID_HANDLE_VALUE) return (gzFile)Z_NULL;
+ strcpy(name, "<gzdopen>"); /* for debugging */
+ #else
if (fd < 0) return (gzFile)Z_NULL;
sprintf(name, "<fd:%d>", fd); /* for debugging */
+ #endif
return gz_open (name, mode, fd);
}
***************
*** 212,217 ****
--- 271,279 ----
int strategy;
{
gz_stream *s = (gz_stream*)file;
+ #ifdef _WIN32_WCE
+ DWORD size;
+ #endif
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
***************
*** 219,225 ****
--- 281,291 ----
if (s->stream.avail_out == 0) {
s->stream.next_out = s->outbuf;
+ #ifdef _WIN32_WCE
+ if (!WriteFile(s->file, s->outbuf, Z_BUFSIZE, &size, NULL) || size != Z_BUFSIZE) {
+ #else
if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
+ #endif
s->z_err = Z_ERRNO;
}
s->stream.avail_out = Z_BUFSIZE;
***************
*** 238,243 ****
--- 304,319 ----
{
if (s->z_eof) return EOF;
if (s->stream.avail_in == 0) {
+ #ifdef _WIN32_WCE
+ SetLastError(NO_ERROR);
+ if (!ReadFile(s->file, s->inbuf, Z_BUFSIZE, &s->stream.avail_in, NULL)) {
+ s->z_err = Z_ERRNO;
+ }
+ if (s->stream.avail_in == 0) {
+ s->z_eof = 1;
+ return -1;
+ }
+ #else
errno = 0;
s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
***************
*** 245,250 ****
--- 321,327 ----
if (ferror(s->file)) s->z_err = Z_ERRNO;
return EOF;
}
+ #endif
s->stream.next_in = s->inbuf;
}
s->stream.avail_in--;
***************
*** 333,342 ****
--- 410,423 ----
err = inflateEnd(&(s->stream));
}
}
+ #ifdef _WIN32_WCE
+ if (s->file != NULL && !CloseHandle(s->file)) {
+ #else
if (s->file != NULL && fclose(s->file)) {
#ifdef ESPIPE
if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
#endif
+ #endif
err = Z_ERRNO;
}
if (s->z_err < 0) err = s->z_err;
***************
*** 360,365 ****
--- 441,449 ----
gz_stream *s = (gz_stream*)file;
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
+ #ifdef _WIN32_WCE
+ DWORD size;
+ #endif
if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
***************
*** 385,392 ****
--- 469,482 ----
s->stream.avail_in -= n;
}
if (s->stream.avail_out > 0) {
+ #ifdef _WIN32_WCE
+ if (ReadFile(s->file, next_out, s->stream.avail_out, &size, NULL)) {
+ s->stream.avail_out -= size;
+ }
+ #else
s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
s->file);
+ #endif
}
len -= s->stream.avail_out;
s->stream.total_in += (uLong)len;
***************
*** 396,401 ****
--- 486,502 ----
}
if (s->stream.avail_in == 0 && !s->z_eof) {
+ #ifdef _WIN32_WCE
+ SetLastError(NO_ERROR);
+ if (!ReadFile(s->file, s->inbuf, Z_BUFSIZE, &s->stream.avail_in, NULL)) {
+ s->z_eof = 1;
+ s->z_err = Z_ERRNO;
+ break;
+ }
+ if (s->stream.avail_in == 0) {
+ s->z_eof = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -