"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "zlib/zlib/contrib/minizip/zip.c" between
muscle7.61.zip and muscle7.62.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

zip.c  (muscle7.61):zip.c  (muscle7.62)
skipping to change at line 18 skipping to change at line 18
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
For more info read MiniZip_info.txt For more info read MiniZip_info.txt
Changes Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes Oct-2009 - Mathias Svensson - Remove old C style function prototypes
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file arch ives Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file arch ives
Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get be tter overview of some functions. Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get be tter overview of some functions.
Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra fi eld data from its ZIP64 data Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra fi eld data from its ZIP64 data
It is used when recreting zip archive with RAW when deleting items from a zip. It is used when recreting zip archive with RAW when deleting items from a zip.
ZIP64 data is automaticly added to items that n eeds it, and existing ZIP64 data need to be removed. ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed.
Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bz ip2 lib is required) Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bz ip2 lib is required)
Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility laye r Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility laye r
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include "zlib.h" #include "zlib.h"
skipping to change at line 115 skipping to change at line 115
#define FLAG_LOCALHEADER_OFFSET (0x06) #define FLAG_LOCALHEADER_OFFSET (0x06)
#define CRC_LOCALHEADER_OFFSET (0x0e) #define CRC_LOCALHEADER_OFFSET (0x0e)
#define SIZECENTRALHEADER (0x2e) /* 46 */ #define SIZECENTRALHEADER (0x2e) /* 46 */
typedef struct linkedlist_datablock_internal_s typedef struct linkedlist_datablock_internal_s
{ {
struct linkedlist_datablock_internal_s* next_datablock; struct linkedlist_datablock_internal_s* next_datablock;
uLong avail_in_this_block; uLong avail_in_this_block;
uLong filled_in_this_block; uLong filled_in_this_block;
uLong unused; /* for future use and alignement */ uLong unused; /* for future use and alignment */
unsigned char data[SIZEDATA_INDATABLOCK]; unsigned char data[SIZEDATA_INDATABLOCK];
} linkedlist_datablock_internal; } linkedlist_datablock_internal;
typedef struct linkedlist_data_s typedef struct linkedlist_data_s
{ {
linkedlist_datablock_internal* first_block; linkedlist_datablock_internal* first_block;
linkedlist_datablock_internal* last_block; linkedlist_datablock_internal* last_block;
} linkedlist_data; } linkedlist_data;
typedef struct typedef struct
skipping to change at line 169 skipping to change at line 169
typedef struct typedef struct
{ {
zlib_filefunc64_32_def z_filefunc; zlib_filefunc64_32_def z_filefunc;
voidpf filestream; /* io structore of the zipfile */ voidpf filestream; /* io structore of the zipfile */
linkedlist_data central_dir;/* datablock with central dir in construction*/ linkedlist_data central_dir;/* datablock with central dir in construction*/
int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/
curfile64_info ci; /* info on the file curretly writing */ curfile64_info ci; /* info on the file curretly writing */
ZPOS64_T begin_pos; /* position of the beginning of the zipfile * / ZPOS64_T begin_pos; /* position of the beginning of the zipfile * /
ZPOS64_T add_position_when_writting_offset; ZPOS64_T add_position_when_writing_offset;
ZPOS64_T number_entry; ZPOS64_T number_entry;
#ifndef NO_ADDFILEINEXISTINGZIP #ifndef NO_ADDFILEINEXISTINGZIP
char *globalcomment; char *globalcomment;
#endif #endif
} zip64_internal; } zip64_internal;
#ifndef NOCRYPT #ifndef NOCRYPT
#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
skipping to change at line 795 skipping to change at line 795
{ {
pziinit->globalcomment = (char*)ALLOC(size_comment+1); pziinit->globalcomment = (char*)ALLOC(size_comment+1);
if (pziinit->globalcomment) if (pziinit->globalcomment)
{ {
size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit-> globalcomment,size_comment); size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit-> globalcomment,size_comment);
pziinit->globalcomment[size_comment]=0; pziinit->globalcomment[size_comment]=0;
} }
} }
byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir);
pziinit->add_position_when_writting_offset = byte_before_the_zipfile; pziinit->add_position_when_writing_offset = byte_before_the_zipfile;
{ {
ZPOS64_T size_central_dir_to_read = size_central_dir; ZPOS64_T size_central_dir_to_read = size_central_dir;
size_t buf_size = SIZEDATA_INDATABLOCK; size_t buf_size = SIZEDATA_INDATABLOCK;
void* buf_read = (void*)ALLOC(buf_size); void* buf_read = (void*)ALLOC(buf_size);
if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + b yte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0) if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + b yte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0)
err=ZIP_ERRNO; err=ZIP_ERRNO;
while ((size_central_dir_to_read>0) && (err==ZIP_OK)) while ((size_central_dir_to_read>0) && (err==ZIP_OK))
{ {
skipping to change at line 861 skipping to change at line 861
if (ziinit.filestream == NULL) if (ziinit.filestream == NULL)
return NULL; return NULL;
if (append == APPEND_STATUS_CREATEAFTER) if (append == APPEND_STATUS_CREATEAFTER)
ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END);
ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream);
ziinit.in_opened_file_inzip = 0; ziinit.in_opened_file_inzip = 0;
ziinit.ci.stream_initialised = 0; ziinit.ci.stream_initialised = 0;
ziinit.number_entry = 0; ziinit.number_entry = 0;
ziinit.add_position_when_writting_offset = 0; ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir)); init_linkedlist(&(ziinit.central_dir));
zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); zi = (zip64_internal*)ALLOC(sizeof(zip64_internal));
if (zi==NULL) if (zi==NULL)
{ {
ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); ZCLOSE64(ziinit.z_filefunc,ziinit.filestream);
return NULL; return NULL;
} }
/* now we add file in a zipfile */ /* now we add file in a zipfile */
skipping to change at line 1145 skipping to change at line 1145
zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->inte rnal_fa,2); zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->inte rnal_fa,2);
if (zipfi==NULL) if (zipfi==NULL)
zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);
else else
zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->exte rnal_fa,4); zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->exte rnal_fa,4);
if(zi->ci.pos_local_header >= 0xffffffff) if(zi->ci.pos_local_header >= 0xffffffff)
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4) ; zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4) ;
else else
zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_lo cal_header - zi->add_position_when_writting_offset,4); zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_lo cal_header - zi->add_position_when_writing_offset,4);
for (i=0;i<size_filename;i++) for (i=0;i<size_filename;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);
for (i=0;i<size_extrafield_global;i++) for (i=0;i<size_extrafield_global;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) = *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =
*(((const char*)extrafield_global)+i); *(((const char*)extrafield_global)+i);
for (i=0;i<size_comment;i++) for (i=0;i<size_comment;i++)
*(zi->ci.central_header+SIZECENTRALHEADER+size_filename+ *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+
skipping to change at line 1732 skipping to change at line 1732
} }
extern int ZEXPORT zipCloseFileInZip (zipFile file) extern int ZEXPORT zipCloseFileInZip (zipFile file)
{ {
return zipCloseFileInZipRaw (file,0,0); return zipCloseFileInZipRaw (file,0,0);
} }
int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo cd_pos_inzip) int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eo cd_pos_inzip)
{ {
int err = ZIP_OK; int err = ZIP_OK;
ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEA DERMAGIC,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEA DERMAGIC,4);
/*num disks*/ /*num disks*/
if (err==ZIP_OK) /* number of the disk with the start of the central directo ry */ if (err==ZIP_OK) /* number of the disk with the start of the central directo ry */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);
/*relative offset*/ /*relative offset*/
if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */ if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8);
skipping to change at line 1785 skipping to change at line 1785
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8);
if (err==ZIP_OK) /* total number of entries in the central dir */ if (err==ZIP_OK) /* total number of entries in the central dir */
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8);
if (err==ZIP_OK) /* size of the central directory */ if (err==ZIP_OK) /* size of the central directory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_cent raldir,8); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_cent raldir,8);
if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */ if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */
{ {
ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8);
} }
return err; return err;
} }
int Write_EndOfCentralDirectoryRecord(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 err = ZIP_OK; int err = ZIP_OK;
/*signature*/ /*signature*/
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC ,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC ,4);
skipping to change at line 1826 skipping to change at line 1826
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
else else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number _entry,2); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number _entry,2);
} }
if (err==ZIP_OK) /* size of the central directory */ if (err==ZIP_OK) /* size of the central directory */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_central dir,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_central dir,4);
if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */ if (err==ZIP_OK) /* offset of start of central directory with respect to the s tarting disk number */
{ {
ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff) if(pos >= 0xffffffff)
{ {
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xfffffff f,4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xfffffff f,4);
} }
else else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centrald ir_pos_inzip - zi->add_position_when_writting_offset),4); err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centrald ir_pos_inzip - zi->add_position_when_writing_offset),4);
} }
return err; return err;
} }
int Write_GlobalComment(zip64_internal* zi, const char* global_comment) int Write_GlobalComment(zip64_internal* zi, const char* global_comment)
{ {
int err = ZIP_OK; int err = ZIP_OK;
uInt size_global_comment = 0; uInt size_global_comment = 0;
skipping to change at line 1898 skipping to change at line 1898
if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->fill ed_in_this_block) != ldi->filled_in_this_block) if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->fill ed_in_this_block) != ldi->filled_in_this_block)
err = ZIP_ERRNO; err = ZIP_ERRNO;
} }
size_centraldir += ldi->filled_in_this_block; size_centraldir += ldi->filled_in_this_block;
ldi = ldi->next_datablock; ldi = ldi->next_datablock;
} }
} }
free_linkedlist(&(zi->central_dir)); free_linkedlist(&(zi->central_dir));
pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
{ {
ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos _inzip); Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos _inzip);
Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos);
} }
if (err==ZIP_OK) if (err==ZIP_OK)
err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_po s_inzip); err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_po s_inzip);
 End of changes. 11 change blocks. 
11 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)