⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zlib.diff

📁 funambol windows mobile plugin source code, the source code is taken from the funambol site
💻 DIFF
📖 第 1 页 / 共 3 页
字号:
      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,188 ****
   */
  void gz_uncompress(in, out)
      gzFile in;
!     FILE   *out;
  {
      local char buf[BUFLEN];
      int len;
      int err;
  
      for (;;) {
          len = gzread(in, buf, sizeof(buf));
          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");
  }
--- 231,263 ----
   */
  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));
          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 ");
***************
*** 295,300 ****
--- 388,400 ----
        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) {
diff -acr zlib/trees.c zlibce/trees.c
*** zlib/trees.c	Mon Mar 11 22:16:01 2002
--- zlibce/trees.c	Tue Mar 19 21:09:44 2002
***************
*** 168,176 ****
--- 168,182 ----
     /* Send a code of the given tree. c and tree must not have side effects */
  
  #else /* DEBUG */
+ #ifdef _WIN32_WCE
+ /* Windows CE is not support DEBUG version's zlib */
+ #  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
+ 
+ #else
  #  define send_code(s, c, tree) \
       { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
         send_bits(s, tree[c].Code, tree[c].Len); }
+ #endif
  #endif
  
  /* ===========================================================================
diff -acr zlib/zconf.h zlibce/zconf.h
*** zlib/zconf.h	Mon Mar 11 22:16:01 2002
--- zlibce/zconf.h	Tue Mar 19 21:10:20 2002
***************
*** 96,101 ****
--- 96,106 ----
  #  define NEED_DUMMY_RETURN
  #endif
  
+ /* Windows CE is not have errno.h file: */
+ #if defined(_WIN32_WCE) && !defined(NO_ERRNO_H)
+ #  define NO_ERRNO_H
+ #endif
+ 
  
  /* Maximum value for memLevel in deflateInit2 */
  #ifndef MAX_MEM_LEVEL
***************
*** 162,168 ****
  
  /* Compile with -DZLIB_DLL for Windows DLL support */
  #if defined(ZLIB_DLL)
! #  if defined(_WINDOWS) || defined(WINDOWS)
  #    ifdef FAR
  #      undef FAR
  #    endif
--- 167,173 ----
  
  /* Compile with -DZLIB_DLL for Windows DLL support */
  #if defined(ZLIB_DLL)
! #  if defined(_WINDOWS) || defined(WINDOWS) || defined(_WIN32_WCE)
  #    ifdef FAR
  #      undef FAR
  #    endif
diff -acr zlib/zutil.c zlibce/zutil.c
*** zlib/zutil.c	Mon Mar 11 22:16:01 2002
--- zlibce/zutil.c	Tue Mar 19 21:10:58 2002
***************
*** 32,37 ****
--- 32,40 ----
  }
  
  #ifdef DEBUG
+ #ifdef _WIN32_WCE
+ /* Windows CE is not support DEBUG version's zlib */
+ #else
  
  #  ifndef verbose
  #    define verbose 0
***************
*** 45,50 ****
--- 48,54 ----
      exit(1);
  }
  #endif
+ #endif
  
  /* exported to allow conversion of error code to string for compress() and
   * uncompress()
***************
*** 211,217 ****
--- 215,225 ----
      unsigned size;
  {
      if (opaque) items += size - size; /* make compiler happy */
+ #ifdef _WIN32_WCE
+     return (voidpf)malloc(items * size);
+ #else
      return (voidpf)calloc(items, size);
+ #endif
  }
  
  void  zcfree (opaque, ptr)
diff -acr zlib/zutil.h zlibce/zutil.h
*** zlib/zutil.h	Mon Mar 11 22:16:01 2002
--- zlibce/zutil.h	Tue Mar 19 21:11:36 2002
***************
*** 16,22 ****
--- 16,26 ----
  #include "zlib.h"
  
  #ifdef STDC
+ #ifdef _WIN32_WCE
+ #  include <malloc.h>
+ #else
  #  include <stddef.h>
+ #endif
  #  include <string.h>
  #  include <stdlib.h>
  #endif
***************
*** 188,193 ****
--- 192,206 ----
  
  /* Diagnostic functions */
  #ifdef DEBUG
+ #ifdef _WIN32_WCE
+ /* Windows CE is not support DEBUG version's zlib */
+ #  define Assert(cond,msg)
+ #  define Trace(x)
+ #  define Tracev(x)
+ #  define Tracevv(x)
+ #  define Tracec(c,x)
+ #  define Tracecv(c,x)
+ #else
  #  include <stdio.h>
     extern int z_verbose;
     extern void z_error    OF((char *m));
***************
*** 197,202 ****
--- 210,216 ----
  #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
  #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
  #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
+ #endif
  #else
  #  define Assert(cond,msg)
  #  define Trace(x)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -