📄 zlib.diff
字号:
+ }
+ #else
errno = 0;
s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
if (s->stream.avail_in == 0) {
***************
*** 405,410 ****
--- 506,512 ----
break;
}
}
+ #endif
s->stream.next_in = s->inbuf;
}
s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
***************
*** 489,494 ****
--- 591,599 ----
unsigned len;
{
gz_stream *s = (gz_stream*)file;
+ #ifdef _WIN32_WCE
+ DWORD size;
+ #endif
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
***************
*** 500,506 ****
--- 605,615 ----
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;
break;
}
***************
*** 519,524 ****
--- 628,667 ----
control of the format string, as in fprintf. gzprintf returns the number of
uncompressed bytes actually written (0 in case of error).
*/
+ #ifdef _WIN32_WCE
+ #include <stdarg.h>
+
+ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
+ {
+ char buf[Z_PRINTF_BUFSIZE];
+ va_list va;
+ int len;
+ TCHAR form[Z_PRINTF_BUFSIZE];
+ TCHAR tbuf[Z_PRINTF_BUFSIZE];
+ int n;
+
+ va_start(va, format);
+ MultiByteToWideChar(CP_ACP, 0, format, -1, form, Z_PRINTF_BUFSIZE);
+ len = lstrlen(form);
+ for ( n = 0; n < len; n++ ) {
+ if ( TEXT('%') == form[n] ) {
+ n++;
+ if ( TEXT('c') == form[n] ) {
+ form[n] = TEXT('C');
+ } else if ( TEXT('s') == form[n] ) {
+ form[n] = TEXT('S');
+ }
+ }
+ }
+ (void)vswprintf(tbuf, form, va);
+ va_end(va);
+ WideCharToMultiByte(CP_ACP, 0, tbuf, -1, buf, Z_PRINTF_BUFSIZE, NULL, NULL);
+ len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
+ if (len <= 0) return 0;
+
+ return gzwrite(file, buf, (unsigned)len);
+ }
+ #else
#ifdef STDC
#include <stdarg.h>
***************
*** 565,570 ****
--- 708,714 ----
return gzwrite(file, buf, len);
}
#endif
+ #endif
/* ===========================================================================
Writes c, converted to an unsigned char, into the compressed file.
***************
*** 604,609 ****
--- 748,756 ----
uInt len;
int done = 0;
gz_stream *s = (gz_stream*)file;
+ #ifdef _WIN32_WCE
+ DWORD size;
+ #endif
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
***************
*** 613,619 ****
--- 760,770 ----
len = Z_BUFSIZE - s->stream.avail_out;
if (len != 0) {
+ #ifdef _WIN32_WCE
+ if (!WriteFile(s->file, s->outbuf, len, &size, NULL) || (uInt)size != len) {
+ #else
if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
+ #endif
s->z_err = Z_ERRNO;
return Z_ERRNO;
}
***************
*** 644,650 ****
--- 795,804 ----
int err = do_flush (file, flush);
if (err) return err;
+ #ifdef _WIN32_WCE
+ #else
fflush(s->file);
+ #endif
return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
}
#endif /* NO_DEFLATE */
***************
*** 707,713 ****
--- 861,871 ----
/* map to fseek */
s->stream.avail_in = 0;
s->stream.next_in = s->inbuf;
+ #ifdef _WIN32_WCE
+ if (SetFilePointer(s->file, offset, NULL, FILE_BEGIN) == 0xFFFFFFFF) return -1L;
+ #else
if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
+ #endif
s->stream.total_in = s->stream.total_out = (uLong)offset;
return offset;
***************
*** 752,763 ****
--- 910,929 ----
s->crc = crc32(0L, Z_NULL, 0);
if (s->startpos == 0) { /* not a compressed file */
+ #ifdef _WIN32_WCE
+ SetFilePointer(s->file, 0, NULL, FILE_BEGIN);
+ #else
rewind(s->file);
+ #endif
return 0;
}
(void) inflateReset(&s->stream);
+ #ifdef _WIN32_WCE
+ return SetFilePointer(s->file, s->startpos, NULL, FILE_BEGIN);
+ #else
return fseek(s->file, s->startpos, SEEK_SET);
+ #endif
}
/* ===========================================================================
***************
*** 786,791 ****
--- 952,972 ----
/* ===========================================================================
Outputs a long in LSB order to the given file
*/
+ #ifdef _WIN32_WCE
+ local void putLong (file, x)
+ HANDLE file;
+ uLong x;
+ {
+ int n;
+ char ch[1];
+ DWORD size;
+ for (n = 0; n < 4; n++) {
+ ch[0] = (int)(x & 0xff);
+ WriteFile(file, ch, 1, &size, NULL);
+ x >>= 8;
+ }
+ }
+ #else
local void putLong (file, x)
FILE *file;
uLong x;
***************
*** 796,801 ****
--- 977,983 ----
x >>= 8;
}
}
+ #endif
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets z_err in case
***************
*** 862,868 ****
--- 1044,1054 ----
*errnum = s->z_err;
if (*errnum == Z_OK) return (const char*)"";
+ #ifdef _WIN32_WCE
+ m = (char*)(*errnum == Z_ERRNO ? zstrerror(GetLastError()) : s->stream.msg);
+ #else
m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
+ #endif
if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
diff -acr zlib/maketree.c zlibce/maketree.c
*** zlib/maketree.c Mon Mar 11 22:56:12 2002
--- zlibce/maketree.c Tue Jun 16 20:27:00 1998
***************
*** 1,5 ****
/* maketree.c -- make inffixed.h table for decoding fixed codes
! * Copyright (C) 1995-2002 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
--- 1,5 ----
/* maketree.c -- make inffixed.h table for decoding fixed codes
! * Copyright (C) 1998 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
diff -acr zlib/minigzip.c zlibce/minigzip.c
*** zlib/minigzip.c Mon Mar 11 22:16:01 2002
--- zlibce/minigzip.c Thu Jul 27 12:04:46 2000
***************
*** 1,5 ****
/* minigzip.c -- simulate gzip using the zlib compression library
! * Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
--- 1,6 ----
/* minigzip.c -- simulate gzip using 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
*/
***************
*** 15,21 ****
--- 16,30 ----
/* @(#) $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
+ #undef USE_MMAP
+ #include <windows.h>
+ #else
#include <stdio.h>
+ #endif
#include "zlib.h"
#ifdef STDC
***************
*** 31,37 ****
# include <sys/stat.h>
#endif
! #if defined(MSDOS) || defined(OS2) || defined(WIN32)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
--- 40,46 ----
# include <sys/stat.h>
#endif
! #if (defined(MSDOS) || defined(OS2) || defined(WIN32)) && !defined(_WIN32_WCE)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
***************
*** 71,84 ****
# define local
#endif
char *prog;
void error OF((const char *msg));
! void gz_compress OF((FILE *in, gzFile out));
#ifdef USE_MMAP
! int gz_compress_mmap OF((FILE *in, gzFile out));
#endif
! void gz_uncompress OF((gzFile in, FILE *out));
void file_compress OF((char *file, char *mode));
void file_uncompress OF((char *file));
int main OF((int argc, char *argv[]));
--- 80,103 ----
# define local
#endif
+ #if defined(_WIN32_WCE)
+ #undef stderr
+ #define stderr stdout
+ #define F_FILE HANDLE
+ #define F_NULL INVALID_HANDLE_VALUE
+ #else
+ #define F_FILE FILE*
+ #define F_NULL NULL
+ #endif
+
char *prog;
void error OF((const char *msg));
! void gz_compress OF((F_FILE in, gzFile out));
#ifdef USE_MMAP
! int gz_compress_mmap OF((F_FILE in, gzFile out));
#endif
! void gz_uncompress OF((gzFile in, F_FILE out));
void file_compress OF((char *file, char *mode));
void file_uncompress OF((char *file));
int main OF((int argc, char *argv[]));
***************
*** 93,104 ****
exit(1);
}
/* ===========================================================================
* Compress input to output then close both files.
*/
void gz_compress(in, out)
! FILE *in;
gzFile out;
{
local char buf[BUFLEN];
--- 112,160 ----
exit(1);
}
+ #if defined(_WIN32_WCE)
+ void perror(msg)
+ const char *msg;
+ {
+ DWORD dwError;
+ LPVOID lpMsgBuf;
+
+ dwError = GetLastError();
+ if ( FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwError,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL) )
+ {
+ wprintf(TEXT("%S: %s\n"), msg, (LPTSTR)lpMsgBuf);
+ LocalFree(lpMsgBuf);
+ }
+ else
+ {
+ wprintf(TEXT("%S: Error #%d\n"), msg, dwError);
+ }
+ }
+
+ int unlink(filename)
+ const char *filename;
+ {
+ TCHAR path[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, filename, -1, path, MAX_PATH);
+ return DeleteFile(path);
+ }
+ #endif
+
/* ===========================================================================
* Compress input to output then close both files.
*/
void gz_compress(in, out)
! F_FILE in;
gzFile out;
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -