ReactOS  0.4.12-dev-396-g37af787
zip.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "zlib.h"
#include "zip.h"
#include <errno.h>
#include "crypt.h"
Include dependency graph for zip.c:

Go to the source code of this file.

Classes

struct  linkedlist_datablock_internal_s
 
struct  linkedlist_data_s
 
struct  curfile64_info
 
struct  zip64_internal
 

Macros

#define local   static
 
#define VERSIONMADEBY   (0x0) /* platform depedent */
 
#define Z_BUFSIZE   (64*1024)
 
#define Z_MAXFILENAMEINZIP   (256)
 
#define ALLOC(size)   (malloc(size))
 
#define TRYFREE(p)   {if (p) free(p);}
 
#define MAKEULONG64(a, b)   ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define SEEK_SET   0
 
#define SIZEDATA_INDATABLOCK   (4096-(4*4))
 
#define LOCALHEADERMAGIC   (0x04034b50)
 
#define CENTRALHEADERMAGIC   (0x02014b50)
 
#define ENDHEADERMAGIC   (0x06054b50)
 
#define ZIP64ENDHEADERMAGIC   (0x6064b50)
 
#define ZIP64ENDLOCHEADERMAGIC   (0x7064b50)
 
#define FLAG_LOCALHEADER_OFFSET   (0x06)
 
#define CRC_LOCALHEADER_OFFSET   (0x0e)
 
#define SIZECENTRALHEADER   (0x2e) /* 46 */
 
#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
 
#define BUFREADCOMMENT   (0x400)
 

Typedefs

typedef struct linkedlist_datablock_internal_s linkedlist_datablock_internal
 
typedef struct linkedlist_data_s linkedlist_data
 

Functions

linkedlist_datablock_internalallocate_new_datablock ()
 
void free_datablock (linkedlist_datablock_internal *ldi)
 
void init_linkedlist (linkedlist_data *ll)
 
void free_linkedlist (linkedlist_data *ll)
 
int add_data_in_datablock (linkedlist_data *ll, const void *buf, uLong len)
 
int zip64local_putValue OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte))
 
int zip64local_putValue (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
 
void zip64local_putValue_inmemory OF ((void *dest, ZPOS64_T x, int nbByte))
 
void zip64local_putValue_inmemory (void *dest, ZPOS64_T x, int nbByte)
 
uLong zip64local_TmzDateToDosDate (const tm_zip *ptm)
 
int zip64local_getByte OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi))
 
int zip64local_getByte (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
 
int zip64local_getShort OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX))
 
int zip64local_getShort (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
int zip64local_getLong (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
int zip64local_getLong64 OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX))
 
int zip64local_getLong64 (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
 
ZPOS64_T zip64local_SearchCentralDir OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream))
 
ZPOS64_T zip64local_SearchCentralDir (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
 
ZPOS64_T zip64local_SearchCentralDir64 (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
 
int LoadCentralDirectoryRecord (zip64_internal *pziinit)
 
zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
 
zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc32_def)
 
zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
 
zipFile ZEXPORT zipOpen (const char *pathname, int append)
 
zipFile ZEXPORT zipOpen64 (const void *pathname, int append)
 
int Write_LocalFileHeader (zip64_internal *zi, const char *filename, uInt size_extrafield_local, const void *extrafield_local)
 
int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
 
int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase)
 
int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting)
 
int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, int zip64)
 
int ZEXPORT zipOpenNewFileInZip2 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw)
 
int ZEXPORT zipOpenNewFileInZip2_64 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int zip64)
 
int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int zip64)
 
int ZEXPORT zipOpenNewFileInZip (zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level)
 
int zip64FlushWriteBuffer (zip64_internal *zi)
 
int ZEXPORT zipWriteInFileInZip (zipFile file, const void *buf, unsigned int len)
 
int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32)
 
int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
 
int ZEXPORT zipCloseFileInZip (zipFile file)
 
int Write_Zip64EndOfCentralDirectoryLocator (zip64_internal *zi, ZPOS64_T zip64eocd_pos_inzip)
 
int Write_Zip64EndOfCentralDirectoryRecord (zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
 
int Write_EndOfCentralDirectoryRecord (zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
 
int Write_GlobalComment (zip64_internal *zi, const char *global_comment)
 
int ZEXPORT zipClose (zipFile file, const char *global_comment)
 
int ZEXPORT zipRemoveExtraInfoBlock (char *pData, int *dataLen, short sHeader)
 

Variables

const char zip_copyright [] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"
 

Macro Definition Documentation

◆ ALLOC

#define ALLOC (   size)    (malloc(size))

Definition at line 62 of file zip.c.

◆ BUFREADCOMMENT

#define BUFREADCOMMENT   (0x400)

Definition at line 472 of file zip.c.

◆ CENTRALHEADERMAGIC

#define CENTRALHEADERMAGIC   (0x02014b50)

Definition at line 104 of file zip.c.

◆ CRC_LOCALHEADER_OFFSET

#define CRC_LOCALHEADER_OFFSET   (0x0e)

Definition at line 110 of file zip.c.

◆ ENDHEADERMAGIC

#define ENDHEADERMAGIC   (0x06054b50)

Definition at line 105 of file zip.c.

◆ FLAG_LOCALHEADER_OFFSET

#define FLAG_LOCALHEADER_OFFSET   (0x06)

Definition at line 109 of file zip.c.

◆ INCLUDECRYPTINGCODE_IFCRYPTALLOWED

#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED

Definition at line 185 of file zip.c.

◆ local

#define local   static

Definition at line 45 of file zip.c.

◆ LOCALHEADERMAGIC

#define LOCALHEADERMAGIC   (0x04034b50)

Definition at line 103 of file zip.c.

◆ MAKEULONG64

#define MAKEULONG64 (   a,
  b 
)    ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))

Definition at line 77 of file zip.c.

◆ SEEK_CUR

#define SEEK_CUR   1

Definition at line 80 of file zip.c.

◆ SEEK_END

#define SEEK_END   2

Definition at line 84 of file zip.c.

◆ SEEK_SET

#define SEEK_SET   0

Definition at line 88 of file zip.c.

◆ SIZECENTRALHEADER

#define SIZECENTRALHEADER   (0x2e) /* 46 */

Definition at line 112 of file zip.c.

◆ SIZEDATA_INDATABLOCK

#define SIZEDATA_INDATABLOCK   (4096-(4*4))

Definition at line 101 of file zip.c.

◆ TRYFREE

#define TRYFREE (   p)    {if (p) free(p);}

Definition at line 65 of file zip.c.

◆ VERSIONMADEBY

#define VERSIONMADEBY   (0x0) /* platform depedent */

Definition at line 50 of file zip.c.

◆ Z_BUFSIZE

#define Z_BUFSIZE   (64*1024)

Definition at line 54 of file zip.c.

◆ Z_MAXFILENAMEINZIP

#define Z_MAXFILENAMEINZIP   (256)

Definition at line 58 of file zip.c.

◆ ZIP64ENDHEADERMAGIC

#define ZIP64ENDHEADERMAGIC   (0x6064b50)

Definition at line 106 of file zip.c.

◆ ZIP64ENDLOCHEADERMAGIC

#define ZIP64ENDLOCHEADERMAGIC   (0x7064b50)

Definition at line 107 of file zip.c.

Typedef Documentation

◆ linkedlist_data

◆ linkedlist_datablock_internal

Function Documentation

◆ add_data_in_datablock()

int add_data_in_datablock ( linkedlist_data ll,
const void buf,
uLong  len 
)

Definition at line 225 of file zip.c.

226 {
228  const unsigned char* from_copy;
229 
230  if (ll==NULL)
231  return ZIP_INTERNALERROR;
232 
233  if (ll->last_block == NULL)
234  {
235  ll->first_block = ll->last_block = allocate_new_datablock();
236  if (ll->first_block == NULL)
237  return ZIP_INTERNALERROR;
238  }
239 
240  ldi = ll->last_block;
241  from_copy = (unsigned char*)buf;
242 
243  while (len>0)
244  {
245  uInt copy_this;
246  uInt i;
247  unsigned char* to_copy;
248 
249  if (ldi->avail_in_this_block==0)
250  {
252  if (ldi->next_datablock == NULL)
253  return ZIP_INTERNALERROR;
254  ldi = ldi->next_datablock ;
255  ll->last_block = ldi;
256  }
257 
258  if (ldi->avail_in_this_block < len)
259  copy_this = (uInt)ldi->avail_in_this_block;
260  else
261  copy_this = (uInt)len;
262 
263  to_copy = &(ldi->data[ldi->filled_in_this_block]);
264 
265  for (i=0;i<copy_this;i++)
266  *(to_copy+i)=*(from_copy+i);
267 
268  ldi->filled_in_this_block += copy_this;
269  ldi->avail_in_this_block -= copy_this;
270  from_copy += copy_this ;
271  len -= copy_this;
272  }
273  return ZIP_OK;
274 }
#define ZIP_OK
Definition: zip.h:72
#define ZIP_INTERNALERROR
Definition: zip.h:77
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned char data[SIZEDATA_INDATABLOCK]
Definition: zip.c:120
struct linkedlist_datablock_internal_s * next_datablock
Definition: zip.c:116
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
linkedlist_datablock_internal * allocate_new_datablock()
Definition: zip.c:189
w ll
Definition: byte_order.h:166
unsigned int uInt
Definition: zconf.h:393

Referenced by LoadCentralDirectoryRecord(), and zipCloseFileInZipRaw64().

◆ allocate_new_datablock()

linkedlist_datablock_internal* allocate_new_datablock ( )

Definition at line 189 of file zip.c.

190 {
194  if (ldi!=NULL)
195  {
196  ldi->next_datablock = NULL ;
197  ldi->filled_in_this_block = 0 ;
199  }
200  return ldi;
201 }
#define SIZEDATA_INDATABLOCK
Definition: zip.c:101
struct linkedlist_datablock_internal_s * next_datablock
Definition: zip.c:116
smooth NULL
Definition: ftsmooth.c:416
#define ALLOC(size)
Definition: zip.c:62

Referenced by add_data_in_datablock().

◆ free_datablock()

void free_datablock ( linkedlist_datablock_internal ldi)

Definition at line 203 of file zip.c.

204 {
205  while (ldi!=NULL)
206  {
208  TRYFREE(ldi);
209  ldi = ldinext;
210  }
211 }
struct linkedlist_datablock_internal_s * next_datablock
Definition: zip.c:116
smooth NULL
Definition: ftsmooth.c:416
#define TRYFREE(p)
Definition: zip.c:65

Referenced by free_linkedlist().

◆ free_linkedlist()

void free_linkedlist ( linkedlist_data ll)

Definition at line 218 of file zip.c.

219 {
220  free_datablock(ll->first_block);
221  ll->first_block = ll->last_block = NULL;
222 }
void free_datablock(linkedlist_datablock_internal *ldi)
Definition: zip.c:203
smooth NULL
Definition: ftsmooth.c:416
w ll
Definition: byte_order.h:166

Referenced by zipClose().

◆ init_linkedlist()

void init_linkedlist ( linkedlist_data ll)

Definition at line 213 of file zip.c.

214 {
215  ll->first_block = ll->last_block = NULL;
216 }
smooth NULL
Definition: ftsmooth.c:416
w ll
Definition: byte_order.h:166

Referenced by zipOpen3().

◆ LoadCentralDirectoryRecord()

int LoadCentralDirectoryRecord ( zip64_internal pziinit)

Definition at line 640 of file zip.c.

641 {
642  int err=ZIP_OK;
643  ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
644 
645  ZPOS64_T size_central_dir; /* size of the central directory */
646  ZPOS64_T offset_central_dir; /* offset of start of central directory */
647  ZPOS64_T central_pos;
648  uLong uL;
649 
650  uLong number_disk; /* number of the current dist, used for
651  spaning ZIP, unsupported, always 0*/
652  uLong number_disk_with_CD; /* number the the disk with central dir, used
653  for spaning ZIP, unsupported, always 0*/
654  ZPOS64_T number_entry;
655  ZPOS64_T number_entry_CD; /* total number of entries in
656  the central dir
657  (same than number_entry on nospan) */
658  uLong VersionMadeBy;
659  uLong VersionNeeded;
660  uLong size_comment;
661 
662  int hasZIP64Record = 0;
663 
664  // check first if we find a ZIP64 record
665  central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);
666  if(central_pos > 0)
667  {
668  hasZIP64Record = 1;
669  }
670  else if(central_pos == 0)
671  {
672  central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream);
673  }
674 
675 /* disable to allow appending to empty ZIP archive
676  if (central_pos==0)
677  err=ZIP_ERRNO;
678 */
679 
680  if(hasZIP64Record)
681  {
682  ZPOS64_T sizeEndOfCentralDirectory;
683  if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0)
684  err=ZIP_ERRNO;
685 
686  /* the signature, already checked */
687  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK)
688  err=ZIP_ERRNO;
689 
690  /* size of zip64 end of central directory record */
691  if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK)
692  err=ZIP_ERRNO;
693 
694  /* version made by */
695  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK)
696  err=ZIP_ERRNO;
697 
698  /* version needed to extract */
699  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionNeeded)!=ZIP_OK)
700  err=ZIP_ERRNO;
701 
702  /* number of this disk */
703  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK)
704  err=ZIP_ERRNO;
705 
706  /* number of the disk with the start of the central directory */
707  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK)
708  err=ZIP_ERRNO;
709 
710  /* total number of entries in the central directory on this disk */
711  if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &number_entry)!=ZIP_OK)
712  err=ZIP_ERRNO;
713 
714  /* total number of entries in the central directory */
715  if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&number_entry_CD)!=ZIP_OK)
716  err=ZIP_ERRNO;
717 
718  if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))
720 
721  /* size of the central directory */
722  if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&size_central_dir)!=ZIP_OK)
723  err=ZIP_ERRNO;
724 
725  /* offset of start of central directory with respect to the
726  starting disk number */
727  if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)
728  err=ZIP_ERRNO;
729 
730  // TODO..
731  // read the comment from the standard central header.
732  size_comment = 0;
733  }
734  else
735  {
736  // Read End of central Directory info
737  if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
738  err=ZIP_ERRNO;
739 
740  /* the signature, already checked */
741  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK)
742  err=ZIP_ERRNO;
743 
744  /* number of this disk */
745  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK)
746  err=ZIP_ERRNO;
747 
748  /* number of the disk with the start of the central directory */
749  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK)
750  err=ZIP_ERRNO;
751 
752  /* total number of entries in the central dir on this disk */
753  number_entry = 0;
754  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)
755  err=ZIP_ERRNO;
756  else
757  number_entry = uL;
758 
759  /* total number of entries in the central dir */
760  number_entry_CD = 0;
761  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)
762  err=ZIP_ERRNO;
763  else
764  number_entry_CD = uL;
765 
766  if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0))
768 
769  /* size of the central directory */
770  size_central_dir = 0;
771  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)
772  err=ZIP_ERRNO;
773  else
774  size_central_dir = uL;
775 
776  /* offset of start of central directory with respect to the starting disk number */
777  offset_central_dir = 0;
778  if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK)
779  err=ZIP_ERRNO;
780  else
781  offset_central_dir = uL;
782 
783 
784  /* zipfile global comment length */
785  if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &size_comment)!=ZIP_OK)
786  err=ZIP_ERRNO;
787  }
788 
789  if ((central_pos<offset_central_dir+size_central_dir) &&
790  (err==ZIP_OK))
792 
793  if (err!=ZIP_OK)
794  {
795  ZCLOSE64(pziinit->z_filefunc, pziinit->filestream);
796  return ZIP_ERRNO;
797  }
798 
799  if (size_comment>0)
800  {
801  pziinit->globalcomment = (char*)ALLOC(size_comment+1);
802  if (pziinit->globalcomment)
803  {
804  size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit->globalcomment,size_comment);
805  pziinit->globalcomment[size_comment]=0;
806  }
807  }
808 
809  byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);
810  pziinit->add_position_when_writing_offset = byte_before_the_zipfile;
811 
812  {
813  ZPOS64_T size_central_dir_to_read = size_central_dir;
814  size_t buf_size = SIZEDATA_INDATABLOCK;
815  void* buf_read = (void*)ALLOC(buf_size);
816  if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)
817  err=ZIP_ERRNO;
818 
819  while ((size_central_dir_to_read>0) && (err==ZIP_OK))
820  {
821  ZPOS64_T read_this = SIZEDATA_INDATABLOCK;
822  if (read_this > size_central_dir_to_read)
823  read_this = size_central_dir_to_read;
824 
825  if (ZREAD64(pziinit->z_filefunc, pziinit->filestream,buf_read,(uLong)read_this) != read_this)
826  err=ZIP_ERRNO;
827 
828  if (err==ZIP_OK)
829  err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this);
830 
831  size_central_dir_to_read-=read_this;
832  }
833  TRYFREE(buf_read);
834  }
835  pziinit->begin_pos = byte_before_the_zipfile;
836  pziinit->number_entry = number_entry_CD;
837 
838  if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0)
839  err=ZIP_ERRNO;
840 
841  return err;
842 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
ssize_t buf_read(int, void *, size_t)
voidpf filestream
Definition: zip.c:168
#define SIZEDATA_INDATABLOCK
Definition: zip.c:101
int zip64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
Definition: zip.c:426
linkedlist_data central_dir
Definition: zip.c:169
char * globalcomment
Definition: zip.c:178
int zip64local_getShort(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
Definition: zip.c:373
#define ZIP_BADZIPFILE
Definition: zip.h:76
#define ZCLOSE64(filefunc, filestream)
Definition: ioapi.h:191
unsigned long uLong
Definition: zconf.h:394
#define ZREAD64(filefunc, filestream, buf, size)
Definition: ioapi.h:187
ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
Definition: zip.c:480
#define TRYFREE(p)
Definition: zip.c:65
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
int add_data_in_datablock(linkedlist_data *ll, const void *buf, uLong len)
Definition: zip.c:225
int zip64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
Definition: zip.c:395
#define ALLOC(size)
Definition: zip.c:62
ZPOS64_T begin_pos
Definition: zip.c:173
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition: ioapi.h:202
ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
Definition: zip.c:542
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114

Referenced by zipOpen3().

◆ OF() [1/6]

int zip64local_putValue OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)  )

◆ OF() [2/6]

◆ OF() [3/6]

int zip64local_getByte OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi )

◆ OF() [4/6]

int zip64local_getShort OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)  )

◆ OF() [5/6]

int zip64local_getLong64 OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)  )

◆ OF() [6/6]

ZPOS64_T zip64local_SearchCentralDir OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)  )

◆ Write_EndOfCentralDirectoryRecord()

int Write_EndOfCentralDirectoryRecord ( zip64_internal zi,
uLong  size_centraldir,
ZPOS64_T  centraldir_pos_inzip 
)

Definition at line 1821 of file zip.c.

1822 {
1823  int err = ZIP_OK;
1824 
1825  /*signature*/
1827 
1828  if (err==ZIP_OK) /* number of this disk */
1830 
1831  if (err==ZIP_OK) /* number of the disk with the start of the central directory */
1833 
1834  if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
1835  {
1836  {
1837  if(zi->number_entry >= 0xFFFF)
1838  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
1839  else
1841  }
1842  }
1843 
1844  if (err==ZIP_OK) /* total number of entries in the central dir */
1845  {
1846  if(zi->number_entry >= 0xFFFF)
1847  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
1848  else
1850  }
1851 
1852  if (err==ZIP_OK) /* size of the central directory */
1853  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4);
1854 
1855  if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
1856  {
1857  ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
1858  if(pos >= 0xffffffff)
1859  {
1860  err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
1861  }
1862  else
1863  err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4);
1864  }
1865 
1866  return err;
1867 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
voidpf filestream
Definition: zip.c:168
#define ENDHEADERMAGIC
Definition: zip.c:105
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
unsigned long uLong
Definition: zconf.h:394
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167

Referenced by zipClose().

◆ Write_GlobalComment()

int Write_GlobalComment ( zip64_internal zi,
const char global_comment 
)

Definition at line 1869 of file zip.c.

1870 {
1871  int err = ZIP_OK;
1872  uInt size_global_comment = 0;
1873 
1874  if(global_comment != NULL)
1875  size_global_comment = (uInt)strlen(global_comment);
1876 
1877  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2);
1878 
1879  if (err == ZIP_OK && size_global_comment > 0)
1880  {
1881  if (ZWRITE64(zi->z_filefunc,zi->filestream, global_comment, size_global_comment) != size_global_comment)
1882  err = ZIP_ERRNO;
1883  }
1884  return err;
1885 }
#define ZIP_OK
Definition: zip.h:72
voidpf filestream
Definition: zip.c:168
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
smooth NULL
Definition: ftsmooth.c:416
unsigned long uLong
Definition: zconf.h:394
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188
unsigned int uInt
Definition: zconf.h:393

Referenced by zipClose().

◆ Write_LocalFileHeader()

int Write_LocalFileHeader ( zip64_internal zi,
const char filename,
uInt  size_extrafield_local,
const void extrafield_local 
)

Definition at line 963 of file zip.c.

964 {
965  /* write the local header */
966  int err;
967  uInt size_filename = (uInt)strlen(filename);
968  uInt size_extrafield = size_extrafield_local;
969 
971 
972  if (err==ZIP_OK)
973  {
974  if(zi->ci.zip64)
975  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */
976  else
977  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */
978  }
979 
980  if (err==ZIP_OK)
982 
983  if (err==ZIP_OK)
985 
986  if (err==ZIP_OK)
988 
989  // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later
990  if (err==ZIP_OK)
991  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
992  if (err==ZIP_OK)
993  {
994  if(zi->ci.zip64)
995  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */
996  else
997  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */
998  }
999  if (err==ZIP_OK)
1000  {
1001  if(zi->ci.zip64)
1002  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */
1003  else
1004  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */
1005  }
1006 
1007  if (err==ZIP_OK)
1008  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2);
1009 
1010  if(zi->ci.zip64)
1011  {
1012  size_extrafield += 20;
1013  }
1014 
1015  if (err==ZIP_OK)
1016  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2);
1017 
1018  if ((err==ZIP_OK) && (size_filename > 0))
1019  {
1020  if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename)
1021  err = ZIP_ERRNO;
1022  }
1023 
1024  if ((err==ZIP_OK) && (size_extrafield_local > 0))
1025  {
1026  if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local)
1027  err = ZIP_ERRNO;
1028  }
1029 
1030 
1031  if ((err==ZIP_OK) && (zi->ci.zip64))
1032  {
1033  // write the Zip64 extended info
1034  short HeaderID = 1;
1035  short DataSize = 16;
1036  ZPOS64_T CompressedSize = 0;
1037  ZPOS64_T UncompressedSize = 0;
1038 
1039  // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
1041 
1042  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)HeaderID,2);
1043  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (short)DataSize,2);
1044 
1045  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8);
1046  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8);
1047  }
1048 
1049  return err;
1050 }
#define ZIP_OK
Definition: zip.h:72
voidpf filestream
Definition: zip.c:168
#define LOCALHEADERMAGIC
Definition: zip.c:103
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const char * filename
Definition: ioapi.h:135
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
int zip64
Definition: zip.c:154
unsigned long uLong
Definition: zconf.h:394
curfile64_info ci
Definition: zip.c:171
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
ZPOS64_T pos_zip64extrainfo
Definition: zip.c:155
uLong dosDate
Definition: zip.c:151
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4733
uLong flag
Definition: zip.c:146
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188
unsigned int uInt
Definition: zconf.h:393
int method
Definition: zip.c:148

Referenced by zipOpenNewFileInZip4_64().

◆ Write_Zip64EndOfCentralDirectoryLocator()

int Write_Zip64EndOfCentralDirectoryLocator ( zip64_internal zi,
ZPOS64_T  zip64eocd_pos_inzip 
)

Definition at line 1760 of file zip.c.

1761 {
1762  int err = ZIP_OK;
1763  ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
1764 
1766 
1767  /*num disks*/
1768  if (err==ZIP_OK) /* number of the disk with the start of the central directory */
1770 
1771  /*relative offset*/
1772  if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */
1774 
1775  /*total disks*/ /* Do not support spawning of disk so always say 1 here*/
1776  if (err==ZIP_OK) /* number of the disk with the start of the central directory */
1778 
1779  return err;
1780 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
#define ZIP64ENDLOCHEADERMAGIC
Definition: zip.c:107
voidpf filestream
Definition: zip.c:168
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
unsigned long uLong
Definition: zconf.h:394
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167

Referenced by zipClose().

◆ Write_Zip64EndOfCentralDirectoryRecord()

int Write_Zip64EndOfCentralDirectoryRecord ( zip64_internal zi,
uLong  size_centraldir,
ZPOS64_T  centraldir_pos_inzip 
)

Definition at line 1782 of file zip.c.

1783 {
1784  int err = ZIP_OK;
1785 
1786  uLong Zip64DataSize = 44;
1787 
1789 
1790  if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */
1791  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ?
1792 
1793  if (err==ZIP_OK) /* version made by */
1795 
1796  if (err==ZIP_OK) /* version needed */
1798 
1799  if (err==ZIP_OK) /* number of this disk */
1801 
1802  if (err==ZIP_OK) /* number of the disk with the start of the central directory */
1804 
1805  if (err==ZIP_OK) /* total number of entries in the central dir on this disk */
1807 
1808  if (err==ZIP_OK) /* total number of entries in the central dir */
1810 
1811  if (err==ZIP_OK) /* size of the central directory */
1812  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_centraldir,8);
1813 
1814  if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */
1815  {
1816  ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
1818  }
1819  return err;
1820 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
voidpf filestream
Definition: zip.c:168
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
unsigned long uLong
Definition: zconf.h:394
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZIP64ENDHEADERMAGIC
Definition: zip.c:106
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167

Referenced by zipClose().

◆ zip64FlushWriteBuffer()

int zip64FlushWriteBuffer ( zip64_internal zi)

Definition at line 1368 of file zip.c.

1369 {
1370  int err=ZIP_OK;
1371 
1372  if (zi->ci.encrypt != 0)
1373  {
1374 #ifndef NOCRYPT
1375  uInt i;
1376  int t;
1377  for (i=0;i<zi->ci.pos_in_buffered_data;i++)
1378  zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t);
1379 #endif
1380  }
1381 
1383  err = ZIP_ERRNO;
1384 
1386 
1387 #ifdef HAVE_BZIP2
1388  if(zi->ci.method == Z_BZIP2ED)
1389  {
1390  zi->ci.totalUncompressedData += zi->ci.bstream.total_in_lo32;
1391  zi->ci.bstream.total_in_lo32 = 0;
1392  zi->ci.bstream.total_in_hi32 = 0;
1393  }
1394  else
1395 #endif
1396  {
1398  zi->ci.stream.total_in = 0;
1399  }
1400 
1401 
1402  zi->ci.pos_in_buffered_data = 0;
1403 
1404  return err;
1405 }
#define ZIP_OK
Definition: zip.h:72
voidpf filestream
Definition: zip.c:168
#define zencode(pkeys, pcrc_32_tab, c, t)
Definition: crypt.h:79
z_stream stream
Definition: zip.c:132
GLdouble GLdouble t
Definition: gl.h:2047
const z_crc_t * pcrc_32_tab
Definition: zip.c:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uInt pos_in_buffered_data
Definition: zip.c:138
#define Z_BZIP2ED
Definition: unzip.h:62
unsigned long keys[3]
Definition: zip.c:159
Byte buffered_data[Z_BUFSIZE]
Definition: zip.c:150
curfile64_info ci
Definition: zip.c:171
uLong total_in
Definition: zlib.h:89
ZPOS64_T totalUncompressedData
Definition: zip.c:157
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
ZPOS64_T totalCompressedData
Definition: zip.c:156
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188
unsigned int uInt
Definition: zconf.h:393
int encrypt
Definition: zip.c:153
int method
Definition: zip.c:148

Referenced by zipCloseFileInZipRaw64(), and zipWriteInFileInZip().

◆ zip64local_getByte()

int zip64local_getByte ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream,
int pi 
)

Definition at line 349 of file zip.c.

350 {
351  unsigned char c;
352  int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1);
353  if (err==1)
354  {
355  *pi = (int)c;
356  return ZIP_OK;
357  }
358  else
359  {
360  if (ZERROR64(*pzlib_filefunc_def,filestream))
361  return ZIP_ERRNO;
362  else
363  return ZIP_EOF;
364  }
365 }
#define ZIP_OK
Definition: zip.h:72
#define ZERROR64(filefunc, filestream)
Definition: ioapi.h:192
#define ZREAD64(filefunc, filestream, buf, size)
Definition: ioapi.h:187
#define ZIP_EOF
Definition: zip.h:73
const GLubyte * c
Definition: glext.h:8905
static DWORD pi
Definition: protocol.c:150
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
#define c
Definition: ke_i.h:80
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by zip64local_getLong(), zip64local_getLong64(), and zip64local_getShort().

◆ zip64local_getLong()

int zip64local_getLong ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream,
uLong pX 
)

Definition at line 395 of file zip.c.

396 {
397  uLong x ;
398  int i = 0;
399  int err;
400 
401  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
402  x = (uLong)i;
403 
404  if (err==ZIP_OK)
405  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
406  x += ((uLong)i)<<8;
407 
408  if (err==ZIP_OK)
409  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
410  x += ((uLong)i)<<16;
411 
412  if (err==ZIP_OK)
413  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
414  x += ((uLong)i)<<24;
415 
416  if (err==ZIP_OK)
417  *pX = x;
418  else
419  *pX = 0;
420  return err;
421 }
#define ZIP_OK
Definition: zip.h:72
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned long uLong
Definition: zconf.h:394
int zip64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
Definition: zip.c:349
#define err(...)
INT x
Definition: msvc.h:62

Referenced by LoadCentralDirectoryRecord(), and zip64local_SearchCentralDir64().

◆ zip64local_getLong64()

int zip64local_getLong64 ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream,
ZPOS64_T pX 
)

Definition at line 426 of file zip.c.

427 {
428  ZPOS64_T x;
429  int i = 0;
430  int err;
431 
432  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
433  x = (ZPOS64_T)i;
434 
435  if (err==ZIP_OK)
436  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
437  x += ((ZPOS64_T)i)<<8;
438 
439  if (err==ZIP_OK)
440  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
441  x += ((ZPOS64_T)i)<<16;
442 
443  if (err==ZIP_OK)
444  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
445  x += ((ZPOS64_T)i)<<24;
446 
447  if (err==ZIP_OK)
448  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
449  x += ((ZPOS64_T)i)<<32;
450 
451  if (err==ZIP_OK)
452  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
453  x += ((ZPOS64_T)i)<<40;
454 
455  if (err==ZIP_OK)
456  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
457  x += ((ZPOS64_T)i)<<48;
458 
459  if (err==ZIP_OK)
460  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
461  x += ((ZPOS64_T)i)<<56;
462 
463  if (err==ZIP_OK)
464  *pX = x;
465  else
466  *pX = 0;
467 
468  return err;
469 }
#define ZIP_OK
Definition: zip.h:72
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int zip64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
Definition: zip.c:349
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define err(...)
INT x
Definition: msvc.h:62

Referenced by LoadCentralDirectoryRecord(), and zip64local_SearchCentralDir64().

◆ zip64local_getShort()

int zip64local_getShort ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream,
uLong pX 
)

Definition at line 373 of file zip.c.

374 {
375  uLong x ;
376  int i = 0;
377  int err;
378 
379  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
380  x = (uLong)i;
381 
382  if (err==ZIP_OK)
383  err = zip64local_getByte(pzlib_filefunc_def,filestream,&i);
384  x += ((uLong)i)<<8;
385 
386  if (err==ZIP_OK)
387  *pX = x;
388  else
389  *pX = 0;
390  return err;
391 }
#define ZIP_OK
Definition: zip.h:72
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned long uLong
Definition: zconf.h:394
int zip64local_getByte(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
Definition: zip.c:349
#define err(...)
INT x
Definition: msvc.h:62

Referenced by LoadCentralDirectoryRecord().

◆ zip64local_putValue()

int zip64local_putValue ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream,
ZPOS64_T  x,
int  nbByte 
)

Definition at line 287 of file zip.c.

288 {
289  unsigned char buf[8];
290  int n;
291  for (n = 0; n < nbByte; n++)
292  {
293  buf[n] = (unsigned char)(x & 0xff);
294  x >>= 8;
295  }
296  if (x != 0)
297  { /* data overflow - hack for ZIP64 (X Roche) */
298  for (n = 0; n < nbByte; n++)
299  {
300  buf[n] = 0xff;
301  }
302  }
303 
304  if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
305  return ZIP_ERRNO;
306  else
307  return ZIP_OK;
308 }
#define ZIP_OK
Definition: zip.h:72
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble n
Definition: glext.h:7729
unsigned char
Definition: typeof.h:27
unsigned long uLong
Definition: zconf.h:394
#define ZIP_ERRNO
Definition: zip.h:74
INT x
Definition: msvc.h:62
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188

Referenced by Write_EndOfCentralDirectoryRecord(), Write_GlobalComment(), Write_LocalFileHeader(), Write_Zip64EndOfCentralDirectoryLocator(), Write_Zip64EndOfCentralDirectoryRecord(), and zipCloseFileInZipRaw64().

◆ zip64local_putValue_inmemory()

void zip64local_putValue_inmemory ( void dest,
ZPOS64_T  x,
int  nbByte 
)

Definition at line 311 of file zip.c.

312 {
313  unsigned char* buf=(unsigned char*)dest;
314  int n;
315  for (n = 0; n < nbByte; n++) {
316  buf[n] = (unsigned char)(x & 0xff);
317  x >>= 8;
318  }
319 
320  if (x != 0)
321  { /* data overflow - hack for ZIP64 */
322  for (n = 0; n < nbByte; n++)
323  {
324  buf[n] = 0xff;
325  }
326  }
327 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble n
Definition: glext.h:7729
unsigned char
Definition: typeof.h:27
INT x
Definition: msvc.h:62
static char * dest
Definition: rtl.c:135

Referenced by zipCloseFileInZipRaw64(), and zipOpenNewFileInZip4_64().

◆ zip64local_SearchCentralDir()

ZPOS64_T zip64local_SearchCentralDir ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)

Definition at line 480 of file zip.c.

481 {
482  unsigned char* buf;
483  ZPOS64_T uSizeFile;
484  ZPOS64_T uBackRead;
485  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
486  ZPOS64_T uPosFound=0;
487 
488  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
489  return 0;
490 
491 
492  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
493 
494  if (uMaxBack>uSizeFile)
495  uMaxBack = uSizeFile;
496 
497  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
498  if (buf==NULL)
499  return 0;
500 
501  uBackRead = 4;
502  while (uBackRead<uMaxBack)
503  {
504  uLong uReadSize;
505  ZPOS64_T uReadPos ;
506  int i;
507  if (uBackRead+BUFREADCOMMENT>uMaxBack)
508  uBackRead = uMaxBack;
509  else
510  uBackRead+=BUFREADCOMMENT;
511  uReadPos = uSizeFile-uBackRead ;
512 
513  uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
514  (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
515  if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
516  break;
517 
518  if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
519  break;
520 
521  for (i=(int)uReadSize-3; (i--)>0;)
522  if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
523  ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
524  {
525  uPosFound = uReadPos+i;
526  break;
527  }
528 
529  if (uPosFound!=0)
530  break;
531  }
532  TRYFREE(buf);
533  return uPosFound;
534 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
unsigned long uLong
Definition: zconf.h:394
#define ZREAD64(filefunc, filestream, buf, size)
Definition: ioapi.h:187
#define TRYFREE(p)
Definition: zip.c:65
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
#define ALLOC(size)
Definition: zip.c:62
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition: ioapi.h:202
#define ZLIB_FILEFUNC_SEEK_END
Definition: ioapi.h:113
#define BUFREADCOMMENT
Definition: zip.c:472
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114

Referenced by LoadCentralDirectoryRecord().

◆ zip64local_SearchCentralDir64()

ZPOS64_T zip64local_SearchCentralDir64 ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)

Definition at line 542 of file zip.c.

543 {
544  unsigned char* buf;
545  ZPOS64_T uSizeFile;
546  ZPOS64_T uBackRead;
547  ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */
548  ZPOS64_T uPosFound=0;
549  uLong uL;
550  ZPOS64_T relativeOffset;
551 
552  if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
553  return 0;
554 
555  uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream);
556 
557  if (uMaxBack>uSizeFile)
558  uMaxBack = uSizeFile;
559 
560  buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
561  if (buf==NULL)
562  return 0;
563 
564  uBackRead = 4;
565  while (uBackRead<uMaxBack)
566  {
567  uLong uReadSize;
568  ZPOS64_T uReadPos;
569  int i;
570  if (uBackRead+BUFREADCOMMENT>uMaxBack)
571  uBackRead = uMaxBack;
572  else
573  uBackRead+=BUFREADCOMMENT;
574  uReadPos = uSizeFile-uBackRead ;
575 
576  uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
577  (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos);
578  if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
579  break;
580 
581  if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
582  break;
583 
584  for (i=(int)uReadSize-3; (i--)>0;)
585  {
586  // Signature "0x07064b50" Zip64 end of central directory locater
587  if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
588  {
589  uPosFound = uReadPos+i;
590  break;
591  }
592  }
593 
594  if (uPosFound!=0)
595  break;
596  }
597 
598  TRYFREE(buf);
599  if (uPosFound == 0)
600  return 0;
601 
602  /* Zip64 end of central directory locator */
603  if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0)
604  return 0;
605 
606  /* the signature, already checked */
607  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
608  return 0;
609 
610  /* number of the disk with the start of the zip64 end of central directory */
611  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
612  return 0;
613  if (uL != 0)
614  return 0;
615 
616  /* relative offset of the zip64 end of central directory record */
617  if (zip64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=ZIP_OK)
618  return 0;
619 
620  /* total number of disks */
621  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
622  return 0;
623  if (uL != 1)
624  return 0;
625 
626  /* Goto Zip64 end of central directory record */
627  if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0)
628  return 0;
629 
630  /* the signature */
631  if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
632  return 0;
633 
634  if (uL != 0x06064b50) // signature of 'Zip64 end of central directory'
635  return 0;
636 
637  return relativeOffset;
638 }
#define ZIP_OK
Definition: zip.h:72
int zip64local_getLong64(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
Definition: zip.c:426
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
unsigned long uLong
Definition: zconf.h:394
#define ZREAD64(filefunc, filestream, buf, size)
Definition: ioapi.h:187
#define TRYFREE(p)
Definition: zip.c:65
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
int zip64local_getLong(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
Definition: zip.c:395
#define ALLOC(size)
Definition: zip.c:62
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition: ioapi.h:202
#define ZLIB_FILEFUNC_SEEK_END
Definition: ioapi.h:113
#define BUFREADCOMMENT
Definition: zip.c:472
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114

Referenced by LoadCentralDirectoryRecord().

◆ zip64local_TmzDateToDosDate()

uLong zip64local_TmzDateToDosDate ( const tm_zip ptm)

Definition at line 332 of file zip.c.

333 {
334  uLong year = (uLong)ptm->tm_year;
335  if (year>=1980)
336  year-=1980;
337  else if (year>=80)
338  year-=80;
339  return
340  (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) |
341  ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour));
342 }
uInt tm_mday
Definition: zip.h:94
unsigned long uLong
Definition: zconf.h:394
if(!(yy_init))
Definition: macro.lex.yy.c:717
uInt tm_mon
Definition: zip.h:95
uInt tm_year
Definition: zip.h:96
uInt tm_sec
Definition: zip.h:91
uInt tm_hour
Definition: zip.h:93
uInt tm_min
Definition: zip.h:92

Referenced by zipOpenNewFileInZip4_64().

◆ zipClose()

int ZEXPORT zipClose ( zipFile  file,
const char global_comment 
)

Definition at line 1887 of file zip.c.

1888 {
1889  zip64_internal* zi;
1890  int err = 0;
1891  uLong size_centraldir = 0;
1892  ZPOS64_T centraldir_pos_inzip;
1893  ZPOS64_T pos;
1894 
1895  if (file == NULL)
1896  return ZIP_PARAMERROR;
1897 
1898  zi = (zip64_internal*)file;
1899 
1900  if (zi->in_opened_file_inzip == 1)
1901  {
1903  }
1904 
1905 #ifndef NO_ADDFILEINEXISTINGZIP
1906  if (global_comment==NULL)
1907  global_comment = zi->globalcomment;
1908 #endif
1909 
1910  centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1911 
1912  if (err==ZIP_OK)
1913  {
1915  while (ldi!=NULL)
1916  {
1917  if ((err==ZIP_OK) && (ldi->filled_in_this_block>0))
1918  {
1920  err = ZIP_ERRNO;
1921  }
1922 
1923  size_centraldir += ldi->filled_in_this_block;
1924  ldi = ldi->next_datablock;
1925  }
1926  }
1927  free_linkedlist(&(zi->central_dir));
1928 
1929  pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
1930  if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
1931  {
1932  ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1933  Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1934 
1935  Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
1936  }
1937 
1938  if (err==ZIP_OK)
1939  err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
1940 
1941  if(err == ZIP_OK)
1942  err = Write_GlobalComment(zi, global_comment);
1943 
1944  if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0)
1945  if (err == ZIP_OK)
1946  err = ZIP_ERRNO;
1947 
1948 #ifndef NO_ADDFILEINEXISTINGZIP
1949  TRYFREE(zi->globalcomment);
1950 #endif
1951  TRYFREE(zi);
1952 
1953  return err;
1954 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
voidpf filestream
Definition: zip.c:168
linkedlist_data central_dir
Definition: zip.c:169
unsigned char data[SIZEDATA_INDATABLOCK]
Definition: zip.c:120
char * globalcomment
Definition: zip.c:178
struct linkedlist_datablock_internal_s * next_datablock
Definition: zip.c:116
int Write_EndOfCentralDirectoryRecord(zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
Definition: zip.c:1821
int in_opened_file_inzip
Definition: zip.c:170
linkedlist_datablock_internal * first_block
Definition: zip.c:125
smooth NULL
Definition: ftsmooth.c:416
#define ZCLOSE64(filefunc, filestream)
Definition: ioapi.h:191
unsigned long uLong
Definition: zconf.h:394
#define TRYFREE(p)
Definition: zip.c:65
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
#define ZIP_ERRNO
Definition: zip.h:74
int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal *zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip)
Definition: zip.c:1782
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
int Write_GlobalComment(zip64_internal *zi, const char *global_comment)
Definition: zip.c:1869
#define ZIP_PARAMERROR
Definition: zip.h:75
void free_linkedlist(linkedlist_data *ll)
Definition: zip.c:218
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal *zi, ZPOS64_T zip64eocd_pos_inzip)
Definition: zip.c:1760
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1755
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188
Definition: fci.c:126

◆ zipCloseFileInZip()

int ZEXPORT zipCloseFileInZip ( zipFile  file)

Definition at line 1755 of file zip.c.

1756 {
1757  return zipCloseFileInZipRaw (file,0,0);
1758 }
int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32)
Definition: zip.c:1514
Definition: fci.c:126

Referenced by zipClose(), and zipOpenNewFileInZip4_64().

◆ zipCloseFileInZipRaw()

int ZEXPORT zipCloseFileInZipRaw ( zipFile  file,
uLong  uncompressed_size,
uLong  crc32 
)

Definition at line 1514 of file zip.c.

1515 {
1516  return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32);
1517 }
int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32)
Definition: zip.c:1519
UINT32 crc32
Definition: btrfs.c:3877
Definition: fci.c:126

Referenced by zipCloseFileInZip().

◆ zipCloseFileInZipRaw64()

int ZEXPORT zipCloseFileInZipRaw64 ( zipFile  file,
ZPOS64_T  uncompressed_size,
uLong  crc32 
)

set internal file attributes field

Definition at line 1519 of file zip.c.

1520 {
1521  zip64_internal* zi;
1522  ZPOS64_T compressed_size;
1523  uLong invalidValue = 0xffffffff;
1524  short datasize = 0;
1525  int err=ZIP_OK;
1526 
1527  if (file == NULL)
1528  return ZIP_PARAMERROR;
1529  zi = (zip64_internal*)file;
1530 
1531  if (zi->in_opened_file_inzip == 0)
1532  return ZIP_PARAMERROR;
1533  zi->ci.stream.avail_in = 0;
1534 
1535  if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
1536  {
1537  while (err==ZIP_OK)
1538  {
1539  uLong uTotalOutBefore;
1540  if (zi->ci.stream.avail_out == 0)
1541  {
1542  if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1543  err = ZIP_ERRNO;
1544  zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
1545  zi->ci.stream.next_out = zi->ci.buffered_data;
1546  }
1547  uTotalOutBefore = zi->ci.stream.total_out;
1548  err=deflate(&zi->ci.stream, Z_FINISH);
1549  zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
1550  }
1551  }
1552  else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1553  {
1554 #ifdef HAVE_BZIP2
1555  err = BZ_FINISH_OK;
1556  while (err==BZ_FINISH_OK)
1557  {
1558  uLong uTotalOutBefore;
1559  if (zi->ci.bstream.avail_out == 0)
1560  {
1561  if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1562  err = ZIP_ERRNO;
1563  zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1564  zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1565  }
1566  uTotalOutBefore = zi->ci.bstream.total_out_lo32;
1567  err=BZ2_bzCompress(&zi->ci.bstream, BZ_FINISH);
1568  if(err == BZ_STREAM_END)
1569  err = Z_STREAM_END;
1570 
1571  zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore);
1572  }
1573 
1574  if(err == BZ_FINISH_OK)
1575  err = ZIP_OK;
1576 #endif
1577  }
1578 
1579  if (err==Z_STREAM_END)
1580  err=ZIP_OK; /* this is normal */
1581 
1582  if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK))
1583  {
1585  err = ZIP_ERRNO;
1586  }
1587 
1588  if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
1589  {
1590  int tmp_err = deflateEnd(&zi->ci.stream);
1591  if (err == ZIP_OK)
1592  err = tmp_err;
1593  zi->ci.stream_initialised = 0;
1594  }
1595 #ifdef HAVE_BZIP2
1596  else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1597  {
1598  int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream);
1599  if (err==ZIP_OK)
1600  err = tmperr;
1601  zi->ci.stream_initialised = 0;
1602  }
1603 #endif
1604 
1605  if (!zi->ci.raw)
1606  {
1607  crc32 = (uLong)zi->ci.crc32;
1608  uncompressed_size = zi->ci.totalUncompressedData;
1609  }
1610  compressed_size = zi->ci.totalCompressedData;
1611 
1612 # ifndef NOCRYPT
1613  compressed_size += zi->ci.crypt_header_size;
1614 # endif
1615 
1616  // update Current Item crc and sizes,
1617  if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)
1618  {
1619  /*version Made by*/
1621  /*version needed*/
1623 
1624  }
1625 
1627 
1628 
1629  if(compressed_size >= 0xffffffff)
1630  zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/
1631  else
1632  zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/
1633 
1635  if (zi->ci.stream.data_type == Z_ASCII)
1637 
1638  if(uncompressed_size >= 0xffffffff)
1639  zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/
1640  else
1641  zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/
1642 
1643  // Add ZIP64 extra info field for uncompressed size
1644  if(uncompressed_size >= 0xffffffff)
1645  datasize += 8;
1646 
1647  // Add ZIP64 extra info field for compressed size
1648  if(compressed_size >= 0xffffffff)
1649  datasize += 8;
1650 
1651  // Add ZIP64 extra info field for relative offset to local file header of current file
1652  if(zi->ci.pos_local_header >= 0xffffffff)
1653  datasize += 8;
1654 
1655  if(datasize > 0)
1656  {
1657  char* p = NULL;
1658 
1659  if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
1660  {
1661  // we can not write more data to the buffer that we have room for.
1662  return ZIP_BADZIPFILE;
1663  }
1664 
1665  p = zi->ci.central_header + zi->ci.size_centralheader;
1666 
1667  // Add Extra Information Header for 'ZIP64 information'
1668  zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID
1669  p += 2;
1670  zip64local_putValue_inmemory(p, datasize, 2); // DataSize
1671  p += 2;
1672 
1673  if(uncompressed_size >= 0xffffffff)
1674  {
1675  zip64local_putValue_inmemory(p, uncompressed_size, 8);
1676  p += 8;
1677  }
1678 
1679  if(compressed_size >= 0xffffffff)
1680  {
1681  zip64local_putValue_inmemory(p, compressed_size, 8);
1682  p += 8;
1683  }
1684 
1685  if(zi->ci.pos_local_header >= 0xffffffff)
1686  {
1688  p += 8;
1689  }
1690 
1691  // Update how much extra free space we got in the memory buffer
1692  // and increase the centralheader size so the new ZIP64 fields are included
1693  // ( 4 below is the size of HeaderID and DataSize field )
1694  zi->ci.size_centralExtraFree -= datasize + 4;
1695  zi->ci.size_centralheader += datasize + 4;
1696 
1697  // Update the extra info size field
1698  zi->ci.size_centralExtra += datasize + 4;
1700  }
1701 
1702  if (err==ZIP_OK)
1704 
1705  free(zi->ci.central_header);
1706 
1707  if (err==ZIP_OK)
1708  {
1709  // Update the LocalFileHeader with the new values.
1710 
1711  ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
1712 
1714  err = ZIP_ERRNO;
1715 
1716  if (err==ZIP_OK)
1717  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
1718 
1719  if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff )
1720  {
1721  if(zi->ci.pos_zip64extrainfo > 0)
1722  {
1723  // Update the size in the ZIP64 extended field.
1725  err = ZIP_ERRNO;
1726 
1727  if (err==ZIP_OK) /* compressed size, unknown */
1728  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8);
1729 
1730  if (err==ZIP_OK) /* uncompressed size, unknown */
1731  err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);
1732  }
1733  else
1734  err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal
1735  }
1736  else
1737  {
1738  if (err==ZIP_OK) /* compressed size, unknown */
1739  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4);
1740 
1741  if (err==ZIP_OK) /* uncompressed size, unknown */
1742  err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4);
1743  }
1744 
1745  if (ZSEEK64(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0)
1746  err = ZIP_ERRNO;
1747  }
1748 
1749  zi->number_entry ++;
1750  zi->in_opened_file_inzip = 0;
1751 
1752  return err;
1753 }
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
voidpf filestream
Definition: zip.c:168
linkedlist_data central_dir
Definition: zip.c:169
int raw
Definition: zip.c:149
int stream_initialised
Definition: zip.c:137
int BZ_API() BZ2_bzCompress(bz_stream *strm, int action)
Definition: bzlib.c:414
#define free
Definition: debug_ros.c:5
z_stream stream
Definition: zip.c:132
uInt avail_in
Definition: zlib.h:88
#define BZ_FINISH
Definition: bzlib.h:31
ZPOS64_T pos_local_header
Definition: zip.c:140
UINT32 crc32
Definition: btrfs.c:3877
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.c:1079
#define Z_STREAM_END
Definition: zlib.h:178
int in_opened_file_inzip
Definition: zip.c:170
int BZ_API() BZ2_bzCompressEnd(bz_stream *strm)
Definition: bzlib.c:475
int zip64local_putValue(const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
Definition: zip.c:287
#define ZIP_BADZIPFILE
Definition: zip.h:76
uInt pos_in_buffered_data
Definition: zip.c:138
int zip64FlushWriteBuffer(zip64_internal *zi)
Definition: zip.c:1368
smooth NULL
Definition: ftsmooth.c:416
#define Z_DEFLATED
Definition: zlib.h:209
#define Z_BZIP2ED
Definition: unzip.h:62
uLong size_centralExtraFree
Definition: zip.c:145
int data_type
Definition: zlib.h:102
unsigned long uLong
Definition: zconf.h:394
void zip64local_putValue_inmemory(void *dest, ZPOS64_T x, int nbByte)
Definition: zip.c:311
Byte buffered_data[Z_BUFSIZE]
Definition: zip.c:150
curfile64_info ci
Definition: zip.c:171
#define BZ_STREAM_END
Definition: bzlib.h:37
#define Z_BUFSIZE
Definition: zip.c:54
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
ZPOS64_T totalUncompressedData
Definition: zip.c:157
#define BZ_FINISH_OK
Definition: bzlib.h:36
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
uLong size_centralheader
Definition: zip.c:144
#define ZIP_ERRNO
Definition: zip.h:74
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.c:766
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
int add_data_in_datablock(linkedlist_data *ll, const void *buf, uLong len)
Definition: zip.c:225
uLong total_out
Definition: zlib.h:93
#define ZIP_PARAMERROR
Definition: zip.h:75
char * central_header
Definition: zip.c:142
#define Z_FINISH
Definition: zlib.h:172
#define Z_ASCII
Definition: zlib.h:205
ZPOS64_T totalCompressedData
Definition: zip.c:156
uLong crc32
Definition: zip.c:152
uInt avail_out
Definition: zlib.h:92
int crypt_header_size
Definition: zip.c:161
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition: ioapi.h:202
ZPOS64_T pos_zip64extrainfo
Definition: zip.c:155
uLong size_centralExtra
Definition: zip.c:143
GLfloat GLfloat p
Definition: glext.h:8902
Bytef * next_out
Definition: zlib.h:91
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114
unsigned int uInt
Definition: zconf.h:393
int method
Definition: zip.c:148
Definition: fci.c:126

Referenced by zipCloseFileInZipRaw().

◆ zipOpen()

zipFile ZEXPORT zipOpen ( const char pathname,
int  append 
)

Definition at line 953 of file zip.c.

954 {
955  return zipOpen3((const void*)pathname,append,NULL,NULL);
956 }
char pathname[512]
Definition: util.h:13
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:380
smooth NULL
Definition: ftsmooth.c:416
zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
Definition: zip.c:849

◆ zipOpen2()

zipFile ZEXPORT zipOpen2 ( const char pathname,
int  append,
zipcharpc globalcomment,
zlib_filefunc_def pzlib_filefunc32_def 
)

Definition at line 924 of file zip.c.

925 {
926  if (pzlib_filefunc32_def != NULL)
927  {
928  zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
929  fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def);
930  return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
931  }
932  else
933  return zipOpen3(pathname, append, globalcomment, NULL);
934 }
char pathname[512]
Definition: util.h:13
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:380
smooth NULL
Definition: ftsmooth.c:416
zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
Definition: zip.c:849
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def *p_filefunc64_32, const zlib_filefunc_def *p_filefunc32)
Definition: ioapi.c:70

◆ zipOpen2_64()

zipFile ZEXPORT zipOpen2_64 ( const void pathname,
int  append,
zipcharpc globalcomment,
zlib_filefunc64_def pzlib_filefunc_def 
)

Definition at line 937 of file zip.c.

938 {
939  if (pzlib_filefunc_def != NULL)
940  {
941  zlib_filefunc64_32_def zlib_filefunc64_32_def_fill;
942  zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
943  zlib_filefunc64_32_def_fill.ztell32_file = NULL;
944  zlib_filefunc64_32_def_fill.zseek32_file = NULL;
945  return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill);
946  }
947  else
948  return zipOpen3(pathname, append, globalcomment, NULL);
949 }
char pathname[512]
Definition: util.h:13
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:380
seek_file_func zseek32_file
Definition: ioapi.h:183
smooth NULL
Definition: ftsmooth.c:416
zlib_filefunc64_def zfile_func64
Definition: ioapi.h:180
tell_file_func ztell32_file
Definition: ioapi.h:182
zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
Definition: zip.c:849

◆ zipOpen3()

zipFile ZEXPORT zipOpen3 ( const void pathname,
int  append,
zipcharpc globalcomment,
zlib_filefunc64_32_def pzlib_filefunc64_32_def 
)

Definition at line 849 of file zip.c.

850 {
851  zip64_internal ziinit;
852  zip64_internal* zi;
853  int err=ZIP_OK;
854 
855  ziinit.z_filefunc.zseek32_file = NULL;
856  ziinit.z_filefunc.ztell32_file = NULL;
857 #ifndef __REACTOS__
858  if (pzlib_filefunc64_32_def==NULL)
860  else
861 #endif
862  ziinit.z_filefunc = *pzlib_filefunc64_32_def;
863 
864 
865  ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
866  pathname,
870 
871  if (ziinit.filestream == NULL)
872  return NULL;
873 
875  ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END);
876 
877  ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);
878  ziinit.in_opened_file_inzip = 0;
879  ziinit.ci.stream_initialised = 0;
880  ziinit.number_entry = 0;
882  init_linkedlist(&(ziinit.central_dir));
883 
884 
885 
886  zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));
887  if (zi==NULL)
888  {
889  ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);
890  return NULL;
891  }
892 
893  /* now we add file in a zipfile */
894 # ifndef NO_ADDFILEINEXISTINGZIP
895  ziinit.globalcomment = NULL;
897  {
898  // Read and Cache Central Directory Records
899  err = LoadCentralDirectoryRecord(&ziinit);
900  }
901 
902  if (globalcomment)
903  {
904  *globalcomment = ziinit.globalcomment;
905  }
906 # endif /* !NO_ADDFILEINEXISTINGZIP*/
907 
908  if (err != ZIP_OK)
909  {
910 # ifndef NO_ADDFILEINEXISTINGZIP
911  TRYFREE(ziinit.globalcomment);
912 # endif /* !NO_ADDFILEINEXISTINGZIP*/
913  TRYFREE(zi);
914  return NULL;
915  }
916  else
917  {
918  *zi = ziinit;
919  return (zipFile)zi;
920  }
921 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
ZPOS64_T number_entry
Definition: zip.c:175
voidpf filestream
Definition: zip.c:168
linkedlist_data central_dir
Definition: zip.c:169
int stream_initialised
Definition: zip.c:137
char * globalcomment
Definition: zip.c:178
char pathname[512]
Definition: util.h:13
#define APPEND_STATUS_CREATEAFTER
Definition: zip.h:113
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:380
#define ZLIB_FILEFUNC_MODE_READ
Definition: ioapi.h:116
int in_opened_file_inzip
Definition: zip.c:170
seek_file_func zseek32_file
Definition: ioapi.h:183
smooth NULL
Definition: ftsmooth.c:416
voidp zipFile
Definition: zip.h:69
#define ZCLOSE64(filefunc, filestream)
Definition: ioapi.h:191
#define SEEK_END
Definition: zip.c:84
#define ZOPEN64(filefunc, filename, mode)
Definition: ioapi.h:200
curfile64_info ci
Definition: zip.c:171
int LoadCentralDirectoryRecord(zip64_internal *pziinit)
Definition: zip.c:640
#define TRYFREE(p)
Definition: zip.c:65
void init_linkedlist(linkedlist_data *ll)
Definition: zip.c:213
zlib_filefunc64_def zfile_func64
Definition: ioapi.h:180
#define ZLIB_FILEFUNC_MODE_CREATE
Definition: ioapi.h:121
void fill_fopen64_filefunc(zlib_filefunc64_def *pzlib_filefunc_def)
Definition: ioapi.c:238
#define ZLIB_FILEFUNC_MODE_EXISTING
Definition: ioapi.h:120
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
tell_file_func ztell32_file
Definition: ioapi.h:182
#define ALLOC(size)
Definition: zip.c:62
ZPOS64_T begin_pos
Definition: zip.c:173
#define ZLIB_FILEFUNC_MODE_WRITE
Definition: ioapi.h:117
#define ZSEEK64(filefunc, filestream, pos, mode)
Definition: ioapi.h:202
#define APPEND_STATUS_ADDINZIP
Definition: zip.h:114
#define APPEND_STATUS_CREATE
Definition: zip.h:112

Referenced by zipOpen(), zipOpen2(), zipOpen2_64(), and zipOpen64().

◆ zipOpen64()

zipFile ZEXPORT zipOpen64 ( const void pathname,
int  append 
)

Definition at line 958 of file zip.c.

959 {
960  return zipOpen3(pathname,append,NULL,NULL);
961 }
char pathname[512]
Definition: util.h:13
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:380
smooth NULL
Definition: ftsmooth.c:416
zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc *globalcomment, zlib_filefunc64_32_def *pzlib_filefunc64_32_def)
Definition: zip.c:849

◆ zipOpenNewFileInZip()

int ZEXPORT zipOpenNewFileInZip ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level 
)

Definition at line 1355 of file zip.c.

1359 {
1360  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1361  extrafield_local, size_extrafield_local,
1362  extrafield_global, size_extrafield_global,
1363  comment, method, level, 0,
1365  NULL, 0, VERSIONMADEBY, 0, 0);
1366 }
GLint level
Definition: gl.h:1546
const char * filename
Definition: ioapi.h:135
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:200
smooth NULL
Definition: ftsmooth.c:416
method
Definition: dragdrop.c:53
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define MAX_WBITS
Definition: zconf.h:270
Definition: fci.c:126

◆ zipOpenNewFileInZip2()

int ZEXPORT zipOpenNewFileInZip2 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw 
)

Definition at line 1316 of file zip.c.

1320 {
1321  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1322  extrafield_local, size_extrafield_local,
1323  extrafield_global, size_extrafield_global,
1324  comment, method, level, raw,
1326  NULL, 0, VERSIONMADEBY, 0, 0);
1327 }
GLint level
Definition: gl.h:1546
const char * filename
Definition: ioapi.h:135
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:200
smooth NULL
Definition: ftsmooth.c:416
method
Definition: dragdrop.c:53
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define MAX_WBITS
Definition: zconf.h:270
Definition: fci.c:126

◆ zipOpenNewFileInZip2_64()

int ZEXPORT zipOpenNewFileInZip2_64 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw,
int  zip64 
)

Definition at line 1329 of file zip.c.

1333 {
1334  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1335  extrafield_local, size_extrafield_local,
1336  extrafield_global, size_extrafield_global,
1337  comment, method, level, raw,
1339  NULL, 0, VERSIONMADEBY, 0, zip64);
1340 }
GLint level
Definition: gl.h:1546
const char * filename
Definition: ioapi.h:135
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:200
smooth NULL
Definition: ftsmooth.c:416
method
Definition: dragdrop.c:53
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define MAX_WBITS
Definition: zconf.h:270
Definition: fci.c:126

◆ zipOpenNewFileInZip3()

int ZEXPORT zipOpenNewFileInZip3 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw,
int  windowBits,
int  memLevel,
int  strategy,
const char password,
uLong  crcForCrypting 
)

Definition at line 1286 of file zip.c.

1292 {
1293  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1294  extrafield_local, size_extrafield_local,
1295  extrafield_global, size_extrafield_global,
1296  comment, method, level, raw,
1297  windowBits, memLevel, strategy,
1298  password, crcForCrypting, VERSIONMADEBY, 0, 0);
1299 }
GLint level
Definition: gl.h:1546
int windowBits
Definition: zlib.h:813
const char * filename
Definition: ioapi.h:135
method
Definition: dragdrop.c:53
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
Definition: fci.c:126

◆ zipOpenNewFileInZip3_64()

int ZEXPORT zipOpenNewFileInZip3_64 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw,
int  windowBits,
int  memLevel,
int  strategy,
const char password,
uLong  crcForCrypting,
int  zip64 
)

Definition at line 1301 of file zip.c.

1307 {
1308  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1309  extrafield_local, size_extrafield_local,
1310  extrafield_global, size_extrafield_global,
1311  comment, method, level, raw,
1312  windowBits, memLevel, strategy,
1313  password, crcForCrypting, VERSIONMADEBY, 0, zip64);
1314 }
GLint level
Definition: gl.h:1546
int windowBits
Definition: zlib.h:813
const char * filename
Definition: ioapi.h:135
method
Definition: dragdrop.c:53
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
Definition: fci.c:126

◆ zipOpenNewFileInZip4()

int ZEXPORT zipOpenNewFileInZip4 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw,
int  windowBits,
int  memLevel,
int  strategy,
const char password,
uLong  crcForCrypting,
uLong  versionMadeBy,
uLong  flagBase 
)

Definition at line 1270 of file zip.c.

1277 {
1278  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1279  extrafield_local, size_extrafield_local,
1280  extrafield_global, size_extrafield_global,
1281  comment, method, level, raw,
1282  windowBits, memLevel, strategy,
1283  password, crcForCrypting, versionMadeBy, flagBase, 0);
1284 }
GLint level
Definition: gl.h:1546
int windowBits
Definition: zlib.h:813
const char * filename
Definition: ioapi.h:135
method
Definition: dragdrop.c:53
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
Definition: id3.c:18
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
Definition: fci.c:126

◆ zipOpenNewFileInZip4_64()

int ZEXPORT zipOpenNewFileInZip4_64 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  raw,
int  windowBits,
int  memLevel,
int  strategy,
const char password,
uLong  crcForCrypting,
uLong  versionMadeBy,
uLong  flagBase,
int  zip64 
)

Definition at line 1060 of file zip.c.

1067 {
1068  zip64_internal* zi;
1069  uInt size_filename;
1070  uInt size_comment;
1071  uInt i;
1072  int err = ZIP_OK;
1073 
1074 # ifdef NOCRYPT
1075  (crcForCrypting);
1076  if (password != NULL)
1077  return ZIP_PARAMERROR;
1078 # endif
1079 
1080  if (file == NULL)
1081  return ZIP_PARAMERROR;
1082 
1083 #ifdef HAVE_BZIP2
1084  if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED))
1085  return ZIP_PARAMERROR;
1086 #else
1087  if ((method!=0) && (method!=Z_DEFLATED))
1088  return ZIP_PARAMERROR;
1089 #endif
1090 
1091  zi = (zip64_internal*)file;
1092 
1093  if (zi->in_opened_file_inzip == 1)
1094  {
1096  if (err != ZIP_OK)
1097  return err;
1098  }
1099 
1100  if (filename==NULL)
1101  filename="-";
1102 
1103  if (comment==NULL)
1104  size_comment = 0;
1105  else
1106  size_comment = (uInt)strlen(comment);
1107 
1108  size_filename = (uInt)strlen(filename);
1109 
1110  if (zipfi == NULL)
1111  zi->ci.dosDate = 0;
1112  else
1113  {
1114  if (zipfi->dosDate != 0)
1115  zi->ci.dosDate = zipfi->dosDate;
1116  else
1118  }
1119 
1120  zi->ci.flag = flagBase;
1121  if ((level==8) || (level==9))
1122  zi->ci.flag |= 2;
1123  if (level==2)
1124  zi->ci.flag |= 4;
1125  if (level==1)
1126  zi->ci.flag |= 6;
1127  if (password != NULL)
1128  zi->ci.flag |= 1;
1129 
1130  zi->ci.crc32 = 0;
1131  zi->ci.method = method;
1132  zi->ci.encrypt = 0;
1133  zi->ci.stream_initialised = 0;
1134  zi->ci.pos_in_buffered_data = 0;
1135  zi->ci.raw = raw;
1137 
1138  zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;
1139  zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data
1140 
1142 
1143  zi->ci.size_centralExtra = size_extrafield_global;
1145  /* version info */
1146  zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2);
1151  zip64local_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/
1152  zip64local_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/
1153  zip64local_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/
1154  zip64local_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);
1155  zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);
1156  zip64local_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);
1157  zip64local_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/
1158 
1159  if (zipfi==NULL)
1161  else
1163 
1164  if (zipfi==NULL)
1166  else
1168 
1169  if(zi->ci.pos_local_header >= 0xffffffff)
1170  zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4);
1171  else
1173 
1174  for (i=0;i<size_filename;i++)
1176 
1177  for (i=0;i<size_extrafield_global;i++)
1178  *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =
1179  *(((const char*)extrafield_global)+i);
1180 
1181  for (i=0;i<size_comment;i++)
1182  *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
1183  size_extrafield_global+i) = *(comment+i);
1184  if (zi->ci.central_header == NULL)
1185  return ZIP_INTERNALERROR;
1186 
1187  zi->ci.zip64 = zip64;
1188  zi->ci.totalCompressedData = 0;
1189  zi->ci.totalUncompressedData = 0;
1190  zi->ci.pos_zip64extrainfo = 0;
1191 
1192  err = Write_LocalFileHeader(zi, filename, size_extrafield_local, extrafield_local);
1193 
1194 #ifdef HAVE_BZIP2
1195  zi->ci.bstream.avail_in = (uInt)0;
1196  zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1197  zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1198  zi->ci.bstream.total_in_hi32 = 0;
1199  zi->ci.bstream.total_in_lo32 = 0;
1200  zi->ci.bstream.total_out_hi32 = 0;
1201  zi->ci.bstream.total_out_lo32 = 0;
1202 #endif
1203 
1204  zi->ci.stream.avail_in = (uInt)0;
1205  zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
1206  zi->ci.stream.next_out = zi->ci.buffered_data;
1207  zi->ci.stream.total_in = 0;
1208  zi->ci.stream.total_out = 0;
1209  zi->ci.stream.data_type = Z_BINARY;
1210 
1211 #ifdef HAVE_BZIP2
1212  if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED || zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1213 #else
1214  if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
1215 #endif
1216  {
1217  if(zi->ci.method == Z_DEFLATED)
1218  {
1219  zi->ci.stream.zalloc = (alloc_func)0;
1220  zi->ci.stream.zfree = (free_func)0;
1221  zi->ci.stream.opaque = (voidpf)0;
1222 
1223  if (windowBits>0)
1225 
1226  err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy);
1227 
1228  if (err==Z_OK)
1230  }
1231  else if(zi->ci.method == Z_BZIP2ED)
1232  {
1233 #ifdef HAVE_BZIP2
1234  // Init BZip stuff here
1235  zi->ci.bstream.bzalloc = 0;
1236  zi->ci.bstream.bzfree = 0;
1237  zi->ci.bstream.opaque = (voidpf)0;
1238 
1239  err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35);
1240  if(err == BZ_OK)
1242 #endif
1243  }
1244 
1245  }
1246 
1247 # ifndef NOCRYPT
1248  zi->ci.crypt_header_size = 0;
1249  if ((err==Z_OK) && (password != NULL))
1250  {
1251  unsigned char bufHead[RAND_HEAD_LEN];
1252  unsigned int sizeHead;
1253  zi->ci.encrypt = 1;
1254  zi->ci.pcrc_32_tab = get_crc_table();
1255  /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
1256 
1257  sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);
1258  zi->ci.crypt_header_size = sizeHead;
1259 
1260  if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead)
1261  err = ZIP_ERRNO;
1262  }
1263 # endif
1264 
1265  if (err==Z_OK)
1266  zi->in_opened_file_inzip = 1;
1267  return err;
1268 }
ZPOS64_T add_position_when_writing_offset
Definition: zip.c:174
#define ZIP_OK
Definition: zip.h:72
GLint level
Definition: gl.h:1546
voidpf filestream
Definition: zip.c:168
uLong dosDate
Definition: zip.h:102
#define ZIP_INTERNALERROR
Definition: zip.h:77
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
uLong internal_fa
Definition: zip.h:105
int windowBits
Definition: zlib.h:813
int raw
Definition: zip.c:149
int stream_initialised
Definition: zip.c:137
z_stream stream
Definition: zip.c:132
#define SIZECENTRALHEADER
Definition: zip.c:112
uInt avail_in
Definition: zlib.h:88
const z_crc_t * pcrc_32_tab
Definition: zip.c:160
ZPOS64_T pos_local_header
Definition: zip.c:140
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy)
Definition: zlib.h:1797
const char * filename
Definition: ioapi.h:135
const z_crc_t FAR *ZEXPORT get_crc_table()
Definition: crc32.c:188
int in_opened_file_inzip
Definition: zip.c:170
uLong external_fa
Definition: zip.h:106
voidpf opaque
Definition: zlib.h:100
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
free_func zfree
Definition: zlib.h:99
int zip64
Definition: zip.c:154
int BZ_API() BZ2_bzCompressInit(bz_stream *strm, int blockSize100k, int verbosity, int workFactor)
Definition: bzlib.c:156
#define Z_OK
Definition: zlib.h:177
uInt pos_in_buffered_data
Definition: zip.c:138
smooth NULL
Definition: ftsmooth.c:416
#define Z_DEFLATED
Definition: zlib.h:209
#define Z_BZIP2ED
Definition: unzip.h:62
unsigned long keys[3]
Definition: zip.c:159
uLong size_centralExtraFree
Definition: zip.c:145
int data_type
Definition: zlib.h:102
#define BZ_OK
Definition: bzlib.h:33
#define Z_BINARY
Definition: zlib.h:203
int Write_LocalFileHeader(zip64_internal *zi, const char *filename, uInt size_extrafield_local, const void *extrafield_local)
Definition: zip.c:963
unsigned long uLong
Definition: zconf.h:394
void zip64local_putValue_inmemory(void *dest, ZPOS64_T x, int nbByte)
Definition: zip.c:311
Byte buffered_data[Z_BUFSIZE]
Definition: zip.c:150
curfile64_info ci
Definition: zip.c:171
uLong total_in
Definition: zlib.h:89
#define Z_BUFSIZE
Definition: zip.c:54
alloc_func zalloc
Definition: zlib.h:98
ZPOS64_T totalUncompressedData
Definition: zip.c:157
method
Definition: dragdrop.c:53
#define ZTELL64(filefunc, filestream)
Definition: ioapi.h:201
uLong size_centralheader
Definition: zip.c:144
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
Definition: id3.c:18
#define ZIP_ERRNO
Definition: zip.h:74
#define err(...)
zlib_filefunc64_32_def z_filefunc
Definition: zip.c:167
uLong total_out
Definition: zlib.h:93
#define ZIP_PARAMERROR
Definition: zip.h:75
char * central_header
Definition: zip.c:142
Byte FAR * voidpf
Definition: zconf.h:413
#define ALLOC(size)
Definition: zip.c:62
ZPOS64_T totalCompressedData
Definition: zip.c:156
uLong crc32
Definition: zip.c:152
uInt avail_out
Definition: zlib.h:92
int crypt_header_size
Definition: zip.c:161
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1755
tm_zip tmz_date
Definition: zip.h:101
ZPOS64_T pos_zip64extrainfo
Definition: zip.c:155
uLong size_centralExtra
Definition: zip.c:143
Bytef * next_out
Definition: zlib.h:91
uLong dosDate
Definition: zip.c:151
uLong zip64local_TmzDateToDosDate(const tm_zip *ptm)
Definition: zip.c:332
uLong flag
Definition: zip.c:146
#define ZWRITE64(filefunc, filestream, buf, size)
Definition: ioapi.h:188
#define CENTRALHEADERMAGIC
Definition: zip.c:104
unsigned int uInt
Definition: zconf.h:393
int encrypt
Definition: zip.c:153
int method
Definition: zip.c:148
Definition: fci.c:126

Referenced by zipOpenNewFileInZip(), zipOpenNewFileInZip2(), zipOpenNewFileInZip2_64(), zipOpenNewFileInZip3(), zipOpenNewFileInZip3_64(), zipOpenNewFileInZip4(), and zipOpenNewFileInZip64().

◆ zipOpenNewFileInZip64()

int ZEXPORT zipOpenNewFileInZip64 ( zipFile  file,
const char filename,
const zip_fileinfo zipfi,
const void extrafield_local,
uInt  size_extrafield_local,
const void extrafield_global,
uInt  size_extrafield_global,
const char comment,
int  method,
int  level,
int  zip64 
)

Definition at line 1342 of file zip.c.

1346 {
1347  return zipOpenNewFileInZip4_64 (file, filename, zipfi,
1348  extrafield_local, size_extrafield_local,
1349  extrafield_global, size_extrafield_global,
1350  comment, method, level, 0,
1352  NULL, 0, VERSIONMADEBY, 0, zip64);
1353 }
GLint level
Definition: gl.h:1546
const char * filename
Definition: ioapi.h:135
#define Z_DEFAULT_STRATEGY
Definition: zlib.h:200
smooth NULL
Definition: ftsmooth.c:416
method
Definition: dragdrop.c:53
Definition: id3.c:18
#define VERSIONMADEBY
Definition: zip.c:50
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uInt size_extrafield_local, const void *extrafield_global, uInt size_extrafield_global, const char *comment, int method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, uLong crcForCrypting, uLong versionMadeBy, uLong flagBase, int zip64)
Definition: zip.c:1060
#define DEF_MEM_LEVEL
Definition: zutil.h:53
#define MAX_WBITS
Definition: zconf.h:270
Definition: fci.c:126

◆ zipRemoveExtraInfoBlock()

int ZEXPORT zipRemoveExtraInfoBlock ( char pData,
int dataLen,
short  sHeader 
)

Definition at line 1956 of file zip.c.

1957 {
1958  char* p = pData;
1959  int size = 0;
1960  char* pNewHeader;
1961  char* pTmp;
1962  short header;
1963  short dataSize;
1964 
1965  int retVal = ZIP_OK;
1966 
1967  if(pData == NULL || *dataLen < 4)
1968  return ZIP_PARAMERROR;
1969 
1970  pNewHeader = (char*)ALLOC(*dataLen);
1971  pTmp = pNewHeader;
1972 
1973  while(p < (pData + *dataLen))
1974  {
1975  header = *(short*)p;
1976  dataSize = *(((short*)p)+1);
1977 
1978  if( header == sHeader ) // Header found.
1979  {
1980  p += dataSize + 4; // skip it. do not copy to temp buffer
1981  }
1982  else
1983  {
1984  // Extra Info block should not be removed, So copy it to the temp buffer.
1985  memcpy(pTmp, p, dataSize + 4);
1986  p += dataSize + 4;
1987  size += dataSize + 4;
1988  }
1989 
1990  }
1991 
1992  if(size < *dataLen)
1993  {
1994  // clean old extra info block.
1995  memset(pData,0, *dataLen);
1996 
1997  // copy the new extra info block over the old
1998  if(size > 0)
1999  memcpy(pData, pNewHeader, size);
2000 
2001  // set the new extra info size
2002  *dataLen = size;
2003 
2004  retVal = ZIP_OK;
2005  }
2006  else
2007  retVal = ZIP_ERRNO;
2008 
2009  TRYFREE(pNewHeader);
2010 
2011  return retVal;
2012 }
#define ZIP_OK
Definition: zip.h:72
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define TRYFREE(p)
Definition: zip.c:65
#define ZIP_ERRNO
Definition: zip.h:74
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ZIP_PARAMERROR
Definition: zip.h:75
#define ALLOC(size)
Definition: zip.c:62
GLenum GLsizei dataSize
Definition: glext.h:11123
GLfloat GLfloat p
Definition: glext.h:8902
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define memset(x, y, z)
Definition: compat.h:39
struct CFHEADER header
Definition: fdi.c:109

◆ zipWriteInFileInZip()

int ZEXPORT zipWriteInFileInZip ( zipFile  file,
const void buf,
unsigned int  len 
)

Definition at line 1407 of file zip.c.

1408 {
1409  zip64_internal* zi;
1410  int err=ZIP_OK;
1411 
1412  if (file == NULL)
1413  return ZIP_PARAMERROR;
1414  zi = (zip64_internal*)file;
1415 
1416  if (zi->in_opened_file_inzip == 0)
1417  return ZIP_PARAMERROR;
1418 
1419  zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len);
1420 
1421 #ifdef HAVE_BZIP2
1422  if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
1423  {
1424  zi->ci.bstream.next_in = (void*)buf;
1425  zi->ci.bstream.avail_in = len;
1426  err = BZ_RUN_OK;
1427 
1428  while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0))
1429  {
1430  if (zi->ci.bstream.avail_out == 0)
1431  {
1432  if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1433  err = ZIP_ERRNO;
1434  zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1435  zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1436  }
1437 
1438 
1439  if(err != BZ_RUN_OK)
1440  break;
1441 
1442  if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1443  {
1444  uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
1445 // uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;
1446  err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
1447 
1448  zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
1449  }
1450  }
1451 
1452  if(err == BZ_RUN_OK)
1453  err = ZIP_OK;
1454  }
1455  else
1456 #endif
1457  {
1458  zi->ci.stream.next_in = (Bytef*)buf;
1459  zi->ci.stream.avail_in = len;
1460 
1461  while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
1462  {
1463  if (zi->ci.stream.avail_out == 0)
1464  {
1465  if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1466  err = ZIP_ERRNO;
1467  zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
1468  zi->ci.stream.next_out = zi->ci.buffered_data;
1469  }
1470 
1471 
1472  if(err != ZIP_OK)
1473  break;
1474 
1475  if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw))
1476  {
1477  uLong uTotalOutBefore = zi->ci.stream.total_out;
1478  err=deflate(&zi->ci.stream, Z_NO_FLUSH);
1479  if(uTotalOutBefore > zi->ci.stream.total_out)
1480  {
1481  int bBreak = 0;
1482  bBreak++;
1483  }
1484 
1485  zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
1486  }
1487  else
1488  {
1489  uInt copy_this,i;
1490  if (zi->ci.stream.avail_in < zi->ci.stream.avail_out)
1491  copy_this = zi->ci.stream.avail_in;
1492  else
1493  copy_this = zi->ci.stream.avail_out;
1494 
1495  for (i = 0; i < copy_this; i++)
1496  *(((char*)zi->ci.stream.next_out)+i) =
1497  *(((const char*)zi->ci.stream.next_in)+i);
1498  {
1499  zi->ci.stream.avail_in -= copy_this;
1500  zi->ci.stream.avail_out-= copy_this;
1501  zi->ci.stream.next_in+= copy_this;
1502  zi->ci.stream.next_out+= copy_this;
1503  zi->ci.stream.total_in+= copy_this;
1504  zi->ci.stream.total_out+= copy_this;
1505  zi->ci.pos_in_buffered_data += copy_this;
1506  }
1507  }
1508  }// while(...)
1509  }
1510 
1511  return err;
1512 }
#define ZIP_OK
Definition: zip.h:72
#define BZ_RUN_OK
Definition: bzlib.h:34
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int raw
Definition: zip.c:149
int BZ_API() BZ2_bzCompress(bz_stream *strm, int action)
Definition: bzlib.c:414
z_stream stream
Definition: zip.c:132
uInt avail_in
Definition: zlib.h:88
UINT32 crc32
Definition: btrfs.c:3877
int in_opened_file_inzip
Definition: zip.c:170
Byte FAR Bytef
Definition: zconf.h:400
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
uInt pos_in_buffered_data
Definition: zip.c:138
int zip64FlushWriteBuffer(zip64_internal *zi)
Definition: zip.c:1368
smooth NULL
Definition: ftsmooth.c:416
#define Z_DEFLATED
Definition: zlib.h:209
#define Z_BZIP2ED
Definition: unzip.h:62
unsigned long uLong
Definition: zconf.h:394
#define BZ_RUN
Definition: bzlib.h:29
Byte buffered_data[Z_BUFSIZE]
Definition: zip.c:150
curfile64_info ci
Definition: zip.c:171
uLong total_in
Definition: zlib.h:89
#define Z_BUFSIZE
Definition: zip.c:54
#define Z_NO_FLUSH
Definition: zlib.h:168
#define ZIP_ERRNO
Definition: zip.h:74
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.c:766
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
uLong total_out
Definition: zlib.h:93
#define ZIP_PARAMERROR
Definition: zip.h:75
uLong crc32
Definition: zip.c:152
uInt avail_out
Definition: zlib.h:92
z_const Bytef * next_in
Definition: zlib.h:87
Bytef * next_out
Definition: zlib.h:91
unsigned int uInt
Definition: zconf.h:393
int method
Definition: zip.c:148
Definition: fci.c:126

Variable Documentation

◆ zip_copyright

const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"

Definition at line 98 of file zip.c.