📄 zlib.diff
字号:
+ #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; { local char buf[BUFLEN];****************** 112,119 ****--- 168,179 ---- if (gz_compress_mmap(in, out) == Z_OK) return; #endif for (;;) {+ #if defined(_WIN32_WCE)+ if (!ReadFile(in, buf, sizeof(buf), &len, NULL)) {+ #else len = fread(buf, 1, sizeof(buf), in); if (ferror(in)) {+ #endif perror("fread"); exit(1); }****************** 121,127 ****--- 181,191 ---- if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); }+ #if defined(_WIN32_WCE)+ CloseHandle(in);+ #else fclose(in);+ #endif if (gzclose(out) != Z_OK) error("failed gzclose"); } ****************** 131,137 **** * if success, Z_ERRNO otherwise. */ int gz_compress_mmap(in, out)! FILE *in; gzFile out; { int len;--- 195,201 ---- * if success, Z_ERRNO otherwise. */ int gz_compress_mmap(in, out)! F_FILE in; gzFile out; { int len;****************** 167,177 **** */ void gz_uncompress(in, out) gzFile in;! FILE *out; { local char buf[BUFLEN]; int len; int err; for (;;) { len = gzread(in, buf, sizeof(buf));--- 231,244 ---- */ void gz_uncompress(in, out) gzFile in;! F_FILE out; { local char buf[BUFLEN]; int len; int err;+ #if defined(_WIN32_WCE)+ int size;+ #endif for (;;) { len = gzread(in, buf, sizeof(buf));****************** 178,188 **** if (len < 0) error (gzerror(in, &err)); if (len == 0) break; if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {! error("failed fwrite");! } } if (fclose(out)) error("failed fclose"); if (gzclose(in) != Z_OK) error("failed gzclose"); }--- 245,263 ---- if (len < 0) error (gzerror(in, &err)); if (len == 0) break; + #if defined(_WIN32_WCE)+ if (!WriteFile(out, buf, (unsigned)len, &size, NULL) || size != len) {+ #else if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {! #endif! error("failed fwrite");! } }+ #if defined(_WIN32_WCE)+ if (!CloseHandle(out)) error("failed fclose");+ #else if (fclose(out)) error("failed fclose");+ #endif if (gzclose(in) != Z_OK) error("failed gzclose"); }****************** 197,215 **** char *mode; { local char outfile[MAX_NAME_LEN];! FILE *in; gzFile out; strcpy(outfile, file); strcat(outfile, GZ_SUFFIX); in = fopen(file, "rb");! if (in == NULL) { perror(file); exit(1); } out = gzopen(outfile, mode);! if (out == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); exit(1); }--- 272,298 ---- char *mode; { local char outfile[MAX_NAME_LEN];! F_FILE in; gzFile out;+ #if defined(_WIN32_WCE)+ TCHAR path[MAX_PATH];+ #endif strcpy(outfile, file); strcat(outfile, GZ_SUFFIX); + #if defined(_WIN32_WCE)+ MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);+ in = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);+ #else in = fopen(file, "rb");! #endif! if (in == F_NULL) { perror(file); exit(1); } out = gzopen(outfile, mode);! if (out == F_NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); exit(1); }****************** 227,235 **** { local char buf[MAX_NAME_LEN]; char *infile, *outfile;! FILE *out; gzFile in; int len = strlen(file); strcpy(buf, file); --- 310,321 ---- { local char buf[MAX_NAME_LEN]; char *infile, *outfile;! F_FILE out; gzFile in; int len = strlen(file);+ #if defined(_WIN32_WCE)+ TCHAR path[MAX_PATH];+ #endif strcpy(buf, file); ****************** 243,254 **** strcat(infile, GZ_SUFFIX); } in = gzopen(infile, "rb");! if (in == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); exit(1); } out = fopen(outfile, "wb");! if (out == NULL) { perror(file); exit(1); }--- 329,345 ---- strcat(infile, GZ_SUFFIX); } in = gzopen(infile, "rb");! if (in == F_NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); exit(1); }+ #if defined(_WIN32_WCE)+ MultiByteToWideChar(CP_ACP, 0, outfile, -1, path, MAX_PATH);+ out = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);+ #else out = fopen(outfile, "wb");! #endif! if (out == F_NULL) { perror(file); exit(1); }****************** 272,278 ****--- 363,371 ---- char *argv[]; { int uncompr = 0;+ #if !defined(_WIN32_WCE) gzFile file;+ #endif char outmode[20]; strcpy(outmode, "wb6 ");****************** 282,300 **** while (argc > 0) { if (strcmp(*argv, "-d") == 0)! uncompr = 1; else if (strcmp(*argv, "-f") == 0)! outmode[3] = 'f'; else if (strcmp(*argv, "-h") == 0)! outmode[3] = 'h'; else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&! (*argv)[2] == 0)! outmode[2] = (*argv)[1]; else! break; argc--, argv++; } if (argc == 0) { SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); if (uncompr) {--- 375,400 ---- while (argc > 0) { if (strcmp(*argv, "-d") == 0)! uncompr = 1; else if (strcmp(*argv, "-f") == 0)! outmode[3] = 'f'; else if (strcmp(*argv, "-h") == 0)! outmode[3] = 'h'; else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&! (*argv)[2] == 0)! outmode[2] = (*argv)[1]; else! break; argc--, argv++; } if (argc == 0) {+ #if defined(_WIN32_WCE)+ wprintf(TEXT("Usage: minigzip [-d] [-f] [-h] [-1 to -9] [files...]\n"));+ wprintf(TEXT(" -d : decompress\n"));+ wprintf(TEXT(" -f : compress with Z_FILTERED\n"));+ wprintf(TEXT(" -h : compress with Z_HUFFMAN_ONLY\n"));+ wprintf(TEXT(" -1 to -9 : compression level\n"));+ #else SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); if (uncompr) {****************** 306,311 ****--- 406,412 ---- if (file == NULL) error("can't gzdopen stdout"); gz_compress(stdin, file); }+ #endif } else { do { if (uncompr) {****************** 318,320 ****--- 419,457 ---- exit(0); return 0; /* to avoid warning */ }+ + #if defined(_WIN32_WCE)+ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpszCmdLine, int nCmdShow)+ {+ #define SIZE_ARGV (32)+ int argc;+ char *argv[SIZE_ARGV];+ int size;+ char *buff;+ char *argp;+ + size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, NULL, 0, NULL, NULL);+ buff = (char *)malloc(size);+ size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, buff, size, NULL, NULL);+ argp = buff;+ argc = 0;+ argv[argc++] = "minigzip.exe";+ if (*argp) {+ argv[argc++] = argp;+ while (*argp) {+ if (*argp == ' ') {+ *argp++ = '\0';+ while (*argp && *argp == ' ') {+ argp++;+ }+ if (*argp && argc < SIZE_ARGV) {+ argv[argc++] = argp;+ }+ } else {+ argp++;+ }+ }+ }+ return main(argc, argv);+ }+ #endif*** zlib113/example.c Sat Jul 8 13:59:49 2000--- zlibwce/example.c Sat Jul 8 13:58:29 2000****************** 1,11 ****--- 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: qt/src/3rdparty/libpng/projects/wince/zlib.diff 2.3.12 edited 2005-10-27 $ */ + #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); \****************** 37,58 **** uLong dictId; /* Adler32 value of the dictionary */ void test_compress OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); void test_gzio OF((const char *out, const char *in, ! Byte *uncompr, int uncomprLen)); void test_deflate OF((Byte *compr, uLong comprLen)); void test_inflate OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); void test_large_deflate OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); void test_large_inflate OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); void test_flush OF((Byte *compr, uLong *comprLen)); void test_sync OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); void test_dict_deflate OF((Byte *compr, uLong comprLen)); void test_dict_inflate OF((Byte *compr, uLong comprLen,! Byte *uncompr, uLong uncomprLen)); int main OF((int argc, char *argv[]));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -