~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to gdchart0.94c/gd-1.8.3/libpng-1.0.8/wince/zlib.diff

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-01-30 21:59:13 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050130215913-xc3ke963bw49b3k4
Tags: 2:3.0-5
* Updated README.Debian file so users will understand what to do at
  install, closes: #291794, #287802.
* Updated ntop init script to give better output.
* Also changed log directory from /var/lib/ntop to /var/log/ntop,
  closes: #252352.
* Quoted the interface list to allow whitespace, closes: #267248.
* Added a couple of logcheck ignores, closes: #269321, #269319.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -ac zlib113/deflate.c zlibwce/deflate.c
2
 
*** zlib113/deflate.c   Fri Jul 10 01:06:12 1998
3
 
--- zlibwce/deflate.c   Thu May 25 16:42:18 2000
4
 
***************
5
 
*** 921,926 ****
6
 
--- 921,930 ----
7
 
  #endif /* ASMV */
8
 
  
9
 
  #ifdef DEBUG
10
 
+ #ifdef _WIN32_WCE
11
 
+ /* Windows CE is not support DEBUG version's zlib */
12
 
+ #  define check_match(s, start, match, length)
13
 
+ #else
14
 
  /* ===========================================================================
15
 
   * Check that the match at match_start is indeed a match.
16
 
   */
17
 
***************
18
 
*** 944,949 ****
19
 
--- 948,954 ----
20
 
          do { putc(s->window[start++], stderr); } while (--length != 0);
21
 
      }
22
 
  }
23
 
+ #endif
24
 
  #else
25
 
  #  define check_match(s, start, match, length)
26
 
  #endif
27
 
diff -ac zlib113/trees.c zlibwce/trees.c
28
 
*** zlib113/trees.c     Thu Jul 09 01:32:58 1998
29
 
--- zlibwce/trees.c     Thu May 25 16:42:50 2000
30
 
***************
31
 
*** 168,176 ****
32
 
--- 168,182 ----
33
 
     /* Send a code of the given tree. c and tree must not have side effects */
34
 
  
35
 
  #else /* DEBUG */
36
 
+ #ifdef _WIN32_WCE
37
 
+ /* Windows CE is not support DEBUG version's zlib */
38
 
+ #  define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
39
 
40
 
+ #else
41
 
  #  define send_code(s, c, tree) \
42
 
       { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
43
 
         send_bits(s, tree[c].Code, tree[c].Len); }
44
 
+ #endif
45
 
  #endif
46
 
  
47
 
  /* ===========================================================================
48
 
diff -ac zlib113/zconf.h zlibwce/zconf.h
49
 
*** zlib113/zconf.h     Thu Jul 09 02:55:28 1998
50
 
--- zlibwce/zconf.h     Thu May 25 16:36:16 2000
51
 
***************
52
 
*** 96,101 ****
53
 
--- 96,106 ----
54
 
  #  define NEED_DUMMY_RETURN
55
 
  #endif
56
 
  
57
 
+ /* Windows CE is not have errno.h file: */
58
 
+ #if defined(_WIN32_WCE)
59
 
+ #  define NO_ERRNO_H
60
 
+ #endif
61
 
62
 
  
63
 
  /* Maximum value for memLevel in deflateInit2 */
64
 
  #ifndef MAX_MEM_LEVEL
65
 
***************
66
 
*** 162,168 ****
67
 
  
68
 
  /* Compile with -DZLIB_DLL for Windows DLL support */
69
 
  #if defined(ZLIB_DLL)
70
 
! #  if defined(_WINDOWS) || defined(WINDOWS)
71
 
  #    ifdef FAR
72
 
  #      undef FAR
73
 
  #    endif
74
 
--- 167,173 ----
75
 
  
76
 
  /* Compile with -DZLIB_DLL for Windows DLL support */
77
 
  #if defined(ZLIB_DLL)
78
 
! #  if defined(_WINDOWS) || defined(WINDOWS) || defined(_WIN32_WCE)
79
 
  #    ifdef FAR
80
 
  #      undef FAR
81
 
  #    endif
82
 
diff -ac zlib113/zutil.c zlibwce/zutil.c
83
 
*** zlib113/zutil.c     Thu Jul 09 02:01:48 1998
84
 
--- zlibwce/zutil.c     Thu May 25 16:43:34 2000
85
 
***************
86
 
*** 32,37 ****
87
 
--- 32,40 ----
88
 
  }
89
 
  
90
 
  #ifdef DEBUG
91
 
+ #ifdef _WIN32_WCE
92
 
+ /* Windows CE is not support DEBUG version's zlib */
93
 
+ #else
94
 
  
95
 
  #  ifndef verbose
96
 
  #    define verbose 0
97
 
***************
98
 
*** 45,50 ****
99
 
--- 48,54 ----
100
 
      exit(1);
101
 
  }
102
 
  #endif
103
 
+ #endif
104
 
  
105
 
  /* exported to allow conversion of error code to string for compress() and
106
 
   * uncompress()
107
 
***************
108
 
*** 211,217 ****
109
 
--- 215,225 ----
110
 
      unsigned size;
111
 
  {
112
 
      if (opaque) items += size - size; /* make compiler happy */
113
 
+ #ifdef _WIN32_WCE
114
 
+     return (voidpf)malloc(items * size);
115
 
+ #else
116
 
      return (voidpf)calloc(items, size);
117
 
+ #endif
118
 
  }
119
 
  
120
 
  void  zcfree (opaque, ptr)
121
 
diff -ac zlib113/zutil.h zlibwce/zutil.h
122
 
*** zlib113/zutil.h     Thu Jul 09 02:01:48 1998
123
 
--- zlibwce/zutil.h     Thu May 25 16:41:44 2000
124
 
***************
125
 
*** 16,22 ****
126
 
--- 16,26 ----
127
 
  #include "zlib.h"
128
 
  
129
 
  #ifdef STDC
130
 
+ #ifdef _WIN32_WCE
131
 
+ #  include <malloc.h>
132
 
+ #else
133
 
  #  include <stddef.h>
134
 
+ #endif
135
 
  #  include <string.h>
136
 
  #  include <stdlib.h>
137
 
  #endif
138
 
***************
139
 
*** 188,193 ****
140
 
--- 192,206 ----
141
 
  
142
 
  /* Diagnostic functions */
143
 
  #ifdef DEBUG
144
 
+ #ifdef _WIN32_WCE
145
 
+ /* Windows CE is not support DEBUG version's zlib */
146
 
+ #  define Assert(cond,msg)
147
 
+ #  define Trace(x)
148
 
+ #  define Tracev(x)
149
 
+ #  define Tracevv(x)
150
 
+ #  define Tracec(c,x)
151
 
+ #  define Tracecv(c,x)
152
 
+ #else
153
 
  #  include <stdio.h>
154
 
     extern int z_verbose;
155
 
     extern void z_error    OF((char *m));
156
 
***************
157
 
*** 197,202 ****
158
 
--- 210,216 ----
159
 
  #  define Tracevv(x) {if (z_verbose>1) fprintf x ;}
160
 
  #  define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
161
 
  #  define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
162
 
+ #endif
163
 
  #else
164
 
  #  define Assert(cond,msg)
165
 
  #  define Trace(x)
166
 
*** zlib113/gzio.c      Sat Jul  8 13:59:49 2000
167
 
--- zlibwce/gzio.c      Sat Jul  8 13:58:29 2000
168
 
***************
169
 
*** 1,5 ****
170
 
! /* gzio.c -- IO on .gz files
171
 
   * Copyright (C) 1995-1998 Jean-loup Gailly.
172
 
   * For conditions of distribution and use, see copyright notice in zlib.h
173
 
   *
174
 
   * Compile this file with -DNO_DEFLATE to avoid the compression code.
175
 
--- 1,6 ----
176
 
! /* gzio.c -- IO on .gz files for WindowsCE
177
 
   * Copyright (C) 1995-1998 Jean-loup Gailly.
178
 
+  * Copyright (C) 2000      Tenik Co.,Ltd.
179
 
   * For conditions of distribution and use, see copyright notice in zlib.h
180
 
   *
181
 
   * Compile this file with -DNO_DEFLATE to avoid the compression code.
182
 
***************
183
 
*** 7,13 ****
184
 
  
185
 
  /* @(#) $Id: zlib.diff,v 1.1.1.1 2000/11/17 14:22:46 rocco Exp $ */
186
 
  
187
 
! #include <stdio.h>
188
 
  
189
 
  #include "zutil.h"
190
 
  
191
 
--- 8,14 ----
192
 
  
193
 
  /* @(#) $Id: zlib.diff,v 1.1.1.1 2000/11/17 14:22:46 rocco Exp $ */
194
 
  
195
 
! #include <windows.h>
196
 
  
197
 
  #include "zutil.h"
198
 
  
199
 
***************
200
 
*** 41,47 ****
201
 
      z_stream stream;
202
 
      int      z_err;   /* error code for last stream operation */
203
 
      int      z_eof;   /* set if end of input file */
204
 
!     FILE     *file;   /* .gz file */
205
 
      Byte     *inbuf;  /* input buffer */
206
 
      Byte     *outbuf; /* output buffer */
207
 
      uLong    crc;     /* crc32 of uncompressed data */
208
 
--- 42,48 ----
209
 
      z_stream stream;
210
 
      int      z_err;   /* error code for last stream operation */
211
 
      int      z_eof;   /* set if end of input file */
212
 
!     HANDLE   file;    /* .gz file */
213
 
      Byte     *inbuf;  /* input buffer */
214
 
      Byte     *outbuf; /* output buffer */
215
 
      uLong    crc;     /* crc32 of uncompressed data */
216
 
***************
217
 
*** 58,64 ****
218
 
  local int    get_byte     OF((gz_stream *s));
219
 
  local void   check_header OF((gz_stream *s));
220
 
  local int    destroy      OF((gz_stream *s));
221
 
! local void   putLong      OF((FILE *file, uLong x));
222
 
  local uLong  getLong      OF((gz_stream *s));
223
 
  
224
 
  /* ===========================================================================
225
 
--- 59,65 ----
226
 
  local int    get_byte     OF((gz_stream *s));
227
 
  local void   check_header OF((gz_stream *s));
228
 
  local int    destroy      OF((gz_stream *s));
229
 
! local void   putLong      OF((HANDLE file, uLong x));
230
 
  local uLong  getLong      OF((gz_stream *s));
231
 
  
232
 
  /* ===========================================================================
233
 
***************
234
 
*** 82,87 ****
235
 
--- 83,91 ----
236
 
      gz_stream *s;
237
 
      char fmode[80]; /* copy of mode, without the compression level */
238
 
      char *m = fmode;
239
 
+     char cbuff[10];
240
 
+     DWORD size;
241
 
+     TCHAR file[MAX_PATH];
242
 
  
243
 
      if (!path || !mode) return Z_NULL;
244
 
  
245
 
***************
246
 
*** 94,100 ****
247
 
      s->stream.next_in = s->inbuf = Z_NULL;
248
 
      s->stream.next_out = s->outbuf = Z_NULL;
249
 
      s->stream.avail_in = s->stream.avail_out = 0;
250
 
!     s->file = NULL;
251
 
      s->z_err = Z_OK;
252
 
      s->z_eof = 0;
253
 
      s->crc = crc32(0L, Z_NULL, 0);
254
 
--- 98,104 ----
255
 
      s->stream.next_in = s->inbuf = Z_NULL;
256
 
      s->stream.next_out = s->outbuf = Z_NULL;
257
 
      s->stream.avail_in = s->stream.avail_out = 0;
258
 
!     s->file = INVALID_HANDLE_VALUE;
259
 
      s->z_err = Z_OK;
260
 
      s->z_eof = 0;
261
 
      s->crc = crc32(0L, Z_NULL, 0);
262
 
***************
263
 
*** 112,125 ****
264
 
          if (*p == 'r') s->mode = 'r';
265
 
          if (*p == 'w' || *p == 'a') s->mode = 'w';
266
 
          if (*p >= '0' && *p <= '9') {
267
 
!           level = *p - '0';
268
 
!       } else if (*p == 'f') {
269
 
!         strategy = Z_FILTERED;
270
 
!       } else if (*p == 'h') {
271
 
!         strategy = Z_HUFFMAN_ONLY;
272
 
!       } else {
273
 
!           *m++ = *p; /* copy the mode */
274
 
!       }
275
 
      } while (*p++ && m != fmode + sizeof(fmode));
276
 
      if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
277
 
      
278
 
--- 116,129 ----
279
 
          if (*p == 'r') s->mode = 'r';
280
 
          if (*p == 'w' || *p == 'a') s->mode = 'w';
281
 
          if (*p >= '0' && *p <= '9') {
282
 
!             level = *p - '0';
283
 
!         } else if (*p == 'f') {
284
 
!           strategy = Z_FILTERED;
285
 
!         } else if (*p == 'h') {
286
 
!           strategy = Z_HUFFMAN_ONLY;
287
 
!         } else {
288
 
!             *m++ = *p; /* copy the mode */
289
 
!         }
290
 
      } while (*p++ && m != fmode + sizeof(fmode));
291
 
      if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
292
 
      
293
 
***************
294
 
*** 152,177 ****
295
 
      }
296
 
      s->stream.avail_out = Z_BUFSIZE;
297
 
  
298
 
!     errno = 0;
299
 
!     s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
300
 
  
301
 
!     if (s->file == NULL) {
302
 
          return destroy(s), (gzFile)Z_NULL;
303
 
      }
304
 
      if (s->mode == 'w') {
305
 
          /* Write a very simple .gz header:
306
 
           */
307
 
!         fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
308
 
!              Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
309
 
!       s->startpos = 10L;
310
 
!       /* We use 10L instead of ftell(s->file) to because ftell causes an
311
 
           * fflush on some systems. This version of the library doesn't use
312
 
           * startpos anyway in write mode, so this initialization is not
313
 
           * necessary.
314
 
           */
315
 
      } else {
316
 
!       check_header(s); /* skip the .gz header */
317
 
!       s->startpos = (ftell(s->file) - s->stream.avail_in);
318
 
      }
319
 
      
320
 
      return (gzFile)s;
321
 
--- 156,195 ----
322
 
      }
323
 
      s->stream.avail_out = Z_BUFSIZE;
324
 
  
325
 
!     SetLastError(NO_ERROR);
326
 
!     if ((HANDLE)fd == INVALID_HANDLE_VALUE) {
327
 
!         MultiByteToWideChar(CP_ACP, 0, path, -1, file, MAX_PATH);
328
 
!         s->file = CreateFile(file, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
329
 
!     } else {
330
 
!         s->file = (HANDLE)fd;
331
 
!     }
332
 
  
333
 
!     if (s->file == INVALID_HANDLE_VALUE) {
334
 
          return destroy(s), (gzFile)Z_NULL;
335
 
      }
336
 
      if (s->mode == 'w') {
337
 
          /* Write a very simple .gz header:
338
 
           */
339
 
!         cbuff[0] = gz_magic[0];
340
 
!         cbuff[1] = gz_magic[1];
341
 
!         cbuff[2] = Z_DEFLATED;
342
 
!         cbuff[3] = 0; /*flags*/
343
 
!         cbuff[4] = 0;
344
 
!         cbuff[5] = 0;
345
 
!         cbuff[6] = 0;
346
 
!         cbuff[7] = 0; /*time*/;
347
 
!         cbuff[8] = 0; /*xflags*/;
348
 
!         cbuff[9] = OS_CODE;
349
 
!         WriteFile(s->file, cbuff, 10, &size, NULL);
350
 
!         s->startpos = 10L;
351
 
!         /* We use 10L instead of ftell(s->file) to because ftell causes an
352
 
           * fflush on some systems. This version of the library doesn't use
353
 
           * startpos anyway in write mode, so this initialization is not
354
 
           * necessary.
355
 
           */
356
 
      } else {
357
 
!         check_header(s); /* skip the .gz header */
358
 
!         s->startpos = (SetFilePointer(s->file, 0, NULL, FILE_CURRENT) - s->stream.avail_in);
359
 
      }
360
 
      
361
 
      return (gzFile)s;
362
 
***************
363
 
*** 197,205 ****
364
 
  {
365
 
      char name[20];
366
 
  
367
 
!     if (fd < 0) return (gzFile)Z_NULL;
368
 
!     sprintf(name, "<fd:%d>", fd); /* for debugging */
369
 
  
370
 
      return gz_open (name, mode, fd);
371
 
  }
372
 
  
373
 
--- 215,225 ----
374
 
  {
375
 
      char name[20];
376
 
  
377
 
!     if ((HANDLE)fd == INVALID_HANDLE_VALUE)
378
 
!         return (gzFile)Z_NULL;
379
 
  
380
 
+     strcpy(name, "<gzdopen>"); /* for debugging */
381
 
382
 
      return gz_open (name, mode, fd);
383
 
  }
384
 
  
385
 
***************
386
 
*** 212,217 ****
387
 
--- 232,238 ----
388
 
      int strategy;
389
 
  {
390
 
      gz_stream *s = (gz_stream*)file;
391
 
+     DWORD size;
392
 
  
393
 
      if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
394
 
  
395
 
***************
396
 
*** 218,228 ****
397
 
      /* Make room to allow flushing */
398
 
      if (s->stream.avail_out == 0) {
399
 
  
400
 
!       s->stream.next_out = s->outbuf;
401
 
!       if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
402
 
!           s->z_err = Z_ERRNO;
403
 
!       }
404
 
!       s->stream.avail_out = Z_BUFSIZE;
405
 
      }
406
 
  
407
 
      return deflateParams (&(s->stream), level, strategy);
408
 
--- 239,249 ----
409
 
      /* Make room to allow flushing */
410
 
      if (s->stream.avail_out == 0) {
411
 
  
412
 
!         s->stream.next_out = s->outbuf;
413
 
!         if (!WriteFile(s->file, s->outbuf, Z_BUFSIZE, &size, NULL) || size != Z_BUFSIZE) {
414
 
!             s->z_err = Z_ERRNO;
415
 
!         }
416
 
!         s->stream.avail_out = Z_BUFSIZE;
417
 
      }
418
 
  
419
 
      return deflateParams (&(s->stream), level, strategy);
420
 
***************
421
 
*** 236,251 ****
422
 
  local int get_byte(s)
423
 
      gz_stream *s;
424
 
  {
425
 
!     if (s->z_eof) return EOF;
426
 
      if (s->stream.avail_in == 0) {
427
 
!       errno = 0;
428
 
!       s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
429
 
!       if (s->stream.avail_in == 0) {
430
 
!           s->z_eof = 1;
431
 
!           if (ferror(s->file)) s->z_err = Z_ERRNO;
432
 
!           return EOF;
433
 
!       }
434
 
!       s->stream.next_in = s->inbuf;
435
 
      }
436
 
      s->stream.avail_in--;
437
 
      return *(s->stream.next_in)++;
438
 
--- 257,273 ----
439
 
  local int get_byte(s)
440
 
      gz_stream *s;
441
 
  {
442
 
!     if (s->z_eof) return -1;
443
 
      if (s->stream.avail_in == 0) {
444
 
!         SetLastError(NO_ERROR);
445
 
!         if (!ReadFile(s->file, s->inbuf, Z_BUFSIZE, &s->stream.avail_in, NULL)) {
446
 
!             s->z_err = Z_ERRNO;
447
 
!         }
448
 
!         if (s->stream.avail_in == 0) {
449
 
!             s->z_eof = 1;
450
 
!             return -1;
451
 
!         }
452
 
!         s->stream.next_in = s->inbuf;
453
 
      }
454
 
      s->stream.avail_in--;
455
 
      return *(s->stream.next_in)++;
456
 
***************
457
 
*** 270,291 ****
458
 
  
459
 
      /* Check the gzip magic header */
460
 
      for (len = 0; len < 2; len++) {
461
 
!       c = get_byte(s);
462
 
!       if (c != gz_magic[len]) {
463
 
!           if (len != 0) s->stream.avail_in++, s->stream.next_in--;
464
 
!           if (c != EOF) {
465
 
!               s->stream.avail_in++, s->stream.next_in--;
466
 
!               s->transparent = 1;
467
 
!           }
468
 
!           s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
469
 
!           return;
470
 
!       }
471
 
      }
472
 
      method = get_byte(s);
473
 
      flags = get_byte(s);
474
 
      if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
475
 
!       s->z_err = Z_DATA_ERROR;
476
 
!       return;
477
 
      }
478
 
  
479
 
      /* Discard time, xflags and OS code: */
480
 
--- 292,313 ----
481
 
  
482
 
      /* Check the gzip magic header */
483
 
      for (len = 0; len < 2; len++) {
484
 
!         c = get_byte(s);
485
 
!         if (c != gz_magic[len]) {
486
 
!             if (len != 0) s->stream.avail_in++, s->stream.next_in--;
487
 
!             if (c != -1) {
488
 
!                 s->stream.avail_in++, s->stream.next_in--;
489
 
!                 s->transparent = 1;
490
 
!             }
491
 
!             s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
492
 
!             return;
493
 
!         }
494
 
      }
495
 
      method = get_byte(s);
496
 
      flags = get_byte(s);
497
 
      if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
498
 
!         s->z_err = Z_DATA_ERROR;
499
 
!         return;
500
 
      }
501
 
  
502
 
      /* Discard time, xflags and OS code: */
503
 
***************
504
 
*** 292,310 ****
505
 
      for (len = 0; len < 6; len++) (void)get_byte(s);
506
 
  
507
 
      if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
508
 
!       len  =  (uInt)get_byte(s);
509
 
!       len += ((uInt)get_byte(s))<<8;
510
 
!       /* len is garbage if EOF but the loop below will quit anyway */
511
 
!       while (len-- != 0 && get_byte(s) != EOF) ;
512
 
      }
513
 
      if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
514
 
!       while ((c = get_byte(s)) != 0 && c != EOF) ;
515
 
      }
516
 
      if ((flags & COMMENT) != 0) {   /* skip the .gz file comment */
517
 
!       while ((c = get_byte(s)) != 0 && c != EOF) ;
518
 
      }
519
 
      if ((flags & HEAD_CRC) != 0) {  /* skip the header crc */
520
 
!       for (len = 0; len < 2; len++) (void)get_byte(s);
521
 
      }
522
 
      s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
523
 
  }
524
 
--- 314,332 ----
525
 
      for (len = 0; len < 6; len++) (void)get_byte(s);
526
 
  
527
 
      if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
528
 
!         len  =  (uInt)get_byte(s);
529
 
!         len += ((uInt)get_byte(s))<<8;
530
 
!         /* len is garbage if EOF but the loop below will quit anyway */
531
 
!         while (len-- != 0 && get_byte(s) != -1) ;
532
 
      }
533
 
      if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
534
 
!         while ((c = get_byte(s)) != 0 && c != -1) ;
535
 
      }
536
 
      if ((flags & COMMENT) != 0) {   /* skip the .gz file comment */
537
 
!         while ((c = get_byte(s)) != 0 && c != -1) ;
538
 
      }
539
 
      if ((flags & HEAD_CRC) != 0) {  /* skip the header crc */
540
 
!         for (len = 0; len < 2; len++) (void)get_byte(s);
541
 
      }
542
 
      s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
543
 
  }
544
 
***************
545
 
*** 323,343 ****
546
 
      TRYFREE(s->msg);
547
 
  
548
 
      if (s->stream.state != NULL) {
549
 
!       if (s->mode == 'w') {
550
 
  #ifdef NO_DEFLATE
551
 
!           err = Z_STREAM_ERROR;
552
 
  #else
553
 
!           err = deflateEnd(&(s->stream));
554
 
  #endif
555
 
!       } else if (s->mode == 'r') {
556
 
!           err = inflateEnd(&(s->stream));
557
 
!       }
558
 
!     }
559
 
!     if (s->file != NULL && fclose(s->file)) {
560
 
! #ifdef ESPIPE
561
 
!       if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
562
 
! #endif
563
 
!           err = Z_ERRNO;
564
 
      }
565
 
      if (s->z_err < 0) err = s->z_err;
566
 
  
567
 
--- 345,362 ----
568
 
      TRYFREE(s->msg);
569
 
  
570
 
      if (s->stream.state != NULL) {
571
 
!         if (s->mode == 'w') {
572
 
  #ifdef NO_DEFLATE
573
 
!             err = Z_STREAM_ERROR;
574
 
  #else
575
 
!             err = deflateEnd(&(s->stream));
576
 
  #endif
577
 
!         } else if (s->mode == 'r') {
578
 
!             err = inflateEnd(&(s->stream));
579
 
!         }
580
 
!     }
581
 
!     if (s->file != NULL && !CloseHandle(s->file)) {
582
 
!         err = Z_ERRNO;
583
 
      }
584
 
      if (s->z_err < 0) err = s->z_err;
585
 
  
586
 
***************
587
 
*** 360,365 ****
588
 
--- 379,385 ----
589
 
      gz_stream *s = (gz_stream*)file;
590
 
      Bytef *start = (Bytef*)buf; /* starting point for crc computation */
591
 
      Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
592
 
+     DWORD size;
593
 
  
594
 
      if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
595
 
  
596
 
***************
597
 
*** 372,440 ****
598
 
  
599
 
      while (s->stream.avail_out != 0) {
600
 
  
601
 
!       if (s->transparent) {
602
 
!           /* Copy first the lookahead bytes: */
603
 
!           uInt n = s->stream.avail_in;
604
 
!           if (n > s->stream.avail_out) n = s->stream.avail_out;
605
 
!           if (n > 0) {
606
 
!               zmemcpy(s->stream.next_out, s->stream.next_in, n);
607
 
!               next_out += n;
608
 
!               s->stream.next_out = next_out;
609
 
!               s->stream.next_in   += n;
610
 
!               s->stream.avail_out -= n;
611
 
!               s->stream.avail_in  -= n;
612
 
!           }
613
 
!           if (s->stream.avail_out > 0) {
614
 
!               s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out,
615
 
!                                            s->file);
616
 
!           }
617
 
!           len -= s->stream.avail_out;
618
 
!           s->stream.total_in  += (uLong)len;
619
 
!           s->stream.total_out += (uLong)len;
620
 
              if (len == 0) s->z_eof = 1;
621
 
!           return (int)len;
622
 
!       }
623
 
          if (s->stream.avail_in == 0 && !s->z_eof) {
624
 
  
625
 
!             errno = 0;
626
 
!             s->stream.avail_in = fread(s->inbuf, 1, Z_BUFSIZE, s->file);
627
 
              if (s->stream.avail_in == 0) {
628
 
                  s->z_eof = 1;
629
 
-               if (ferror(s->file)) {
630
 
-                   s->z_err = Z_ERRNO;
631
 
-                   break;
632
 
-               }
633
 
              }
634
 
              s->stream.next_in = s->inbuf;
635
 
          }
636
 
          s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
637
 
  
638
 
!       if (s->z_err == Z_STREAM_END) {
639
 
!           /* Check CRC and original size */
640
 
!           s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
641
 
!           start = s->stream.next_out;
642
 
643
 
!           if (getLong(s) != s->crc) {
644
 
!               s->z_err = Z_DATA_ERROR;
645
 
!           } else {
646
 
!               (void)getLong(s);
647
 
                  /* The uncompressed length returned by above getlong() may
648
 
                   * be different from s->stream.total_out) in case of
649
 
!                * concatenated .gz files. Check for such files:
650
 
!                */
651
 
!               check_header(s);
652
 
!               if (s->z_err == Z_OK) {
653
 
!                   uLong total_in = s->stream.total_in;
654
 
!                   uLong total_out = s->stream.total_out;
655
 
656
 
!                   inflateReset(&(s->stream));
657
 
!                   s->stream.total_in = total_in;
658
 
!                   s->stream.total_out = total_out;
659
 
!                   s->crc = crc32(0L, Z_NULL, 0);
660
 
!               }
661
 
!           }
662
 
!       }
663
 
!       if (s->z_err != Z_OK || s->z_eof) break;
664
 
      }
665
 
      s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
666
 
  
667
 
--- 392,461 ----
668
 
  
669
 
      while (s->stream.avail_out != 0) {
670
 
  
671
 
!         if (s->transparent) {
672
 
!             /* Copy first the lookahead bytes: */
673
 
!             uInt n = s->stream.avail_in;
674
 
!             if (n > s->stream.avail_out) n = s->stream.avail_out;
675
 
!             if (n > 0) {
676
 
!                 zmemcpy(s->stream.next_out, s->stream.next_in, n);
677
 
!                 next_out += n;
678
 
!                 s->stream.next_out = next_out;
679
 
!                 s->stream.next_in   += n;
680
 
!                 s->stream.avail_out -= n;
681
 
!                 s->stream.avail_in  -= n;
682
 
!             }
683
 
!             if (s->stream.avail_out > 0) {
684
 
!                 if (ReadFile(s->file, next_out, s->stream.avail_out, &size, NULL)) {
685
 
!                     s->stream.avail_out -= size;
686
 
!                 }
687
 
!             }
688
 
!             len -= s->stream.avail_out;
689
 
!             s->stream.total_in  += (uLong)len;
690
 
!             s->stream.total_out += (uLong)len;
691
 
              if (len == 0) s->z_eof = 1;
692
 
!             return (int)len;
693
 
!         }
694
 
          if (s->stream.avail_in == 0 && !s->z_eof) {
695
 
  
696
 
!             SetLastError(NO_ERROR);
697
 
!             if (!ReadFile(s->file, s->inbuf, Z_BUFSIZE, &s->stream.avail_in, NULL)) {
698
 
!                 s->z_eof = 1;
699
 
!                 s->z_err = Z_ERRNO;
700
 
!                 break;
701
 
!             }
702
 
              if (s->stream.avail_in == 0) {
703
 
                  s->z_eof = 1;
704
 
              }
705
 
              s->stream.next_in = s->inbuf;
706
 
          }
707
 
          s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
708
 
  
709
 
!         if (s->z_err == Z_STREAM_END) {
710
 
!             /* Check CRC and original size */
711
 
!             s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
712
 
!             start = s->stream.next_out;
713
 
714
 
!             if (getLong(s) != s->crc) {
715
 
!                 s->z_err = Z_DATA_ERROR;
716
 
!             } else {
717
 
!                 (void)getLong(s);
718
 
                  /* The uncompressed length returned by above getlong() may
719
 
                   * be different from s->stream.total_out) in case of
720
 
!                  * concatenated .gz files. Check for such files:
721
 
!                  */
722
 
!                 check_header(s);
723
 
!                 if (s->z_err == Z_OK) {
724
 
!                     uLong total_in = s->stream.total_in;
725
 
!                     uLong total_out = s->stream.total_out;
726
 
727
 
!                     inflateReset(&(s->stream));
728
 
!                     s->stream.total_in = total_in;
729
 
!                     s->stream.total_out = total_out;
730
 
!                     s->crc = crc32(0L, Z_NULL, 0);
731
 
!                 }
732
 
!             }
733
 
!         }
734
 
!         if (s->z_err != Z_OK || s->z_eof) break;
735
 
      }
736
 
      s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
737
 
  
738
 
***************
739
 
*** 489,494 ****
740
 
--- 510,516 ----
741
 
      unsigned len;
742
 
  {
743
 
      gz_stream *s = (gz_stream*)file;
744
 
+     DWORD size;
745
 
  
746
 
      if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
747
 
  
748
 
***************
749
 
*** 500,506 ****
750
 
          if (s->stream.avail_out == 0) {
751
 
  
752
 
              s->stream.next_out = s->outbuf;
753
 
!             if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
754
 
                  s->z_err = Z_ERRNO;
755
 
                  break;
756
 
              }
757
 
--- 522,528 ----
758
 
          if (s->stream.avail_out == 0) {
759
 
  
760
 
              s->stream.next_out = s->outbuf;
761
 
!             if (!WriteFile(s->file, s->outbuf, Z_BUFSIZE, &size, NULL) || size != Z_BUFSIZE) {
762
 
                  s->z_err = Z_ERRNO;
763
 
                  break;
764
 
              }
765
 
***************
766
 
*** 527,540 ****
767
 
      char buf[Z_PRINTF_BUFSIZE];
768
 
      va_list va;
769
 
      int len;
770
 
  
771
 
      va_start(va, format);
772
 
! #ifdef HAS_vsnprintf
773
 
!     (void)vsnprintf(buf, sizeof(buf), format, va);
774
 
! #else
775
 
!     (void)vsprintf(buf, format, va);
776
 
! #endif
777
 
      va_end(va);
778
 
      len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
779
 
      if (len <= 0) return 0;
780
 
  
781
 
--- 549,574 ----
782
 
      char buf[Z_PRINTF_BUFSIZE];
783
 
      va_list va;
784
 
      int len;
785
 
+     TCHAR form[Z_PRINTF_BUFSIZE];
786
 
+     TCHAR tbuf[Z_PRINTF_BUFSIZE];
787
 
+     int n;
788
 
  
789
 
      va_start(va, format);
790
 
!     MultiByteToWideChar(CP_ACP, 0, format, -1, form, Z_PRINTF_BUFSIZE);
791
 
!     len = lstrlen(form);
792
 
!     for ( n = 0; n < len; n++ ) {
793
 
!         if ( TEXT('%') == form[n] ) {
794
 
!             n++;
795
 
!             if ( TEXT('c') == form[n] ) {
796
 
!                 form[n] = TEXT('C');
797
 
!             } else if ( TEXT('s') == form[n] ) {
798
 
!                 form[n] = TEXT('S');
799
 
!             }
800
 
!         }
801
 
!     }
802
 
!     (void)vswprintf(tbuf, form, va);
803
 
      va_end(va);
804
 
+     WideCharToMultiByte(CP_ACP, 0, tbuf, -1, buf, Z_PRINTF_BUFSIZE, NULL, NULL);
805
 
      len = strlen(buf); /* some *sprintf don't return the nb of bytes written */
806
 
      if (len <= 0) return 0;
807
 
  
808
 
***************
809
 
*** 543,553 ****
810
 
  #else /* not ANSI C */
811
 
  
812
 
  int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
813
 
!                      a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
814
 
      gzFile file;
815
 
      const char *format;
816
 
      int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
817
 
!       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
818
 
  {
819
 
      char buf[Z_PRINTF_BUFSIZE];
820
 
      int len;
821
 
--- 577,587 ----
822
 
  #else /* not ANSI C */
823
 
  
824
 
  int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
825
 
!                        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
826
 
      gzFile file;
827
 
      const char *format;
828
 
      int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
829
 
!         a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
830
 
  {
831
 
      char buf[Z_PRINTF_BUFSIZE];
832
 
      int len;
833
 
***************
834
 
*** 554,563 ****
835
 
  
836
 
  #ifdef HAS_snprintf
837
 
      snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
838
 
!            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
839
 
  #else
840
 
      sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
841
 
!           a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
842
 
  #endif
843
 
      len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */
844
 
      if (len <= 0) return 0;
845
 
--- 588,597 ----
846
 
  
847
 
  #ifdef HAS_snprintf
848
 
      snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
849
 
!              a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
850
 
  #else
851
 
      sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
852
 
!             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
853
 
  #endif
854
 
      len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */
855
 
      if (len <= 0) return 0;
856
 
***************
857
 
*** 604,609 ****
858
 
--- 638,644 ----
859
 
      uInt len;
860
 
      int done = 0;
861
 
      gz_stream *s = (gz_stream*)file;
862
 
+     DWORD size;
863
 
  
864
 
      if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
865
 
  
866
 
***************
867
 
*** 613,619 ****
868
 
          len = Z_BUFSIZE - s->stream.avail_out;
869
 
  
870
 
          if (len != 0) {
871
 
!             if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
872
 
                  s->z_err = Z_ERRNO;
873
 
                  return Z_ERRNO;
874
 
              }
875
 
--- 648,654 ----
876
 
          len = Z_BUFSIZE - s->stream.avail_out;
877
 
  
878
 
          if (len != 0) {
879
 
!             if (!WriteFile(s->file, s->outbuf, len, &size, NULL) || (uInt)size != len) {
880
 
                  s->z_err = Z_ERRNO;
881
 
                  return Z_ERRNO;
882
 
              }
883
 
***************
884
 
*** 623,630 ****
885
 
          if (done) break;
886
 
          s->z_err = deflate(&(s->stream), flush);
887
 
  
888
 
!       /* Ignore the second of two consecutive flushes: */
889
 
!       if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
890
 
  
891
 
          /* deflate has finished flushing only when it hasn't used up
892
 
           * all the available space in the output buffer: 
893
 
--- 658,665 ----
894
 
          if (done) break;
895
 
          s->z_err = deflate(&(s->stream), flush);
896
 
  
897
 
!         /* Ignore the second of two consecutive flushes: */
898
 
!         if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
899
 
  
900
 
          /* deflate has finished flushing only when it hasn't used up
901
 
           * all the available space in the output buffer: 
902
 
***************
903
 
*** 644,650 ****
904
 
      int err = do_flush (file, flush);
905
 
  
906
 
      if (err) return err;
907
 
!     fflush(s->file);
908
 
      return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
909
 
  }
910
 
  #endif /* NO_DEFLATE */
911
 
--- 679,685 ----
912
 
      int err = do_flush (file, flush);
913
 
  
914
 
      if (err) return err;
915
 
916
 
      return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
917
 
  }
918
 
  #endif /* NO_DEFLATE */
919
 
***************
920
 
*** 665,698 ****
921
 
      gz_stream *s = (gz_stream*)file;
922
 
  
923
 
      if (s == NULL || whence == SEEK_END ||
924
 
!       s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
925
 
!       return -1L;
926
 
      }
927
 
      
928
 
      if (s->mode == 'w') {
929
 
  #ifdef NO_DEFLATE
930
 
!       return -1L;
931
 
  #else
932
 
!       if (whence == SEEK_SET) {
933
 
!           offset -= s->stream.total_in;
934
 
!       }
935
 
!       if (offset < 0) return -1L;
936
 
937
 
!       /* At this point, offset is the number of zero bytes to write. */
938
 
!       if (s->inbuf == Z_NULL) {
939
 
!           s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
940
 
!           zmemzero(s->inbuf, Z_BUFSIZE);
941
 
!       }
942
 
!       while (offset > 0)  {
943
 
!           uInt size = Z_BUFSIZE;
944
 
!           if (offset < Z_BUFSIZE) size = (uInt)offset;
945
 
946
 
!           size = gzwrite(file, s->inbuf, size);
947
 
!           if (size == 0) return -1L;
948
 
949
 
!           offset -= size;
950
 
!       }
951
 
!       return (z_off_t)s->stream.total_in;
952
 
  #endif
953
 
      }
954
 
      /* Rest of function is for reading only */
955
 
--- 700,733 ----
956
 
      gz_stream *s = (gz_stream*)file;
957
 
  
958
 
      if (s == NULL || whence == SEEK_END ||
959
 
!         s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
960
 
!         return -1L;
961
 
      }
962
 
      
963
 
      if (s->mode == 'w') {
964
 
  #ifdef NO_DEFLATE
965
 
!         return -1L;
966
 
  #else
967
 
!         if (whence == SEEK_SET) {
968
 
!             offset -= s->stream.total_in;
969
 
!         }
970
 
!         if (offset < 0) return -1L;
971
 
972
 
!         /* At this point, offset is the number of zero bytes to write. */
973
 
!         if (s->inbuf == Z_NULL) {
974
 
!             s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
975
 
!             zmemzero(s->inbuf, Z_BUFSIZE);
976
 
!         }
977
 
!         while (offset > 0)  {
978
 
!             uInt size = Z_BUFSIZE;
979
 
!             if (offset < Z_BUFSIZE) size = (uInt)offset;
980
 
981
 
!             size = gzwrite(file, s->inbuf, size);
982
 
!             if (size == 0) return -1L;
983
 
984
 
!             offset -= size;
985
 
!         }
986
 
!         return (z_off_t)s->stream.total_in;
987
 
  #endif
988
 
      }
989
 
      /* Rest of function is for reading only */
990
 
***************
991
 
*** 699,736 ****
992
 
  
993
 
      /* compute absolute position */
994
 
      if (whence == SEEK_CUR) {
995
 
!       offset += s->stream.total_out;
996
 
      }
997
 
      if (offset < 0) return -1L;
998
 
  
999
 
      if (s->transparent) {
1000
 
!       /* map to fseek */
1001
 
!       s->stream.avail_in = 0;
1002
 
!       s->stream.next_in = s->inbuf;
1003
 
!         if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
1004
 
  
1005
 
!       s->stream.total_in = s->stream.total_out = (uLong)offset;
1006
 
!       return offset;
1007
 
      }
1008
 
  
1009
 
      /* For a negative seek, rewind and use positive seek */
1010
 
      if ((uLong)offset >= s->stream.total_out) {
1011
 
!       offset -= s->stream.total_out;
1012
 
      } else if (gzrewind(file) < 0) {
1013
 
!       return -1L;
1014
 
      }
1015
 
      /* offset is now the number of bytes to skip. */
1016
 
  
1017
 
      if (offset != 0 && s->outbuf == Z_NULL) {
1018
 
!       s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
1019
 
      }
1020
 
      while (offset > 0)  {
1021
 
!       int size = Z_BUFSIZE;
1022
 
!       if (offset < Z_BUFSIZE) size = (int)offset;
1023
 
  
1024
 
!       size = gzread(file, s->outbuf, (uInt)size);
1025
 
!       if (size <= 0) return -1L;
1026
 
!       offset -= size;
1027
 
      }
1028
 
      return (z_off_t)s->stream.total_out;
1029
 
  }
1030
 
--- 734,771 ----
1031
 
  
1032
 
      /* compute absolute position */
1033
 
      if (whence == SEEK_CUR) {
1034
 
!         offset += s->stream.total_out;
1035
 
      }
1036
 
      if (offset < 0) return -1L;
1037
 
  
1038
 
      if (s->transparent) {
1039
 
!         /* map to fseek */
1040
 
!         s->stream.avail_in = 0;
1041
 
!         s->stream.next_in = s->inbuf;
1042
 
!         if (SetFilePointer(s->file, offset, NULL, FILE_BEGIN) == 0xFFFFFFFF) return -1L;
1043
 
  
1044
 
!         s->stream.total_in = s->stream.total_out = (uLong)offset;
1045
 
!         return offset;
1046
 
      }
1047
 
  
1048
 
      /* For a negative seek, rewind and use positive seek */
1049
 
      if ((uLong)offset >= s->stream.total_out) {
1050
 
!         offset -= s->stream.total_out;
1051
 
      } else if (gzrewind(file) < 0) {
1052
 
!         return -1L;
1053
 
      }
1054
 
      /* offset is now the number of bytes to skip. */
1055
 
  
1056
 
      if (offset != 0 && s->outbuf == Z_NULL) {
1057
 
!         s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
1058
 
      }
1059
 
      while (offset > 0)  {
1060
 
!         int size = Z_BUFSIZE;
1061
 
!         if (offset < Z_BUFSIZE) size = (int)offset;
1062
 
  
1063
 
!         size = gzread(file, s->outbuf, (uInt)size);
1064
 
!         if (size <= 0) return -1L;
1065
 
!         offset -= size;
1066
 
      }
1067
 
      return (z_off_t)s->stream.total_out;
1068
 
  }
1069
 
***************
1070
 
*** 742,748 ****
1071
 
      gzFile file;
1072
 
  {
1073
 
      gz_stream *s = (gz_stream*)file;
1074
 
!     
1075
 
      if (s == NULL || s->mode != 'r') return -1;
1076
 
  
1077
 
      s->z_err = Z_OK;
1078
 
--- 777,783 ----
1079
 
      gzFile file;
1080
 
  {
1081
 
      gz_stream *s = (gz_stream*)file;
1082
 
1083
 
      if (s == NULL || s->mode != 'r') return -1;
1084
 
  
1085
 
      s->z_err = Z_OK;
1086
 
***************
1087
 
*** 750,763 ****
1088
 
      s->stream.avail_in = 0;
1089
 
      s->stream.next_in = s->inbuf;
1090
 
      s->crc = crc32(0L, Z_NULL, 0);
1091
 
!       
1092
 
      if (s->startpos == 0) { /* not a compressed file */
1093
 
!       rewind(s->file);
1094
 
!       return 0;
1095
 
      }
1096
 
  
1097
 
      (void) inflateReset(&s->stream);
1098
 
!     return fseek(s->file, s->startpos, SEEK_SET);
1099
 
  }
1100
 
  
1101
 
  /* ===========================================================================
1102
 
--- 785,798 ----
1103
 
      s->stream.avail_in = 0;
1104
 
      s->stream.next_in = s->inbuf;
1105
 
      s->crc = crc32(0L, Z_NULL, 0);
1106
 
!         
1107
 
      if (s->startpos == 0) { /* not a compressed file */
1108
 
!         SetFilePointer(s->file, 0, NULL, FILE_BEGIN);
1109
 
!         return 0;
1110
 
      }
1111
 
  
1112
 
      (void) inflateReset(&s->stream);
1113
 
!     return SetFilePointer(s->file, s->startpos, NULL, FILE_BEGIN);
1114
 
  }
1115
 
  
1116
 
  /* ===========================================================================
1117
 
***************
1118
 
*** 787,798 ****
1119
 
     Outputs a long in LSB order to the given file
1120
 
  */
1121
 
  local void putLong (file, x)
1122
 
!     FILE *file;
1123
 
      uLong x;
1124
 
  {
1125
 
      int n;
1126
 
      for (n = 0; n < 4; n++) {
1127
 
!         fputc((int)(x & 0xff), file);
1128
 
          x >>= 8;
1129
 
      }
1130
 
  }
1131
 
--- 822,836 ----
1132
 
     Outputs a long in LSB order to the given file
1133
 
  */
1134
 
  local void putLong (file, x)
1135
 
!     HANDLE file;
1136
 
      uLong x;
1137
 
  {
1138
 
      int n;
1139
 
+     char ch[1];
1140
 
+     DWORD size;
1141
 
      for (n = 0; n < 4; n++) {
1142
 
!         ch[0] = (int)(x & 0xff);
1143
 
!         WriteFile(file, ch, 1, &size, NULL);
1144
 
          x >>= 8;
1145
 
      }
1146
 
  }
1147
 
***************
1148
 
*** 810,816 ****
1149
 
      x += ((uLong)get_byte(s))<<8;
1150
 
      x += ((uLong)get_byte(s))<<16;
1151
 
      c = get_byte(s);
1152
 
!     if (c == EOF) s->z_err = Z_DATA_ERROR;
1153
 
      x += ((uLong)c)<<24;
1154
 
      return x;
1155
 
  }
1156
 
--- 848,854 ----
1157
 
      x += ((uLong)get_byte(s))<<8;
1158
 
      x += ((uLong)get_byte(s))<<16;
1159
 
      c = get_byte(s);
1160
 
!     if (c == -1) s->z_err = Z_DATA_ERROR;
1161
 
      x += ((uLong)c)<<24;
1162
 
      return x;
1163
 
  }
1164
 
***************
1165
 
*** 829,835 ****
1166
 
  
1167
 
      if (s->mode == 'w') {
1168
 
  #ifdef NO_DEFLATE
1169
 
!       return Z_STREAM_ERROR;
1170
 
  #else
1171
 
          err = do_flush (file, Z_FINISH);
1172
 
          if (err != Z_OK) return destroy((gz_stream*)file);
1173
 
--- 867,873 ----
1174
 
  
1175
 
      if (s->mode == 'w') {
1176
 
  #ifdef NO_DEFLATE
1177
 
!         return Z_STREAM_ERROR;
1178
 
  #else
1179
 
          err = do_flush (file, Z_FINISH);
1180
 
          if (err != Z_OK) return destroy((gz_stream*)file);
1181
 
***************
1182
 
*** 862,868 ****
1183
 
      *errnum = s->z_err;
1184
 
      if (*errnum == Z_OK) return (const char*)"";
1185
 
  
1186
 
!     m =  (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
1187
 
  
1188
 
      if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
1189
 
  
1190
 
--- 900,906 ----
1191
 
      *errnum = s->z_err;
1192
 
      if (*errnum == Z_OK) return (const char*)"";
1193
 
  
1194
 
!     m =  (char*)(*errnum == Z_ERRNO ? zstrerror(GetLastError()) : s->stream.msg);
1195
 
  
1196
 
      if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
1197
 
  
1198
 
*** zlib113/minigzip.c  Sat Jul  8 13:59:49 2000
1199
 
--- zlibwce/minigzip.c  Sat Jul  8 13:58:29 2000
1200
 
***************
1201
 
*** 1,5 ****
1202
 
--- 1,6 ----
1203
 
  /* minigzip.c -- simulate gzip using the zlib compression library
1204
 
   * Copyright (C) 1995-1998 Jean-loup Gailly.
1205
 
+  * Copyright (C) 2000      Tenik Co.,Ltd.
1206
 
   * For conditions of distribution and use, see copyright notice in zlib.h 
1207
 
   */
1208
 
  
1209
 
***************
1210
 
*** 15,21 ****
1211
 
--- 16,30 ----
1212
 
  
1213
 
  /* @(#) $Id: zlib.diff,v 1.1.1.1 2000/11/17 14:22:46 rocco Exp $ */
1214
 
  
1215
 
+ #if defined(_WIN32_WCE)
1216
 
+ #if _WIN32_WCE < 211
1217
 
+ #error (f|w)printf functions is not support old WindowsCE.
1218
 
+ #endif
1219
 
+ #undef USE_MMAP
1220
 
+ #include <windows.h>
1221
 
+ #else
1222
 
  #include <stdio.h>
1223
 
+ #endif
1224
 
  #include "zlib.h"
1225
 
  
1226
 
  #ifdef STDC
1227
 
***************
1228
 
*** 31,37 ****
1229
 
  #  include <sys/stat.h>
1230
 
  #endif
1231
 
  
1232
 
! #if defined(MSDOS) || defined(OS2) || defined(WIN32)
1233
 
  #  include <fcntl.h>
1234
 
  #  include <io.h>
1235
 
  #  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
1236
 
--- 40,46 ----
1237
 
  #  include <sys/stat.h>
1238
 
  #endif
1239
 
  
1240
 
! #if (defined(MSDOS) || defined(OS2) || defined(WIN32)) && !defined(_WIN32_WCE)
1241
 
  #  include <fcntl.h>
1242
 
  #  include <io.h>
1243
 
  #  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
1244
 
***************
1245
 
*** 71,84 ****
1246
 
  #  define local
1247
 
  #endif
1248
 
  
1249
 
  char *prog;
1250
 
  
1251
 
  void error            OF((const char *msg));
1252
 
! void gz_compress      OF((FILE   *in, gzFile out));
1253
 
  #ifdef USE_MMAP
1254
 
! int  gz_compress_mmap OF((FILE   *in, gzFile out));
1255
 
  #endif
1256
 
! void gz_uncompress    OF((gzFile in, FILE   *out));
1257
 
  void file_compress    OF((char  *file, char *mode));
1258
 
  void file_uncompress  OF((char  *file));
1259
 
  int  main             OF((int argc, char *argv[]));
1260
 
--- 80,103 ----
1261
 
  #  define local
1262
 
  #endif
1263
 
  
1264
 
+ #if defined(_WIN32_WCE)
1265
 
+ #undef  stderr
1266
 
+ #define stderr  stdout
1267
 
+ #define F_FILE  HANDLE
1268
 
+ #define F_NULL  INVALID_HANDLE_VALUE
1269
 
+ #else
1270
 
+ #define F_FILE  FILE*
1271
 
+ #define F_NULL  NULL
1272
 
+ #endif
1273
 
1274
 
  char *prog;
1275
 
  
1276
 
  void error            OF((const char *msg));
1277
 
! void gz_compress      OF((F_FILE in, gzFile out));
1278
 
  #ifdef USE_MMAP
1279
 
! int  gz_compress_mmap OF((F_FILE in, gzFile out));
1280
 
  #endif
1281
 
! void gz_uncompress    OF((gzFile in, F_FILE out));
1282
 
  void file_compress    OF((char  *file, char *mode));
1283
 
  void file_uncompress  OF((char  *file));
1284
 
  int  main             OF((int argc, char *argv[]));
1285
 
***************
1286
 
*** 93,104 ****
1287
 
      exit(1);
1288
 
  }
1289
 
  
1290
 
  /* ===========================================================================
1291
 
   * Compress input to output then close both files.
1292
 
   */
1293
 
  
1294
 
  void gz_compress(in, out)
1295
 
!     FILE   *in;
1296
 
      gzFile out;
1297
 
  {
1298
 
      local char buf[BUFLEN];
1299
 
--- 112,160 ----
1300
 
      exit(1);
1301
 
  }
1302
 
  
1303
 
+ #if defined(_WIN32_WCE)
1304
 
+ void perror(msg)
1305
 
+     const char *msg;
1306
 
+ {
1307
 
+     DWORD dwError;
1308
 
+     LPVOID lpMsgBuf;
1309
 
1310
 
+     dwError = GetLastError();
1311
 
+     if ( FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
1312
 
+         FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE |
1313
 
+         FORMAT_MESSAGE_IGNORE_INSERTS,
1314
 
+         NULL,
1315
 
+         dwError,
1316
 
+         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
1317
 
+         (LPTSTR) &lpMsgBuf,
1318
 
+         0,
1319
 
+         NULL) )
1320
 
+     {
1321
 
+         wprintf(TEXT("%S: %s\n"), msg, (LPTSTR)lpMsgBuf);
1322
 
+         LocalFree(lpMsgBuf);
1323
 
+     }
1324
 
+     else
1325
 
+     {
1326
 
+         wprintf(TEXT("%S: Error #%d\n"), msg, dwError);
1327
 
+     }
1328
 
+ }
1329
 
1330
 
+ int unlink(filename)
1331
 
+     const char *filename;
1332
 
+ {
1333
 
+     TCHAR path[MAX_PATH];
1334
 
1335
 
+     MultiByteToWideChar(CP_ACP, 0, filename, -1, path, MAX_PATH);
1336
 
+     return DeleteFile(path);
1337
 
+ }
1338
 
+ #endif
1339
 
1340
 
  /* ===========================================================================
1341
 
   * Compress input to output then close both files.
1342
 
   */
1343
 
  
1344
 
  void gz_compress(in, out)
1345
 
!     F_FILE in;
1346
 
      gzFile out;
1347
 
  {
1348
 
      local char buf[BUFLEN];
1349
 
***************
1350
 
*** 112,119 ****
1351
 
--- 168,179 ----
1352
 
      if (gz_compress_mmap(in, out) == Z_OK) return;
1353
 
  #endif
1354
 
      for (;;) {
1355
 
+ #if defined(_WIN32_WCE)
1356
 
+         if (!ReadFile(in, buf, sizeof(buf), &len, NULL)) {
1357
 
+ #else
1358
 
          len = fread(buf, 1, sizeof(buf), in);
1359
 
          if (ferror(in)) {
1360
 
+ #endif
1361
 
              perror("fread");
1362
 
              exit(1);
1363
 
          }
1364
 
***************
1365
 
*** 121,127 ****
1366
 
--- 181,191 ----
1367
 
  
1368
 
          if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
1369
 
      }
1370
 
+ #if defined(_WIN32_WCE)
1371
 
+     CloseHandle(in);
1372
 
+ #else
1373
 
      fclose(in);
1374
 
+ #endif
1375
 
      if (gzclose(out) != Z_OK) error("failed gzclose");
1376
 
  }
1377
 
  
1378
 
***************
1379
 
*** 131,137 ****
1380
 
   * if success, Z_ERRNO otherwise.
1381
 
   */
1382
 
  int gz_compress_mmap(in, out)
1383
 
!     FILE   *in;
1384
 
      gzFile out;
1385
 
  {
1386
 
      int len;
1387
 
--- 195,201 ----
1388
 
   * if success, Z_ERRNO otherwise.
1389
 
   */
1390
 
  int gz_compress_mmap(in, out)
1391
 
!     F_FILE in;
1392
 
      gzFile out;
1393
 
  {
1394
 
      int len;
1395
 
***************
1396
 
*** 167,177 ****
1397
 
   */
1398
 
  void gz_uncompress(in, out)
1399
 
      gzFile in;
1400
 
!     FILE   *out;
1401
 
  {
1402
 
      local char buf[BUFLEN];
1403
 
      int len;
1404
 
      int err;
1405
 
  
1406
 
      for (;;) {
1407
 
          len = gzread(in, buf, sizeof(buf));
1408
 
--- 231,244 ----
1409
 
   */
1410
 
  void gz_uncompress(in, out)
1411
 
      gzFile in;
1412
 
!     F_FILE out;
1413
 
  {
1414
 
      local char buf[BUFLEN];
1415
 
      int len;
1416
 
      int err;
1417
 
+ #if defined(_WIN32_WCE)
1418
 
+     int size;
1419
 
+ #endif
1420
 
  
1421
 
      for (;;) {
1422
 
          len = gzread(in, buf, sizeof(buf));
1423
 
***************
1424
 
*** 178,188 ****
1425
 
          if (len < 0) error (gzerror(in, &err));
1426
 
          if (len == 0) break;
1427
 
  
1428
 
          if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
1429
 
!           error("failed fwrite");
1430
 
!       }
1431
 
      }
1432
 
      if (fclose(out)) error("failed fclose");
1433
 
  
1434
 
      if (gzclose(in) != Z_OK) error("failed gzclose");
1435
 
  }
1436
 
--- 245,263 ----
1437
 
          if (len < 0) error (gzerror(in, &err));
1438
 
          if (len == 0) break;
1439
 
  
1440
 
+ #if defined(_WIN32_WCE)
1441
 
+         if (!WriteFile(out, buf, (unsigned)len, &size, NULL) || size != len) {
1442
 
+ #else
1443
 
          if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
1444
 
! #endif
1445
 
!             error("failed fwrite");
1446
 
!         }
1447
 
      }
1448
 
+ #if defined(_WIN32_WCE)
1449
 
+     if (!CloseHandle(out)) error("failed fclose");
1450
 
+ #else
1451
 
      if (fclose(out)) error("failed fclose");
1452
 
+ #endif
1453
 
  
1454
 
      if (gzclose(in) != Z_OK) error("failed gzclose");
1455
 
  }
1456
 
***************
1457
 
*** 197,215 ****
1458
 
      char  *mode;
1459
 
  {
1460
 
      local char outfile[MAX_NAME_LEN];
1461
 
!     FILE  *in;
1462
 
      gzFile out;
1463
 
  
1464
 
      strcpy(outfile, file);
1465
 
      strcat(outfile, GZ_SUFFIX);
1466
 
  
1467
 
      in = fopen(file, "rb");
1468
 
!     if (in == NULL) {
1469
 
          perror(file);
1470
 
          exit(1);
1471
 
      }
1472
 
      out = gzopen(outfile, mode);
1473
 
!     if (out == NULL) {
1474
 
          fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
1475
 
          exit(1);
1476
 
      }
1477
 
--- 272,298 ----
1478
 
      char  *mode;
1479
 
  {
1480
 
      local char outfile[MAX_NAME_LEN];
1481
 
!     F_FILE in;
1482
 
      gzFile out;
1483
 
+ #if defined(_WIN32_WCE)
1484
 
+     TCHAR path[MAX_PATH];
1485
 
+ #endif
1486
 
  
1487
 
      strcpy(outfile, file);
1488
 
      strcat(outfile, GZ_SUFFIX);
1489
 
  
1490
 
+ #if defined(_WIN32_WCE)
1491
 
+     MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);
1492
 
+     in = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
1493
 
+ #else
1494
 
      in = fopen(file, "rb");
1495
 
! #endif
1496
 
!     if (in == F_NULL) {
1497
 
          perror(file);
1498
 
          exit(1);
1499
 
      }
1500
 
      out = gzopen(outfile, mode);
1501
 
!     if (out == F_NULL) {
1502
 
          fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
1503
 
          exit(1);
1504
 
      }
1505
 
***************
1506
 
*** 227,235 ****
1507
 
  {
1508
 
      local char buf[MAX_NAME_LEN];
1509
 
      char *infile, *outfile;
1510
 
!     FILE  *out;
1511
 
      gzFile in;
1512
 
      int len = strlen(file);
1513
 
  
1514
 
      strcpy(buf, file);
1515
 
  
1516
 
--- 310,321 ----
1517
 
  {
1518
 
      local char buf[MAX_NAME_LEN];
1519
 
      char *infile, *outfile;
1520
 
!     F_FILE out;
1521
 
      gzFile in;
1522
 
      int len = strlen(file);
1523
 
+ #if defined(_WIN32_WCE)
1524
 
+     TCHAR path[MAX_PATH];
1525
 
+ #endif
1526
 
  
1527
 
      strcpy(buf, file);
1528
 
  
1529
 
***************
1530
 
*** 243,254 ****
1531
 
          strcat(infile, GZ_SUFFIX);
1532
 
      }
1533
 
      in = gzopen(infile, "rb");
1534
 
!     if (in == NULL) {
1535
 
          fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
1536
 
          exit(1);
1537
 
      }
1538
 
      out = fopen(outfile, "wb");
1539
 
!     if (out == NULL) {
1540
 
          perror(file);
1541
 
          exit(1);
1542
 
      }
1543
 
--- 329,345 ----
1544
 
          strcat(infile, GZ_SUFFIX);
1545
 
      }
1546
 
      in = gzopen(infile, "rb");
1547
 
!     if (in == F_NULL) {
1548
 
          fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
1549
 
          exit(1);
1550
 
      }
1551
 
+ #if defined(_WIN32_WCE)
1552
 
+     MultiByteToWideChar(CP_ACP, 0, outfile, -1, path, MAX_PATH);
1553
 
+     out = CreateFile(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1554
 
+ #else
1555
 
      out = fopen(outfile, "wb");
1556
 
! #endif
1557
 
!     if (out == F_NULL) {
1558
 
          perror(file);
1559
 
          exit(1);
1560
 
      }
1561
 
***************
1562
 
*** 272,278 ****
1563
 
--- 363,371 ----
1564
 
      char *argv[];
1565
 
  {
1566
 
      int uncompr = 0;
1567
 
+ #if !defined(_WIN32_WCE)
1568
 
      gzFile file;
1569
 
+ #endif
1570
 
      char outmode[20];
1571
 
  
1572
 
      strcpy(outmode, "wb6 ");
1573
 
***************
1574
 
*** 282,300 ****
1575
 
  
1576
 
      while (argc > 0) {
1577
 
        if (strcmp(*argv, "-d") == 0)
1578
 
!       uncompr = 1;
1579
 
        else if (strcmp(*argv, "-f") == 0)
1580
 
!       outmode[3] = 'f';
1581
 
        else if (strcmp(*argv, "-h") == 0)
1582
 
!       outmode[3] = 'h';
1583
 
        else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
1584
 
!              (*argv)[2] == 0)
1585
 
!       outmode[2] = (*argv)[1];
1586
 
        else
1587
 
!       break;
1588
 
        argc--, argv++;
1589
 
      }
1590
 
      if (argc == 0) {
1591
 
          SET_BINARY_MODE(stdin);
1592
 
          SET_BINARY_MODE(stdout);
1593
 
          if (uncompr) {
1594
 
--- 375,400 ----
1595
 
  
1596
 
      while (argc > 0) {
1597
 
        if (strcmp(*argv, "-d") == 0)
1598
 
!         uncompr = 1;
1599
 
        else if (strcmp(*argv, "-f") == 0)
1600
 
!         outmode[3] = 'f';
1601
 
        else if (strcmp(*argv, "-h") == 0)
1602
 
!         outmode[3] = 'h';
1603
 
        else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
1604
 
!                (*argv)[2] == 0)
1605
 
!         outmode[2] = (*argv)[1];
1606
 
        else
1607
 
!         break;
1608
 
        argc--, argv++;
1609
 
      }
1610
 
      if (argc == 0) {
1611
 
+ #if defined(_WIN32_WCE)
1612
 
+         wprintf(TEXT("Usage:  minigzip [-d] [-f] [-h] [-1 to -9] [files...]\n"));
1613
 
+         wprintf(TEXT("  -d : decompress\n"));
1614
 
+         wprintf(TEXT("  -f : compress with Z_FILTERED\n"));
1615
 
+         wprintf(TEXT("  -h : compress with Z_HUFFMAN_ONLY\n"));
1616
 
+         wprintf(TEXT("  -1 to -9 : compression level\n"));
1617
 
+ #else
1618
 
          SET_BINARY_MODE(stdin);
1619
 
          SET_BINARY_MODE(stdout);
1620
 
          if (uncompr) {
1621
 
***************
1622
 
*** 306,311 ****
1623
 
--- 406,412 ----
1624
 
              if (file == NULL) error("can't gzdopen stdout");
1625
 
              gz_compress(stdin, file);
1626
 
          }
1627
 
+ #endif
1628
 
      } else {
1629
 
          do {
1630
 
              if (uncompr) {
1631
 
***************
1632
 
*** 318,320 ****
1633
 
--- 419,457 ----
1634
 
      exit(0);
1635
 
      return 0; /* to avoid warning */
1636
 
  }
1637
 
1638
 
+ #if defined(_WIN32_WCE)
1639
 
+ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpszCmdLine, int nCmdShow)
1640
 
+ {
1641
 
+     #define SIZE_ARGV   (32)
1642
 
+     int argc;
1643
 
+     char *argv[SIZE_ARGV];
1644
 
+     int size;
1645
 
+     char *buff;
1646
 
+     char *argp;
1647
 
1648
 
+     size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, NULL, 0, NULL, NULL);
1649
 
+     buff = (char *)malloc(size);
1650
 
+     size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, buff, size, NULL, NULL);
1651
 
+     argp = buff;
1652
 
+     argc = 0;
1653
 
+     argv[argc++] = "minigzip.exe";
1654
 
+     if (*argp) {
1655
 
+         argv[argc++] = argp;
1656
 
+         while (*argp) {
1657
 
+             if (*argp == ' ') {
1658
 
+                 *argp++ = '\0';
1659
 
+                 while (*argp && *argp == ' ') {
1660
 
+                     argp++;
1661
 
+                 }
1662
 
+                 if (*argp && argc < SIZE_ARGV) {
1663
 
+                     argv[argc++] = argp;
1664
 
+                 }
1665
 
+             } else {
1666
 
+                 argp++;
1667
 
+             }
1668
 
+         }
1669
 
+     }
1670
 
+     return main(argc, argv);
1671
 
+ }
1672
 
+ #endif
1673
 
*** zlib113/example.c   Sat Jul  8 13:59:49 2000
1674
 
--- zlibwce/example.c   Sat Jul  8 13:58:29 2000
1675
 
***************
1676
 
*** 1,11 ****
1677
 
--- 1,19 ----
1678
 
  /* example.c -- usage example of the zlib compression library
1679
 
   * Copyright (C) 1995-1998 Jean-loup Gailly.
1680
 
+  * Copyright (C) 2000      Tenik Co.,Ltd.
1681
 
   * For conditions of distribution and use, see copyright notice in zlib.h 
1682
 
   */
1683
 
  
1684
 
  /* @(#) $Id: zlib.diff,v 1.1.1.1 2000/11/17 14:22:46 rocco Exp $ */
1685
 
  
1686
 
+ #if defined(_WIN32_WCE)
1687
 
+ #if _WIN32_WCE < 211
1688
 
+ #error (f|w)printf functions is not support old WindowsCE.
1689
 
+ #endif
1690
 
+ #include <windows.h>
1691
 
+ #else
1692
 
  #include <stdio.h>
1693
 
+ #endif
1694
 
  #include "zlib.h"
1695
 
  
1696
 
  #ifdef STDC
1697
 
***************
1698
 
*** 21,26 ****
1699
 
--- 29,43 ----
1700
 
  #  define TESTFILE "foo.gz"
1701
 
  #endif
1702
 
  
1703
 
+ #if defined(_WIN32_WCE)
1704
 
+ #define calloc(x,y) malloc((x)*(y))
1705
 
+ #undef  stderr
1706
 
+ #define stderr  stdout
1707
 
+ #define F_NULL  INVALID_HANDLE_VALUE
1708
 
+ #else
1709
 
+ #define F_NULL  NULL
1710
 
+ #endif
1711
 
1712
 
  #define CHECK_ERR(err, msg) { \
1713
 
      if (err != Z_OK) { \
1714
 
          fprintf(stderr, "%s error: %d\n", msg, err); \
1715
 
***************
1716
 
*** 37,58 ****
1717
 
  uLong dictId; /* Adler32 value of the dictionary */
1718
 
  
1719
 
  void test_compress      OF((Byte *compr, uLong comprLen,
1720
 
!                           Byte *uncompr, uLong uncomprLen));
1721
 
  void test_gzio          OF((const char *out, const char *in, 
1722
 
!                           Byte *uncompr, int uncomprLen));
1723
 
  void test_deflate       OF((Byte *compr, uLong comprLen));
1724
 
  void test_inflate       OF((Byte *compr, uLong comprLen,
1725
 
!                           Byte *uncompr, uLong uncomprLen));
1726
 
  void test_large_deflate OF((Byte *compr, uLong comprLen,
1727
 
!                           Byte *uncompr, uLong uncomprLen));
1728
 
  void test_large_inflate OF((Byte *compr, uLong comprLen,
1729
 
!                           Byte *uncompr, uLong uncomprLen));
1730
 
  void test_flush         OF((Byte *compr, uLong *comprLen));
1731
 
  void test_sync          OF((Byte *compr, uLong comprLen,
1732
 
!                           Byte *uncompr, uLong uncomprLen));
1733
 
  void test_dict_deflate  OF((Byte *compr, uLong comprLen));
1734
 
  void test_dict_inflate  OF((Byte *compr, uLong comprLen,
1735
 
!                           Byte *uncompr, uLong uncomprLen));
1736
 
  int  main               OF((int argc, char *argv[]));
1737
 
  
1738
 
  /* ===========================================================================
1739
 
--- 54,75 ----
1740
 
  uLong dictId; /* Adler32 value of the dictionary */
1741
 
  
1742
 
  void test_compress      OF((Byte *compr, uLong comprLen,
1743
 
!                             Byte *uncompr, uLong uncomprLen));
1744
 
  void test_gzio          OF((const char *out, const char *in, 
1745
 
!                             Byte *uncompr, int uncomprLen));
1746
 
  void test_deflate       OF((Byte *compr, uLong comprLen));
1747
 
  void test_inflate       OF((Byte *compr, uLong comprLen,
1748
 
!                             Byte *uncompr, uLong uncomprLen));
1749
 
  void test_large_deflate OF((Byte *compr, uLong comprLen,
1750
 
!                             Byte *uncompr, uLong uncomprLen));
1751
 
  void test_large_inflate OF((Byte *compr, uLong comprLen,
1752
 
!                             Byte *uncompr, uLong uncomprLen));
1753
 
  void test_flush         OF((Byte *compr, uLong *comprLen));
1754
 
  void test_sync          OF((Byte *compr, uLong comprLen,
1755
 
!                             Byte *uncompr, uLong uncomprLen));
1756
 
  void test_dict_deflate  OF((Byte *compr, uLong comprLen));
1757
 
  void test_dict_inflate  OF((Byte *compr, uLong comprLen,
1758
 
!                             Byte *uncompr, uLong uncomprLen));
1759
 
  int  main               OF((int argc, char *argv[]));
1760
 
  
1761
 
  /* ===========================================================================
1762
 
***************
1763
 
*** 75,81 ****
1764
 
  
1765
 
      if (strcmp((char*)uncompr, hello)) {
1766
 
          fprintf(stderr, "bad uncompress\n");
1767
 
!       exit(1);
1768
 
      } else {
1769
 
          printf("uncompress(): %s\n", (char *)uncompr);
1770
 
      }
1771
 
--- 92,98 ----
1772
 
  
1773
 
      if (strcmp((char*)uncompr, hello)) {
1774
 
          fprintf(stderr, "bad uncompress\n");
1775
 
!         exit(1);
1776
 
      } else {
1777
 
          printf("uncompress(): %s\n", (char *)uncompr);
1778
 
      }
1779
 
***************
1780
 
*** 96,102 ****
1781
 
      z_off_t pos;
1782
 
  
1783
 
      file = gzopen(out, "wb");
1784
 
!     if (file == NULL) {
1785
 
          fprintf(stderr, "gzopen error\n");
1786
 
          exit(1);
1787
 
      }
1788
 
--- 113,119 ----
1789
 
      z_off_t pos;
1790
 
  
1791
 
      file = gzopen(out, "wb");
1792
 
!     if (file == F_NULL) {
1793
 
          fprintf(stderr, "gzopen error\n");
1794
 
          exit(1);
1795
 
      }
1796
 
***************
1797
 
*** 103,119 ****
1798
 
      gzputc(file, 'h');
1799
 
      if (gzputs(file, "ello") != 4) {
1800
 
          fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
1801
 
!       exit(1);
1802
 
      }
1803
 
      if (gzprintf(file, ", %s!", "hello") != 8) {
1804
 
          fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
1805
 
!       exit(1);
1806
 
      }
1807
 
      gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
1808
 
      gzclose(file);
1809
 
  
1810
 
      file = gzopen(in, "rb");
1811
 
!     if (file == NULL) {
1812
 
          fprintf(stderr, "gzopen error\n");
1813
 
      }
1814
 
      strcpy((char*)uncompr, "garbage");
1815
 
--- 120,136 ----
1816
 
      gzputc(file, 'h');
1817
 
      if (gzputs(file, "ello") != 4) {
1818
 
          fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
1819
 
!         exit(1);
1820
 
      }
1821
 
      if (gzprintf(file, ", %s!", "hello") != 8) {
1822
 
          fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
1823
 
!         exit(1);
1824
 
      }
1825
 
      gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
1826
 
      gzclose(file);
1827
 
  
1828
 
      file = gzopen(in, "rb");
1829
 
!     if (file == F_NULL) {
1830
 
          fprintf(stderr, "gzopen error\n");
1831
 
      }
1832
 
      strcpy((char*)uncompr, "garbage");
1833
 
***************
1834
 
*** 121,131 ****
1835
 
      uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen);
1836
 
      if (uncomprLen != len) {
1837
 
          fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
1838
 
!       exit(1);
1839
 
      }
1840
 
      if (strcmp((char*)uncompr, hello)) {
1841
 
          fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
1842
 
!       exit(1);
1843
 
      } else {
1844
 
          printf("gzread(): %s\n", (char *)uncompr);
1845
 
      }
1846
 
--- 138,148 ----
1847
 
      uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen);
1848
 
      if (uncomprLen != len) {
1849
 
          fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
1850
 
!         exit(1);
1851
 
      }
1852
 
      if (strcmp((char*)uncompr, hello)) {
1853
 
          fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
1854
 
!         exit(1);
1855
 
      } else {
1856
 
          printf("gzread(): %s\n", (char *)uncompr);
1857
 
      }
1858
 
***************
1859
 
*** 132,145 ****
1860
 
  
1861
 
      pos = gzseek(file, -8L, SEEK_CUR);
1862
 
      if (pos != 6 || gztell(file) != pos) {
1863
 
!       fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
1864
 
!               (long)pos, (long)gztell(file));
1865
 
!       exit(1);
1866
 
      }
1867
 
  
1868
 
      if (gzgetc(file) != ' ') {
1869
 
!       fprintf(stderr, "gzgetc error\n");
1870
 
!       exit(1);
1871
 
      }
1872
 
  
1873
 
      gzgets(file, (char*)uncompr, uncomprLen);
1874
 
--- 149,162 ----
1875
 
  
1876
 
      pos = gzseek(file, -8L, SEEK_CUR);
1877
 
      if (pos != 6 || gztell(file) != pos) {
1878
 
!         fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
1879
 
!                 (long)pos, (long)gztell(file));
1880
 
!         exit(1);
1881
 
      }
1882
 
  
1883
 
      if (gzgetc(file) != ' ') {
1884
 
!         fprintf(stderr, "gzgetc error\n");
1885
 
!         exit(1);
1886
 
      }
1887
 
  
1888
 
      gzgets(file, (char*)uncompr, uncomprLen);
1889
 
***************
1890
 
*** 146,156 ****
1891
 
      uncomprLen = strlen((char*)uncompr);
1892
 
      if (uncomprLen != 6) { /* "hello!" */
1893
 
          fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
1894
 
!       exit(1);
1895
 
      }
1896
 
      if (strcmp((char*)uncompr, hello+7)) {
1897
 
          fprintf(stderr, "bad gzgets after gzseek\n");
1898
 
!       exit(1);
1899
 
      } else {
1900
 
          printf("gzgets() after gzseek: %s\n", (char *)uncompr);
1901
 
      }
1902
 
--- 163,173 ----
1903
 
      uncomprLen = strlen((char*)uncompr);
1904
 
      if (uncomprLen != 6) { /* "hello!" */
1905
 
          fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
1906
 
!         exit(1);
1907
 
      }
1908
 
      if (strcmp((char*)uncompr, hello+7)) {
1909
 
          fprintf(stderr, "bad gzgets after gzseek\n");
1910
 
!         exit(1);
1911
 
      } else {
1912
 
          printf("gzgets() after gzseek: %s\n", (char *)uncompr);
1913
 
      }
1914
 
***************
1915
 
*** 231,237 ****
1916
 
  
1917
 
      if (strcmp((char*)uncompr, hello)) {
1918
 
          fprintf(stderr, "bad inflate\n");
1919
 
!       exit(1);
1920
 
      } else {
1921
 
          printf("inflate(): %s\n", (char *)uncompr);
1922
 
      }
1923
 
--- 248,254 ----
1924
 
  
1925
 
      if (strcmp((char*)uncompr, hello)) {
1926
 
          fprintf(stderr, "bad inflate\n");
1927
 
!         exit(1);
1928
 
      } else {
1929
 
          printf("inflate(): %s\n", (char *)uncompr);
1930
 
      }
1931
 
***************
1932
 
*** 266,272 ****
1933
 
      CHECK_ERR(err, "deflate");
1934
 
      if (c_stream.avail_in != 0) {
1935
 
          fprintf(stderr, "deflate not greedy\n");
1936
 
!       exit(1);
1937
 
      }
1938
 
  
1939
 
      /* Feed in already compressed data and switch to no compression: */
1940
 
--- 283,289 ----
1941
 
      CHECK_ERR(err, "deflate");
1942
 
      if (c_stream.avail_in != 0) {
1943
 
          fprintf(stderr, "deflate not greedy\n");
1944
 
!         exit(1);
1945
 
      }
1946
 
  
1947
 
      /* Feed in already compressed data and switch to no compression: */
1948
 
***************
1949
 
*** 286,292 ****
1950
 
      err = deflate(&c_stream, Z_FINISH);
1951
 
      if (err != Z_STREAM_END) {
1952
 
          fprintf(stderr, "deflate should report Z_STREAM_END\n");
1953
 
!       exit(1);
1954
 
      }
1955
 
      err = deflateEnd(&c_stream);
1956
 
      CHECK_ERR(err, "deflateEnd");
1957
 
--- 303,309 ----
1958
 
      err = deflate(&c_stream, Z_FINISH);
1959
 
      if (err != Z_STREAM_END) {
1960
 
          fprintf(stderr, "deflate should report Z_STREAM_END\n");
1961
 
!         exit(1);
1962
 
      }
1963
 
      err = deflateEnd(&c_stream);
1964
 
      CHECK_ERR(err, "deflateEnd");
1965
 
***************
1966
 
*** 316,322 ****
1967
 
  
1968
 
      for (;;) {
1969
 
          d_stream.next_out = uncompr;            /* discard the output */
1970
 
!       d_stream.avail_out = (uInt)uncomprLen;
1971
 
          err = inflate(&d_stream, Z_NO_FLUSH);
1972
 
          if (err == Z_STREAM_END) break;
1973
 
          CHECK_ERR(err, "large inflate");
1974
 
--- 333,339 ----
1975
 
  
1976
 
      for (;;) {
1977
 
          d_stream.next_out = uncompr;            /* discard the output */
1978
 
!         d_stream.avail_out = (uInt)uncomprLen;
1979
 
          err = inflate(&d_stream, Z_NO_FLUSH);
1980
 
          if (err == Z_STREAM_END) break;
1981
 
          CHECK_ERR(err, "large inflate");
1982
 
***************
1983
 
*** 327,333 ****
1984
 
  
1985
 
      if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
1986
 
          fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
1987
 
!       exit(1);
1988
 
      } else {
1989
 
          printf("large_inflate(): OK\n");
1990
 
      }
1991
 
--- 344,350 ----
1992
 
  
1993
 
      if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
1994
 
          fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
1995
 
!         exit(1);
1996
 
      } else {
1997
 
          printf("large_inflate(): OK\n");
1998
 
      }
1999
 
***************
2000
 
*** 407,413 ****
2001
 
      if (err != Z_DATA_ERROR) {
2002
 
          fprintf(stderr, "inflate should report DATA_ERROR\n");
2003
 
          /* Because of incorrect adler32 */
2004
 
!       exit(1);
2005
 
      }
2006
 
      err = inflateEnd(&d_stream);
2007
 
      CHECK_ERR(err, "inflateEnd");
2008
 
--- 424,430 ----
2009
 
      if (err != Z_DATA_ERROR) {
2010
 
          fprintf(stderr, "inflate should report DATA_ERROR\n");
2011
 
          /* Because of incorrect adler32 */
2012
 
!         exit(1);
2013
 
      }
2014
 
      err = inflateEnd(&d_stream);
2015
 
      CHECK_ERR(err, "inflateEnd");
2016
 
***************
2017
 
*** 433,439 ****
2018
 
      CHECK_ERR(err, "deflateInit");
2019
 
  
2020
 
      err = deflateSetDictionary(&c_stream,
2021
 
!                              (const Bytef*)dictionary, sizeof(dictionary));
2022
 
      CHECK_ERR(err, "deflateSetDictionary");
2023
 
  
2024
 
      dictId = c_stream.adler;
2025
 
--- 450,456 ----
2026
 
      CHECK_ERR(err, "deflateInit");
2027
 
  
2028
 
      err = deflateSetDictionary(&c_stream,
2029
 
!                                (const Bytef*)dictionary, sizeof(dictionary));
2030
 
      CHECK_ERR(err, "deflateSetDictionary");
2031
 
  
2032
 
      dictId = c_stream.adler;
2033
 
***************
2034
 
*** 446,452 ****
2035
 
      err = deflate(&c_stream, Z_FINISH);
2036
 
      if (err != Z_STREAM_END) {
2037
 
          fprintf(stderr, "deflate should report Z_STREAM_END\n");
2038
 
!       exit(1);
2039
 
      }
2040
 
      err = deflateEnd(&c_stream);
2041
 
      CHECK_ERR(err, "deflateEnd");
2042
 
--- 463,469 ----
2043
 
      err = deflate(&c_stream, Z_FINISH);
2044
 
      if (err != Z_STREAM_END) {
2045
 
          fprintf(stderr, "deflate should report Z_STREAM_END\n");
2046
 
!         exit(1);
2047
 
      }
2048
 
      err = deflateEnd(&c_stream);
2049
 
      CHECK_ERR(err, "deflateEnd");
2050
 
***************
2051
 
*** 480,493 ****
2052
 
      for (;;) {
2053
 
          err = inflate(&d_stream, Z_NO_FLUSH);
2054
 
          if (err == Z_STREAM_END) break;
2055
 
!       if (err == Z_NEED_DICT) {
2056
 
!           if (d_stream.adler != dictId) {
2057
 
!               fprintf(stderr, "unexpected dictionary");
2058
 
!               exit(1);
2059
 
!           }
2060
 
!           err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
2061
 
!                                      sizeof(dictionary));
2062
 
!       }
2063
 
          CHECK_ERR(err, "inflate with dict");
2064
 
      }
2065
 
  
2066
 
--- 497,510 ----
2067
 
      for (;;) {
2068
 
          err = inflate(&d_stream, Z_NO_FLUSH);
2069
 
          if (err == Z_STREAM_END) break;
2070
 
!         if (err == Z_NEED_DICT) {
2071
 
!             if (d_stream.adler != dictId) {
2072
 
!                 fprintf(stderr, "unexpected dictionary");
2073
 
!                 exit(1);
2074
 
!             }
2075
 
!             err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
2076
 
!                                        sizeof(dictionary));
2077
 
!         }
2078
 
          CHECK_ERR(err, "inflate with dict");
2079
 
      }
2080
 
  
2081
 
***************
2082
 
*** 496,502 ****
2083
 
  
2084
 
      if (strcmp((char*)uncompr, hello)) {
2085
 
          fprintf(stderr, "bad inflate with dict\n");
2086
 
!       exit(1);
2087
 
      } else {
2088
 
          printf("inflate with dictionary: %s\n", (char *)uncompr);
2089
 
      }
2090
 
--- 513,519 ----
2091
 
  
2092
 
      if (strcmp((char*)uncompr, hello)) {
2093
 
          fprintf(stderr, "bad inflate with dict\n");
2094
 
!         exit(1);
2095
 
      } else {
2096
 
          printf("inflate with dictionary: %s\n", (char *)uncompr);
2097
 
      }
2098
 
***************
2099
 
*** 530,542 ****
2100
 
       */
2101
 
      if (compr == Z_NULL || uncompr == Z_NULL) {
2102
 
          printf("out of memory\n");
2103
 
!       exit(1);
2104
 
      }
2105
 
      test_compress(compr, comprLen, uncompr, uncomprLen);
2106
 
  
2107
 
      test_gzio((argc > 1 ? argv[1] : TESTFILE),
2108
 
                (argc > 2 ? argv[2] : TESTFILE),
2109
 
!             uncompr, (int)uncomprLen);
2110
 
  
2111
 
      test_deflate(compr, comprLen);
2112
 
      test_inflate(compr, comprLen, uncompr, uncomprLen);
2113
 
--- 547,559 ----
2114
 
       */
2115
 
      if (compr == Z_NULL || uncompr == Z_NULL) {
2116
 
          printf("out of memory\n");
2117
 
!         exit(1);
2118
 
      }
2119
 
      test_compress(compr, comprLen, uncompr, uncomprLen);
2120
 
  
2121
 
      test_gzio((argc > 1 ? argv[1] : TESTFILE),
2122
 
                (argc > 2 ? argv[2] : TESTFILE),
2123
 
!               uncompr, (int)uncomprLen);
2124
 
  
2125
 
      test_deflate(compr, comprLen);
2126
 
      test_inflate(compr, comprLen, uncompr, uncomprLen);
2127
 
***************
2128
 
*** 554,556 ****
2129
 
--- 571,609 ----
2130
 
      exit(0);
2131
 
      return 0; /* to avoid warning */
2132
 
  }
2133
 
2134
 
+ #if defined(_WIN32_WCE)
2135
 
+ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPWSTR lpszCmdLine, int nCmdShow)
2136
 
+ {
2137
 
+     #define SIZE_ARGV   (32)
2138
 
+     int argc;
2139
 
+     char *argv[SIZE_ARGV];
2140
 
+     int size;
2141
 
+     char *buff;
2142
 
+     char *argp;
2143
 
2144
 
+     size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, NULL, 0, NULL, NULL);
2145
 
+     buff = (char *)malloc(size);
2146
 
+     size = WideCharToMultiByte(CP_ACP, 0, lpszCmdLine, -1, buff, size, NULL, NULL);
2147
 
+     argp = buff;
2148
 
+     argc = 0;
2149
 
+     argv[argc++] = "example.exe";
2150
 
+     if (*argp) {
2151
 
+         argv[argc++] = argp;
2152
 
+         while (*argp) {
2153
 
+             if (*argp == ' ') {
2154
 
+                 *argp++ = '\0';
2155
 
+                 while (*argp && *argp == ' ') {
2156
 
+                     argp++;
2157
 
+                 }
2158
 
+                 if (*argp && argc < SIZE_ARGV) {
2159
 
+                     argv[argc++] = argp;
2160
 
+                 }
2161
 
+             } else {
2162
 
+                 argp++;
2163
 
+             }
2164
 
+         }
2165
 
+     }
2166
 
+     return main(argc, argv);
2167
 
+ }
2168
 
+ #endif