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 +# $RCSfile: makefile.mk,v $
11 +# last change: $Author: mtg $ $Date: 2000/11/09 10:19:32 $
13 +# Copyright according the GNU Public License.
15 +#*************************************************************************
22 +EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
24 +# --- Settings -----------------------------------------------------
26 +.INCLUDE : settings.mk
28 +# --- Files --------------------------------------------------------
30 +INCEXT=contrib$/minizip
32 +SLOFILES= $(SLO)$/adler32.obj \
33 + $(SLO)$/compress.obj \
34 + $(SLO)$/deflate.obj \
36 + $(SLO)$/infblock.obj \
37 + $(SLO)$/infcodes.obj \
38 + $(SLO)$/inffast.obj \
39 + $(SLO)$/inflate.obj \
40 + $(SLO)$/inftrees.obj \
41 + $(SLO)$/infutil.obj \
48 +LIB1TARGET=$(SLB)$/$(TARGET).lib
49 +LIB1ARCHIV=$(LB)$/lib$(TARGET).a
50 +LIB1OBJFILES=$(SLOFILES)
52 +.IF "$(BUILD_X64)"!=""
53 +SLOFILES_X64= $(SLO_X64)$/adler32.obj \
54 + $(SLO_X64)$/compress.obj \
55 + $(SLO_X64)$/deflate.obj \
56 + $(SLO_X64)$/crc32.obj \
57 + $(SLO_X64)$/infblock.obj \
58 + $(SLO_X64)$/infcodes.obj \
59 + $(SLO_X64)$/inffast.obj \
60 + $(SLO_X64)$/inflate.obj \
61 + $(SLO_X64)$/inftrees.obj \
62 + $(SLO_X64)$/infutil.obj \
63 + $(SLO_X64)$/trees.obj \
64 + $(SLO_X64)$/zutil.obj \
65 + $(SLO_X64)$/unzip.obj \
68 +LIB1TARGET_X64=$(SLB_X64)$/$(TARGET).lib
69 +LIB1OBJFILES_X64=$(SLOFILES_X64)
70 +.ENDIF # "$(BUILD_X64)"!=""
73 +# --- Targets ------------------------------------------------------
75 +$(MISC)$/%.c : contrib$/minizip$/%.c
76 + @echo ------------------------------
80 +.INCLUDE : set_wntx64.mk
82 +.INCLUDE : tg_wntx64.mk
84 --- misc/zlib-1.1.4/zconf.h Mon Mar 11 14:16:01 2002
85 +++ misc/build/zlib-1.1.4/zconf.h Fri Mar 14 10:15:45 2008
87 * If you *really* need a unique prefix for all types and library functions,
88 * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
91 + * we need the prefix to get the same names as in 1.1.3
97 # define deflateInit_ z_deflateInit_
98 # define deflate z_deflate
100 # define crc32 z_crc32
101 # define get_crc_table z_get_crc_table
103 +# define inflate_blocks z_inflate_blocks
104 +# define inflate_blocks_new z_inflate_blocks_new
105 +# define inflate_blocks_free z_inflate_blocks_free
106 +# define inflate_blocks_reset z_inflate_blocks_reset
107 +# define inflate_codes_free z_inflate_codes_free
108 +# define inflate_codes z_inflate_codes
109 +# define inflate_fast z_inflate_fast
110 +# define inflate_flush z_inflate_flush
111 +# define inflate_mask z_inflate_mask
112 +# define inflate_set_dictionary z_inflate_set_dictionary
113 +# define inflate_copyright z_inflate_copyright
114 +# define inflate_trees_bits z_inflate_trees_bits
115 +# define inflate_trees_dynamic z_inflate_trees_dynamic
116 +# define inflate_trees_fixed z_inflate_trees_fixed
117 +# define inflate_trees_free z_inflate_trees_free
121 # define uLong z_uLong
122 -# define Bytef z_Bytef
123 +# define Bytef z_Bytef
124 # define charf z_charf
126 # define uIntf z_uIntf
127 --- misc/zlib-1.1.4/zlib.h Mon Mar 11 14:56:38 2002
128 +++ misc/build/zlib-1.1.4/zlib.h Fri Mar 14 10:15:45 2008
130 Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
131 (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
139 /* basic functions */
141 +#if !defined(ZUTIL_PROTOS_OFF)
142 ZEXTERN const char * ZEXPORT zlibVersion OF((void));
144 /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
145 If the first character differs, the library code actually used is
146 not compatible with the zlib.h header file used by the application.
148 struct internal_state {int dummy;}; /* hack for buggy compilers */
151 +#if !defined(ZUTIL_PROTOS_OFF)
152 ZEXTERN const char * ZEXPORT zError OF((int err));
154 ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
155 ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
157 --- misc/zlib-1.1.4/zutil.c Mon Mar 11 14:16:01 2002
158 +++ misc/build/zlib-1.1.4/zutil.c Fri Mar 14 10:15:45 2008
164 +#define ZUTIL_PROTOS_OFF
168 struct internal_state {int dummy;}; /* for buggy compilers */
169 --- misc/zlib-1.1.4/contrib/minizip/unzip.c 1998-06-15 17:34:20.000000000 +0200
170 +++ misc/build/zlib-1.1.4/contrib/minizip/unzip.c 2009-07-17 10:15:05.156250000 +0200
172 -/* unzip.c -- IO on .zip files using zlib
173 - Version 0.15 beta, Mar 19th, 1998,
174 +/* unzip.c -- IO for uncompress .zip files using zlib
175 + Version 1.01e, February 12th, 2005
177 + Copyright (C) 1998-2005 Gilles Vollant
179 Read unzip.h for more info
182 +/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
183 +compatibility with older software. The following is from the original crypt.c. Code
184 +woven in by Terry Thorsen 1/2003.
187 + Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
189 + See the accompanying file LICENSE, version 2000-Apr-09 or later
190 + (the contents of which are also included in zip.h) for terms of use.
191 + If, for some reason, all these files are missing, the Info-ZIP license
192 + also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
195 + crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
197 + The encryption/decryption parts of this source code (as opposed to the
198 + non-echoing password parts) were originally written in Europe. The
199 + whole source package can be freely distributed, including from the USA.
200 + (Prior to January 2000, re-export from the US was a violation of US law.)
204 + This encryption code is a direct transcription of the algorithm from
205 + Roger Schlafly, described by Phil Katz in the file appnote.txt. This
206 + file (appnote.txt) is distributed with the PKZIP program (even in the
207 + version without encryption capabilities).
214 /* compile with -Dlocal if your debugger can't find static symbols */
218 -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
219 - !defined(CASESENSITIVITYDEFAULT_NO)
220 -#define CASESENSITIVITYDEFAULT_NO
221 +#ifndef CASESENSITIVITYDEFAULT_NO
222 +# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
223 +# define CASESENSITIVITYDEFAULT_NO
229 #define SIZEZIPLOCALHEADER (0x1e)
232 -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
246 const char unz_copyright[] =
247 - " unzip 0.15 Copyright 1998 Gilles Vollant ";
248 + " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
250 /* unz_file_info_interntal contain internal info about a file in zipfile*/
251 typedef struct unz_file_info_internal_s
253 when reading and decompress it */
256 - char *read_buffer; /* internal buffer for compressed data */
257 - z_stream stream; /* zLib stream structure for inflate */
258 + char *read_buffer; /* internal buffer for compressed data */
259 + z_stream stream; /* zLib stream structure for inflate */
261 - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
262 - uLong stream_initialised; /* flag set if stream structure is initialised*/
263 + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
264 + uLong stream_initialised; /* flag set if stream structure is initialised*/
266 - uLong offset_local_extrafield;/* offset of the local extra field */
267 - uInt size_local_extrafield;/* size of the local extra field */
268 - uLong pos_local_extrafield; /* position in the local extra field in read*/
270 - uLong crc32; /* crc32 of all data uncompressed */
271 - uLong crc32_wait; /* crc32 we must obtain after decompress all */
272 - uLong rest_read_compressed; /* number of byte to be decompressed */
273 - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
274 - FILE* file; /* io structore of the zipfile */
275 - uLong compression_method; /* compression method (0==store) */
276 - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
277 + uLong offset_local_extrafield;/* offset of the local extra field */
278 + uInt size_local_extrafield;/* size of the local extra field */
279 + uLong pos_local_extrafield; /* position in the local extra field in read*/
281 + uLong crc32; /* crc32 of all data uncompressed */
282 + uLong crc32_wait; /* crc32 we must obtain after decompress all */
283 + uLong rest_read_compressed; /* number of byte to be decompressed */
284 + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
285 + zlib_filefunc_def z_filefunc;
286 + voidpf filestream; /* io structore of the zipfile */
287 + uLong compression_method; /* compression method (0==store) */
288 + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
290 } file_in_zip_read_info_s;
293 @@ -107,25 +127,35 @@
297 - FILE* file; /* io structore of the zipfile */
298 - unz_global_info gi; /* public global information */
299 - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
300 - uLong num_file; /* number of the current file in the zipfile*/
301 - uLong pos_in_central_dir; /* pos of the current file in the central dir*/
302 - uLong current_file_ok; /* flag about the usability of the current file*/
303 - uLong central_pos; /* position of the beginning of the central dir*/
305 - uLong size_central_dir; /* size of the central directory */
306 - uLong offset_central_dir; /* offset of start of central directory with
307 - respect to the starting disk number */
308 + zlib_filefunc_def z_filefunc;
309 + voidpf filestream; /* io structore of the zipfile */
310 + unz_global_info gi; /* public global information */
311 + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
312 + uLong num_file; /* number of the current file in the zipfile*/
313 + uLong pos_in_central_dir; /* pos of the current file in the central dir*/
314 + uLong current_file_ok; /* flag about the usability of the current file*/
315 + uLong central_pos; /* position of the beginning of the central dir*/
317 + uLong size_central_dir; /* size of the central directory */
318 + uLong offset_central_dir; /* offset of start of central directory with
319 + respect to the starting disk number */
321 - unz_file_info cur_file_info; /* public info about the current file in zip*/
322 - unz_file_info_internal cur_file_info_internal; /* private info about it*/
323 + unz_file_info cur_file_info; /* public info about the current file in zip*/
324 + unz_file_info_internal cur_file_info_internal; /* private info about it*/
325 file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
326 - file if we are decompressing it */
327 + file if we are decompressing it */
330 + unsigned long keys[3]; /* keys defining the pseudo-random sequence */
331 + const unsigned long* pcrc_32_tab;
340 /* ===========================================================================
341 Read a byte from a gz_stream; update next_in and avail_in. Return EOF
343 @@ -133,12 +163,18 @@
347 -local int unzlocal_getByte(fin,pi)
350 +local int unzlocal_getByte OF((
351 + const zlib_filefunc_def* pzlib_filefunc_def,
355 +local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
356 + const zlib_filefunc_def* pzlib_filefunc_def;
361 - int err = fread(&c, 1, 1, fin);
362 + int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
371 + if (ZERROR(*pzlib_filefunc_def,filestream))
375 @@ -155,23 +191,29 @@
378 /* ===========================================================================
379 - Reads a long in LSB order from the given gz_stream. Sets
380 + Reads a long in LSB order from the given gz_stream. Sets
382 -local int unzlocal_getShort (fin,pX)
384 +local int unzlocal_getShort OF((
385 + const zlib_filefunc_def* pzlib_filefunc_def,
389 +local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
390 + const zlib_filefunc_def* pzlib_filefunc_def;
398 - err = unzlocal_getByte(fin,&i);
399 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
404 - err = unzlocal_getByte(fin,&i);
405 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
412 @@ -179,29 +221,35 @@
416 -local int unzlocal_getLong (fin,pX)
418 +local int unzlocal_getLong OF((
419 + const zlib_filefunc_def* pzlib_filefunc_def,
423 +local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
424 + const zlib_filefunc_def* pzlib_filefunc_def;
432 - err = unzlocal_getByte(fin,&i);
433 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
438 - err = unzlocal_getByte(fin,&i);
439 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
443 - err = unzlocal_getByte(fin,&i);
444 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
448 - err = unzlocal_getByte(fin,&i);
449 + err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
456 @@ -212,26 +260,26 @@
458 /* My own strcmpi / strcasecmp */
459 local int strcmpcasenosensitive_internal (fileName1,fileName2)
460 - const char* fileName1;
461 - const char* fileName2;
462 + const char* fileName1;
463 + const char* fileName2;
467 - char c1=*(fileName1++);
468 - char c2=*(fileName2++);
469 - if ((c1>='a') && (c1<='z'))
471 - if ((c2>='a') && (c2<='z'))
474 - return ((c2=='\0') ? 0 : -1);
484 + char c1=*(fileName1++);
485 + char c2=*(fileName2++);
486 + if ((c1>='a') && (c1<='z'))
488 + if ((c2>='a') && (c2<='z'))
491 + return ((c2=='\0') ? 0 : -1);
503 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
508 Compare two filename (fileName1,fileName2).
509 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
510 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
511 @@ -255,203 +303,225 @@
514 extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
515 - const char* fileName1;
516 - const char* fileName2;
517 - int iCaseSensitivity;
518 + const char* fileName1;
519 + const char* fileName2;
520 + int iCaseSensitivity;
522 - if (iCaseSensitivity==0)
523 - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
524 + if (iCaseSensitivity==0)
525 + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
527 - if (iCaseSensitivity==1)
528 - return strcmp(fileName1,fileName2);
529 + if (iCaseSensitivity==1)
530 + return strcmp(fileName1,fileName2);
532 - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
534 + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
537 +#ifndef BUFREADCOMMENT
538 #define BUFREADCOMMENT (0x400)
542 Locate the Central directory of a zipfile (at the end, just before
545 -local uLong unzlocal_SearchCentralDir(fin)
547 +local uLong unzlocal_SearchCentralDir OF((
548 + const zlib_filefunc_def* pzlib_filefunc_def,
549 + voidpf filestream));
551 +local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
552 + const zlib_filefunc_def* pzlib_filefunc_def;
555 - unsigned char* buf;
558 - uLong uMaxBack=0xffff; /* maximum size of global comment */
561 - if (fseek(fin,0,SEEK_END) != 0)
565 - uSizeFile = ftell( fin );
567 - if (uMaxBack>uSizeFile)
568 - uMaxBack = uSizeFile;
570 - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
575 - while (uBackRead<uMaxBack)
577 - uLong uReadSize,uReadPos ;
579 - if (uBackRead+BUFREADCOMMENT>uMaxBack)
580 - uBackRead = uMaxBack;
582 - uBackRead+=BUFREADCOMMENT;
583 - uReadPos = uSizeFile-uBackRead ;
585 - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
586 + unsigned char* buf;
589 + uLong uMaxBack=0xffff; /* maximum size of global comment */
592 + if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
596 + uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
598 + if (uMaxBack>uSizeFile)
599 + uMaxBack = uSizeFile;
601 + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
606 + while (uBackRead<uMaxBack)
608 + uLong uReadSize,uReadPos ;
610 + if (uBackRead+BUFREADCOMMENT>uMaxBack)
611 + uBackRead = uMaxBack;
613 + uBackRead+=BUFREADCOMMENT;
614 + uReadPos = uSizeFile-uBackRead ;
616 + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
617 (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
618 - if (fseek(fin,uReadPos,SEEK_SET)!=0)
620 + if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
623 - if (fread(buf,(uInt)uReadSize,1,fin)!=1)
625 + if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
628 - for (i=(int)uReadSize-3; (i--)>0;)
629 - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
630 - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
632 - uPosFound = uReadPos+i;
641 + for (i=(int)uReadSize-3; (i--)>0;)
642 + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
643 + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
645 + uPosFound = uReadPos+i;
657 Open a Zip file. path contain the full pathname (by example,
658 - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
659 - "zlib/zlib109.zip".
660 - If the zipfile cannot be opened (file don't exist or in not valid), the
661 - return value is NULL.
662 + on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
663 + "zlib/zlib114.zip".
664 + If the zipfile cannot be opened (file doesn't exist or in not valid), the
665 + return value is NULL.
666 Else, the return value is a unzFile Handle, usable with other function
667 - of this unzip package.
668 + of this unzip package.
670 -extern unzFile ZEXPORT unzOpen (path)
675 - uLong central_pos,uL;
678 - uLong number_disk; /* number of the current dist, used for
679 - spaning ZIP, unsupported, always 0*/
680 - uLong number_disk_with_CD; /* number the the disk with central dir, used
681 - for spaning ZIP, unsupported, always 0*/
682 - uLong number_entry_CD; /* total number of entries in
684 - (same than number_entry on nospan) */
685 +extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
687 + zlib_filefunc_def* pzlib_filefunc_def;
691 + uLong central_pos,uL;
693 + uLong number_disk; /* number of the current dist, used for
694 + spaning ZIP, unsupported, always 0*/
695 + uLong number_disk_with_CD; /* number the the disk with central dir, used
696 + for spaning ZIP, unsupported, always 0*/
697 + uLong number_entry_CD; /* total number of entries in
699 + (same than number_entry on nospan) */
704 if (unz_copyright[0]!=' ')
707 - fin=fopen(path,"rb");
711 - central_pos = unzlocal_SearchCentralDir(fin);
712 - if (central_pos==0)
715 - if (fseek(fin,central_pos,SEEK_SET)!=0)
718 - /* the signature, already checked */
719 - if (unzlocal_getLong(fin,&uL)!=UNZ_OK)
722 - /* number of this disk */
723 - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK)
726 - /* number of the disk with the start of the central directory */
727 - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK)
730 - /* total number of entries in the central dir on this disk */
731 - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK)
734 - /* total number of entries in the central dir */
735 - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK)
738 - if ((number_entry_CD!=us.gi.number_entry) ||
739 - (number_disk_with_CD!=0) ||
741 - err=UNZ_BADZIPFILE;
743 - /* size of the central directory */
744 - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK)
747 - /* offset of start of central directory with respect to the
748 - starting disk number */
749 - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK)
752 - /* zipfile comment length */
753 - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK)
756 - if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
758 - err=UNZ_BADZIPFILE;
767 - us.byte_before_the_zipfile = central_pos -
768 - (us.offset_central_dir+us.size_central_dir);
769 - us.central_pos = central_pos;
770 + if (pzlib_filefunc_def==NULL)
771 + fill_fopen_filefunc(&us.z_filefunc);
773 + us.z_filefunc = *pzlib_filefunc_def;
775 + us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
777 + ZLIB_FILEFUNC_MODE_READ |
778 + ZLIB_FILEFUNC_MODE_EXISTING);
779 + if (us.filestream==NULL)
782 + central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
783 + if (central_pos==0)
786 + if (ZSEEK(us.z_filefunc, us.filestream,
787 + central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
790 + /* the signature, already checked */
791 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
794 + /* number of this disk */
795 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
798 + /* number of the disk with the start of the central directory */
799 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
802 + /* total number of entries in the central dir on this disk */
803 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
806 + /* total number of entries in the central dir */
807 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
810 + if ((number_entry_CD!=us.gi.number_entry) ||
811 + (number_disk_with_CD!=0) ||
813 + err=UNZ_BADZIPFILE;
815 + /* size of the central directory */
816 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
819 + /* offset of start of central directory with respect to the
820 + starting disk number */
821 + if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
824 + /* zipfile comment length */
825 + if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
828 + if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
830 + err=UNZ_BADZIPFILE;
834 + ZCLOSE(us.z_filefunc, us.filestream);
838 + us.byte_before_the_zipfile = central_pos -
839 + (us.offset_central_dir+us.size_central_dir);
840 + us.central_pos = central_pos;
841 us.pfile_in_zip_read = NULL;
845 - s=(unz_s*)ALLOC(sizeof(unz_s));
847 - unzGoToFirstFile((unzFile)s);
850 + s=(unz_s*)ALLOC(sizeof(unz_s));
852 + unzGoToFirstFile((unzFile)s);
857 +extern unzFile ZEXPORT unzOpen (path)
860 + return unzOpen2(path, NULL);
864 Close a ZipFile opened with unzipOpen.
865 If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
866 these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
867 return UNZ_OK if there is no problem. */
868 extern int ZEXPORT unzClose (file)
874 - return UNZ_PARAMERROR;
878 + return UNZ_PARAMERROR;
881 if (s->pfile_in_zip_read!=NULL)
882 unzCloseCurrentFile(file);
887 + ZCLOSE(s->z_filefunc, s->filestream);
893 @@ -460,15 +530,15 @@
894 No preparation of the structure is needed
895 return UNZ_OK if there is no problem. */
896 extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
898 - unz_global_info *pglobal_info;
900 + unz_global_info *pglobal_info;
904 - return UNZ_PARAMERROR;
906 - *pglobal_info=s->gi;
910 + return UNZ_PARAMERROR;
912 + *pglobal_info=s->gi;
917 @@ -495,14 +565,14 @@
919 local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
920 unz_file_info *pfile_info,
921 - unz_file_info_internal
922 + unz_file_info_internal
923 *pfile_info_internal,
925 - uLong fileNameBufferSize,
926 + uLong fileNameBufferSize,
928 - uLong extraFieldBufferSize,
929 + uLong extraFieldBufferSize,
931 - uLong commentBufferSize));
932 + uLong commentBufferSize));
934 local int unzlocal_GetCurrentFileInfoInternal (file,
936 @@ -510,156 +580,158 @@
937 szFileName, fileNameBufferSize,
938 extraField, extraFieldBufferSize,
939 szComment, commentBufferSize)
941 - unz_file_info *pfile_info;
942 - unz_file_info_internal *pfile_info_internal;
944 - uLong fileNameBufferSize;
946 - uLong extraFieldBufferSize;
948 - uLong commentBufferSize;
951 - unz_file_info file_info;
952 - unz_file_info_internal file_info_internal;
958 - return UNZ_PARAMERROR;
960 - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0)
964 - /* we check the magic */
966 - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
968 - else if (uMagic!=0x02014b50)
969 - err=UNZ_BADZIPFILE;
971 - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
974 - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK)
977 + unz_file_info *pfile_info;
978 + unz_file_info_internal *pfile_info_internal;
980 + uLong fileNameBufferSize;
982 + uLong extraFieldBufferSize;
984 + uLong commentBufferSize;
987 + unz_file_info file_info;
988 + unz_file_info_internal file_info_internal;
994 + return UNZ_PARAMERROR;
996 + if (ZSEEK(s->z_filefunc, s->filestream,
997 + s->pos_in_central_dir+s->byte_before_the_zipfile,
998 + ZLIB_FILEFUNC_SEEK_SET)!=0)
1002 + /* we check the magic */
1004 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1006 + else if (uMagic!=0x02014b50)
1007 + err=UNZ_BADZIPFILE;
1009 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
1012 - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK)
1014 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
1017 - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK)
1019 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
1022 - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK)
1024 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
1027 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
1030 unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
1032 - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK)
1034 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
1037 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
1040 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
1043 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
1046 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
1049 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
1052 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
1055 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
1058 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
1061 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1064 + lSeek+=file_info.size_filename;
1065 + if ((err==UNZ_OK) && (szFileName!=NULL))
1068 + if (file_info.size_filename<fileNameBufferSize)
1070 + *(szFileName+file_info.size_filename)='\0';
1071 + uSizeRead = file_info.size_filename;
1074 + uSizeRead = fileNameBufferSize;
1076 + if ((file_info.size_filename>0) && (fileNameBufferSize>0))
1077 + if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
1079 + lSeek -= uSizeRead;
1083 + if ((err==UNZ_OK) && (extraField!=NULL))
1086 + if (file_info.size_file_extra<extraFieldBufferSize)
1087 + uSizeRead = file_info.size_file_extra;
1089 + uSizeRead = extraFieldBufferSize;
1092 + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1096 + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1097 + if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
1099 + lSeek += file_info.size_file_extra - uSizeRead;
1102 + lSeek+=file_info.size_file_extra;
1104 - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK)
1107 - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK)
1109 + if ((err==UNZ_OK) && (szComment!=NULL))
1112 + if (file_info.size_file_comment<commentBufferSize)
1114 + *(szComment+file_info.size_file_comment)='\0';
1115 + uSizeRead = file_info.size_file_comment;
1118 + uSizeRead = commentBufferSize;
1120 - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK)
1123 - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK)
1126 - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK)
1129 - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK)
1132 - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK)
1135 - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK)
1138 - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK)
1141 - lSeek+=file_info.size_filename;
1142 - if ((err==UNZ_OK) && (szFileName!=NULL))
1145 - if (file_info.size_filename<fileNameBufferSize)
1147 - *(szFileName+file_info.size_filename)='\0';
1148 - uSizeRead = file_info.size_filename;
1151 - uSizeRead = fileNameBufferSize;
1153 - if ((file_info.size_filename>0) && (fileNameBufferSize>0))
1154 - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1)
1156 - lSeek -= uSizeRead;
1160 - if ((err==UNZ_OK) && (extraField!=NULL))
1163 - if (file_info.size_file_extra<extraFieldBufferSize)
1164 - uSizeRead = file_info.size_file_extra;
1166 - uSizeRead = extraFieldBufferSize;
1169 - if (fseek(s->file,lSeek,SEEK_CUR)==0)
1173 - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
1174 - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1)
1176 - lSeek += file_info.size_file_extra - uSizeRead;
1179 - lSeek+=file_info.size_file_extra;
1182 - if ((err==UNZ_OK) && (szComment!=NULL))
1185 - if (file_info.size_file_comment<commentBufferSize)
1187 - *(szComment+file_info.size_file_comment)='\0';
1188 - uSizeRead = file_info.size_file_comment;
1191 - uSizeRead = commentBufferSize;
1194 - if (fseek(s->file,lSeek,SEEK_CUR)==0)
1198 - if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1199 - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1)
1201 - lSeek+=file_info.size_file_comment - uSizeRead;
1204 - lSeek+=file_info.size_file_comment;
1206 + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
1210 + if ((file_info.size_file_comment>0) && (commentBufferSize>0))
1211 + if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
1213 + lSeek+=file_info.size_file_comment - uSizeRead;
1216 + lSeek+=file_info.size_file_comment;
1218 - if ((err==UNZ_OK) && (pfile_info!=NULL))
1219 - *pfile_info=file_info;
1220 + if ((err==UNZ_OK) && (pfile_info!=NULL))
1221 + *pfile_info=file_info;
1223 - if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1224 - *pfile_info_internal=file_info_internal;
1225 + if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
1226 + *pfile_info_internal=file_info_internal;
1233 @@ -670,23 +742,23 @@
1234 return UNZ_OK if there is no problem.
1236 extern int ZEXPORT unzGetCurrentFileInfo (file,
1238 - szFileName, fileNameBufferSize,
1239 - extraField, extraFieldBufferSize,
1240 - szComment, commentBufferSize)
1242 - unz_file_info *pfile_info;
1244 - uLong fileNameBufferSize;
1246 - uLong extraFieldBufferSize;
1248 - uLong commentBufferSize;
1250 - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1251 - szFileName,fileNameBufferSize,
1252 - extraField,extraFieldBufferSize,
1253 - szComment,commentBufferSize);
1255 + szFileName, fileNameBufferSize,
1256 + extraField, extraFieldBufferSize,
1257 + szComment, commentBufferSize)
1259 + unz_file_info *pfile_info;
1261 + uLong fileNameBufferSize;
1263 + uLong extraFieldBufferSize;
1265 + uLong commentBufferSize;
1267 + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
1268 + szFileName,fileNameBufferSize,
1269 + extraField,extraFieldBufferSize,
1270 + szComment,commentBufferSize);
1274 @@ -694,50 +766,50 @@
1275 return UNZ_OK if there is no problem
1277 extern int ZEXPORT unzGoToFirstFile (file)
1284 - return UNZ_PARAMERROR;
1286 - s->pos_in_central_dir=s->offset_central_dir;
1288 - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1289 - &s->cur_file_info_internal,
1290 - NULL,0,NULL,0,NULL,0);
1291 - s->current_file_ok = (err == UNZ_OK);
1296 + return UNZ_PARAMERROR;
1298 + s->pos_in_central_dir=s->offset_central_dir;
1300 + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1301 + &s->cur_file_info_internal,
1302 + NULL,0,NULL,0,NULL,0);
1303 + s->current_file_ok = (err == UNZ_OK);
1309 Set the current file of the zipfile to the next file.
1310 return UNZ_OK if there is no problem
1311 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
1313 extern int ZEXPORT unzGoToNextFile (file)
1323 - return UNZ_PARAMERROR;
1325 - if (!s->current_file_ok)
1326 - return UNZ_END_OF_LIST_OF_FILE;
1327 - if (s->num_file+1==s->gi.number_entry)
1328 - return UNZ_END_OF_LIST_OF_FILE;
1330 - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1331 - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
1333 - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1334 - &s->cur_file_info_internal,
1335 - NULL,0,NULL,0,NULL,0);
1336 - s->current_file_ok = (err == UNZ_OK);
1339 + return UNZ_PARAMERROR;
1341 + if (!s->current_file_ok)
1342 + return UNZ_END_OF_LIST_OF_FILE;
1343 + if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
1344 + if (s->num_file+1==s->gi.number_entry)
1345 + return UNZ_END_OF_LIST_OF_FILE;
1347 + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
1348 + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
1350 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1351 + &s->cur_file_info_internal,
1352 + NULL,0,NULL,0,NULL,0);
1353 + s->current_file_ok = (err == UNZ_OK);
1358 @@ -750,50 +822,130 @@
1359 UNZ_END_OF_LIST_OF_FILE if the file is not found
1361 extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
1363 - const char *szFileName;
1364 - int iCaseSensitivity;
1366 + const char *szFileName;
1367 + int iCaseSensitivity;
1375 - uLong num_fileSaved;
1376 - uLong pos_in_central_dirSaved;
1377 + /* We remember the 'current' position in the file so that we can jump
1378 + * back there if we fail.
1380 + unz_file_info cur_file_infoSaved;
1381 + unz_file_info_internal cur_file_info_internalSaved;
1382 + uLong num_fileSaved;
1383 + uLong pos_in_central_dirSaved;
1387 - return UNZ_PARAMERROR;
1389 + return UNZ_PARAMERROR;
1391 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
1392 return UNZ_PARAMERROR;
1395 - if (!s->current_file_ok)
1396 - return UNZ_END_OF_LIST_OF_FILE;
1398 - num_fileSaved = s->num_file;
1399 - pos_in_central_dirSaved = s->pos_in_central_dir;
1401 - err = unzGoToFirstFile(file);
1403 - while (err == UNZ_OK)
1405 - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1406 - unzGetCurrentFileInfo(file,NULL,
1407 - szCurrentFileName,sizeof(szCurrentFileName)-1,
1409 - if (unzStringFileNameCompare(szCurrentFileName,
1410 - szFileName,iCaseSensitivity)==0)
1412 - err = unzGoToNextFile(file);
1415 - s->num_file = num_fileSaved ;
1416 - s->pos_in_central_dir = pos_in_central_dirSaved ;
1419 + if (!s->current_file_ok)
1420 + return UNZ_END_OF_LIST_OF_FILE;
1422 + /* Save the current state */
1423 + num_fileSaved = s->num_file;
1424 + pos_in_central_dirSaved = s->pos_in_central_dir;
1425 + cur_file_infoSaved = s->cur_file_info;
1426 + cur_file_info_internalSaved = s->cur_file_info_internal;
1428 + err = unzGoToFirstFile(file);
1430 + while (err == UNZ_OK)
1432 + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
1433 + err = unzGetCurrentFileInfo(file,NULL,
1434 + szCurrentFileName,sizeof(szCurrentFileName)-1,
1436 + if (err == UNZ_OK)
1438 + if (unzStringFileNameCompare(szCurrentFileName,
1439 + szFileName,iCaseSensitivity)==0)
1441 + err = unzGoToNextFile(file);
1445 + /* We failed, so restore the state of the 'current file' to where we
1448 + s->num_file = num_fileSaved ;
1449 + s->pos_in_central_dir = pos_in_central_dirSaved ;
1450 + s->cur_file_info = cur_file_infoSaved;
1451 + s->cur_file_info_internal = cur_file_info_internalSaved;
1457 +///////////////////////////////////////////
1458 +// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
1459 +// I need random access
1461 +// Further optimization could be realized by adding an ability
1462 +// to cache the directory in memory. The goal being a single
1463 +// comprehensive file read to put the file I need in a memory.
1467 +typedef struct unz_file_pos_s
1469 + uLong pos_in_zip_directory; // offset in file
1470 + uLong num_of_file; // # of file
1474 +extern int ZEXPORT unzGetFilePos(file, file_pos)
1476 + unz_file_pos* file_pos;
1480 + if (file==NULL || file_pos==NULL)
1481 + return UNZ_PARAMERROR;
1483 + if (!s->current_file_ok)
1484 + return UNZ_END_OF_LIST_OF_FILE;
1486 + file_pos->pos_in_zip_directory = s->pos_in_central_dir;
1487 + file_pos->num_of_file = s->num_file;
1492 +extern int ZEXPORT unzGoToFilePos(file, file_pos)
1494 + unz_file_pos* file_pos;
1499 + if (file==NULL || file_pos==NULL)
1500 + return UNZ_PARAMERROR;
1503 + /* jump to the right spot */
1504 + s->pos_in_central_dir = file_pos->pos_in_zip_directory;
1505 + s->num_file = file_pos->num_of_file;
1507 + /* set the current file */
1508 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
1509 + &s->cur_file_info_internal,
1510 + NULL,0,NULL,0,NULL,0);
1511 + /* return results */
1512 + s->current_file_ok = (err == UNZ_OK);
1517 +// Unzip Helper Functions - should be here?
1518 +///////////////////////////////////////////
1522 Read the local header of the current zipfile
1523 @@ -803,185 +955,261 @@
1524 (filename and size of extra field data)
1526 local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
1527 - poffset_local_extrafield,
1528 - psize_local_extrafield)
1531 - uLong *poffset_local_extrafield;
1532 - uInt *psize_local_extrafield;
1534 - uLong uMagic,uData,uFlags;
1535 - uLong size_filename;
1536 - uLong size_extra_field;
1540 - *poffset_local_extrafield = 0;
1541 - *psize_local_extrafield = 0;
1543 - if (fseek(s->file,s->cur_file_info_internal.offset_curfile +
1544 - s->byte_before_the_zipfile,SEEK_SET)!=0)
1549 - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
1551 - else if (uMagic!=0x04034b50)
1552 - err=UNZ_BADZIPFILE;
1554 - if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
1557 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1558 - err=UNZ_BADZIPFILE;
1560 - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK)
1563 - if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
1565 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1566 - err=UNZ_BADZIPFILE;
1567 + poffset_local_extrafield,
1568 + psize_local_extrafield)
1571 + uLong *poffset_local_extrafield;
1572 + uInt *psize_local_extrafield;
1574 + uLong uMagic,uData,uFlags;
1575 + uLong size_filename;
1576 + uLong size_extra_field;
1580 + *poffset_local_extrafield = 0;
1581 + *psize_local_extrafield = 0;
1583 + if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
1584 + s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
1589 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
1591 + else if (uMagic!=0x04034b50)
1592 + err=UNZ_BADZIPFILE;
1594 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1597 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
1598 + err=UNZ_BADZIPFILE;
1600 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
1603 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
1605 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
1606 + err=UNZ_BADZIPFILE;
1608 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
1609 (s->cur_file_info.compression_method!=Z_DEFLATED))
1612 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
1614 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
1617 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
1619 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
1620 - ((uFlags & 8)==0))
1621 - err=UNZ_BADZIPFILE;
1623 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */
1625 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
1626 - ((uFlags & 8)==0))
1627 - err=UNZ_BADZIPFILE;
1629 - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */
1631 - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
1632 - ((uFlags & 8)==0))
1633 - err=UNZ_BADZIPFILE;
1636 - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK)
1638 - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1639 - err=UNZ_BADZIPFILE;
1641 - *piSizeVar += (uInt)size_filename;
1643 - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK)
1645 - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1646 - SIZEZIPLOCALHEADER + size_filename;
1647 - *psize_local_extrafield = (uInt)size_extra_field;
1648 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
1650 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
1651 + ((uFlags & 8)==0))
1652 + err=UNZ_BADZIPFILE;
1654 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
1656 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
1657 + ((uFlags & 8)==0))
1658 + err=UNZ_BADZIPFILE;
1660 - *piSizeVar += (uInt)size_extra_field;
1661 + if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
1663 + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
1664 + ((uFlags & 8)==0))
1665 + err=UNZ_BADZIPFILE;
1668 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
1670 + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
1671 + err=UNZ_BADZIPFILE;
1674 + *piSizeVar += (uInt)size_filename;
1676 + if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
1678 + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
1679 + SIZEZIPLOCALHEADER + size_filename;
1680 + *psize_local_extrafield = (uInt)size_extra_field;
1682 + *piSizeVar += (uInt)size_extra_field;
1689 Open for reading data the current file in the zipfile.
1690 If there is no error and the file is opened, the return value is UNZ_OK.
1692 -extern int ZEXPORT unzOpenCurrentFile (file)
1699 - file_in_zip_read_info_s* pfile_in_zip_read_info;
1700 - uLong offset_local_extrafield; /* offset of the local extra field */
1701 - uInt size_local_extrafield; /* size of the local extra field */
1704 - return UNZ_PARAMERROR;
1706 - if (!s->current_file_ok)
1707 - return UNZ_PARAMERROR;
1708 +extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
1713 + const char* password;
1718 + file_in_zip_read_info_s* pfile_in_zip_read_info;
1719 + uLong offset_local_extrafield; /* offset of the local extra field */
1720 + uInt size_local_extrafield; /* size of the local extra field */
1724 + if (password != NULL)
1725 + return UNZ_PARAMERROR;
1729 + return UNZ_PARAMERROR;
1731 + if (!s->current_file_ok)
1732 + return UNZ_PARAMERROR;
1734 if (s->pfile_in_zip_read != NULL)
1735 unzCloseCurrentFile(file);
1737 - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
1738 - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1739 - return UNZ_BADZIPFILE;
1741 - pfile_in_zip_read_info = (file_in_zip_read_info_s*)
1742 - ALLOC(sizeof(file_in_zip_read_info_s));
1743 - if (pfile_in_zip_read_info==NULL)
1744 - return UNZ_INTERNALERROR;
1746 - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
1747 - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1748 - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1749 - pfile_in_zip_read_info->pos_local_extrafield=0;
1751 - if (pfile_in_zip_read_info->read_buffer==NULL)
1753 - TRYFREE(pfile_in_zip_read_info);
1754 - return UNZ_INTERNALERROR;
1757 - pfile_in_zip_read_info->stream_initialised=0;
1759 - if ((s->cur_file_info.compression_method!=0) &&
1760 + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
1761 + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
1762 + return UNZ_BADZIPFILE;
1764 + pfile_in_zip_read_info = (file_in_zip_read_info_s*)
1765 + ALLOC(sizeof(file_in_zip_read_info_s));
1766 + if (pfile_in_zip_read_info==NULL)
1767 + return UNZ_INTERNALERROR;
1769 + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
1770 + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
1771 + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
1772 + pfile_in_zip_read_info->pos_local_extrafield=0;
1773 + pfile_in_zip_read_info->raw=raw;
1775 + if (pfile_in_zip_read_info->read_buffer==NULL)
1777 + TRYFREE(pfile_in_zip_read_info);
1778 + return UNZ_INTERNALERROR;
1781 + pfile_in_zip_read_info->stream_initialised=0;
1784 + *method = (int)s->cur_file_info.compression_method;
1789 + switch (s->cur_file_info.flag & 0x06)
1791 + case 6 : *level = 1; break;
1792 + case 4 : *level = 2; break;
1793 + case 2 : *level = 9; break;
1797 + if ((s->cur_file_info.compression_method!=0) &&
1798 (s->cur_file_info.compression_method!=Z_DEFLATED))
1799 - err=UNZ_BADZIPFILE;
1800 - Store = s->cur_file_info.compression_method==0;
1801 + err=UNZ_BADZIPFILE;
1803 - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1804 - pfile_in_zip_read_info->crc32=0;
1805 - pfile_in_zip_read_info->compression_method =
1806 + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
1807 + pfile_in_zip_read_info->crc32=0;
1808 + pfile_in_zip_read_info->compression_method =
1809 s->cur_file_info.compression_method;
1810 - pfile_in_zip_read_info->file=s->file;
1811 - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1812 + pfile_in_zip_read_info->filestream=s->filestream;
1813 + pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
1814 + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
1816 pfile_in_zip_read_info->stream.total_out = 0;
1820 - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1821 - pfile_in_zip_read_info->stream.zfree = (free_func)0;
1822 - pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1824 - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1826 - pfile_in_zip_read_info->stream_initialised=1;
1827 + if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
1830 + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
1831 + pfile_in_zip_read_info->stream.zfree = (free_func)0;
1832 + pfile_in_zip_read_info->stream.opaque = (voidpf)0;
1833 + pfile_in_zip_read_info->stream.next_in = (voidpf)0;
1834 + pfile_in_zip_read_info->stream.avail_in = 0;
1836 + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
1838 + pfile_in_zip_read_info->stream_initialised=1;
1841 + TRYFREE(pfile_in_zip_read_info);
1844 /* windowBits is passed < 0 to tell that there is no zlib header.
1845 * Note that in this case inflate *requires* an extra "dummy" byte
1846 * after the compressed stream in order to complete decompression and
1847 - * return Z_STREAM_END.
1848 - * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1849 + * return Z_STREAM_END.
1850 + * In unzip, i don't wait absolutely Z_STREAM_END because I known the
1851 * size of both compressed and uncompressed data
1854 - pfile_in_zip_read_info->rest_read_compressed =
1856 + pfile_in_zip_read_info->rest_read_compressed =
1857 s->cur_file_info.compressed_size ;
1858 - pfile_in_zip_read_info->rest_read_uncompressed =
1859 + pfile_in_zip_read_info->rest_read_uncompressed =
1860 s->cur_file_info.uncompressed_size ;
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 + pfile_in_zip_read_info->pos_in_zipfile =
1870 + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
1873 + pfile_in_zip_read_info->stream.avail_in = (uInt)0;
1875 + s->pfile_in_zip_read = pfile_in_zip_read_info;
1878 + if (password != NULL)
1881 + s->pcrc_32_tab = get_crc_table();
1882 + init_keys(password,s->keys,s->pcrc_32_tab);
1883 + if (ZSEEK(s->z_filefunc, s->filestream,
1884 + s->pfile_in_zip_read->pos_in_zipfile +
1885 + s->pfile_in_zip_read->byte_before_the_zipfile,
1887 + return UNZ_INTERNALERROR;
1888 + if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12)
1889 + return UNZ_INTERNALERROR;
1891 + for (i = 0; i<12; i++)
1892 + zdecode(s->keys,s->pcrc_32_tab,source[i]);
1894 + s->pfile_in_zip_read->pos_in_zipfile+=12;
1900 - s->pfile_in_zip_read = pfile_in_zip_read_info;
1904 +extern int ZEXPORT unzOpenCurrentFile (file)
1907 + return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
1910 +extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
1912 + const char* password;
1914 + return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
1917 +extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
1923 + return unzOpenCurrentFile3(file, method, level, raw, NULL);
1927 Read bytes from the current file.
1928 @@ -994,126 +1222,160 @@
1929 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
1931 extern int ZEXPORT unzReadCurrentFile (file, buf, len)
1939 - file_in_zip_read_info_s* pfile_in_zip_read_info;
1941 - return UNZ_PARAMERROR;
1950 + file_in_zip_read_info_s* pfile_in_zip_read_info;
1952 + return UNZ_PARAMERROR;
1954 pfile_in_zip_read_info=s->pfile_in_zip_read;
1956 - if (pfile_in_zip_read_info==NULL)
1957 - return UNZ_PARAMERROR;
1958 + if (pfile_in_zip_read_info==NULL)
1959 + return UNZ_PARAMERROR;
1962 - if ((pfile_in_zip_read_info->read_buffer == NULL))
1963 - return UNZ_END_OF_LIST_OF_FILE;
1967 - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1969 - pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1971 - if (len>pfile_in_zip_read_info->rest_read_uncompressed)
1972 - pfile_in_zip_read_info->stream.avail_out =
1973 - (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1975 - while (pfile_in_zip_read_info->stream.avail_out>0)
1977 - if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1978 + if ((pfile_in_zip_read_info->read_buffer == NULL))
1979 + return UNZ_END_OF_LIST_OF_FILE;
1983 + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1985 + pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1987 + if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
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_uncompressed;
1992 + if ((len>pfile_in_zip_read_info->rest_read_compressed+
1993 + pfile_in_zip_read_info->stream.avail_in) &&
1994 + (pfile_in_zip_read_info->raw))
1995 + pfile_in_zip_read_info->stream.avail_out =
1996 + (uInt)pfile_in_zip_read_info->rest_read_compressed+
1997 + pfile_in_zip_read_info->stream.avail_in;
1999 + while (pfile_in_zip_read_info->stream.avail_out>0)
2001 + if ((pfile_in_zip_read_info->stream.avail_in==0) &&
2002 (pfile_in_zip_read_info->rest_read_compressed>0))
2004 - uInt uReadThis = UNZ_BUFSIZE;
2005 - if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
2006 - uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
2007 - if (uReadThis == 0)
2009 - if (fseek(pfile_in_zip_read_info->file,
2010 - pfile_in_zip_read_info->pos_in_zipfile +
2011 - pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0)
2013 - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1,
2014 - pfile_in_zip_read_info->file)!=1)
2016 - pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
2018 - pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
2020 - pfile_in_zip_read_info->stream.next_in =
2022 + uInt uReadThis = UNZ_BUFSIZE;
2023 + if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
2024 + uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
2025 + if (uReadThis == 0)
2027 + if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
2028 + pfile_in_zip_read_info->filestream,
2029 + pfile_in_zip_read_info->pos_in_zipfile +
2030 + pfile_in_zip_read_info->byte_before_the_zipfile,
2031 + ZLIB_FILEFUNC_SEEK_SET)!=0)
2033 + if (ZREAD(pfile_in_zip_read_info->z_filefunc,
2034 + pfile_in_zip_read_info->filestream,
2035 + pfile_in_zip_read_info->read_buffer,
2036 + uReadThis)!=uReadThis)
2044 + for(i=0;i<uReadThis;i++)
2045 + pfile_in_zip_read_info->read_buffer[i] =
2046 + zdecode(s->keys,s->pcrc_32_tab,
2047 + pfile_in_zip_read_info->read_buffer[i]);
2052 + pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
2054 + pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
2056 + pfile_in_zip_read_info->stream.next_in =
2057 (Bytef*)pfile_in_zip_read_info->read_buffer;
2058 - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
2060 + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
2063 + if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
2067 + if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
2068 + (pfile_in_zip_read_info->rest_read_compressed == 0))
2069 + return (iRead==0) ? UNZ_EOF : iRead;
2071 - if (pfile_in_zip_read_info->compression_method==0)
2074 - if (pfile_in_zip_read_info->stream.avail_out <
2075 + if (pfile_in_zip_read_info->stream.avail_out <
2076 pfile_in_zip_read_info->stream.avail_in)
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 + uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
2085 + uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
2087 + for (i=0;i<uDoCopy;i++)
2088 + *(pfile_in_zip_read_info->stream.next_out+i) =
2089 *(pfile_in_zip_read_info->stream.next_in+i);
2091 - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
2092 - pfile_in_zip_read_info->stream.next_out,
2094 - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
2095 - pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
2096 - pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
2097 - pfile_in_zip_read_info->stream.next_out += uDoCopy;
2098 - pfile_in_zip_read_info->stream.next_in += uDoCopy;
2100 + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
2101 + pfile_in_zip_read_info->stream.next_out,
2103 + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
2104 + pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
2105 + pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
2106 + pfile_in_zip_read_info->stream.next_out += uDoCopy;
2107 + pfile_in_zip_read_info->stream.next_in += uDoCopy;
2108 pfile_in_zip_read_info->stream.total_out += uDoCopy;
2113 - uLong uTotalOutBefore,uTotalOutAfter;
2114 - const Bytef *bufBefore;
2116 - int flush=Z_SYNC_FLUSH;
2118 - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
2119 - bufBefore = pfile_in_zip_read_info->stream.next_out;
2122 - if ((pfile_in_zip_read_info->rest_read_uncompressed ==
2123 - pfile_in_zip_read_info->stream.avail_out) &&
2124 - (pfile_in_zip_read_info->rest_read_compressed == 0))
2127 - err=inflate(&pfile_in_zip_read_info->stream,flush);
2129 - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
2130 - uOutThis = uTotalOutAfter-uTotalOutBefore;
2132 - pfile_in_zip_read_info->crc32 =
2137 + uLong uTotalOutBefore,uTotalOutAfter;
2138 + const Bytef *bufBefore;
2140 + int flush=Z_SYNC_FLUSH;
2142 + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
2143 + bufBefore = pfile_in_zip_read_info->stream.next_out;
2146 + if ((pfile_in_zip_read_info->rest_read_uncompressed ==
2147 + pfile_in_zip_read_info->stream.avail_out) &&
2148 + (pfile_in_zip_read_info->rest_read_compressed == 0))
2151 + err=inflate(&pfile_in_zip_read_info->stream,flush);
2153 + if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
2154 + err = Z_DATA_ERROR;
2156 + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
2157 + uOutThis = uTotalOutAfter-uTotalOutBefore;
2159 + pfile_in_zip_read_info->crc32 =
2160 crc32(pfile_in_zip_read_info->crc32,bufBefore,
2163 - pfile_in_zip_read_info->rest_read_uncompressed -=
2164 + pfile_in_zip_read_info->rest_read_uncompressed -=
2167 - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
2169 - if (err==Z_STREAM_END)
2170 - return (iRead==0) ? UNZ_EOF : iRead;
2179 + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
2181 + if (err==Z_STREAM_END)
2182 + return (iRead==0) ? UNZ_EOF : iRead;
2194 @@ -1121,42 +1383,42 @@
2195 Give the current position in uncompressed data
2197 extern z_off_t ZEXPORT unztell (file)
2202 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2204 - return UNZ_PARAMERROR;
2207 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2209 + return UNZ_PARAMERROR;
2211 pfile_in_zip_read_info=s->pfile_in_zip_read;
2213 - if (pfile_in_zip_read_info==NULL)
2214 - return UNZ_PARAMERROR;
2215 + if (pfile_in_zip_read_info==NULL)
2216 + return UNZ_PARAMERROR;
2218 - return (z_off_t)pfile_in_zip_read_info->stream.total_out;
2219 + return (z_off_t)pfile_in_zip_read_info->stream.total_out;
2224 - return 1 if the end of file was reached, 0 elsewhere
2225 + return 1 if the end of file was reached, 0 elsewhere
2227 extern int ZEXPORT unzeof (file)
2232 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2234 - return UNZ_PARAMERROR;
2237 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2239 + return UNZ_PARAMERROR;
2241 pfile_in_zip_read_info=s->pfile_in_zip_read;
2243 - if (pfile_in_zip_read_info==NULL)
2244 - return UNZ_PARAMERROR;
2246 - if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2250 + if (pfile_in_zip_read_info==NULL)
2251 + return UNZ_PARAMERROR;
2253 + if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2260 @@ -1169,51 +1431,55 @@
2261 if buf==NULL, it return the size of the local extra field that can be read
2263 if buf!=NULL, len is the size of the buffer, the extra header is copied in
2265 - the return value is the number of bytes copied in buf, or (if <0)
2268 + the return value is the number of bytes copied in buf, or (if <0)
2271 extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
2277 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2279 - uLong size_to_read;
2282 - return UNZ_PARAMERROR;
2289 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2291 + uLong size_to_read;
2294 + return UNZ_PARAMERROR;
2296 pfile_in_zip_read_info=s->pfile_in_zip_read;
2298 - if (pfile_in_zip_read_info==NULL)
2299 - return UNZ_PARAMERROR;
2300 + if (pfile_in_zip_read_info==NULL)
2301 + return UNZ_PARAMERROR;
2303 - size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
2304 - pfile_in_zip_read_info->pos_local_extrafield);
2305 + size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
2306 + pfile_in_zip_read_info->pos_local_extrafield);
2309 - return (int)size_to_read;
2311 - if (len>size_to_read)
2312 - read_now = (uInt)size_to_read;
2314 - read_now = (uInt)len ;
2319 - if (fseek(pfile_in_zip_read_info->file,
2320 - pfile_in_zip_read_info->offset_local_extrafield +
2321 - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0)
2324 + return (int)size_to_read;
2326 - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1)
2328 + if (len>size_to_read)
2329 + read_now = (uInt)size_to_read;
2331 + read_now = (uInt)len ;
2336 - return (int)read_now;
2337 + if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
2338 + pfile_in_zip_read_info->filestream,
2339 + pfile_in_zip_read_info->offset_local_extrafield +
2340 + pfile_in_zip_read_info->pos_local_extrafield,
2341 + ZLIB_FILEFUNC_SEEK_SET)!=0)
2344 + if (ZREAD(pfile_in_zip_read_info->z_filefunc,
2345 + pfile_in_zip_read_info->filestream,
2346 + buf,read_now)!=read_now)
2349 + return (int)read_now;
2353 @@ -1221,39 +1487,40 @@
2354 Return UNZ_CRCERROR if all the file was read but the CRC is not good
2356 extern int ZEXPORT unzCloseCurrentFile (file)
2364 - file_in_zip_read_info_s* pfile_in_zip_read_info;
2366 - return UNZ_PARAMERROR;
2369 + file_in_zip_read_info_s* pfile_in_zip_read_info;
2371 + return UNZ_PARAMERROR;
2373 pfile_in_zip_read_info=s->pfile_in_zip_read;
2375 - if (pfile_in_zip_read_info==NULL)
2376 - return UNZ_PARAMERROR;
2377 + if (pfile_in_zip_read_info==NULL)
2378 + return UNZ_PARAMERROR;
2381 - if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
2383 - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2386 + if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
2387 + (!pfile_in_zip_read_info->raw))
2389 + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
2394 - TRYFREE(pfile_in_zip_read_info->read_buffer);
2395 - pfile_in_zip_read_info->read_buffer = NULL;
2396 - if (pfile_in_zip_read_info->stream_initialised)
2397 - inflateEnd(&pfile_in_zip_read_info->stream);
2398 + TRYFREE(pfile_in_zip_read_info->read_buffer);
2399 + pfile_in_zip_read_info->read_buffer = NULL;
2400 + if (pfile_in_zip_read_info->stream_initialised)
2401 + inflateEnd(&pfile_in_zip_read_info->stream);
2403 - pfile_in_zip_read_info->stream_initialised = 0;
2404 - TRYFREE(pfile_in_zip_read_info);
2405 + pfile_in_zip_read_info->stream_initialised = 0;
2406 + TRYFREE(pfile_in_zip_read_info);
2408 s->pfile_in_zip_read=NULL;
2415 @@ -1263,32 +1530,69 @@
2416 return the number of byte copied or an error code <0
2418 extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
2427 - return UNZ_PARAMERROR;
2430 - uReadThis = uSizeBuf;
2431 - if (uReadThis>s->gi.size_comment)
2432 - uReadThis = s->gi.size_comment;
2441 + return UNZ_PARAMERROR;
2444 - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0)
2446 + uReadThis = uSizeBuf;
2447 + if (uReadThis>s->gi.size_comment)
2448 + uReadThis = s->gi.size_comment;
2451 + if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
2457 - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1)
2459 + if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
2463 - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2464 - *(szComment+s->gi.size_comment)='\0';
2465 - return (int)uReadThis;
2466 + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
2467 + *(szComment+s->gi.size_comment)='\0';
2468 + return (int)uReadThis;
2471 +/* Additions by RX '2004 */
2472 +extern uLong ZEXPORT unzGetOffset (file)
2478 + return UNZ_PARAMERROR;
2480 + if (!s->current_file_ok)
2482 + if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
2483 + if (s->num_file==s->gi.number_entry)
2485 + return s->pos_in_central_dir;
2488 +extern int ZEXPORT unzSetOffset (file, pos)
2496 + return UNZ_PARAMERROR;
2499 + s->pos_in_central_dir = pos;
2500 + s->num_file = s->gi.number_entry; /* hack */
2501 + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
2502 + &s->cur_file_info_internal,
2503 + NULL,0,NULL,0,NULL,0);
2504 + s->current_file_ok = (err == UNZ_OK);
2507 --- misc/zlib-1.1.4/contrib/minizip/unzip.h 1998-03-19 00:15:00.000000000 +0100
2508 +++ misc/build/zlib-1.1.4/contrib/minizip/unzip.h 2009-07-17 10:15:15.609375000 +0200
2510 -/* unzip.h -- IO for uncompress .zip files using zlib
2511 - Version 0.15 beta, Mar 19th, 1998,
2512 +/* unzip.h -- IO for uncompress .zip files using zlib
2513 + Version 1.01e, February 12th, 2005
2515 - Copyright (C) 1998 Gilles Vollant
2516 + Copyright (C) 1998-2005 Gilles Vollant
2518 This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
2519 WinZip, InfoZip tools and compatible.
2520 - Encryption and multi volume ZipFile (span) are not supported.
2522 + Multi volume ZipFile (span) are not supported.
2523 + Encryption compatible with pkzip 2.04g only supported
2524 Old compressions used by old PKZip 1.x are not supported
2526 - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
2527 - CAN CHANGE IN FUTURE VERSION !!
2529 I WAIT FEEDBACK at mail info@winimage.com
2530 Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
2536 -/* for more info about .ZIP format, see
2537 - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
2539 +/* for more info about .ZIP format, see
2540 + http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
2541 + http://www.info-zip.org/pub/infozip/doc/
2542 PkWare has also a specification at :
2543 - ftp://ftp.pkware.com/probdesc.zip */
2544 + ftp://ftp.pkware.com/probdesc.zip
2554 +#include "zlib/zlib.h"
2557 +#ifndef _ZLIBIOAPI_H
2561 #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
2562 /* like the STRICT of WIN32, we define a pointer that cannot be converted
2563 from (void*) without cast */
2564 -typedef struct TagunzFile__ { int unused; } unzFile__;
2565 +typedef struct TagunzFile__ { int unused; } unzFile__;
2566 typedef unzFile__ *unzFile;
2568 typedef voidp unzFile;
2573 -#define UNZ_END_OF_LIST_OF_FILE (-100)
2574 -#define UNZ_ERRNO (Z_ERRNO)
2575 -#define UNZ_EOF (0)
2577 +#define UNZ_END_OF_LIST_OF_FILE (-100)
2578 +#define UNZ_ERRNO (Z_ERRNO)
2579 +#define UNZ_EOF (0)
2580 #define UNZ_PARAMERROR (-102)
2581 #define UNZ_BADZIPFILE (-103)
2582 #define UNZ_INTERNALERROR (-104)
2583 #define UNZ_CRCERROR (-105)
2585 /* tm_unz contain date/time info */
2586 -typedef struct tm_unz_s
2587 +typedef struct tm_unz_s
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] */
2595 + uInt tm_sec; /* seconds after the minute - [0,59] */
2596 + uInt tm_min; /* minutes after the hour - [0,59] */
2597 + uInt tm_hour; /* hours since midnight - [0,23] */
2598 + uInt tm_mday; /* day of the month - [1,31] */
2599 + uInt tm_mon; /* months since January - [0,11] */
2600 + uInt tm_year; /* years - [1980..2044] */
2603 /* unz_global_info structure contain global data about the ZIPfile
2604 These data comes from the end of central dir */
2605 typedef struct unz_global_info_s
2607 - uLong number_entry; /* total number of entries in
2608 - the central dir on this disk */
2609 - uLong size_comment; /* size of the global comment of the zipfile */
2610 + uLong number_entry; /* total number of entries in
2611 + the central dir on this disk */
2612 + uLong size_comment; /* size of the global comment of the zipfile */
2617 uLong compression_method; /* compression method 2 bytes */
2618 uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
2619 uLong crc; /* crc-32 4 bytes */
2620 - uLong compressed_size; /* compressed size 4 bytes */
2621 - uLong uncompressed_size; /* uncompressed size 4 bytes */
2622 + uLong compressed_size; /* compressed size 4 bytes */
2623 + uLong uncompressed_size; /* uncompressed size 4 bytes */
2624 uLong size_filename; /* filename length 2 bytes */
2625 uLong size_file_extra; /* extra field length 2 bytes */
2626 uLong size_file_comment; /* file comment length 2 bytes */
2627 @@ -112,27 +120,34 @@
2630 extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
2631 - const char* fileName2,
2632 - int iCaseSensitivity));
2633 + const char* fileName2,
2634 + int iCaseSensitivity));
2636 Compare two filename (fileName1,fileName2).
2637 If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
2638 If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
2641 If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
2642 - (like 1 on Unix, 2 on Windows)
2643 + (like 1 on Unix, 2 on Windows)
2647 extern unzFile ZEXPORT unzOpen OF((const char *path));
2649 Open a Zip file. path contain the full pathname (by example,
2650 - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
2651 - "zlib/zlib111.zip".
2652 - If the zipfile cannot be opened (file don't exist or in not valid), the
2653 - return value is NULL.
2654 + on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
2655 + "zlib/zlib113.zip".
2656 + If the zipfile cannot be opened (file don't exist or in not valid), the
2657 + return value is NULL.
2658 Else, the return value is a unzFile Handle, usable with other function
2659 - of this unzip package.
2660 + of this unzip package.
2663 +extern unzFile ZEXPORT unzOpen2 OF((const char *path,
2664 + zlib_filefunc_def* pzlib_filefunc_def));
2666 + Open a Zip file, like unzOpen, but provide a set of file low level API
2667 + for read/write the zip file (see ioapi.h)
2670 extern int ZEXPORT unzClose OF((unzFile file));
2672 return UNZ_OK if there is no problem. */
2674 extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
2675 - unz_global_info *pglobal_info));
2676 + unz_global_info *pglobal_info));
2678 Write info about the ZipFile in the *pglobal_info structure.
2679 No preparation of the structure is needed
2683 extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
2689 Get the global comment string of the ZipFile, in the szComment buffer.
2690 uSizeBuf is the size of the szComment buffer.
2692 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
2695 -extern int ZEXPORT unzLocateFile OF((unzFile file,
2696 - const char *szFileName,
2697 - int iCaseSensitivity));
2698 +extern int ZEXPORT unzLocateFile OF((unzFile file,
2699 + const char *szFileName,
2700 + int iCaseSensitivity));
2702 Try locate the file szFileName in the zipfile.
2703 For the iCaseSensitivity signification, see unzStringFileNameCompare
2704 @@ -189,25 +204,44 @@
2708 +/* ****************************************** */
2709 +/* Ryan supplied functions */
2710 +/* unz_file_info contain information about a file in the zipfile */
2711 +typedef struct unz_file_pos_s
2713 + uLong pos_in_zip_directory; /* offset in zip file directory */
2714 + uLong num_of_file; /* # of file */
2717 +extern int ZEXPORT unzGetFilePos(
2719 + unz_file_pos* file_pos);
2721 +extern int ZEXPORT unzGoToFilePos(
2723 + unz_file_pos* file_pos);
2725 +/* ****************************************** */
2727 extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
2728 - unz_file_info *pfile_info,
2730 - uLong fileNameBufferSize,
2732 - uLong extraFieldBufferSize,
2734 - uLong commentBufferSize));
2735 + unz_file_info *pfile_info,
2737 + uLong fileNameBufferSize,
2739 + uLong extraFieldBufferSize,
2741 + uLong commentBufferSize));
2743 Get Info about the current file
2744 if pfile_info!=NULL, the *pfile_info structure will contain somes info about
2747 if szFileName!=NULL, the filemane string will be copied in szFileName
2748 - (fileNameBufferSize is the size of the buffer)
2749 + (fileNameBufferSize is the size of the buffer)
2750 if extraField!=NULL, the extra field information will be copied in extraField
2751 - (extraFieldBufferSize is the size of the buffer).
2752 - This is the Central-header version of the extra field
2753 + (extraFieldBufferSize is the size of the buffer).
2754 + This is the Central-header version of the extra field
2755 if szComment!=NULL, the comment string of the file will be copied in szComment
2756 - (commentBufferSize is the size of the buffer)
2757 + (commentBufferSize is the size of the buffer)
2760 /***************************************************************************/
2761 @@ -221,16 +255,51 @@
2762 If there is no error, the return value is UNZ_OK.
2765 +extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
2766 + const char* password));
2768 + Open for reading data the current file in the zipfile.
2769 + password is a crypting password
2770 + If there is no error, the return value is UNZ_OK.
2773 +extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
2778 + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
2780 + *method will receive method of compression, *level will receive level of
2782 + note : you can set level parameter as NULL (if you did not want known level,
2783 + but you CANNOT set method parameter as NULL
2786 +extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
2790 + const char* password));
2792 + Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
2794 + *method will receive method of compression, *level will receive level of
2796 + note : you can set level parameter as NULL (if you did not want known level,
2797 + but you CANNOT set method parameter as NULL
2801 extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
2803 Close the file in zip opened with unzOpenCurrentFile
2804 Return UNZ_CRCERROR if all the file was read but the CRC is not good
2808 -extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
2811 +extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
2815 Read bytes from the current file (opened by unzOpenCurrentFile)
2816 buf contain buffer where data must be copied
2817 @@ -249,12 +318,12 @@
2819 extern int ZEXPORT unzeof OF((unzFile file));
2821 - return 1 if the end of file was reached, 0 elsewhere
2822 + return 1 if the end of file was reached, 0 elsewhere
2825 extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
2831 Read extra field from the current file (opened by unzOpenCurrentFile)
2832 This is the local-header version of the extra field (sometimes, there is
2833 @@ -263,11 +332,21 @@
2834 if buf==NULL, it return the size of the local extra field
2836 if buf!=NULL, len is the size of the buffer, the extra header is copied in
2838 - the return value is the number of bytes copied in buf, or (if <0)
2841 + the return value is the number of bytes copied in buf, or (if <0)
2845 +/***************************************************************************/
2847 +/* Get the current file offset */
2848 +extern uLong ZEXPORT unzGetOffset (unzFile file);
2850 +/* Set the current file offset */
2851 +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
2858 --- misc/zlib-1.1.4/contrib/minizip/crypt.h 2009-07-17 11:13:37.281250000 +0200
2859 +++ misc/build/zlib-1.1.4/contrib/minizip/crypt.h 2009-07-17 10:58:41.843750000 +0200
2861 +/* crypt.h -- base code for crypt/uncrypt ZIPfile
2864 + Version 1.01e, February 12th, 2005
2866 + Copyright (C) 1998-2005 Gilles Vollant
2868 + This code is a modified version of crypting code in Infozip distribution
2870 + The encryption/decryption parts of this source code (as opposed to the
2871 + non-echoing password parts) were originally written in Europe. The
2872 + whole source package can be freely distributed, including from the USA.
2873 + (Prior to January 2000, re-export from the US was a violation of US law.)
2875 + This encryption code is a direct transcription of the algorithm from
2876 + Roger Schlafly, described by Phil Katz in the file appnote.txt. This
2877 + file (appnote.txt) is distributed with the PKZIP program (even in the
2878 + version without encryption capabilities).
2880 + If you don't need crypting in your application, just define symbols
2881 + NOCRYPT and NOUNCRYPT.
2883 + This code support the "Traditional PKWARE Encryption".
2885 + The new AES encryption added on Zip format by Winzip (see the page
2886 + http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
2887 + Encryption is not supported.
2890 +#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
2892 +/***********************************************************************
2893 + * Return the next byte in the pseudo-random sequence
2895 +static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
2897 + unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
2898 + * unpredictable manner on 16-bit systems; not a problem
2899 + * with any known compiler so far, though */
2901 + temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
2902 + return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
2905 +/***********************************************************************
2906 + * Update the encryption keys with the next byte of plain text
2908 +static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
2910 + (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
2911 + (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
2912 + (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
2914 + register int keyshift = (int)((*(pkeys+1)) >> 24);
2915 + (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
2921 +/***********************************************************************
2922 + * Initialize the encryption keys and the random header according to
2923 + * the given password.
2925 +static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
2927 + *(pkeys+0) = 305419896L;
2928 + *(pkeys+1) = 591751049L;
2929 + *(pkeys+2) = 878082192L;
2930 + while (*passwd != '\0') {
2931 + update_keys(pkeys,pcrc_32_tab,(int)*passwd);
2936 +#define zdecode(pkeys,pcrc_32_tab,c) \
2937 + (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
2939 +#define zencode(pkeys,pcrc_32_tab,c,t) \
2940 + (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
2942 +#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
2944 +#define RAND_HEAD_LEN 12
2945 + /* "last resort" source for second part of crypt seed pattern */
2947 +# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
2950 +static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
2951 + const char *passwd; /* password string */
2952 + unsigned char *buf; /* where to write header */
2954 + unsigned long* pkeys;
2955 + const unsigned long* pcrc_32_tab;
2956 + unsigned long crcForCrypting;
2958 + int n; /* index in random header */
2959 + int t; /* temporary */
2960 + int c; /* random byte */
2961 + unsigned char header[RAND_HEAD_LEN-2]; /* random header */
2962 + static unsigned calls = 0; /* ensure different random header each time */
2964 + if (bufSize<RAND_HEAD_LEN)
2967 + /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
2968 + * output of rand() to get less predictability, since rand() is
2969 + * often poorly implemented.
2973 + srand((unsigned)(time(NULL) ^ ZCR_SEED2));
2975 + init_keys(passwd, pkeys, pcrc_32_tab);
2976 + for (n = 0; n < RAND_HEAD_LEN-2; n++)
2978 + c = (rand() >> 7) & 0xff;
2979 + header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
2981 + /* Encrypt random header (last two bytes is high word of crc) */
2982 + init_keys(passwd, pkeys, pcrc_32_tab);
2983 + for (n = 0; n < RAND_HEAD_LEN-2; n++)
2985 + buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
2987 + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
2988 + buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
2993 --- misc/zlib-1.1.4/contrib/minizip/ioapi.c 2009-07-17 11:13:18.593750000 +0200
2994 +++ misc/build/zlib-1.1.4/contrib/minizip/ioapi.c 2009-07-17 10:58:56.718750000 +0200
2996 +/* ioapi.c -- IO base function header for compress/uncompress .zip
2997 + files using zlib + zip or unzip API
2999 + Version 1.01e, February 12th, 2005
3001 + Copyright (C) 1998-2005 Gilles Vollant
3005 +#include <stdlib.h>
3006 +#include <string.h>
3013 +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
3027 +voidpf ZCALLBACK fopen_file_func OF((
3029 + const char* filename,
3032 +uLong ZCALLBACK fread_file_func OF((
3038 +uLong ZCALLBACK fwrite_file_func OF((
3044 +long ZCALLBACK ftell_file_func OF((
3048 +long ZCALLBACK fseek_file_func OF((
3054 +int ZCALLBACK fclose_file_func OF((
3058 +int ZCALLBACK ferror_file_func OF((
3063 +voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
3065 + const char* filename;
3068 + FILE* file = NULL;
3069 + const char* mode_fopen = NULL;
3070 + if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
3071 + mode_fopen = "rb";
3073 + if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
3074 + mode_fopen = "r+b";
3076 + if (mode & ZLIB_FILEFUNC_MODE_CREATE)
3077 + mode_fopen = "wb";
3079 + if ((filename!=NULL) && (mode_fopen != NULL))
3080 + file = fopen(filename, mode_fopen);
3085 +uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
3092 + ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
3097 +uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
3104 + ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
3108 +long ZCALLBACK ftell_file_func (opaque, stream)
3113 + ret = ftell((FILE *)stream);
3117 +long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
3123 + int fseek_origin=0;
3127 + case ZLIB_FILEFUNC_SEEK_CUR :
3128 + fseek_origin = SEEK_CUR;
3130 + case ZLIB_FILEFUNC_SEEK_END :
3131 + fseek_origin = SEEK_END;
3133 + case ZLIB_FILEFUNC_SEEK_SET :
3134 + fseek_origin = SEEK_SET;
3136 + default: return -1;
3139 + fseek((FILE *)stream, offset, fseek_origin);
3143 +int ZCALLBACK fclose_file_func (opaque, stream)
3148 + ret = fclose((FILE *)stream);
3152 +int ZCALLBACK ferror_file_func (opaque, stream)
3157 + ret = ferror((FILE *)stream);
3161 +void fill_fopen_filefunc (pzlib_filefunc_def)
3162 + zlib_filefunc_def* pzlib_filefunc_def;
3164 + pzlib_filefunc_def->zopen_file = fopen_file_func;
3165 + pzlib_filefunc_def->zread_file = fread_file_func;
3166 + pzlib_filefunc_def->zwrite_file = fwrite_file_func;
3167 + pzlib_filefunc_def->ztell_file = ftell_file_func;
3168 + pzlib_filefunc_def->zseek_file = fseek_file_func;
3169 + pzlib_filefunc_def->zclose_file = fclose_file_func;
3170 + pzlib_filefunc_def->zerror_file = ferror_file_func;
3171 + pzlib_filefunc_def->opaque = NULL;
3173 --- misc/zlib-1.1.4/contrib/minizip/ioapi.h 2009-07-17 11:13:30.109375000 +0200
3174 +++ misc/build/zlib-1.1.4/contrib/minizip/ioapi.h 2009-07-17 10:59:06.375000000 +0200
3176 +/* ioapi.h -- IO base function header for compress/uncompress .zip
3177 + files using zlib + zip or unzip API
3179 + Version 1.01e, February 12th, 2005
3181 + Copyright (C) 1998-2005 Gilles Vollant
3184 +#ifndef _ZLIBIOAPI_H
3185 +#define _ZLIBIOAPI_H
3188 +#define ZLIB_FILEFUNC_SEEK_CUR (1)
3189 +#define ZLIB_FILEFUNC_SEEK_END (2)
3190 +#define ZLIB_FILEFUNC_SEEK_SET (0)
3192 +#define ZLIB_FILEFUNC_MODE_READ (1)
3193 +#define ZLIB_FILEFUNC_MODE_WRITE (2)
3194 +#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
3196 +#define ZLIB_FILEFUNC_MODE_EXISTING (4)
3197 +#define ZLIB_FILEFUNC_MODE_CREATE (8)
3202 +#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
3203 +#define ZCALLBACK CALLBACK
3213 +typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
3214 +typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
3215 +typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
3216 +typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
3217 +typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
3218 +typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
3219 +typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
3221 +typedef struct zlib_filefunc_def_s
3223 + open_file_func zopen_file;
3224 + read_file_func zread_file;
3225 + write_file_func zwrite_file;
3226 + tell_file_func ztell_file;
3227 + seek_file_func zseek_file;
3228 + close_file_func zclose_file;
3229 + testerror_file_func zerror_file;
3231 +} zlib_filefunc_def;
3235 +void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
3237 +#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
3238 +#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
3239 +#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
3240 +#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
3241 +#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
3242 +#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))