Biomedical Image Analysis Library
The Biomedical Image Analysis Library is a poweful tool for developers, physicians, researchers, engineers, and so on.
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
 
struct  linkedlist_data
 
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)
 

Functions

static linkedlist_datablock_internalallocate_new_datablock ()
 
static void free_datablock (linkedlist_datablock_internal *ldi)
 
static void init_linkedlist (linkedlist_data *ll)
 
static void free_linkedlist (linkedlist_data *ll)
 
static int add_data_in_datablock (linkedlist_data *ll, const void *buf, uLong len)
 
static int zip64local_putValue OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte))
 
static int zip64local_putValue (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
 
static void zip64local_putValue_inmemory OF ((void *dest, ZPOS64_T x, int nbByte))
 
static void zip64local_putValue_inmemory (void *dest, ZPOS64_T x, int nbByte)
 
static uLong zip64local_TmzDateToDosDate (const tm_zip *ptm)
 
static int zip64local_getByte OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi))
 
static int zip64local_getByte (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)
 
static int zip64local_getShort OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX))
 
static int zip64local_getShort (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
static int zip64local_getLong (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
 
static int zip64local_getLong64 OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX))
 
static int zip64local_getLong64 (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
 
static ZPOS64_T zip64local_SearchCentralDir OF ((const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream))
 
static ZPOS64_T zip64local_SearchCentralDir (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)
 
static 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)
 
static 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"
 

Class Documentation

struct linkedlist_datablock_internal

Definition at line 114 of file zip.c.

Collaboration diagram for linkedlist_datablock_internal:
Collaboration graph
Class Members
uLong avail_in_this_block
unsigned char data[(4096-(4 *4))]
uLong filled_in_this_block
struct
linkedlist_datablock_internal_s *
next_datablock
uLong unused
struct linkedlist_data

Definition at line 123 of file zip.c.

Collaboration diagram for linkedlist_data:
Collaboration graph
Class Members
linkedlist_datablock_internal * first_block
linkedlist_datablock_internal * last_block
struct curfile64_info

Definition at line 130 of file zip.c.

Collaboration diagram for curfile64_info:
Collaboration graph
Class Members
Byte buffered_data[(64 *1024)]
char * central_header
uLong crc32
int crypt_header_size
uLong dosDate
int encrypt
uLong flag
unsigned long keys[3]
int method
const z_crc_t * pcrc_32_tab
uInt pos_in_buffered_data
ZPOS64_T pos_local_header
ZPOS64_T pos_zip64extrainfo
int raw
uLong size_centralExtra
uLong size_centralExtraFree
uLong size_centralheader
z_stream stream
int stream_initialised
ZPOS64_T totalCompressedData
ZPOS64_T totalUncompressedData
int zip64
struct zip64_internal

Definition at line 165 of file zip.c.

Collaboration diagram for zip64_internal:
Collaboration graph
Class Members
ZPOS64_T add_position_when_writting_offset
ZPOS64_T begin_pos
linkedlist_data central_dir
curfile64_info ci
voidpf filestream
char * globalcomment
int in_opened_file_inzip
ZPOS64_T number_entry
zlib_filefunc64_32_def z_filefunc

Macro Definition Documentation

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

Definition at line 62 of file zip.c.

#define BUFREADCOMMENT   (0x400)

Definition at line 472 of file zip.c.

#define CENTRALHEADERMAGIC   (0x02014b50)

Definition at line 104 of file zip.c.

#define CRC_LOCALHEADER_OFFSET   (0x0e)

Definition at line 110 of file zip.c.

#define ENDHEADERMAGIC   (0x06054b50)

Definition at line 105 of file zip.c.

#define FLAG_LOCALHEADER_OFFSET   (0x06)

Definition at line 109 of file zip.c.

#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED

Definition at line 185 of file zip.c.

#define local   static

Definition at line 45 of file zip.c.

#define LOCALHEADERMAGIC   (0x04034b50)

Definition at line 103 of file zip.c.

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

Definition at line 77 of file zip.c.

#define SEEK_CUR   1

Definition at line 80 of file zip.c.

#define SEEK_END   2

Definition at line 84 of file zip.c.

#define SEEK_SET   0

Definition at line 88 of file zip.c.

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

Definition at line 112 of file zip.c.

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

Definition at line 101 of file zip.c.

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

Definition at line 65 of file zip.c.

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

Definition at line 50 of file zip.c.

#define Z_BUFSIZE   (64*1024)

Definition at line 54 of file zip.c.

#define Z_MAXFILENAMEINZIP   (256)

Definition at line 58 of file zip.c.

#define ZIP64ENDHEADERMAGIC   (0x6064b50)

Definition at line 106 of file zip.c.

#define ZIP64ENDLOCHEADERMAGIC   (0x7064b50)

Definition at line 107 of file zip.c.

Function Documentation

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

Definition at line 225 of file zip.c.

static linkedlist_datablock_internal* allocate_new_datablock ( )
static

Definition at line 189 of file zip.c.

static void free_datablock ( linkedlist_datablock_internal ldi)
static

Definition at line 203 of file zip.c.

static void free_linkedlist ( linkedlist_data ll)
static

Definition at line 218 of file zip.c.

static void init_linkedlist ( linkedlist_data ll)
static

Definition at line 213 of file zip.c.

int LoadCentralDirectoryRecord ( zip64_internal pziinit)

Definition at line 640 of file zip.c.

static int zip64local_putValue OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)  )
static
static void zip64local_putValue_inmemory OF ( (void *dest, ZPOS64_T x, int nbByte)  )
static
static int zip64local_getByte OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, int *pi)  )
static
static int zip64local_getShort OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)  )
static
static int zip64local_getLong64 OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)  )
static
static ZPOS64_T zip64local_SearchCentralDir OF ( (const zlib_filefunc64_32_def *pzlib_filefunc_def, voidpf filestream)  )
static
int Write_EndOfCentralDirectoryRecord ( zip64_internal zi,
uLong  size_centraldir,
ZPOS64_T  centraldir_pos_inzip 
)

Definition at line 1816 of file zip.c.

int Write_GlobalComment ( zip64_internal zi,
const char *  global_comment 
)

Definition at line 1864 of file zip.c.

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

Definition at line 958 of file zip.c.

int Write_Zip64EndOfCentralDirectoryLocator ( zip64_internal zi,
ZPOS64_T  zip64eocd_pos_inzip 
)

Definition at line 1755 of file zip.c.

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

Definition at line 1777 of file zip.c.

static int zip64FlushWriteBuffer ( zip64_internal zi)
static

Definition at line 1363 of file zip.c.

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

Definition at line 349 of file zip.c.

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

Definition at line 395 of file zip.c.

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

Definition at line 426 of file zip.c.

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

Definition at line 373 of file zip.c.

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

Definition at line 287 of file zip.c.

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

Definition at line 311 of file zip.c.

static ZPOS64_T zip64local_SearchCentralDir ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)
static

Definition at line 480 of file zip.c.

static ZPOS64_T zip64local_SearchCentralDir64 ( const zlib_filefunc64_32_def pzlib_filefunc_def,
voidpf  filestream 
)
static

Definition at line 542 of file zip.c.

static uLong zip64local_TmzDateToDosDate ( const tm_zip ptm)
static

Definition at line 332 of file zip.c.

int ZEXPORT zipClose ( zipFile  file,
const char *  global_comment 
)

Definition at line 1882 of file zip.c.

int ZEXPORT zipCloseFileInZip ( zipFile  file)

Definition at line 1750 of file zip.c.

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

Definition at line 1509 of file zip.c.

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

set internal file attributes field

Definition at line 1514 of file zip.c.

zipFile ZEXPORT zipOpen ( const char *  pathname,
int  append 
)

Definition at line 948 of file zip.c.

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

Definition at line 920 of file zip.c.

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

Definition at line 932 of file zip.c.

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.

zipFile ZEXPORT zipOpen64 ( const void *  pathname,
int  append 
)

Definition at line 953 of file zip.c.

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 1350 of file zip.c.

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 1311 of file zip.c.

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 1324 of file zip.c.

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 1281 of file zip.c.

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 1296 of file zip.c.

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 1265 of file zip.c.

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 1055 of file zip.c.

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 1337 of file zip.c.

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

Definition at line 1951 of file zip.c.

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

Definition at line 1402 of file zip.c.

Variable Documentation

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.