/*
* This is intended to be a standalone, reduced capability
* implementation of Gzip and Zip functionality. Its
* targeted use case is for archiving and retrieving single files
* which use these encoding types. Being memory based and
* non-optimized, it is not useful in cases where very large
* archives are needed or where high performance is desired.
* However, it should hopefully work very well for smaller,
* one-at-a-time tasks. What you get in return is the ability
* to drop these files into your project and remove the dependencies
* on ZLib and Info-Zip. Enjoy.
*
* Authors:
* Bob Jamison
*
* Copyright (C) 2006-2007 Bob Jamison
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <string>
#include "ziptool.h"
//########################################################################
//# A D L E R 3 2
//########################################################################
/**
* Constructor
*/
{
reset();
}
/**
* Destructor
*/
{
}
/**
* Reset Adler-32 checksum to initial value.
*/
{
value = 1;
}
// ADLER32_BASE is the largest prime number smaller than 65536
{
s1 += b & 0xff;
}
{
if (str)
while (*str)
}
/**
* Returns current checksum value.
*/
{
return value & 0xffffffffL;
}
//########################################################################
//# C R C 3 2
//########################################################################
/**
* Constructor
*/
{
reset();
}
/**
* Destructor
*/
{
}
static bool crc_table_ready = false;
/**
* make the table for a fast CRC.
*/
static void makeCrcTable()
{
if (crc_table_ready)
return;
for (int n = 0; n < 256; n++)
{
unsigned long c = n;
for (int k = 8; --k >= 0; )
{
if ((c & 1) != 0)
c = 0xedb88320 ^ (c >> 1);
else
c >>= 1;
}
crc_table[n] = c;
}
crc_table_ready = true;
}
/**
* Reset CRC-32 checksum to initial value.
*/
{
value = 0;
makeCrcTable();
}
{
unsigned long c = ~value;
c &= 0xffffffff;
value = ~c;
}
{
if (str)
while (*str)
}
{
{
}
}
/**
* Returns current checksum value.
*/
{
return value & 0xffffffffL;
}
//########################################################################
//# I N F L A T E R
//########################################################################
/**
*
*/
typedef struct
{
} Huffman;
/**
*
*/
class Inflater
{
public:
Inflater();
virtual ~Inflater();
/**
*
*/
private:
/**
*
*/
#ifdef G_GNUC_PRINTF
#endif
;
/**
*
*/
#ifdef G_GNUC_PRINTF
#endif
;
/**
*
*/
void dump();
/**
*
*/
/**
*
*/
/**
*
*/
/**
*
*/
/**
*
*/
bool doStored();
/**
*
*/
bool doFixed();
/**
*
*/
bool doDynamic();
int bitBuf;
int bitCnt;
};
/**
*
*/
dest(),
src(),
srcPos(0),
bitBuf(0),
bitCnt(0)
{
}
/**
*
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
{
}
}
/**
*
*/
{
// count number of codes of each length
if (h->count[0] == n) // no codes!
{
error("huffman tree will result in failed decode");
return -1;
}
// check for an over-subscribed or incomplete set of lengths
{
if (left < 0)
{
error("huffman over subscribed");
return -1;
}
}
// generate offsets into symbol table for each length for sorting
offs[1] = 0;
/*
* put symbols in table sorted by length, by symbol order within each
* length
*/
// return zero for complete set, positive for incomplete set
return left;
}
/**
*
*/
{
//add more bytes if needed
while (bitCnt < requiredBits)
{
{
error("premature end of input");
return false;
}
bitCnt += 8;
}
//update the buffer and return the data
bitCnt -= requiredBits;
return true;
}
/**
*
*/
{
int code = 0;
int first = 0;
int index = 0;
while (true)
{
while (left--)
{
bitTmp >>= 1;
{ /* if length len, return symbol */
}
first <<= 1;
code <<= 1;
len++;
}
if (left == 0)
break;
{
error("premature end of input");
dump();
return -1;
}
if (left > 8)
left = 8;
}
error("no end of block found");
return -1;
}
/**
*
*/
{
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577};
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
12, 12, 13, 13};
while (true)
{
if (symbol == 256)
break;
if (symbol < 0)
{
return false;
}
{
}
{
symbol -= 257;
if (symbol >= 29)
{
error("invalid fixed code");
return false;
}
int ret;
return false;
if (symbol < 0)
{
return false;
}
return false;
{
dump();
//printf("pos:%d\n", srcPos);
return false;
}
// copy length bytes from distance bytes back
//dest.push_back('{');
while (len--)
{
}
//dest.push_back('}');
}
}
return true;
}
/**
*/
{
//trace("### stored ###");
// clear bits from current byte
bitBuf = 0;
bitCnt = 0;
// length
{
error("not enough input");
return false;
}
//trace("### len:%d", len);
// check complement
{
error("twos complement for storage size do not match");
return false;
}
// copy data
{
error("Not enough input for stored block");
return false;
}
while (len--)
return true;
}
/**
*/
{
//trace("### fixed ###");
static bool firstTime = true;
if (firstTime)
{
firstTime = false;
int symbol = 0;
// distance table
}
// decode data until end-of-block code
return ret;
}
/**
*/
{
//trace("### dynamic ###");
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
// get number of lengths in each table, check lengths
int ret;
return false;
return false;
return false;
{
error("Bad codes");
return false;
}
// get code length code lengths
int index = 0;
{
return false;
}
// build huffman table for code lengths codes
return false;
index = 0;
{
else
{ // repeat instruction
if (symbol == 16)
{ // repeat last length 3..6 times
if (index == 0)
{
error("no last length");
return false;
}
return false;
}
{
return false;
}
else // == 18, repeat zero 11..138 times
{
return false;
}
{
error("too many lengths");
return false;
}
while (symbol--) // repeat last or zero symbol times
}
}
{
error("incomplete length codes");
//return false;
}
// build huffman table for distance codes
{
error("incomplete dist codes");
return false;
}
// decode data until end-of-block code
return retn;
}
/**
*/
{
srcPos = 0;
bitBuf = 0;
bitCnt = 0;
while (true)
{
return false;
return false;
switch (type)
{
case 0:
if (!doStored())
return false;
break;
case 1:
if (!doFixed())
return false;
break;
case 2:
if (!doDynamic())
return false;
break;
default:
return false;
}
if (last)
break;
}
destination = dest;
return true;
}
//########################################################################
//# D E F L A T E R
//########################################################################
class Deflater
{
public:
/**
*
*/
Deflater();
/**
*
*/
virtual ~Deflater();
/**
*
*/
virtual void reset();
/**
*
*/
/**
*
*/
virtual bool finish();
/**
*
*/
/**
*
*/
private:
//debug messages
#ifdef G_GNUC_PRINTF
#endif
;
#ifdef G_GNUC_PRINTF
#endif
;
bool compressWindow();
bool compress();
unsigned int windowPos;
//#### Output
unsigned int outputBitBuf;
unsigned int outputNrBits;
void putFlush();
//#### Huffman Encode
void encodeLiteralStatic(unsigned int ch);
//assume 32-bit ints
};
//########################################################################
//# A P I
//########################################################################
/**
*
*/
{
reset();
}
/**
*
*/
{
}
/**
*
*/
{
compressed.clear();
windowPos = 0;
outputBitBuf = 0;
outputNrBits = 0;
for (int k=0; k<DEFLATER_BUF_SIZE; k++)
{
windowBuf[k]=0;
windowHashBuf[k]=0;
}
}
/**
*
*/
{
return true;
}
/**
*
*/
{
return compress();
}
/**
*
*/
{
return compressed;
}
/**
*
*/
{
reset();
uncompressed = src;
if (!compress())
return false;
dest = compressed;
return true;
}
//########################################################################
//# W O R K I N G C O D E
//########################################################################
//#############################
//# M E S S A G E S
//#############################
/**
* Print error messages
*/
{
}
/**
* Print trace messages
*/
{
}
//#############################
//# O U T P U T
//#############################
/**
*
*/
{
outputBitBuf = 0;
outputNrBits = 0;
}
/**
*
*/
{
}
/**
*
*/
{
if (outputNrBits > 0)
{
}
outputBitBuf = 0;
outputNrBits = 0;
}
/**
*
*/
{
//trace("n:%4u, %d\n", ch, bitsWanted);
while (bitsWanted--)
{
//add bits to position 7. shift right
ch >>= 1;
outputNrBits++;
if (outputNrBits >= 8)
{
unsigned char b = outputBitBuf & 0xff;
//printf("b:%02x\n", b);
put(b);
}
}
}
{
unsigned int outb = 0;
while (nrBits--)
{
code >>= 1;
}
return outb;
}
/**
*
*/
{
//trace("r:%4u, %d", ch, bitsWanted);
}
//#############################
//# E N C O D E
//#############################
{
//trace("c: %d", ch);
if (ch < 144)
{
}
else if (ch < 256)
{
}
else if (ch < 280)
{
}
else if (ch < 288)
{
}
else //out of range
{
}
}
typedef struct
{
unsigned int base;
unsigned int range;
unsigned int bits;
} LenBase;
{
{ 3, 1, 0 },
{ 4, 1, 0 },
{ 5, 1, 0 },
{ 6, 1, 0 },
{ 7, 1, 0 },
{ 8, 1, 0 },
{ 9, 1, 0 },
{ 10, 1, 0 },
{ 11, 2, 1 },
{ 13, 2, 1 },
{ 15, 2, 1 },
{ 17, 2, 1 },
{ 19, 4, 2 },
{ 23, 4, 2 },
{ 27, 4, 2 },
{ 31, 4, 2 },
{ 35, 8, 3 },
{ 43, 8, 3 },
{ 51, 8, 3 },
{ 59, 8, 3 },
{ 67, 16, 4 },
{ 83, 16, 4 },
{ 99, 16, 4 },
{ 115, 16, 4 },
{ 131, 32, 5 },
{ 163, 32, 5 },
{ 195, 32, 5 },
{ 227, 32, 5 },
{ 258, 1, 0 }
};
typedef struct
{
unsigned int base;
unsigned int range;
unsigned int bits;
} DistBase;
{
{ 1, 1, 0 },
{ 2, 1, 0 },
{ 3, 1, 0 },
{ 4, 1, 0 },
{ 5, 2, 1 },
{ 7, 2, 1 },
{ 9, 4, 2 },
{ 13, 4, 2 },
{ 17, 8, 3 },
{ 25, 8, 3 },
{ 33, 16, 4 },
{ 49, 16, 4 },
{ 65, 32, 5 },
{ 97, 32, 5 },
{ 129, 64, 6 },
{ 193, 64, 6 },
{ 257, 128, 7 },
{ 385, 128, 7 },
{ 513, 256, 8 },
{ 769, 256, 8 },
{ 1025, 512, 9 },
{ 1537, 512, 9 },
{ 2049, 1024, 10 },
{ 3073, 1024, 10 },
{ 4097, 2048, 11 },
{ 6145, 2048, 11 },
{ 8193, 4096, 12 },
{ 12289, 4096, 12 },
{ 16385, 8192, 13 },
{ 24577, 8192, 13 }
};
{
//## Output length
{
return;
}
bool found = false;
for (int i=0 ; i<30 ; i++)
{
{
//trace("--- %d %d %d %d", len, base, range, length);
found = true;
break;
}
}
if (!found)
{
return;
}
//## Output distance
{
return;
}
found = false;
for (int i=0 ; i<30 ; i++)
{
{
unsigned int distCode = i;
//error("--- %d %d %d %d", dist, base, range, distance);
found = true;
break;
}
}
if (!found)
{
return;
}
}
//#############################
//# C O M P R E S S
//#############################
/**
* This method does the dirty work of dictionary
* compression. Basically it looks for redundant
* strings and has the current duplicate refer back
* to the previous one.
*/
{
windowPos = 0;
//### Compress as much of the window as possible
unsigned int hash = 0;
//Have each value be a long with the byte at this position,
//plus the 3 bytes after it in the window
for (int i=windowSize-1 ; i>=0 ; i--)
{
windowHashBuf[i] = hash;
}
{
//### Find best match, if any
unsigned int bestMatchLen = 0;
unsigned int bestMatchDist = 0;
if (windowPos >= 4)
{
{
//Check 4-char hashes first, before continuing with string
{
if (lookAheadMax > 258)
lookAheadMax = 258;
while (lookAhead<lookAheadMax)
{
break;
lookAhead++;
}
if (lookAhead > bestMatchLen)
{
}
}
}
}
if (bestMatchLen > 3)
{
//Distance encode
//trace("### distance");
/*
printf("### 1 '");
for (int i=0 ; i < bestMatchLen ; i++)
fputc(window[windowPos+i], stdout);
printf("'\n### 2 '");
for (int i=0 ; i < bestMatchLen ; i++)
fputc(window[windowPos-bestMatchDist+i], stdout);
printf("'\n");
*/
}
else
{
//Literal encode
//trace("### literal");
windowPos++;
}
}
while (windowPos < windowSize)
encodeLiteralStatic(256);
return true;
}
/**
*
*/
{
//trace("compress");
unsigned long total = 0L;
windowPos = 0;
{
{
++iter;
}
else
if (!compressWindow())
return false;
}
putFlush();
return true;
}
//########################################################################
//# G Z I P F I L E
//########################################################################
/**
* Constructor
*/
data(),
fileName(),
fileBuf(),
fileBufPos(0),
{
}
/**
* Destructor
*/
{
}
/**
* Print error messages
*/
{
}
/**
* Print trace messages
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
return data;
}
/**
*
*/
{
return fileName;
}
/**
*
*/
{
}
//#####################################
//# U T I L I T Y
//#####################################
/**
* Loads a new file into an existing GzipFile
*/
{
if (!f)
{
return false;
}
while (true)
{
if (ch < 0)
break;
}
fclose(f);
return true;
}
//#####################################
//# W R I T E
//#####################################
/**
*
*/
{
return true;
}
/**
*
*/
{
return true;
}
/**
*
*/
{
//xfl
putByte(0);
//OS
putByte(0);
//file name
putByte(0);
//compress
{
return false;
}
{
}
return true;
}
/**
*
*/
{
if (!write())
return false;
return true;
}
/**
*
*/
{
if (!write())
return false;
if (!f)
return false;
{
}
fclose(f);
return true;
}
//#####################################
//# R E A D
//#####################################
{
{
error("unexpected end of data");
return false;
}
return true;
}
/**
*
*/
{
return false;
((ch1 ) & 0x000000ffL);
return true;
}
{
fileBufPos = 0;
unsigned char ch;
//magic cookie
return false;
if (ch != 0x1f)
{
error("bad gzip header");
return false;
}
return false;
if (ch != 0x8b)
{
error("bad gzip header");
return false;
}
//## compression method
return false;
//## flags
return false;
//bool ftext = ch & 0x01;
//trace("cm:%d ftext:%d fhcrc:%d fextra:%d fname:%d fcomment:%d",
// cm, ftext, fhcrc, fextra, fname, fcomment);
//## file time
unsigned long ltime;
return false;
//time_t mtime = (time_t)ltime;
//## XFL
return false;
//int xfl = ch;
//## OS
return false;
//int os = ch;
//std::string timestr = ctime(&mtime);
//trace("xfl:%d os:%d mtime:%s", xfl, os, timestr.c_str());
if (fextra)
{
return false;
return false;
for (long l=0 ; l<xlen ; l++)
{
return false;
}
}
if (fname)
{
fileName = "";
while (true)
{
return false;
if (ch==0)
break;
}
}
if (fcomment)
{
while (true)
{
return false;
if (ch==0)
break;
}
}
if (fhcrc)
{
return false;
return false;
}
//read remainder of stream
//compressed data runs up until 8 bytes before end of buffer
{
return false;
}
//uncompress
{
return false;
}
//Get the CRC and compare
unsigned long givenCrc;
return false;
{
error("Specified crc, %ud, not what received: %ud",
return false;
}
//Get the file size and compare
unsigned long givenFileSize;
if (!getLong(&givenFileSize))
return false;
{
error("Specified data size, %ld, not what received: %ld",
return false;
}
return true;
}
/**
*
*/
{
if (!read())
return false;
return true;
}
/**
*
*/
{
if (!f)
return false;
while (true)
{
if (ch < 0)
break;
}
fclose(f);
if (!read())
return false;
return true;
}
//########################################################################
//# Z I P F I L E
//########################################################################
/**
* Constructor
*/
crc (0L),
fileName (),
comment (),
compressionMethod (8),
compressedData (),
uncompressedData (),
position (0)
{
}
/**
*
*/
crc (0L),
compressionMethod (8),
compressedData (),
uncompressedData (),
position (0)
{
}
/**
* Destructor
*/
{
}
/**
*
*/
{
return fileName;
}
/**
*
*/
{
}
/**
*
*/
{
return comment;
}
/**
*
*/
{
}
/**
*
*/
{
return (unsigned long)compressedData.size();
}
/**
*
*/
{
return compressionMethod;
}
/**
*
*/
{
}
/**
*
*/
{
return compressedData;
}
/**
*
*/
{
}
/**
*
*/
{
return (unsigned long)uncompressedData.size();
}
/**
*
*/
{
return uncompressedData;
}
/**
*
*/
{
}
/**
*
*/
{
return crc;
}
/**
*
*/
{
}
/**
*
*/
{
}
/**
*
*/
{
{
}
switch (compressionMethod)
{
case 0: //none
{
{
}
break;
}
case 8: //deflate
{
{
//some error
}
break;
}
default:
{
printf("error: unknown compression method %d\n",
}
}
}
/**
*
*/
{
crc = 0L;
if (!f)
{
return false;
}
while (true)
{
if (ch < 0)
break;
}
fclose(f);
finish();
return true;
}
/**
*
*/
{
}
/**
*
*/
{
return position;
}
/**
* Constructor
*/
entries(),
fileBuf(),
fileBufPos(0),
comment()
{
}
/**
* Destructor
*/
{
{
delete entry;
}
}
/**
*
*/
{
}
/**
*
*/
{
return comment;
}
/**
*
*/
{
return entries;
}
//#####################################
//# M E S S A G E S
//#####################################
{
}
{
}
//#####################################
//# U T I L I T Y
//#####################################
/**
*
*/
{
{
delete ze;
return NULL;
}
return ze;
}
/**
*
*/
{
return ze;
}
//#####################################
//# W R I T E
//#####################################
/**
*
*/
{
return true;
}
/**
*
*/
{
return true;
}
/**
*
*/
{
return true;
}
/**
*
*/
{
{
//##### HEADER
putLong(0x04034b50L);
putInt(0); //gpBitFlag
//putInt(0); //compression method
putInt(0); //mod time
putInt(0); //mod date
//file name
//extra field
putInt(0x7855);
putInt(4);
putInt(100);
putInt(100);
//##### DATA
{
}
}
return true;
}
/**
*
*/
{
{
putInt(0); //gpBitFlag
putInt(0); //mod time
putInt(0); //mod date
putInt(0); //disk number start
putInt(0); //internal attributes
putLong(0); //external attributes
//file name
//extra field
putInt(0x7855);
putInt(0);
//comment
}
putLong(0x06054b50L);
putInt(0);//number of this disk
putInt(0);//nr of disk with central dir
return true;
}
/**
*
*/
{
if (!writeFileData())
return false;
if (!writeCentralDirectory())
return false;
return true;
}
/**
*
*/
{
if (!write())
return false;
return true;
}
/**
*
*/
{
if (!write())
return false;
if (!f)
return false;
{
}
fclose(f);
return true;
}
//#####################################
//# R E A D
//#####################################
/**
*
*/
{
return false;
((ch1 ) & 0x000000ffL);
return true;
}
/**
*
*/
{
return false;
((ch1 ) & 0x00ff);
return true;
}
/**
*
*/
{
return false;
return true;
}
/**
*
*/
{
//printf("#################################################\n");
//printf("###D A T A\n");
//printf("#################################################\n");
while (true)
{
unsigned long magicCookie;
if (!getLong(&magicCookie))
{
error("magic cookie not found");
break;
}
break;
if (magicCookie != 0x04034b50L)
{
error("file header not found");
return false;
}
unsigned int versionNeeded;
if (!getInt(&versionNeeded))
{
error("bad version needed found");
return false;
}
unsigned int gpBitFlag;
{
error("bad bit flag found");
return false;
}
unsigned int compressionMethod;
if (!getInt(&compressionMethod))
{
error("bad compressionMethod found");
return false;
}
unsigned int modTime;
{
error("bad modTime found");
return false;
}
unsigned int modDate;
{
error("bad modDate found");
return false;
}
unsigned long crc32;
{
error("bad crc32 found");
return false;
}
unsigned long compressedSize;
if (!getLong(&compressedSize))
{
error("bad compressedSize found");
return false;
}
unsigned long uncompressedSize;
if (!getLong(&uncompressedSize))
{
error("bad uncompressedSize found");
return false;
}
unsigned int fileNameLength;
if (!getInt(&fileNameLength))
{
error("bad fileNameLength found");
return false;
}
unsigned int extraFieldLength;
if (!getInt(&extraFieldLength))
{
error("bad extraFieldLength found");
return false;
}
for (unsigned int i=0 ; i<fileNameLength ; i++)
{
unsigned char ch;
break;
}
for (unsigned int i=0 ; i<extraFieldLength ; i++)
{
unsigned char ch;
break;
}
trace("######################### DATA");
//#### Uncompress the data
{
while (true)
{
unsigned char ch;
{
error("premature end of data");
break;
}
{
trace("found end of compressed data");
//remove the cookie
break;
}
}
}
else
{
{
unsigned char ch;
{
error("premature end of data");
break;
}
}
}
printf("### data: ");
for (int i=0 ; i<10 ; i++)
printf("\n");
{
/* this cookie was read in the loop above
unsigned long dataDescriptorSignature ;
if (!getLong(&dataDescriptorSignature))
break;
if (dataDescriptorSignature != 0x08074b50L)
{
error("bad dataDescriptorSignature found");
return false;
}
*/
unsigned long crc32;
{
error("bad crc32 found");
return false;
}
unsigned long compressedSize;
if (!getLong(&compressedSize))
{
error("bad compressedSize found");
return false;
}
unsigned long uncompressedSize;
if (!getLong(&uncompressedSize))
{
error("bad uncompressedSize found");
return false;
}
}//bit 3 was set
//break;
switch (compressionMethod)
{
case 8: //deflate
{
{
return false;
}
break;
}
default:
{
return false;
}
}
{
error("Size mismatch. Expected %ld, received %ld",
return false;
}
{
return false;
}
}
return true;
}
/**
*
*/
{
//printf("#################################################\n");
//printf("###D I R E C T O R Y\n");
//printf("#################################################\n");
while (true)
{
//We start with a central directory cookie already
//Check at the bottom of the loop.
unsigned int version;
{
error("bad version found");
return false;
}
unsigned int versionNeeded;
if (!getInt(&versionNeeded))
{
error("bad version found");
return false;
}
unsigned int gpBitFlag;
{
error("bad bit flag found");
return false;
}
unsigned int compressionMethod;
if (!getInt(&compressionMethod))
{
error("bad compressionMethod found");
return false;
}
unsigned int modTime;
{
error("bad modTime found");
return false;
}
unsigned int modDate;
{
error("bad modDate found");
return false;
}
unsigned long crc32;
{
error("bad crc32 found");
return false;
}
unsigned long compressedSize;
if (!getLong(&compressedSize))
{
error("bad compressedSize found");
return false;
}
unsigned long uncompressedSize;
if (!getLong(&uncompressedSize))
{
error("bad uncompressedSize found");
return false;
}
unsigned int fileNameLength;
if (!getInt(&fileNameLength))
{
error("bad fileNameLength found");
return false;
}
unsigned int extraFieldLength;
if (!getInt(&extraFieldLength))
{
error("bad extraFieldLength found");
return false;
}
unsigned int fileCommentLength;
if (!getInt(&fileCommentLength))
{
error("bad fileCommentLength found");
return false;
}
unsigned int diskNumberStart;
if (!getInt(&diskNumberStart))
{
error("bad diskNumberStart found");
return false;
}
unsigned int internalFileAttributes;
if (!getInt(&internalFileAttributes))
{
error("bad internalFileAttributes found");
return false;
}
unsigned long externalFileAttributes;
if (!getLong(&externalFileAttributes))
{
error("bad externalFileAttributes found");
return false;
}
unsigned long localHeaderOffset;
if (!getLong(&localHeaderOffset))
{
error("bad localHeaderOffset found");
return false;
}
for (unsigned int i=0 ; i<fileNameLength ; i++)
{
unsigned char ch;
break;
}
for (unsigned int i=0 ; i<extraFieldLength ; i++)
{
unsigned char ch;
break;
}
for (unsigned int i=0 ; i<fileCommentLength ; i++)
{
unsigned char ch;
break;
}
trace("######################### ENTRY");
unsigned long magicCookie;
if (!getLong(&magicCookie))
{
error("magic cookie not found");
return false;
}
break;
{
//## Digital Signature
unsigned int signatureSize;
if (!getInt(&signatureSize))
{
error("bad signatureSize found");
return false;
}
for (unsigned int i=0 ; i<signatureSize ; i++)
{
unsigned char ch;
break;
}
}
{
error("directory file header not found");
return false;
}
}
unsigned int diskNr;
{
error("bad diskNr found");
return false;
}
unsigned int diskWithCd;
if (!getInt(&diskWithCd))
{
error("bad diskWithCd found");
return false;
}
unsigned int nrEntriesDisk;
if (!getInt(&nrEntriesDisk))
{
error("bad nrEntriesDisk found");
return false;
}
unsigned int nrEntriesTotal;
if (!getInt(&nrEntriesTotal))
{
error("bad nrEntriesTotal found");
return false;
}
unsigned long cdSize;
{
error("bad cdSize found");
return false;
}
unsigned long cdPos;
{
error("bad cdPos found");
return false;
}
unsigned int commentSize;
if (!getInt(&commentSize))
{
error("bad commentSize found");
return false;
}
comment = "";
for (unsigned int i=0 ; i<commentSize ; i++)
{
unsigned char ch;
break;
}
return true;
}
/**
*
*/
{
fileBufPos = 0;
if (!readFileData())
{
return false;
}
if (!readCentralDirectory())
{
return false;
}
return true;
}
/**
*
*/
{
if (!read())
return false;
return true;
}
/**
*
*/
{
if (!f)
return false;
while (true)
{
if (ch < 0)
break;
}
fclose(f);
if (!read())
return false;
return true;
}
//########################################################################
//# E N D O F F I L E
//########################################################################