1 --- misc/zlib-1.1.4/makefile.mk Fri Mar 14 10:17:06 2008
2 +++ misc/build/zlib-1.1.4/makefile.mk Fri Mar 14 10:16:56 2008
5 +#*************************************************************************
7 +# Copyright according the GNU Public License.
9 +#*************************************************************************
16 +EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
18 +# --- Settings -----------------------------------------------------
20 +.INCLUDE : settings.mk
22 +# --- Files --------------------------------------------------------
24 +INCEXT=contrib$/minizip
26 +SLOFILES= $(SLO)$/adler32.obj \
27 + $(SLO)$/compress.obj \
28 + $(SLO)$/deflate.obj \
30 + $(SLO)$/infblock.obj \
31 + $(SLO)$/infcodes.obj \
32 + $(SLO)$/inffast.obj \
33 + $(SLO)$/inflate.obj \
34 + $(SLO)$/inftrees.obj \
35 + $(SLO)$/infutil.obj \
42 +LIB1TARGET=$(SLB)$/$(TARGET).lib
43 +LIB1ARCHIV=$(LB)$/lib$(TARGET).a
44 +LIB1OBJFILES=$(SLOFILES)
46 +.IF "$(BUILD_X64)"!=""
47 +SLOFILES_X64= $(SLO_X64)$/adler32.obj \
48 + $(SLO_X64)$/compress.obj \
49 + $(SLO_X64)$/deflate.obj \
50 + $(SLO_X64)$/crc32.obj \
51 + $(SLO_X64)$/infblock.obj \
52 + $(SLO_X64)$/infcodes.obj \
53 + $(SLO_X64)$/inffast.obj \
54 + $(SLO_X64)$/inflate.obj \
55 + $(SLO_X64)$/inftrees.obj \
56 + $(SLO_X64)$/infutil.obj \
57 + $(SLO_X64)$/trees.obj \
58 + $(SLO_X64)$/zutil.obj \
59 + $(SLO_X64)$/unzip.obj \
60 + $(SLO_X64)$/ioapi.obj
62 +LIB1TARGET_X64=$(SLB_X64)$/$(TARGET).lib
63 +LIB1OBJFILES_X64=$(SLOFILES_X64)
64 +.ENDIF # "$(BUILD_X64)"!=""
67 +# --- Targets ------------------------------------------------------
69 +$(MISC)$/%.c : contrib$/minizip$/%.c
70 + @echo ------------------------------
74 +.INCLUDE : set_wntx64.mk
76 +.INCLUDE : tg_wntx64.mk
78 --- misc/zlib-1.1.4/zconf.h Mon Mar 11 14:16:01 2002
79 +++ misc/build/zlib-1.1.4/zconf.h Fri Mar 14 10:15:45 2008
81 * If you *really* need a unique prefix for all types and library functions,
82 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
85 + * we need the prefix to get the same names as in 1.1.3
91 # define deflateInit_ z_deflateInit_
92 # define deflate z_deflate
94 # define crc32 z_crc32
95 # define get_crc_table z_get_crc_table
97 +# define inflate_blocks z_inflate_blocks
98 +# define inflate_blocks_new z_inflate_blocks_new
99 +# define inflate_blocks_free z_inflate_blocks_free
100 +# define inflate_blocks_reset z_inflate_blocks_reset
101 +# define inflate_codes_free z_inflate_codes_free
102 +# define inflate_codes z_inflate_codes
103 +# define inflate_fast z_inflate_fast
104 +# define inflate_flush z_inflate_flush
105 +# define inflate_mask z_inflate_mask
106 +# define inflate_set_dictionary z_inflate_set_dictionary
107 +# define inflate_copyright z_inflate_copyright
108 +# define inflate_trees_bits z_inflate_trees_bits
109 +# define inflate_trees_dynamic z_inflate_trees_dynamic
110 +# define inflate_trees_fixed z_inflate_trees_fixed
111 +# define inflate_trees_free z_inflate_trees_free
115 # define uLong z_uLong
116 -# define Bytef z_Bytef
117 +# define Bytef z_Bytef
118 # define charf z_charf
120 # define uIntf z_uIntf
121 --- misc/zlib-1.1.4/zlib.h Mon Mar 11 14:56:38 2002
122 +++ misc/build/zlib-1.1.4/zlib.h Fri Mar 14 10:15:45 2008
124 Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
125 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
133 /* basic functions */
135 +#if !defined(ZUTIL_PROTOS_OFF)
136 ZEXTERN const char * ZEXPORT zlibVersion OF((void));
138 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
139 If the first character differs, the library code actually used is
140 not compatible with the zlib.h header file used by the application.
142 struct internal_state {int dummy;}; /* hack for buggy compilers */
145 +#if !defined(ZUTIL_PROTOS_OFF)
146 ZEXTERN const char * ZEXPORT zError OF((int err));
148 ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
149 ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
151 --- misc/zlib-1.1.4/zutil.c Mon Mar 11 14:16:01 2002
152 +++ misc/build/zlib-1.1.4/zutil.c Fri Mar 14 10:15:45 2008
158 +#define ZUTIL_PROTOS_OFF
162 struct internal_state {int dummy;}; /* for buggy compilers */
163 --- misc/zlib-1.1.4/contrib/minizip/unzip.c 1998-06-15 17:34:20.000000000 +0200
164 +++ misc/build/zlib-1.1.4/contrib/minizip/unzip.c 2009-07-17 10:15:05.156250000 +0200
166 -/* unzip.c -- IO on .zip files using zlib
167 - Version 0.15 beta, Mar 19th, 1998,
168 +/* unzip.c -- IO for uncompress .zip files using zlib
169 + Version 1.01e, February 12th, 2005
171 + Copyright (C) 1998-2005 Gilles Vollant
173 Read unzip.h for more info
176 +/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
177 +compatibility with older software. The following is from the original crypt.c. Code
178 +woven in by Terry Thorsen 1/2003.
181 + Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
183 + See the accompanying file LICENSE, version 2000-Apr-09 or later
184 + (the contents of which are also included in zip.h) for terms of use.
185 + If, for some reason, all these files are missing, the Info-ZIP license
186 + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
189 + crypt.c (full version) by Info-ZIP. Last revised: [see info_zip_crypt.h]
191 + The encryption/decryption parts of this source code (as opposed to the
192 + non-echoing password parts) were originally written in Europe. The
193 + whole source package can be freely distributed, including from the USA.
194 + (Prior to January 2000, re-export from the US was a violation of US law.)
198 + This encryption code is a direct transcription of the algorithm from
199 + Roger Schlafly, described by Phil Katz in the file appnote.txt. This
200 + file (appnote.txt) is distributed with the PKZIP program (even in the
201 + version without encryption capabilities).
208 /* compile with -Dlocal if your debugger can't find static symbols */
212 -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
213 - !defined(CASESENSITIVITYDEFAULT_NO)
214 -#define CASESENSITIVITYDEFAULT_NO
215 +#ifndef CASESENSITIVITYDEFAULT_NO
216 +# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
217 +# define CASESENSITIVITYDEFAULT_NO
223 #define SIZEZIPLOCALHEADER (0x1e)
226 -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
240 const char unz_copyright[] =
241 - " unzip 0.15 Copyright 1998 Gilles Vollant ";
242 + " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
244 /* unz_file_info_interntal contain internal info about a file in zipfile*/
245 typedef struct unz_file_info_internal_s
247 when reading and decompress it */
250 - char *read_buffer; /* internal buffer for compressed data */
251 - z_stream stream; /* zLib stream structure for inflate */
252 + char *read_buffer; /* internal buffer for compressed data */
253 + z_stream stream; /* zLib stream structure for inflate */
255 - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
256 - uLong stream_initialised; /* flag set if stream structure is initialised*/
257 + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
258 + uLong stream_initialised; /* flag set if stream structure is initialised*/
260 - uLong offset_local_extrafield;/* offset of the local extra field */
261 - uInt size_local_extrafield;/* size of the local extra field */
262 - uLong pos_local_extrafield; /* position in the local extra field in read*/
264 - uLong crc32; /* crc32 of all data uncompressed */
265 - uLong crc32_wait; /* crc32 we must obtain after decompress all */
266 - uLong rest_read_compressed; /* number of byte to be decompressed */
267 - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
268 - FILE* file; /* io structore of the zipfile */
269 - uLong compression_method; /* compression method (0==store) */
270 - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
271 + uLong offset_local_extrafield;/* offset of the local extra field */
272 + uInt size_local_extrafield;/* size of the local extra field */
273 + uLong pos_local_extrafield; /* position in the local extra field in read*/
275 + uLong crc32; /* crc32 of all data uncompressed */
276 + uLong crc32_wait; /* crc32 we must obtain after decompress all */
277 + uLong rest_read_compressed; /* number of byte to be decompressed */
278 + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
279 + zlib_filefunc_def z_filefunc;
280 + voidpf filestream; /* io structore of the zipfile */
281 + uLong compression_method; /* compression method (0==store) */
282 + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
284 } file_in_zip_read_info_s;
287 @@ -107,25 +127,35 @@
291 - FILE* file; /* io structore of the zipfile */
292 - unz_global_info gi; /* public global information */
293 - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
294 - uLong num_file; /* number of the current file in the zipfile*/
295 - uLong pos_in_central_dir; /* pos of the current file in the central dir*/
296 - uLong current_file_ok; /* flag about the usability of the current file*/
297 - uLong central_pos; /* position of the beginning of the central dir*/
299 - uLong size_central_dir; /* size of the central directory */
300 - uLong offset_central_dir; /* offset of start of central directory with
301 - respect to the starting disk number */
302 + zlib_filefunc_def z_filefunc;
303 + voidpf filestream; /* io structore of the zipfile */
304 + unz_global_info gi; /* public global information */
305 + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
306 + uLong num_file; /* number of the current file in the zipfile*/
307 + uLong pos_in_central_dir; /* pos of the current file in the central dir*/
308 + uLong current_file_ok; /* flag about the usability of the current file*/
309 + uLong central_pos; /* position of the beginning of the central dir*/
311 + uLong size_central_dir; /* size of the central directory */
312 + uLong offset_central_dir; /* offset of start of central directory with
313 + respect to the starting disk number */
315 - unz_file_info cur_file_info; /* public info about the current file in zip*/
316 - unz_file_info_internal cur_file_info_internal; /* private info about it*/
317 + unz_file_info cur_file_info; /* public info about the current file in zip*/
318 + unz_file_info_internal cur_file_info_internal; /* private info about it*/
319 file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
320 - file if we are decompressing it */
321 + file if we are decompressing it */
324 + unsigned long keys[3]; /* keys defining the pseudo-random sequence */
325 + const unsigned long* pcrc_32_tab;
331 +#include "info_zip_crypt.h"
334 /* ===========================================================================
335 Read a byte from a gz_stream; update next_in and avail_in. Return EOF
337 @@ -133,12 +163,18 @@
341 -local int unzlocal_getByte(fin,pi)
344 +local int unzlocal_getByte OF((
345 + const zlib_filefunc_def* pzlib_filefunc_def,
349 +local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
350 + const zlib_filefunc_def* pzlib_filefunc_def;
355 - int err = fread(&c, 1, 1, fin);
356 + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
365 + if (ZERROR(*pzlib_filefunc_def,filestream))
369 @@ -155,23 +191,29 @@
372 /* ===========================================================================
373 - Reads a long in LSB order from the given gz_stream. Sets
374 + Reads a long in LSB order from the given gz_stream. Sets
376 -local int unzlocal_getShort (fin,pX)
378 +local int unzlocal_getShort OF((
379 + const zlib_filefunc_def* pzlib_filefunc_def,
383 +local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
384 + const zlib_filefunc_def* pzlib_filefunc_def;
392 - err = unzlocal_getByte(fin,&i);
393 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
398 - err = unzlocal_getByte(fin,&i);
399 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
406 @@ -179,29 +221,35 @@
410 -local int unzlocal_getLong (fin,pX)
412 +local int unzlocal_getLong OF((
413 + const zlib_filefunc_def* pzlib_filefunc_def,
417 +local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
418 + const zlib_filefunc_def* pzlib_filefunc_def;
426 - err = unzlocal_getByte(fin,&i);
427 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
432 - err = unzlocal_getByte(fin,&i);
433 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
437 - err = unzlocal_getByte(fin,&i);
438 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
442 - err = unzlocal_getByte(fin,&i);
443 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
450 @@ -212,26 +260,26 @@
452 /* My own strcmpi / strcasecmp */
453 local int strcmpcasenosensitive_internal (fileName1,fileName2)
454 - const char* fileName1;
455 - const char* fileName2;
456 + const char* fileName1;
457 + const char* fileName2;
461 - char c1=*(fileName1++);
462 - char c2=*(fileName2++);
463 - if ((c1>='a') && (c1<='z'))
465 - if ((c2>='a') && (c2<='z'))
468 - return ((c2=='\0') ? 0 : -1);
478 + char c1=*(fileName1++);
479 + char c2=*(fileName2++);
480 + if ((c1>='a') && (c1<='z'))
482 + if ((c2>='a') && (c2<='z'))
485 + return ((c2=='\0') ? 0 : -1);
497 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
502 Compare two filename (fileName1,fileName2).
503 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
504 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
505 @@ -255,203 +303,225 @@
508 extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
509 - const char* fileName1;
510 - const char* fileName2;
511 - int iCaseSensitivity;
512 + const char* fileName1;
513 + const char* fileName2;
514 + int iCaseSensitivity;
516 - if (iCaseSensitivity==0)
517 - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
518 + if (iCaseSensitivity==0)
519 + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
521 - if (iCaseSensitivity==1)
522 - return strcmp(fileName1,fileName2);
523 + if (iCaseSensitivity==1)
524 + return strcmp(fileName1,fileName2);
526 - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
528 + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
531 +#ifndef BUFREADCOMMENT
532 #define BUFREADCOMMENT (0x400)
536 Locate the Central directory of a zipfile (at the end, just before
539 -local uLong unzlocal_SearchCentralDir(fin)
541 +local uLong unzlocal_SearchCentralDir OF((
542 + const zlib_filefunc_def* pzlib_filefunc_def,
543 + voidpf filestream));
545 +local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
546 + const zlib_filefunc_def* pzlib_filefunc_def;
549 - unsigned char* buf;
552 - uLong uMaxBack=0xffff; /* maximum size of global comment */
555 - if (fseek(fin,0,SEEK_END) != 0)
559 - uSizeFile = ftell( fin );
561 - if (uMaxBack>uSizeFile)
562 - uMaxBack = uSizeFile;
564 - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
569 - while (uBackRead<uMaxBack)
571 - uLong uReadSize,uReadPos ;
573 - if (uBackRead+BUFREADCOMMENT>uMaxBack)
574 - uBackRead = uMaxBack;
576 - uBackRead+=BUFREADCOMMENT;
577 - uReadPos = uSizeFile-uBackRead ;
579 - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
580 + unsigned char* buf;
583 + uLong uMaxBack=0xffff; /* maximum size of global comment */
586 + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
590 + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
592 + if (uMaxBack>uSizeFile)
593 + uMaxBack = uSizeFile;
595 + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
600 + while (uBackRead<uMaxBack)
602 + uLong uReadSize,uReadPos ;
604 + if (uBackRead+BUFREADCOMMENT>uMaxBack)
605 + uBackRead = uMaxBack;
607 + uBackRead+=BUFREADCOMMENT;
608 + uReadPos = uSizeFile-uBackRead ;
610 + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
611 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
612 - if (fseek(fin,uReadPos,SEEK_SET)!=0)
614 + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
617 - if (fread(buf,(uInt)uReadSize,1,fin)!=1)
619 + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
622 - for (i=(int)uReadSize-3; (i--)>0;)
623 - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
624 - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
626 - uPosFound = uReadPos+i;
635 + for (i=(int)uReadSize-3; (i--)>0;)
636 + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
637 + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
639 + uPosFound = uReadPos+i;
651 Open a Zip file. path contain the full pathname (by example,
652 - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
653 - "zlib/zlib109.zip".
654 - If the zipfile cannot be opened (file don't exist or in not valid), the
655 - return value is NULL.
656 + on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
657 + "zlib/zlib114.zip".
658 + If the zipfile cannot be opened (file doesn't exist or in not valid), the
659 + return value is NULL.
660 Else, the return value is a unzFile Handle, usable with other function
661 - of this unzip package.
662 + of this unzip package.
664 -extern unzFile ZEXPORT unzOpen (path)
669 - uLong central_pos,uL;
672 - uLong number_disk; /* number of the current dist, used for
673 - spaning ZIP, unsupported, always 0*/
674 - uLong number_disk_with_CD; /* number the the disk with central dir, used
675 - for spaning ZIP, unsupported, always 0*/
676 - uLong number_entry_CD; /* total number of entries in
678 - (same than number_entry on nospan) */
679 +extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
681 + zlib_filefunc_def* pzlib_filefunc_def;
685 + uLong central_pos,uL;
687 + uLong number_disk; /* number of the current dist, used for
688 + spaning ZIP, unsupported, always 0*/
689 + uLong number_disk_with_CD; /* number the the disk with central dir, used
690 + for spaning ZIP, unsupported, always 0*/
691 + uLong number_entry_CD; /* total number of entries in
693 + (same than number_entry on nospan) */
698 if (unz_copyright[0]!=' ')
701 - fin=fopen(path,"rb");
705 - central_pos = unzlocal_SearchCentralDir(fin);
706 - if (central_pos==0)
709 - if (fseek(fin,central_pos,SEEK_SET)!=0)
712 - /* the signature, already checked */
713 - if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
716 - /* number of this disk */
717 - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
720 - /* number of the disk with the start of the central directory */
721 - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
724 - /* total number of entries in the central dir on this disk */
725 - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
728 - /* total number of entries in the central dir */
729 - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
732 - if ((number_entry_CD!=us.gi.number_entry) ||
733 - (number_disk_with_CD!=0) ||
735 - err=UNZ_BADZIPFILE;
737 - /* size of the central directory */
738 - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
741 - /* offset of start of central directory with respect to the
742 - starting disk number */
743 - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
746 - /* zipfile comment length */
747 - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
750 - if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
752 - err=UNZ_BADZIPFILE;
761 - us.byte_before_the_zipfile = central_pos -
762 - (us.offset_central_dir+us.size_central_dir);
763 - us.central_pos = central_pos;
764 + if (pzlib_filefunc_def==NULL)
765 + fill_fopen_filefunc(&us.z_filefunc);
767 + us.z_filefunc = *pzlib_filefunc_def;
769 + us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
771 + ZLIB_FILEFUNC_MODE_READ |
772 + ZLIB_FILEFUNC_MODE_EXISTING);
773 + if (us.filestream==NULL)
776 + central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
777 + if (central_pos==0)
780 + if (ZSEEK(us.z_filefunc, us.filestream,
781 + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
784 + /* the signature, already checked */
785 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
788 + /* number of this disk */
789 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
792 + /* number of the disk with the start of the central directory */
793 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
796 + /* total number of entries in the central dir on this disk */
797 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
800 + /* total number of entries in the central dir */
801 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
804 + if ((number_entry_CD!=us.gi.number_entry) ||
805 + (number_disk_with_CD!=0) ||
807 + err=UNZ_BADZIPFILE;
809 + /* size of the central directory */
810 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
813 + /* offset of start of central directory with respect to the
814 + starting disk number */
815 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
818 + /* zipfile comment length */
819 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
822 + if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
824 + err=UNZ_BADZIPFILE;
828 + ZCLOSE(us.z_filefunc, us.filestream);
832 + us.byte_before_the_zipfile = central_pos -
833 + (us.offset_central_dir+us.size_central_dir);
834 + us.central_pos = central_pos;
835 us.pfile_in_zip_read = NULL;
839 - s=(unz_s*)ALLOC(sizeof(unz_s));
841 - unzGoToFirstFile((unzFile)s);
844 + s=(unz_s*)ALLOC(sizeof(unz_s));
846 + unzGoToFirstFile((unzFile)s);
851 +extern unzFile ZEXPORT unzOpen (path)
854 + return unzOpen2(path, NULL);
858 Close a ZipFile opened with unzipOpen.
859 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
860 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
861 return UNZ_OK if there is no problem. */
862 extern int ZEXPORT unzClose (file)
868 - return UNZ_PARAMERROR;
872 + return UNZ_PARAMERROR;
875 if (s->pfile_in_zip_read!=NULL)
876 unzCloseCurrentFile(file);
881 + ZCLOSE(s->z_filefunc, s->filestream);
887 @@ -460,15 +530,15 @@
888 No preparation of the structure is needed
889 return UNZ_OK if there is no problem. */
890 extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
892 - unz_global_info *pglobal_info;
894 + unz_global_info *pglobal_info;
898 - return UNZ_PARAMERROR;
900 - *pglobal_info=s->gi;
904 + return UNZ_PARAMERROR;
906 + *pglobal_info=s->gi;
911 @@ -495,14 +565,14 @@
913 local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
914 unz_file_info *pfile_info,
915 - unz_file_info_internal
916 + unz_file_info_internal
917 *pfile_info_internal,
919 - uLong fileNameBufferSize,
920 + uLong fileNameBufferSize,
922 - uLong extraFieldBufferSize,
923 + uLong extraFieldBufferSize,
925 - uLong commentBufferSize));
926 + uLong commentBufferSize));
928 local int unzlocal_GetCurrentFileInfoInternal (file,
930 @@ -510,156 +580,158 @@
931 szFileName, fileNameBufferSize,
932 extraField, extraFieldBufferSize,
933 szComment, commentBufferSize)
935 - unz_file_info *pfile_info;
936 - unz_file_info_internal *pfile_info_internal;
938 - uLong fileNameBufferSize;
940 - uLong extraFieldBufferSize;
942 - uLong commentBufferSize;
945 - unz_file_info file_info;
946 - unz_file_info_internal file_info_internal;
952 - return UNZ_PARAMERROR;
954 - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
958 - /* we check the magic */
960 - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
962 - else if (uMagic!=0x02014b50)
963 - err=UNZ_BADZIPFILE;
965 - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
968 - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
971 + unz_file_info *pfile_info;
972 + unz_file_info_internal *pfile_info_internal;
974 + uLong fileNameBufferSize;
976 + uLong extraFieldBufferSize;
978 + uLong commentBufferSize;
981 + unz_file_info file_info;
982 + unz_file_info_internal file_info_internal;
988 + return UNZ_PARAMERROR;
990 + if (ZSEEK(s->z_filefunc, s->filestream,
991 + s->pos_in_central_dir+s->byte_before_the_zipfile,
992 + ZLIB_FILEFUNC_SEEK_SET)!=0)
996 + /* we check the magic */
998 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1000 + else if (uMagic!=0x02014b50)
1001 + err=UNZ_BADZIPFILE;
1003 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
1006 - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
1008 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
1011 - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
1013 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
1016 - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
1018 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
1021 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
1024 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
1026 - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
1028 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
1031 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
1034 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
1037 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
1040 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
1043 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
1046 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
1049 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
1052 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
1055 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1058 + lSeek+=file_info.size_filename;
1059 + if ((err==UNZ_OK) && (szFileName!=NULL))
1062 + if (file_info.size_filename<fileNameBufferSize)
1064 + *(szFileName+file_info.size_filename)='\0';
1065 + uSizeRead = file_info.size_filename;
1068 + uSizeRead = fileNameBufferSize;
1070 + if ((file_info.size_filename>0) && (fileNameBufferSize>0))
1071 + if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
1073 + lSeek -= uSizeRead;
1077 + if ((err==UNZ_OK) && (extraField!=NULL))
1080 + if (file_info.size_file_extra<extraFieldBufferSize)
1081 + uSizeRead = file_info.size_file_extra;
1083 + uSizeRead = extraFieldBufferSize;
1086 + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1090 + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1091 + if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
1093 + lSeek += file_info.size_file_extra - uSizeRead;
1096 + lSeek+=file_info.size_file_extra;
1098 - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
1101 - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
1103 + if ((err==UNZ_OK) && (szComment!=NULL))
1106 + if (file_info.size_file_comment<commentBufferSize)
1108 + *(szComment+file_info.size_file_comment)='\0';
1109 + uSizeRead = file_info.size_file_comment;
1112 + uSizeRead = commentBufferSize;
1114 - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
1117 - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
1120 - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
1123 - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
1126 - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
1129 - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
1132 - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
1135 - lSeek+=file_info.size_filename;
1136 - if ((err==UNZ_OK) && (szFileName!=NULL))
1139 - if (file_info.size_filename<fileNameBufferSize)
1141 - *(szFileName+file_info.size_filename)='\0';
1142 - uSizeRead = file_info.size_filename;
1145 - uSizeRead = fileNameBufferSize;
1147 - if ((file_info.size_filename>0) && (fileNameBufferSize>0))
1148 - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
1150 - lSeek -= uSizeRead;
1154 - if ((err==UNZ_OK) && (extraField!=NULL))
1157 - if (file_info.size_file_extra<extraFieldBufferSize)
1158 - uSizeRead = file_info.size_file_extra;
1160 - uSizeRead = extraFieldBufferSize;
1163 - if (fseek(s->file,lSeek,SEEK_CUR)==0)
1167 - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1168 - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
1170 - lSeek += file_info.size_file_extra - uSizeRead;
1173 - lSeek+=file_info.size_file_extra;
1176 - if ((err==UNZ_OK) && (szComment!=NULL))
1179 - if (file_info.size_file_comment<commentBufferSize)
1181 - *(szComment+file_info.size_file_comment)='\0';
1182 - uSizeRead = file_info.size_file_comment;
1185 - uSizeRead = commentBufferSize;
1188 - if (fseek(s->file,lSeek,SEEK_CUR)==0)
1192 - if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1193 - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
1195 - lSeek+=file_info.size_file_comment - uSizeRead;
1198 - lSeek+=file_info.size_file_comment;
1200 + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1204 + if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1205 + if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
1207 + lSeek+=file_info.size_file_comment - uSizeRead;
1210 + lSeek+=file_info.size_file_comment;
1212 - if ((err==UNZ_OK) && (pfile_info!=NULL))
1213 - *pfile_info=file_info;
1214 + if ((err==UNZ_OK) && (pfile_info!=NULL))
1215 + *pfile_info=file_info;
1217 - if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1218 - *pfile_info_internal=file_info_internal;
1219 + if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1220 + *pfile_info_internal=file_info_internal;
1227 @@ -670,23 +742,23 @@
1228 return UNZ_OK if there is no problem.
1230 extern int ZEXPORT unzGetCurrentFileInfo (file,
1232 - szFileName, fileNameBufferSize,
1233 - extraField, extraFieldBufferSize,
1234 - szComment, commentBufferSize)
1236 - unz_file_info *pfile_info;
1238 - uLong fileNameBufferSize;
1240 - uLong extraFieldBufferSize;
1242 - uLong commentBufferSize;
1244 - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1245 - szFileName,fileNameBufferSize,
1246 - extraField,extraFieldBufferSize,
1247 - szComment,commentBufferSize);
1249 + szFileName, fileNameBufferSize,
1250 + extraField, extraFieldBufferSize,
1251 + szComment, commentBufferSize)
1253 + unz_file_info *pfile_info;
1255 + uLong fileNameBufferSize;
1257 + uLong extraFieldBufferSize;
1259 + uLong commentBufferSize;
1261 + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1262 + szFileName,fileNameBufferSize,
1263 + extraField,extraFieldBufferSize,
1264 + szComment,commentBufferSize);
1268 @@ -694,50 +766,50 @@
1269 return UNZ_OK if there is no problem
1271 extern int ZEXPORT unzGoToFirstFile (file)
1278 - return UNZ_PARAMERROR;
1280 - s->pos_in_central_dir=s->offset_central_dir;
1282 - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1283 - &s->cur_file_info_internal,
1284 - NULL,0,NULL,0,NULL,0);
1285 - s->current_file_ok = (err == UNZ_OK);
1290 + return UNZ_PARAMERROR;
1292 + s->pos_in_central_dir=s->offset_central_dir;
1294 + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1295 + &s->cur_file_info_internal,
1296 + NULL,0,NULL,0,NULL,0);
1297 + s->current_file_ok = (err == UNZ_OK);
1303 Set the current file of the zipfile to the next file.
1304 return UNZ_OK if there is no problem
1305 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
1307 extern int ZEXPORT unzGoToNextFile (file)
1317 - return UNZ_PARAMERROR;
1319 - if (!s->current_file_ok)
1320 - return UNZ_END_OF_LIST_OF_FILE;
1321 - if (s->num_file+1==s->gi.number_entry)
1322 - return UNZ_END_OF_LIST_OF_FILE;
1324 - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1325 - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
1327 - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1328 - &s->cur_file_info_internal,
1329 - NULL,0,NULL,0,NULL,0);
1330 - s->current_file_ok = (err == UNZ_OK);
1333 + return UNZ_PARAMERROR;
1335 + if (!s->current_file_ok)
1336 + return UNZ_END_OF_LIST_OF_FILE;
1337 + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
1338 + if (s->num_file+1==s->gi.number_entry)
1339 + return UNZ_END_OF_LIST_OF_FILE;
1341 + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1342 + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
1344 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1345 + &s->cur_file_info_internal,
1346 + NULL,0,NULL,0,NULL,0);
1347 + s->current_file_ok = (err == UNZ_OK);
1352 @@ -750,50 +822,130 @@
1353 UNZ_END_OF_LIST_OF_FILE if the file is not found
1355 extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
1357 - const char *szFileName;
1358 - int iCaseSensitivity;
1360 + const char *szFileName;
1361 + int iCaseSensitivity;
1369 - uLong num_fileSaved;
1370 - uLong pos_in_central_dirSaved;
1371 + /* We remember the 'current' position in the file so that we can jump
1372 + * back there if we fail.
1374 + unz_file_info cur_file_infoSaved;
1375 + unz_file_info_internal cur_file_info_internalSaved;
1376 + uLong num_fileSaved;
1377 + uLong pos_in_central_dirSaved;
1381 - return UNZ_PARAMERROR;
1383 + return UNZ_PARAMERROR;
1385 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
1386 return UNZ_PARAMERROR;
1389 - if (!s->current_file_ok)
1390 - return UNZ_END_OF_LIST_OF_FILE;
1392 - num_fileSaved = s->num_file;
1393 - pos_in_central_dirSaved = s->pos_in_central_dir;
1395 - err = unzGoToFirstFile(file);
1397 - while (err == UNZ_OK)
1399 - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1400 - unzGetCurrentFileInfo(file,NULL,
1401 - szCurrentFileName,sizeof(szCurrentFileName)-1,
1403 - if (unzStringFileNameCompare(szCurrentFileName,
1404 - szFileName,iCaseSensitivity)==0)
1406 - err = unzGoToNextFile(file);
1409 - s->num_file = num_fileSaved ;
1410 - s->pos_in_central_dir = pos_in_central_dirSaved ;
1413 + if (!s->current_file_ok)
1414 + return UNZ_END_OF_LIST_OF_FILE;
1416 + /* Save the current state */
1417 + num_fileSaved = s->num_file;
1418 + pos_in_central_dirSaved = s->pos_in_central_dir;
1419 + cur_file_infoSaved = s->cur_file_info;
1420 + cur_file_info_internalSaved = s->cur_file_info_internal;
1422 + err = unzGoToFirstFile(file);
1424 + while (err == UNZ_OK)
1426 + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1427 + err = unzGetCurrentFileInfo(file,NULL,
1428 + szCurrentFileName,sizeof(szCurrentFileName)-1,
1430 + if (err == UNZ_OK)
1432 + if (unzStringFileNameCompare(szCurrentFileName,
1433 + szFileName,iCaseSensitivity)==0)
1435 + err = unzGoToNextFile(file);
1439 + /* We failed, so restore the state of the 'current file' to where we
1442 + s->num_file = num_fileSaved ;
1443 + s->pos_in_central_dir = pos_in_central_dirSaved ;
1444 + s->cur_file_info = cur_file_infoSaved;
1445 + s->cur_file_info_internal = cur_file_info_internalSaved;
1451 +///////////////////////////////////////////
1452 +// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
1453 +// I need random access
1455 +// Further optimization could be realized by adding an ability
1456 +// to cache the directory in memory. The goal being a single
1457 +// comprehensive file read to put the file I need in a memory.
1461 +typedef struct unz_file_pos_s
1463 + uLong pos_in_zip_directory; // offset in file
1464 + uLong num_of_file; // # of file
1468 +extern int ZEXPORT unzGetFilePos(file, file_pos)
1470 + unz_file_pos* file_pos;
1474 + if (file==NULL || file_pos==NULL)
1475 + return UNZ_PARAMERROR;
1477 + if (!s->current_file_ok)
1478 + return UNZ_END_OF_LIST_OF_FILE;
1480 + file_pos->pos_in_zip_directory = s->pos_in_central_dir;
1481 + file_pos->num_of_file = s->num_file;
1486 +extern int ZEXPORT unzGoToFilePos(file, file_pos)
1488 + unz_file_pos* file_pos;
1493 + if (file==NULL || file_pos==NULL)
1494 + return UNZ_PARAMERROR;
1497 + /* jump to the right spot */
1498 + s->pos_in_central_dir = file_pos->pos_in_zip_directory;
1499 + s->num_file = file_pos->num_of_file;
1501 + /* set the current file */
1502 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1503 + &s->cur_file_info_internal,
1504 + NULL,0,NULL,0,NULL,0);
1505 + /* return results */
1506 + s->current_file_ok = (err == UNZ_OK);
1511 +// Unzip Helper Functions - should be here?
1512 +///////////////////////////////////////////
1516 Read the local header of the current zipfile
1517 @@ -803,185 +955,261 @@
1518 (filename and size of extra field data)
1520 local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
1521 - poffset_local_extrafield,
1522 - psize_local_extrafield)
1525 - uLong *poffset_local_extrafield;
1526 - uInt *psize_local_extrafield;
1528 - uLong uMagic,uData,uFlags;
1529 - uLong size_filename;
1530 - uLong size_extra_field;
1534 - *poffset_local_extrafield = 0;
1535 - *psize_local_extrafield = 0;
1537 - if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
1538 - s->byte_before_the_zipfile,SEEK_SET)!=0)
1543 - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
1545 - else if (uMagic!=0x04034b50)
1546 - err=UNZ_BADZIPFILE;
1548 - if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
1551 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1552 - err=UNZ_BADZIPFILE;
1554 - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
1557 - if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
1559 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1560 - err=UNZ_BADZIPFILE;
1561 + poffset_local_extrafield,
1562 + psize_local_extrafield)
1565 + uLong *poffset_local_extrafield;
1566 + uInt *psize_local_extrafield;
1568 + uLong uMagic,uData,uFlags;
1569 + uLong size_filename;
1570 + uLong size_extra_field;
1574 + *poffset_local_extrafield = 0;
1575 + *psize_local_extrafield = 0;
1577 + if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
1578 + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
1583 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1585 + else if (uMagic!=0x04034b50)
1586 + err=UNZ_BADZIPFILE;
1588 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1591 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1592 + err=UNZ_BADZIPFILE;
1594 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
1597 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1599 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1600 + err=UNZ_BADZIPFILE;
1602 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
1603 (s->cur_file_info.compression_method!=Z_DEFLATED))
1606 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
1608 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
1611 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
1613 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
1614 - ((uFlags & 8)==0))
1615 - err=UNZ_BADZIPFILE;
1617 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
1619 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
1620 - ((uFlags & 8)==0))
1621 - err=UNZ_BADZIPFILE;
1623 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
1625 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
1626 - ((uFlags & 8)==0))
1627 - err=UNZ_BADZIPFILE;
1630 - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
1632 - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1633 - err=UNZ_BADZIPFILE;
1635 - *piSizeVar += (uInt)size_filename;
1637 - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
1639 - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1640 - SIZEZIPLOCALHEADER + size_filename;
1641 - *psize_local_extrafield = (uInt)size_extra_field;
1642 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
1644 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
1645 + ((uFlags & 8)==0))
1646 + err=UNZ_BADZIPFILE;
1648 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
1650 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
1651 + ((uFlags & 8)==0))
1652 + err=UNZ_BADZIPFILE;
1654 - *piSizeVar += (uInt)size_extra_field;
1655 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
1657 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
1658 + ((uFlags & 8)==0))
1659 + err=UNZ_BADZIPFILE;
1662 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
1664 + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1665 + err=UNZ_BADZIPFILE;
1668 + *piSizeVar += (uInt)size_filename;
1670 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
1672 + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1673 + SIZEZIPLOCALHEADER + size_filename;
1674 + *psize_local_extrafield = (uInt)size_extra_field;
1676 + *piSizeVar += (uInt)size_extra_field;
1683 Open for reading data the current file in the zipfile.
1684 If there is no error and the file is opened, the return value is UNZ_OK.
1686 -extern int ZEXPORT unzOpenCurrentFile (file)
1693 - file_in_zip_read_info_s* pfile_in_zip_read_info;
1694 - uLong offset_local_extrafield; /* offset of the local extra field */
1695 - uInt size_local_extrafield; /* size of the local extra field */
1698 - return UNZ_PARAMERROR;
1700 - if (!s->current_file_ok)
1701 - return UNZ_PARAMERROR;
1702 +extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
1707 + const char* password;
1712 + file_in_zip_read_info_s* pfile_in_zip_read_info;
1713 + uLong offset_local_extrafield; /* offset of the local extra field */
1714 + uInt size_local_extrafield; /* size of the local extra field */
1718 + if (password != NULL)
1719 + return UNZ_PARAMERROR;
1723 + return UNZ_PARAMERROR;
1725 + if (!s->current_file_ok)
1726 + return UNZ_PARAMERROR;
1728 if (s->pfile_in_zip_read != NULL)
1729 unzCloseCurrentFile(file);
1731 - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
1732 - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1733 - return UNZ_BADZIPFILE;
1735 - pfile_in_zip_read_info = (file_in_zip_read_info_s*)
1736 - ALLOC(sizeof(file_in_zip_read_info_s));
1737 - if (pfile_in_zip_read_info==NULL)
1738 - return UNZ_INTERNALERROR;
1740 - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
1741 - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1742 - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1743 - pfile_in_zip_read_info->pos_local_extrafield=0;
1745 - if (pfile_in_zip_read_info->read_buffer==NULL)
1747 - TRYFREE(pfile_in_zip_read_info);
1748 - return UNZ_INTERNALERROR;
1751 - pfile_in_zip_read_info->stream_initialised=0;
1753 - if ((s->cur_file_info.compression_method!=0) &&
1754 + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
1755 + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1756 + return UNZ_BADZIPFILE;
1758 + pfile_in_zip_read_info = (file_in_zip_read_info_s*)
1759 + ALLOC(sizeof(file_in_zip_read_info_s));
1760 + if (pfile_in_zip_read_info==NULL)
1761 + return UNZ_INTERNALERROR;
1763 + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
1764 + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1765 + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1766 + pfile_in_zip_read_info->pos_local_extrafield=0;
1767 + pfile_in_zip_read_info->raw=raw;
1769 + if (pfile_in_zip_read_info->read_buffer==NULL)
1771 + TRYFREE(pfile_in_zip_read_info);
1772 + return UNZ_INTERNALERROR;
1775 + pfile_in_zip_read_info->stream_initialised=0;
1778 + *method = (int)s->cur_file_info.compression_method;
1783 + switch (s->cur_file_info.flag & 0x06)
1785 + case 6 : *level = 1; break;
1786 + case 4 : *level = 2; break;
1787 + case 2 : *level = 9; break;
1791 + if ((s->cur_file_info.compression_method!=0) &&
1792 (s->cur_file_info.compression_method!=Z_DEFLATED))
1793 - err=UNZ_BADZIPFILE;
1794 - Store = s->cur_file_info.compression_method==0;
1795 + err=UNZ_BADZIPFILE;
1797 - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1798 - pfile_in_zip_read_info->crc32=0;
1799 - pfile_in_zip_read_info->compression_method =
1800 + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1801 + pfile_in_zip_read_info->crc32=0;
1802 + pfile_in_zip_read_info->compression_method =
1803 s->cur_file_info.compression_method;
1804 - pfile_in_zip_read_info->file=s->file;
1805 - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1806 + pfile_in_zip_read_info->filestream=s->filestream;
1807 + pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
1808 + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1810 pfile_in_zip_read_info->stream.total_out = 0;
1814 - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1815 - pfile_in_zip_read_info->stream.zfree = (free_func)0;
1816 - pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1818 - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1820 - pfile_in_zip_read_info->stream_initialised=1;
1821 + if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
1824 + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1825 + pfile_in_zip_read_info->stream.zfree = (free_func)0;
1826 + pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1827 + pfile_in_zip_read_info->stream.next_in = (voidpf)0;
1828 + pfile_in_zip_read_info->stream.avail_in = 0;
1830 + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1832 + pfile_in_zip_read_info->stream_initialised=1;
1835 + TRYFREE(pfile_in_zip_read_info);
1838 /* windowBits is passed < 0 to tell that there is no zlib header.
1839 * Note that in this case inflate *requires* an extra "dummy" byte
1840 * after the compressed stream in order to complete decompression and
1841 - * return Z_STREAM_END.
1842 - * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1843 + * return Z_STREAM_END.
1844 + * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1845 * size of both compressed and uncompressed data
1848 - pfile_in_zip_read_info->rest_read_compressed =
1850 + pfile_in_zip_read_info->rest_read_compressed =
1851 s->cur_file_info.compressed_size ;
1852 - pfile_in_zip_read_info->rest_read_uncompressed =
1853 + pfile_in_zip_read_info->rest_read_uncompressed =
1854 s->cur_file_info.uncompressed_size ;
1857 - pfile_in_zip_read_info->pos_in_zipfile =
1858 - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
1861 - pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1863 + pfile_in_zip_read_info->pos_in_zipfile =
1864 + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
1867 + pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1869 + s->pfile_in_zip_read = pfile_in_zip_read_info;
1872 + if (password != NULL)
1875 + s->pcrc_32_tab = get_crc_table();
1876 + init_keys(password,s->keys,s->pcrc_32_tab);
1877 + if (ZSEEK(s->z_filefunc, s->filestream,
1878 + s->pfile_in_zip_read->pos_in_zipfile +
1879 + s->pfile_in_zip_read->byte_before_the_zipfile,
1881 + return UNZ_INTERNALERROR;
1882 + if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
1883 + return UNZ_INTERNALERROR;
1885 + for (i = 0; i<12; i++)
1886 + zdecode(s->keys,s->pcrc_32_tab,source[i]);
1888 + s->pfile_in_zip_read->pos_in_zipfile+=12;
1894 - s->pfile_in_zip_read = pfile_in_zip_read_info;
1898 +extern int ZEXPORT unzOpenCurrentFile (file)
1901 + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1904 +extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
1906 + const char* password;
1908 + return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1911 +extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
1917 + return unzOpenCurrentFile3(file, method, level, raw, NULL);
1921 Read bytes from the current file.
1922 @@ -994,126 +1222,160 @@
1923 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
1925 extern int ZEXPORT unzReadCurrentFile (file, buf, len)
1933 - file_in_zip_read_info_s* pfile_in_zip_read_info;
1935 - return UNZ_PARAMERROR;
1944 + file_in_zip_read_info_s* pfile_in_zip_read_info;
1946 + return UNZ_PARAMERROR;
1948 pfile_in_zip_read_info=s->pfile_in_zip_read;
1950 - if (pfile_in_zip_read_info==NULL)
1951 - return UNZ_PARAMERROR;
1952 + if (pfile_in_zip_read_info==NULL)
1953 + return UNZ_PARAMERROR;
1956 - if ((pfile_in_zip_read_info->read_buffer == NULL))
1957 - return UNZ_END_OF_LIST_OF_FILE;
1961 - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1963 - pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1965 - if (len>pfile_in_zip_read_info->rest_read_uncompressed)
1966 - pfile_in_zip_read_info->stream.avail_out =
1967 - (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1969 - while (pfile_in_zip_read_info->stream.avail_out>0)
1971 - if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1972 + if ((pfile_in_zip_read_info->read_buffer == NULL))
1973 + return UNZ_END_OF_LIST_OF_FILE;
1977 + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1979 + pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1981 + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
1982 + (!(pfile_in_zip_read_info->raw)))
1983 + pfile_in_zip_read_info->stream.avail_out =
1984 + (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1986 + if ((len>pfile_in_zip_read_info->rest_read_compressed+
1987 + pfile_in_zip_read_info->stream.avail_in) &&
1988 + (pfile_in_zip_read_info->raw))
1989 + pfile_in_zip_read_info->stream.avail_out =
1990 + (uInt)pfile_in_zip_read_info->rest_read_compressed+
1991 + pfile_in_zip_read_info->stream.avail_in;
1993 + while (pfile_in_zip_read_info->stream.avail_out>0)
1995 + if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1996 (pfile_in_zip_read_info->rest_read_compressed>0))
1998 - uInt uReadThis = UNZ_BUFSIZE;
1999 - if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
2000 - uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
2001 - if (uReadThis == 0)
2003 - if (fseek(pfile_in_zip_read_info->file,
2004 - pfile_in_zip_read_info->pos_in_zipfile +
2005 - pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
2007 - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
2008 - pfile_in_zip_read_info->file)!=1)
2010 - pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
2012 - pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
2014 - pfile_in_zip_read_info->stream.next_in =
2016 + uInt uReadThis = UNZ_BUFSIZE;
2017 + if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
2018 + uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
2019 + if (uReadThis == 0)
2021 + if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
2022 + pfile_in_zip_read_info->filestream,
2023 + pfile_in_zip_read_info->pos_in_zipfile +
2024 + pfile_in_zip_read_info->byte_before_the_zipfile,
2025 + ZLIB_FILEFUNC_SEEK_SET)!=0)
2027 + if (ZREAD(pfile_in_zip_read_info->z_filefunc,
2028 + pfile_in_zip_read_info->filestream,
2029 + pfile_in_zip_read_info->read_buffer,
2030 + uReadThis)!=uReadThis)
2038 + for(i=0;i<uReadThis;i++)
2039 + pfile_in_zip_read_info->read_buffer[i] =
2040 + zdecode(s->keys,s->pcrc_32_tab,
2041 + pfile_in_zip_read_info->read_buffer[i]);
2046 + pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
2048 + pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
2050 + pfile_in_zip_read_info->stream.next_in =
2051 (Bytef*)pfile_in_zip_read_info->read_buffer;
2052 - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
2054 + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
2057 + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
2061 + if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
2062 + (pfile_in_zip_read_info->rest_read_compressed == 0))
2063 + return (iRead==0) ? UNZ_EOF : iRead;
2065 - if (pfile_in_zip_read_info->compression_method==0)
2068 - if (pfile_in_zip_read_info->stream.avail_out <
2069 + if (pfile_in_zip_read_info->stream.avail_out <
2070 pfile_in_zip_read_info->stream.avail_in)
2071 - uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
2073 - uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
2075 - for (i=0;i<uDoCopy;i++)
2076 - *(pfile_in_zip_read_info->stream.next_out+i) =
2077 + uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
2079 + uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
2081 + for (i=0;i<uDoCopy;i++)
2082 + *(pfile_in_zip_read_info->stream.next_out+i) =
2083 *(pfile_in_zip_read_info->stream.next_in+i);
2085 - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
2086 - pfile_in_zip_read_info->stream.next_out,
2088 - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
2089 - pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
2090 - pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
2091 - pfile_in_zip_read_info->stream.next_out += uDoCopy;
2092 - pfile_in_zip_read_info->stream.next_in += uDoCopy;
2094 + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
2095 + pfile_in_zip_read_info->stream.next_out,
2097 + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
2098 + pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
2099 + pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
2100 + pfile_in_zip_read_info->stream.next_out += uDoCopy;
2101 + pfile_in_zip_read_info->stream.next_in += uDoCopy;
2102 pfile_in_zip_read_info->stream.total_out += uDoCopy;
2107 - uLong uTotalOutBefore,uTotalOutAfter;
2108 - const Bytef *bufBefore;
2110 - int flush=Z_SYNC_FLUSH;
2112 - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
2113 - bufBefore = pfile_in_zip_read_info->stream.next_out;
2116 - if ((pfile_in_zip_read_info->rest_read_uncompressed ==
2117 - pfile_in_zip_read_info->stream.avail_out) &&
2118 - (pfile_in_zip_read_info->rest_read_compressed == 0))
2121 - err=inflate(&pfile_in_zip_read_info->stream,flush);
2123 - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
2124 - uOutThis = uTotalOutAfter-uTotalOutBefore;
2126 - pfile_in_zip_read_info->crc32 =
2131 + uLong uTotalOutBefore,uTotalOutAfter;
2132 + const Bytef *bufBefore;
2134 + int flush=Z_SYNC_FLUSH;
2136 + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
2137 + bufBefore = pfile_in_zip_read_info->stream.next_out;
2140 + if ((pfile_in_zip_read_info->rest_read_uncompressed ==
2141 + pfile_in_zip_read_info->stream.avail_out) &&
2142 + (pfile_in_zip_read_info->rest_read_compressed == 0))
2145 + err=inflate(&pfile_in_zip_read_info->stream,flush);
2147 + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
2148 + err = Z_DATA_ERROR;
2150 + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
2151 + uOutThis = uTotalOutAfter-uTotalOutBefore;
2153 + pfile_in_zip_read_info->crc32 =
2154 crc32(pfile_in_zip_read_info->crc32,bufBefore,
2157 - pfile_in_zip_read_info->rest_read_uncompressed -=
2158 + pfile_in_zip_read_info->rest_read_uncompressed -=
2161 - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
2163 - if (err==Z_STREAM_END)
2164 - return (iRead==0) ? UNZ_EOF : iRead;
2173 + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
2175 + if (err==Z_STREAM_END)
2176 + return (iRead==0) ? UNZ_EOF : iRead;
2188 @@ -1121,42 +1383,42 @@
2189 Give the current position in uncompressed data
2191 extern z_off_t ZEXPORT unztell (file)
2196 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2198 - return UNZ_PARAMERROR;
2201 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2203 + return UNZ_PARAMERROR;
2205 pfile_in_zip_read_info=s->pfile_in_zip_read;
2207 - if (pfile_in_zip_read_info==NULL)
2208 - return UNZ_PARAMERROR;
2209 + if (pfile_in_zip_read_info==NULL)
2210 + return UNZ_PARAMERROR;
2212 - return (z_off_t)pfile_in_zip_read_info->stream.total_out;
2213 + return (z_off_t)pfile_in_zip_read_info->stream.total_out;
2218 - return 1 if the end of file was reached, 0 elsewhere
2219 + return 1 if the end of file was reached, 0 elsewhere
2221 extern int ZEXPORT unzeof (file)
2226 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2228 - return UNZ_PARAMERROR;
2231 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2233 + return UNZ_PARAMERROR;
2235 pfile_in_zip_read_info=s->pfile_in_zip_read;
2237 - if (pfile_in_zip_read_info==NULL)
2238 - return UNZ_PARAMERROR;
2240 - if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2244 + if (pfile_in_zip_read_info==NULL)
2245 + return UNZ_PARAMERROR;
2247 + if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2254 @@ -1169,51 +1431,55 @@
2255 if buf==NULL, it return the size of the local extra field that can be read
2257 if buf!=NULL, len is the size of the buffer, the extra header is copied in
2259 - the return value is the number of bytes copied in buf, or (if <0)
2262 + the return value is the number of bytes copied in buf, or (if <0)
2265 extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
2271 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2273 - uLong size_to_read;
2276 - return UNZ_PARAMERROR;
2283 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2285 + uLong size_to_read;
2288 + return UNZ_PARAMERROR;
2290 pfile_in_zip_read_info=s->pfile_in_zip_read;
2292 - if (pfile_in_zip_read_info==NULL)
2293 - return UNZ_PARAMERROR;
2294 + if (pfile_in_zip_read_info==NULL)
2295 + return UNZ_PARAMERROR;
2297 - size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
2298 - pfile_in_zip_read_info->pos_local_extrafield);
2299 + size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
2300 + pfile_in_zip_read_info->pos_local_extrafield);
2303 - return (int)size_to_read;
2305 - if (len>size_to_read)
2306 - read_now = (uInt)size_to_read;
2308 - read_now = (uInt)len ;
2313 - if (fseek(pfile_in_zip_read_info->file,
2314 - pfile_in_zip_read_info->offset_local_extrafield +
2315 - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
2318 + return (int)size_to_read;
2320 - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
2322 + if (len>size_to_read)
2323 + read_now = (uInt)size_to_read;
2325 + read_now = (uInt)len ;
2330 - return (int)read_now;
2331 + if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
2332 + pfile_in_zip_read_info->filestream,
2333 + pfile_in_zip_read_info->offset_local_extrafield +
2334 + pfile_in_zip_read_info->pos_local_extrafield,
2335 + ZLIB_FILEFUNC_SEEK_SET)!=0)
2338 + if (ZREAD(pfile_in_zip_read_info->z_filefunc,
2339 + pfile_in_zip_read_info->filestream,
2340 + buf,read_now)!=read_now)
2343 + return (int)read_now;
2347 @@ -1221,39 +1487,40 @@
2348 Return UNZ_CRCERROR if all the file was read but the CRC is not good
2350 extern int ZEXPORT unzCloseCurrentFile (file)
2358 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2360 - return UNZ_PARAMERROR;
2363 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2365 + return UNZ_PARAMERROR;
2367 pfile_in_zip_read_info=s->pfile_in_zip_read;
2369 - if (pfile_in_zip_read_info==NULL)
2370 - return UNZ_PARAMERROR;
2371 + if (pfile_in_zip_read_info==NULL)
2372 + return UNZ_PARAMERROR;
2375 - if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2377 - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2380 + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
2381 + (!pfile_in_zip_read_info->raw))
2383 + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2388 - TRYFREE(pfile_in_zip_read_info->read_buffer);
2389 - pfile_in_zip_read_info->read_buffer = NULL;
2390 - if (pfile_in_zip_read_info->stream_initialised)
2391 - inflateEnd(&pfile_in_zip_read_info->stream);
2392 + TRYFREE(pfile_in_zip_read_info->read_buffer);
2393 + pfile_in_zip_read_info->read_buffer = NULL;
2394 + if (pfile_in_zip_read_info->stream_initialised)
2395 + inflateEnd(&pfile_in_zip_read_info->stream);
2397 - pfile_in_zip_read_info->stream_initialised = 0;
2398 - TRYFREE(pfile_in_zip_read_info);
2399 + pfile_in_zip_read_info->stream_initialised = 0;
2400 + TRYFREE(pfile_in_zip_read_info);
2402 s->pfile_in_zip_read=NULL;
2409 @@ -1263,32 +1530,69 @@
2410 return the number of byte copied or an error code <0
2412 extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
2421 - return UNZ_PARAMERROR;
2424 - uReadThis = uSizeBuf;
2425 - if (uReadThis>s->gi.size_comment)
2426 - uReadThis = s->gi.size_comment;
2435 + return UNZ_PARAMERROR;
2438 - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
2440 + uReadThis = uSizeBuf;
2441 + if (uReadThis>s->gi.size_comment)
2442 + uReadThis = s->gi.size_comment;
2445 + if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
2451 - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
2453 + if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
2457 - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2458 - *(szComment+s->gi.size_comment)='\0';
2459 - return (int)uReadThis;
2460 + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2461 + *(szComment+s->gi.size_comment)='\0';
2462 + return (int)uReadThis;
2465 +/* Additions by RX '2004 */
2466 +extern uLong ZEXPORT unzGetOffset (file)
2472 + return UNZ_PARAMERROR;
2474 + if (!s->current_file_ok)
2476 + if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
2477 + if (s->num_file==s->gi.number_entry)
2479 + return s->pos_in_central_dir;
2482 +extern int ZEXPORT unzSetOffset (file, pos)
2490 + return UNZ_PARAMERROR;
2493 + s->pos_in_central_dir = pos;
2494 + s->num_file = s->gi.number_entry; /* hack */
2495 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
2496 + &s->cur_file_info_internal,
2497 + NULL,0,NULL,0,NULL,0);
2498 + s->current_file_ok = (err == UNZ_OK);
2501 --- misc/zlib-1.1.4/contrib/minizip/unzip.h 1998-03-19 00:15:00.000000000 +0100
2502 +++ misc/build/zlib-1.1.4/contrib/minizip/unzip.h 2009-07-17 10:15:15.609375000 +0200
2504 -/* unzip.h -- IO for uncompress .zip files using zlib
2505 - Version 0.15 beta, Mar 19th, 1998,
2506 +/* unzip.h -- IO for uncompress .zip files using zlib
2507 + Version 1.01e, February 12th, 2005
2509 - Copyright (C) 1998 Gilles Vollant
2510 + Copyright (C) 1998-2005 Gilles Vollant
2512 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
2513 WinZip, InfoZip tools and compatible.
2514 - Encryption and multi volume ZipFile (span) are not supported.
2516 + Multi volume ZipFile (span) are not supported.
2517 + Encryption compatible with pkzip 2.04g only supported
2518 Old compressions used by old PKZip 1.x are not supported
2520 - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
2521 - CAN CHANGE IN FUTURE VERSION !!
2523 I WAIT FEEDBACK at mail info@winimage.com
2524 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
2530 -/* for more info about .ZIP format, see
2531 - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
2533 +/* for more info about .ZIP format, see
2534 + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
2535 + http://www.info-zip.org/pub/infozip/doc/
2536 PkWare has also a specification at :
2537 - ftp://ftp.pkware.com/probdesc.zip */
2538 + ftp://ftp.pkware.com/probdesc.zip
2548 +#include "zlib/zlib.h"
2551 +#ifndef _ZLIBIOAPI_H
2555 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
2556 /* like the STRICT of WIN32, we define a pointer that cannot be converted
2557 from (void*) without cast */
2558 -typedef struct TagunzFile__ { int unused; } unzFile__;
2559 +typedef struct TagunzFile__ { int unused; } unzFile__;
2560 typedef unzFile__ *unzFile;
2562 typedef voidp unzFile;
2567 -#define UNZ_END_OF_LIST_OF_FILE (-100)
2568 -#define UNZ_ERRNO (Z_ERRNO)
2569 -#define UNZ_EOF (0)
2571 +#define UNZ_END_OF_LIST_OF_FILE (-100)
2572 +#define UNZ_ERRNO (Z_ERRNO)
2573 +#define UNZ_EOF (0)
2574 #define UNZ_PARAMERROR (-102)
2575 #define UNZ_BADZIPFILE (-103)
2576 #define UNZ_INTERNALERROR (-104)
2577 #define UNZ_CRCERROR (-105)
2579 /* tm_unz contain date/time info */
2580 -typedef struct tm_unz_s
2581 +typedef struct tm_unz_s
2583 - uInt tm_sec; /* seconds after the minute - [0,59] */
2584 - uInt tm_min; /* minutes after the hour - [0,59] */
2585 - uInt tm_hour; /* hours since midnight - [0,23] */
2586 - uInt tm_mday; /* day of the month - [1,31] */
2587 - uInt tm_mon; /* months since January - [0,11] */
2588 - uInt tm_year; /* years - [1980..2044] */
2589 + uInt tm_sec; /* seconds after the minute - [0,59] */
2590 + uInt tm_min; /* minutes after the hour - [0,59] */
2591 + uInt tm_hour; /* hours since midnight - [0,23] */
2592 + uInt tm_mday; /* day of the month - [1,31] */
2593 + uInt tm_mon; /* months since January - [0,11] */
2594 + uInt tm_year; /* years - [1980..2044] */
2597 /* unz_global_info structure contain global data about the ZIPfile
2598 These data comes from the end of central dir */
2599 typedef struct unz_global_info_s
2601 - uLong number_entry; /* total number of entries in
2602 - the central dir on this disk */
2603 - uLong size_comment; /* size of the global comment of the zipfile */
2604 + uLong number_entry; /* total number of entries in
2605 + the central dir on this disk */
2606 + uLong size_comment; /* size of the global comment of the zipfile */
2611 uLong compression_method; /* compression method 2 bytes */
2612 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
2613 uLong crc; /* crc-32 4 bytes */
2614 - uLong compressed_size; /* compressed size 4 bytes */
2615 - uLong uncompressed_size; /* uncompressed size 4 bytes */
2616 + uLong compressed_size; /* compressed size 4 bytes */
2617 + uLong uncompressed_size; /* uncompressed size 4 bytes */
2618 uLong size_filename; /* filename length 2 bytes */
2619 uLong size_file_extra; /* extra field length 2 bytes */
2620 uLong size_file_comment; /* file comment length 2 bytes */
2621 @@ -112,27 +120,34 @@
2624 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
2625 - const char* fileName2,
2626 - int iCaseSensitivity));
2627 + const char* fileName2,
2628 + int iCaseSensitivity));
2630 Compare two filename (fileName1,fileName2).
2631 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
2632 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
2635 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
2636 - (like 1 on Unix, 2 on Windows)
2637 + (like 1 on Unix, 2 on Windows)
2641 extern unzFile ZEXPORT unzOpen OF((const char *path));
2643 Open a Zip file. path contain the full pathname (by example,
2644 - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
2645 - "zlib/zlib111.zip".
2646 - If the zipfile cannot be opened (file don't exist or in not valid), the
2647 - return value is NULL.
2648 + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
2649 + "zlib/zlib113.zip".
2650 + If the zipfile cannot be opened (file don't exist or in not valid), the
2651 + return value is NULL.
2652 Else, the return value is a unzFile Handle, usable with other function
2653 - of this unzip package.
2654 + of this unzip package.
2657 +extern unzFile ZEXPORT unzOpen2 OF((const char *path,
2658 + zlib_filefunc_def* pzlib_filefunc_def));
2660 + Open a Zip file, like unzOpen, but provide a set of file low level API
2661 + for read/write the zip file (see ioapi.h)
2664 extern int ZEXPORT unzClose OF((unzFile file));
2666 return UNZ_OK if there is no problem. */
2668 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
2669 - unz_global_info *pglobal_info));
2670 + unz_global_info *pglobal_info));
2672 Write info about the ZipFile in the *pglobal_info structure.
2673 No preparation of the structure is needed
2677 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
2683 Get the global comment string of the ZipFile, in the szComment buffer.
2684 uSizeBuf is the size of the szComment buffer.
2686 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
2689 -extern int ZEXPORT unzLocateFile OF((unzFile file,
2690 - const char *szFileName,
2691 - int iCaseSensitivity));
2692 +extern int ZEXPORT unzLocateFile OF((unzFile file,
2693 + const char *szFileName,
2694 + int iCaseSensitivity));
2696 Try locate the file szFileName in the zipfile.
2697 For the iCaseSensitivity signification, see unzStringFileNameCompare
2698 @@ -189,25 +204,44 @@
2702 +/* ****************************************** */
2703 +/* Ryan supplied functions */
2704 +/* unz_file_info contain information about a file in the zipfile */
2705 +typedef struct unz_file_pos_s
2707 + uLong pos_in_zip_directory; /* offset in zip file directory */
2708 + uLong num_of_file; /* # of file */
2711 +extern int ZEXPORT unzGetFilePos(
2713 + unz_file_pos* file_pos);
2715 +extern int ZEXPORT unzGoToFilePos(
2717 + unz_file_pos* file_pos);
2719 +/* ****************************************** */
2721 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
2722 - unz_file_info *pfile_info,
2724 - uLong fileNameBufferSize,
2726 - uLong extraFieldBufferSize,
2728 - uLong commentBufferSize));
2729 + unz_file_info *pfile_info,
2731 + uLong fileNameBufferSize,
2733 + uLong extraFieldBufferSize,
2735 + uLong commentBufferSize));
2737 Get Info about the current file
2738 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
2741 if szFileName!=NULL, the filemane string will be copied in szFileName
2742 - (fileNameBufferSize is the size of the buffer)
2743 + (fileNameBufferSize is the size of the buffer)
2744 if extraField!=NULL, the extra field information will be copied in extraField
2745 - (extraFieldBufferSize is the size of the buffer).
2746 - This is the Central-header version of the extra field
2747 + (extraFieldBufferSize is the size of the buffer).
2748 + This is the Central-header version of the extra field
2749 if szComment!=NULL, the comment string of the file will be copied in szComment
2750 - (commentBufferSize is the size of the buffer)
2751 + (commentBufferSize is the size of the buffer)
2754 /***************************************************************************/
2755 @@ -221,16 +255,51 @@
2756 If there is no error, the return value is UNZ_OK.
2759 +extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
2760 + const char* password));
2762 + Open for reading data the current file in the zipfile.
2763 + password is a crypting password
2764 + If there is no error, the return value is UNZ_OK.
2767 +extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
2772 + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
2774 + *method will receive method of compression, *level will receive level of
2776 + note : you can set level parameter as NULL (if you did not want known level,
2777 + but you CANNOT set method parameter as NULL
2780 +extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
2784 + const char* password));
2786 + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
2788 + *method will receive method of compression, *level will receive level of
2790 + note : you can set level parameter as NULL (if you did not want known level,
2791 + but you CANNOT set method parameter as NULL
2795 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
2797 Close the file in zip opened with unzOpenCurrentFile
2798 Return UNZ_CRCERROR if all the file was read but the CRC is not good
2802 -extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
2805 +extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
2809 Read bytes from the current file (opened by unzOpenCurrentFile)
2810 buf contain buffer where data must be copied
2811 @@ -249,12 +318,12 @@
2813 extern int ZEXPORT unzeof OF((unzFile file));
2815 - return 1 if the end of file was reached, 0 elsewhere
2816 + return 1 if the end of file was reached, 0 elsewhere
2819 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
2825 Read extra field from the current file (opened by unzOpenCurrentFile)
2826 This is the local-header version of the extra field (sometimes, there is
2827 @@ -263,11 +332,21 @@
2828 if buf==NULL, it return the size of the local extra field
2830 if buf!=NULL, len is the size of the buffer, the extra header is copied in
2832 - the return value is the number of bytes copied in buf, or (if <0)
2835 + the return value is the number of bytes copied in buf, or (if <0)
2839 +/***************************************************************************/
2841 +/* Get the current file offset */
2842 +extern uLong ZEXPORT unzGetOffset (unzFile file);
2844 +/* Set the current file offset */
2845 +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
2852 --- misc/zlib-1.1.4/contrib/minizip/info_zip_crypt.h 2009-07-17 11:13:37.281250000 +0200
2853 +++ misc/build/zlib-1.1.4/contrib/minizip/info_zip_crypt.h 2009-07-17 10:58:41.843750000 +0200
2855 +/* info_zip_crypt.h -- base code for crypt/uncrypt ZIPfile
2858 + Version 1.01e, February 12th, 2005
2860 + Copyright (C) 1998-2005 Gilles Vollant
2862 + This code is a modified version of crypting code in Infozip distribution
2864 + The encryption/decryption parts of this source code (as opposed to the
2865 + non-echoing password parts) were originally written in Europe. The
2866 + whole source package can be freely distributed, including from the USA.
2867 + (Prior to January 2000, re-export from the US was a violation of US law.)
2869 + This encryption code is a direct transcription of the algorithm from
2870 + Roger Schlafly, described by Phil Katz in the file appnote.txt. This
2871 + file (appnote.txt) is distributed with the PKZIP program (even in the
2872 + version without encryption capabilities).
2874 + If you don't need crypting in your application, just define symbols
2875 + NOCRYPT and NOUNCRYPT.
2877 + This code support the "Traditional PKWARE Encryption".
2879 + The new AES encryption added on Zip format by Winzip (see the page
2880 + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
2881 + Encryption is not supported.
2884 +#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
2886 +/***********************************************************************
2887 + * Return the next byte in the pseudo-random sequence
2889 +static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
2891 + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
2892 + * unpredictable manner on 16-bit systems; not a problem
2893 + * with any known compiler so far, though */
2895 + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
2896 + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
2899 +/***********************************************************************
2900 + * Update the encryption keys with the next byte of plain text
2902 +static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
2904 + (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
2905 + (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
2906 + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
2908 + register int keyshift = (int)((*(pkeys+1)) >> 24);
2909 + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
2915 +/***********************************************************************
2916 + * Initialize the encryption keys and the random header according to
2917 + * the given password.
2919 +static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
2921 + *(pkeys+0) = 305419896L;
2922 + *(pkeys+1) = 591751049L;
2923 + *(pkeys+2) = 878082192L;
2924 + while (*passwd != '\0') {
2925 + update_keys(pkeys,pcrc_32_tab,(int)*passwd);
2930 +#define zdecode(pkeys,pcrc_32_tab,c) \
2931 + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
2933 +#define zencode(pkeys,pcrc_32_tab,c,t) \
2934 + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
2936 +#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
2938 +#define RAND_HEAD_LEN 12
2939 + /* "last resort" source for second part of crypt seed pattern */
2941 +# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
2944 +static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
2945 + const char *passwd; /* password string */
2946 + unsigned char *buf; /* where to write header */
2948 + unsigned long* pkeys;
2949 + const unsigned long* pcrc_32_tab;
2950 + unsigned long crcForCrypting;
2952 + int n; /* index in random header */
2953 + int t; /* temporary */
2954 + int c; /* random byte */
2955 + unsigned char header[RAND_HEAD_LEN-2]; /* random header */
2956 + static unsigned calls = 0; /* ensure different random header each time */
2958 + if (bufSize<RAND_HEAD_LEN)
2961 + /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
2962 + * output of rand() to get less predictability, since rand() is
2963 + * often poorly implemented.
2967 + srand((unsigned)(time(NULL) ^ ZCR_SEED2));
2969 + init_keys(passwd, pkeys, pcrc_32_tab);
2970 + for (n = 0; n < RAND_HEAD_LEN-2; n++)
2972 + c = (rand() >> 7) & 0xff;
2973 + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
2975 + /* Encrypt random header (last two bytes is high word of crc) */
2976 + init_keys(passwd, pkeys, pcrc_32_tab);
2977 + for (n = 0; n < RAND_HEAD_LEN-2; n++)
2979 + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
2981 + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
2982 + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
2987 --- misc/zlib-1.1.4/contrib/minizip/ioapi.c 2009-07-17 11:13:18.593750000 +0200
2988 +++ misc/build/zlib-1.1.4/contrib/minizip/ioapi.c 2009-07-17 10:58:56.718750000 +0200
2990 +/* ioapi.c -- IO base function header for compress/uncompress .zip
2991 + files using zlib + zip or unzip API
2993 + Version 1.01e, February 12th, 2005
2995 + Copyright (C) 1998-2005 Gilles Vollant
2999 +#include <stdlib.h>
3000 +#include <string.h>
3007 +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
3021 +voidpf ZCALLBACK fopen_file_func OF((
3023 + const char* filename,
3026 +uLong ZCALLBACK fread_file_func OF((
3032 +uLong ZCALLBACK fwrite_file_func OF((
3038 +long ZCALLBACK ftell_file_func OF((
3042 +long ZCALLBACK fseek_file_func OF((
3048 +int ZCALLBACK fclose_file_func OF((
3052 +int ZCALLBACK ferror_file_func OF((
3057 +voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
3059 + const char* filename;
3062 + FILE* file = NULL;
3063 + const char* mode_fopen = NULL;
3064 + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
3065 + mode_fopen = "rb";
3067 + if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
3068 + mode_fopen = "r+b";
3070 + if (mode & ZLIB_FILEFUNC_MODE_CREATE)
3071 + mode_fopen = "wb";
3073 + if ((filename!=NULL) && (mode_fopen != NULL))
3074 + file = fopen(filename, mode_fopen);
3079 +uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
3086 + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
3091 +uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
3098 + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
3102 +long ZCALLBACK ftell_file_func (opaque, stream)
3107 + ret = ftell((FILE *)stream);
3111 +long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
3117 + int fseek_origin=0;
3121 + case ZLIB_FILEFUNC_SEEK_CUR :
3122 + fseek_origin = SEEK_CUR;
3124 + case ZLIB_FILEFUNC_SEEK_END :
3125 + fseek_origin = SEEK_END;
3127 + case ZLIB_FILEFUNC_SEEK_SET :
3128 + fseek_origin = SEEK_SET;
3130 + default: return -1;
3133 + fseek((FILE *)stream, offset, fseek_origin);
3137 +int ZCALLBACK fclose_file_func (opaque, stream)
3142 + ret = fclose((FILE *)stream);
3146 +int ZCALLBACK ferror_file_func (opaque, stream)
3151 + ret = ferror((FILE *)stream);
3155 +void fill_fopen_filefunc (pzlib_filefunc_def)
3156 + zlib_filefunc_def* pzlib_filefunc_def;
3158 + pzlib_filefunc_def->zopen_file = fopen_file_func;
3159 + pzlib_filefunc_def->zread_file = fread_file_func;
3160 + pzlib_filefunc_def->zwrite_file = fwrite_file_func;
3161 + pzlib_filefunc_def->ztell_file = ftell_file_func;
3162 + pzlib_filefunc_def->zseek_file = fseek_file_func;
3163 + pzlib_filefunc_def->zclose_file = fclose_file_func;
3164 + pzlib_filefunc_def->zerror_file = ferror_file_func;
3165 + pzlib_filefunc_def->opaque = NULL;
3167 --- misc/zlib-1.1.4/contrib/minizip/ioapi.h 2009-07-17 11:13:30.109375000 +0200
3168 +++ misc/build/zlib-1.1.4/contrib/minizip/ioapi.h 2009-07-17 10:59:06.375000000 +0200
3170 +/* ioapi.h -- IO base function header for compress/uncompress .zip
3171 + files using zlib + zip or unzip API
3173 + Version 1.01e, February 12th, 2005
3175 + Copyright (C) 1998-2005 Gilles Vollant
3178 +#ifndef _ZLIBIOAPI_H
3179 +#define _ZLIBIOAPI_H
3182 +#define ZLIB_FILEFUNC_SEEK_CUR (1)
3183 +#define ZLIB_FILEFUNC_SEEK_END (2)
3184 +#define ZLIB_FILEFUNC_SEEK_SET (0)
3186 +#define ZLIB_FILEFUNC_MODE_READ (1)
3187 +#define ZLIB_FILEFUNC_MODE_WRITE (2)
3188 +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
3190 +#define ZLIB_FILEFUNC_MODE_EXISTING (4)
3191 +#define ZLIB_FILEFUNC_MODE_CREATE (8)
3196 +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
3197 +#define ZCALLBACK CALLBACK
3207 +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
3208 +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
3209 +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
3210 +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
3211 +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
3212 +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
3213 +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
3215 +typedef struct zlib_filefunc_def_s
3217 + open_file_func zopen_file;
3218 + read_file_func zread_file;
3219 + write_file_func zwrite_file;
3220 + tell_file_func ztell_file;
3221 + seek_file_func zseek_file;
3222 + close_file_func zclose_file;
3223 + testerror_file_func zerror_file;
3225 +} zlib_filefunc_def;
3229 +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
3231 +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
3232 +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
3233 +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
3234 +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
3235 +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
3236 +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))