zlib 1.2.1

This commit is contained in:
James Turk 2003-12-13 04:13:40 +00:00
parent b8335aa3ff
commit 882008e1ec
36 changed files with 15674 additions and 8636 deletions

441
include/zlib/crc32.h Normal file
View File

@ -0,0 +1,441 @@
/* crc32.h -- tables for rapid CRC calculation
* Generated automatically by crc32.c
*/
local const unsigned long FAR crc_table[TBLS][256] =
{
{
0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
0x2d02ef8dUL
#ifdef BYFOUR
},
{
0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
0x9324fd72UL
},
{
0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
0xbe9834edUL
},
{
0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
0xde0506f1UL
},
{
0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
0x8def022dUL
},
{
0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
0x72fd2493UL
},
{
0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
0xed3498beUL
},
{
0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
0xf10605deUL
#endif
}
};

132
include/zlib/crypt.h Normal file
View File

@ -0,0 +1,132 @@
/* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}
/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
while (*passwd != '\0') {
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++;
}
}
#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN)
return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n;
}
#endif

View File

@ -1,318 +1,326 @@
/* deflate.h -- internal compression state /* deflate.h -- internal compression state
* Copyright (C) 1995-2002 Jean-loup Gailly * Copyright (C) 1995-2002 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* @(#) $Id: deflate.h,v 1.1 2003/10/13 21:02:38 cozman Exp $ */ /* @(#) $Id: deflate.h,v 1.2 2003/12/13 04:15:27 cozman Exp $ */
#ifndef _DEFLATE_H #ifndef DEFLATE_H
#define _DEFLATE_H #define DEFLATE_H
#include "zutil.h" #include "zutil.h"
/* =========================================================================== /* define NO_GZIP when compiling if you want to disable gzip header and
* Internal compression state. trailer creation by deflate(). NO_GZIP would be used to avoid linking in
*/ the crc code when it is not needed. For shared libraries, gzip encoding
should be left enabled. */
#define LENGTH_CODES 29 #ifndef NO_GZIP
/* number of length codes, not counting the special END_BLOCK code */ # define GZIP
#endif
#define LITERALS 256
/* number of literal bytes 0..255 */ /* ===========================================================================
* Internal compression state.
#define L_CODES (LITERALS+1+LENGTH_CODES) */
/* number of Literal or Length codes, including the END_BLOCK code */
#define LENGTH_CODES 29
#define D_CODES 30 /* number of length codes, not counting the special END_BLOCK code */
/* number of distance codes */
#define LITERALS 256
#define BL_CODES 19 /* number of literal bytes 0..255 */
/* number of codes used to transfer the bit lengths */
#define L_CODES (LITERALS+1+LENGTH_CODES)
#define HEAP_SIZE (2*L_CODES+1) /* number of Literal or Length codes, including the END_BLOCK code */
/* maximum heap size */
#define D_CODES 30
#define MAX_BITS 15 /* number of distance codes */
/* All codes must not exceed MAX_BITS bits */
#define BL_CODES 19
#define INIT_STATE 42 /* number of codes used to transfer the bit lengths */
#define BUSY_STATE 113
#define FINISH_STATE 666 #define HEAP_SIZE (2*L_CODES+1)
/* Stream status */ /* maximum heap size */
#define MAX_BITS 15
/* Data structure describing a single value and its code string. */ /* All codes must not exceed MAX_BITS bits */
typedef struct ct_data_s {
union { #define INIT_STATE 42
ush freq; /* frequency count */ #define BUSY_STATE 113
ush code; /* bit string */ #define FINISH_STATE 666
} fc; /* Stream status */
union {
ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */ /* Data structure describing a single value and its code string. */
} dl; typedef struct ct_data_s {
} FAR ct_data; union {
ush freq; /* frequency count */
#define Freq fc.freq ush code; /* bit string */
#define Code fc.code } fc;
#define Dad dl.dad union {
#define Len dl.len ush dad; /* father node in Huffman tree */
ush len; /* length of bit string */
typedef struct static_tree_desc_s static_tree_desc; } dl;
} FAR ct_data;
typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */ #define Freq fc.freq
int max_code; /* largest code with non zero frequency */ #define Code fc.code
static_tree_desc *stat_desc; /* the corresponding static tree */ #define Dad dl.dad
} FAR tree_desc; #define Len dl.len
typedef ush Pos; typedef struct static_tree_desc_s static_tree_desc;
typedef Pos FAR Posf;
typedef unsigned IPos; typedef struct tree_desc_s {
ct_data *dyn_tree; /* the dynamic tree */
/* A Pos is an index in the character window. We use short instead of int to int max_code; /* largest code with non zero frequency */
* save space in the various tables. IPos is used only for parameter passing. static_tree_desc *stat_desc; /* the corresponding static tree */
*/ } FAR tree_desc;
typedef struct internal_state { typedef ush Pos;
z_streamp strm; /* pointer back to this zlib stream */ typedef Pos FAR Posf;
int status; /* as the name implies */ typedef unsigned IPos;
Bytef *pending_buf; /* output still pending */
ulg pending_buf_size; /* size of pending_buf */ /* A Pos is an index in the character window. We use short instead of int to
Bytef *pending_out; /* next pending byte to output to the stream */ * save space in the various tables. IPos is used only for parameter passing.
int pending; /* nb of bytes in the pending buffer */ */
int noheader; /* suppress zlib header and adler32 */
Byte data_type; /* UNKNOWN, BINARY or ASCII */ typedef struct internal_state {
Byte method; /* STORED (for zip only) or DEFLATED */ z_streamp strm; /* pointer back to this zlib stream */
int last_flush; /* value of flush param for previous deflate call */ int status; /* as the name implies */
Bytef *pending_buf; /* output still pending */
/* used by deflate.c: */ ulg pending_buf_size; /* size of pending_buf */
Bytef *pending_out; /* next pending byte to output to the stream */
uInt w_size; /* LZ77 window size (32K by default) */ int pending; /* nb of bytes in the pending buffer */
uInt w_bits; /* log2(w_size) (8..16) */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
uInt w_mask; /* w_size - 1 */ Byte data_type; /* UNKNOWN, BINARY or ASCII */
Byte method; /* STORED (for zip only) or DEFLATED */
Bytef *window; int last_flush; /* value of flush param for previous deflate call */
/* Sliding window. Input bytes are read into the second half of the window,
* and move to the first half later to keep a dictionary of at least wSize /* used by deflate.c: */
* bytes. With this organization, matches are limited to a distance of
* wSize-MAX_MATCH bytes, but this ensures that IO is always uInt w_size; /* LZ77 window size (32K by default) */
* performed with a length multiple of the block size. Also, it limits uInt w_bits; /* log2(w_size) (8..16) */
* the window size to 64K, which is quite useful on MSDOS. uInt w_mask; /* w_size - 1 */
* To do: use the user input buffer as sliding window.
*/ Bytef *window;
/* Sliding window. Input bytes are read into the second half of the window,
ulg window_size; * and move to the first half later to keep a dictionary of at least wSize
/* Actual size of window: 2*wSize, except when the user input buffer * bytes. With this organization, matches are limited to a distance of
* is directly used as sliding window. * wSize-MAX_MATCH bytes, but this ensures that IO is always
*/ * performed with a length multiple of the block size. Also, it limits
* the window size to 64K, which is quite useful on MSDOS.
Posf *prev; * To do: use the user input buffer as sliding window.
/* Link to older string with same hash index. To limit the size of this */
* array to 64K, this link is maintained only for the last 32K strings.
* An index in this array is thus a window index modulo 32K. ulg window_size;
*/ /* Actual size of window: 2*wSize, except when the user input buffer
* is directly used as sliding window.
Posf *head; /* Heads of the hash chains or NIL. */ */
uInt ins_h; /* hash index of string to be inserted */ Posf *prev;
uInt hash_size; /* number of elements in hash table */ /* Link to older string with same hash index. To limit the size of this
uInt hash_bits; /* log2(hash_size) */ * array to 64K, this link is maintained only for the last 32K strings.
uInt hash_mask; /* hash_size-1 */ * An index in this array is thus a window index modulo 32K.
*/
uInt hash_shift;
/* Number of bits by which ins_h must be shifted at each input Posf *head; /* Heads of the hash chains or NIL. */
* step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is: uInt ins_h; /* hash index of string to be inserted */
* hash_shift * MIN_MATCH >= hash_bits uInt hash_size; /* number of elements in hash table */
*/ uInt hash_bits; /* log2(hash_size) */
uInt hash_mask; /* hash_size-1 */
long block_start;
/* Window position at the beginning of the current output block. Gets uInt hash_shift;
* negative when the window is moved backwards. /* Number of bits by which ins_h must be shifted at each input
*/ * step. It must be such that after MIN_MATCH steps, the oldest
* byte no longer takes part in the hash key, that is:
uInt match_length; /* length of best match */ * hash_shift * MIN_MATCH >= hash_bits
IPos prev_match; /* previous match */ */
int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */ long block_start;
uInt match_start; /* start of matching string */ /* Window position at the beginning of the current output block. Gets
uInt lookahead; /* number of valid bytes ahead in window */ * negative when the window is moved backwards.
*/
uInt prev_length;
/* Length of the best match at previous step. Matches not greater than this uInt match_length; /* length of best match */
* are discarded. This is used in the lazy match evaluation. IPos prev_match; /* previous match */
*/ int match_available; /* set if previous match exists */
uInt strstart; /* start of string to insert */
uInt max_chain_length; uInt match_start; /* start of matching string */
/* To speed up deflation, hash chains are never searched beyond this uInt lookahead; /* number of valid bytes ahead in window */
* length. A higher limit improves compression ratio but degrades the
* speed. uInt prev_length;
*/ /* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
uInt max_lazy_match; */
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression uInt max_chain_length;
* levels >= 4. /* To speed up deflation, hash chains are never searched beyond this
*/ * length. A higher limit improves compression ratio but degrades the
# define max_insert_length max_lazy_match * speed.
/* Insert new strings in the hash table only if the match length is not */
* greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3. uInt max_lazy_match;
*/ /* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
int level; /* compression level (1..9) */ * levels >= 4.
int strategy; /* favor or force Huffman coding*/ */
# define max_insert_length max_lazy_match
uInt good_match; /* Insert new strings in the hash table only if the match length is not
/* Use a faster search when the previous match is longer than this */ * greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
int nice_match; /* Stop searching when current match exceeds this */ */
/* used by trees.c: */ int level; /* compression level (1..9) */
/* Didn't use ct_data typedef below to supress compiler warning */ int strategy; /* favor or force Huffman coding*/
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ uInt good_match;
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ /* Use a faster search when the previous match is longer than this */
struct tree_desc_s l_desc; /* desc. for literal tree */ int nice_match; /* Stop searching when current match exceeds this */
struct tree_desc_s d_desc; /* desc. for distance tree */
struct tree_desc_s bl_desc; /* desc. for bit length tree */ /* used by trees.c: */
/* Didn't use ct_data typedef below to supress compiler warning */
ush bl_count[MAX_BITS+1]; struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
/* number of codes at each bit length for an optimal tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
int heap_len; /* number of elements in the heap */ struct tree_desc_s l_desc; /* desc. for literal tree */
int heap_max; /* element of largest frequency */ struct tree_desc_s d_desc; /* desc. for distance tree */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. struct tree_desc_s bl_desc; /* desc. for bit length tree */
* The same heap array is used to build all trees.
*/ ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
*/ int heap_len; /* number of elements in the heap */
int heap_max; /* element of largest frequency */
uchf *l_buf; /* buffer for literals or lengths */ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
uInt lit_bufsize; */
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K: uch depth[2*L_CODES+1];
* - frequencies can be kept in 16 bit counters /* Depth of each subtree used as tie breaker for trees of equal frequency
* - if compression is not successful for the first block, all input */
* data is still in the window so we can still emit a stored block even
* when input comes from standard input. (This can also be done for uchf *l_buf; /* buffer for literals or lengths */
* all blocks if lit_bufsize is not greater than 32K.)
* - if compression is not successful for a file smaller than 64K, we can uInt lit_bufsize;
* even emit a stored file instead of a stored block (saving 5 bytes). /* Size of match buffer for literals/lengths. There are 4 reasons for
* This is applicable only for zip (not gzip or zlib). * limiting lit_bufsize to 64K:
* - creating new Huffman trees less frequently may not provide fast * - frequencies can be kept in 16 bit counters
* adaptation to changes in the input data statistics. (Take for * - if compression is not successful for the first block, all input
* example a binary file with poorly compressible code followed by * data is still in the window so we can still emit a stored block even
* a highly compressible string table.) Smaller buffer sizes give * when input comes from standard input. (This can also be done for
* fast adaptation but have of course the overhead of transmitting * all blocks if lit_bufsize is not greater than 32K.)
* trees more frequently. * - if compression is not successful for a file smaller than 64K, we can
* - I can't count above 4 * even emit a stored file instead of a stored block (saving 5 bytes).
*/ * This is applicable only for zip (not gzip or zlib).
* - creating new Huffman trees less frequently may not provide fast
uInt last_lit; /* running index in l_buf */ * adaptation to changes in the input data statistics. (Take for
* example a binary file with poorly compressible code followed by
ushf *d_buf; * a highly compressible string table.) Smaller buffer sizes give
/* Buffer for distances. To simplify the code, d_buf and l_buf have * fast adaptation but have of course the overhead of transmitting
* the same number of elements. To use different lengths, an extra flag * trees more frequently.
* array would be necessary. * - I can't count above 4
*/ */
ulg opt_len; /* bit length of current block with optimal trees */ uInt last_lit; /* running index in l_buf */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */ ushf *d_buf;
int last_eob_len; /* bit length of EOB code for last block */ /* Buffer for distances. To simplify the code, d_buf and l_buf have
* the same number of elements. To use different lengths, an extra flag
#ifdef DEBUG * array would be necessary.
ulg compressed_len; /* total bit length of compressed file mod 2^32 */ */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
ush bi_buf; uInt matches; /* number of string matches in current block */
/* Output buffer. bits are inserted starting at the bottom (least int last_eob_len; /* bit length of EOB code for last block */
* significant bits).
*/ #ifdef DEBUG
int bi_valid; ulg compressed_len; /* total bit length of compressed file mod 2^32 */
/* Number of valid bits in bi_buf. All bits above the last valid bit ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
* are always zero. #endif
*/
ush bi_buf;
} FAR deflate_state; /* Output buffer. bits are inserted starting at the bottom (least
* significant bits).
/* Output a byte on the stream. */
* IN assertion: there is enough room in pending_buf. int bi_valid;
*/ /* Number of valid bits in bi_buf. All bits above the last valid bit
#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} * are always zero.
*/
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) } FAR deflate_state;
/* Minimum amount of lookahead, except at the end of the input file.
* See deflate.c for comments about the MIN_MATCH+1. /* Output a byte on the stream.
*/ * IN assertion: there is enough room in pending_buf.
*/
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
/* In order to simplify the code, particularly on 16 bit machines, match
* distances are limited to MAX_DIST instead of WSIZE.
*/ #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
/* Minimum amount of lookahead, except at the end of the input file.
/* in trees.c */ * See deflate.c for comments about the MIN_MATCH+1.
void _tr_init OF((deflate_state *s)); */
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
int eof)); /* In order to simplify the code, particularly on 16 bit machines, match
void _tr_align OF((deflate_state *s)); * distances are limited to MAX_DIST instead of WSIZE.
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, */
int eof));
/* in trees.c */
#define d_code(dist) \ void _tr_init OF((deflate_state *s));
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
/* Mapping from a distance to a distance code. dist is the distance - 1 and void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
* must not have side effects. _dist_code[256] and _dist_code[257] are never int eof));
* used. void _tr_align OF((deflate_state *s));
*/ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof));
#ifndef DEBUG
/* Inline versions of _tr_tally for speed: */ #define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
#if defined(GEN_TREES_H) || !defined(STDC) /* Mapping from a distance to a distance code. dist is the distance - 1 and
extern uch _length_code[]; * must not have side effects. _dist_code[256] and _dist_code[257] are never
extern uch _dist_code[]; * used.
#else */
extern const uch _length_code[];
extern const uch _dist_code[]; #ifndef DEBUG
#endif /* Inline versions of _tr_tally for speed: */
# define _tr_tally_lit(s, c, flush) \ #if defined(GEN_TREES_H) || !defined(STDC)
{ uch cc = (c); \ extern uch _length_code[];
s->d_buf[s->last_lit] = 0; \ extern uch _dist_code[];
s->l_buf[s->last_lit++] = cc; \ #else
s->dyn_ltree[cc].Freq++; \ extern const uch _length_code[];
flush = (s->last_lit == s->lit_bufsize-1); \ extern const uch _dist_code[];
} #endif
# define _tr_tally_dist(s, distance, length, flush) \
{ uch len = (length); \ # define _tr_tally_lit(s, c, flush) \
ush dist = (distance); \ { uch cc = (c); \
s->d_buf[s->last_lit] = dist; \ s->d_buf[s->last_lit] = 0; \
s->l_buf[s->last_lit++] = len; \ s->l_buf[s->last_lit++] = cc; \
dist--; \ s->dyn_ltree[cc].Freq++; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \
s->dyn_dtree[d_code(dist)].Freq++; \ }
flush = (s->last_lit == s->lit_bufsize-1); \ # define _tr_tally_dist(s, distance, length, flush) \
} { uch len = (length); \
#else ush dist = (distance); \
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) s->d_buf[s->last_lit] = dist; \
# define _tr_tally_dist(s, distance, length, flush) \ s->l_buf[s->last_lit++] = len; \
flush = _tr_tally(s, distance, length) dist--; \
#endif s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
#endif flush = (s->last_lit == s->lit_bufsize-1); \
}
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
#endif /* DEFLATE_H */

View File

@ -1,17 +1,11 @@
/* inffast.h -- header to use inffast.c /* inffast.h -- header to use inffast.c
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
extern int inflate_fast OF(( void inflate_fast OF((z_streamp strm, unsigned start));
uInt,
uInt,
inflate_huft *,
inflate_huft *,
inflate_blocks_statef *,
z_streamp ));

View File

@ -1,151 +1,94 @@
/* inffixed.h -- table for decoding fixed codes /* inffixed.h -- table for decoding fixed codes
* Generated automatically by the maketree.c program * Generated automatically by makefixed().
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It
part of the implementation of the compression library and is is part of the implementation of the compression library and
subject to change. Applications should only use zlib.h. is subject to change. Applications should only use zlib.h.
*/ */
local uInt fixed_bl = 9; static const code lenfix[512] = {
local uInt fixed_bd = 5; {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
local inflate_huft fixed_tl[] = { {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
{{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
{{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
{{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
{{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
{{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
{{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
{{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
{{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, {0,9,255}
{{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, };
{{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201},
{{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, static const code distfix[32] = {
{{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
{{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
{{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
{{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
{{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, {22,5,193},{64,5,0}
{{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, };
{{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165},
{{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229},
{{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149},
{{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213},
{{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181},
{{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245},
{{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205},
{{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173},
{{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237},
{{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157},
{{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221},
{{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189},
{{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253},
{{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131},
{{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195},
{{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163},
{{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227},
{{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147},
{{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211},
{{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179},
{{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243},
{{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258},
{{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203},
{{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171},
{{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235},
{{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155},
{{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219},
{{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187},
{{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251},
{{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195},
{{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199},
{{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167},
{{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231},
{{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151},
{{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215},
{{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183},
{{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247},
{{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0},
{{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207},
{{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175},
{{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239},
{{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159},
{{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223},
{{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191},
{{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255}
};
local inflate_huft fixed_td[] = {
{{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097},
{{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385},
{{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193},
{{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577},
{{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145},
{{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577},
{{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289},
{{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577}
};

117
include/zlib/inflate.h Normal file
View File

@ -0,0 +1,117 @@
/* inflate.h -- internal inflate state definition
* Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip decoding
should be left enabled. */
#ifndef NO_GZIP
# define GUNZIP
#endif
/* Possible inflate modes between inflate() calls */
typedef enum {
HEAD, /* i: waiting for magic header */
#ifdef GUNZIP
FLAGS, /* i: waiting for method and flags (gzip) */
TIME, /* i: waiting for modification time (gzip) */
OS, /* i: waiting for extra flags and operating system (gzip) */
EXLEN, /* i: waiting for extra length (gzip) */
EXTRA, /* i: waiting for extra bytes (gzip) */
NAME, /* i: waiting for end of file name (gzip) */
COMMENT, /* i: waiting for end of comment (gzip) */
HCRC, /* i: waiting for header crc (gzip) */
#endif
DICTID, /* i: waiting for dictionary check value */
DICT, /* waiting for inflateSetDictionary() call */
TYPE, /* i: waiting for type bits, including last-flag bit */
TYPEDO, /* i: same, but skip check to exit inflate on new block */
STORED, /* i: waiting for stored size (length and complement) */
COPY, /* i/o: waiting for input or output to copy stored block */
TABLE, /* i: waiting for dynamic block table lengths */
LENLENS, /* i: waiting for code length code lengths */
CODELENS, /* i: waiting for length/lit and distance code lengths */
LEN, /* i: waiting for length/lit code */
LENEXT, /* i: waiting for length extra bits */
DIST, /* i: waiting for distance code */
DISTEXT, /* i: waiting for distance extra bits */
MATCH, /* o: waiting for output space to copy string */
LIT, /* o: waiting for output space to write literal */
CHECK, /* i: waiting for 32-bit check value */
#ifdef GUNZIP
LENGTH, /* i: waiting for 32-bit length (gzip) */
#endif
DONE, /* finished check, done -- remain here until reset */
BAD, /* got a data error -- remain here until reset */
MEM, /* got an inflate() memory error -- remain here until reset */
SYNC /* looking for synchronization bytes to restart inflate() */
} inflate_mode;
/*
State transitions between above modes -
(most modes can go to the BAD or MEM mode -- not shown for clarity)
Process header:
HEAD -> (gzip) or (zlib)
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
NAME -> COMMENT -> HCRC -> TYPE
(zlib) -> DICTID or TYPE
DICTID -> DICT -> TYPE
Read deflate blocks:
TYPE -> STORED or TABLE or LEN or CHECK
STORED -> COPY -> TYPE
TABLE -> LENLENS -> CODELENS -> LEN
Read deflate codes:
LEN -> LENEXT or LIT or TYPE
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
LIT -> LEN
Process trailer:
CHECK -> LENGTH -> DONE
*/
/* state maintained between inflate() calls. Approximately 7K bytes. */
struct inflate_state {
inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
int havedict; /* true if dictionary provided */
int flags; /* gzip header method and flags (0 if zlib) */
unsigned long check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */
/* sliding window */
unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */
/* for string and stored block copying */
unsigned length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */
/* for table and code decoding */
unsigned extra; /* extra bits needed */
/* fixed and dynamic code tables */
code const FAR *lencode; /* starting table for length/literal codes */
code const FAR *distcode; /* starting table for distance codes */
unsigned lenbits; /* index bits for lencode */
unsigned distbits; /* index bits for distcode */
/* dynamic table building */
unsigned ncode; /* number of code length code lengths */
unsigned nlen; /* number of length code lengths */
unsigned ndist; /* number of distance code lengths */
unsigned have; /* number of code lengths in lens[] */
code FAR *next; /* next available space in codes[] */
unsigned short lens[320]; /* temporary storage for code lengths */
unsigned short work[288]; /* work area for code table building */
code codes[ENOUGH]; /* space for code tables */
};

View File

@ -1,58 +1,55 @@
/* inftrees.h -- header to use inftrees.c /* inftrees.h -- header to use inftrees.c
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* Huffman code lookup table entry--this entry is four bytes for machines /* Structure for decoding tables. Each entry provides either the
that have 16-bit pointers (e.g. PC's in the small or medium model). */ information needed to do the operation requested by the code that
indexed that table entry, or it provides a pointer to another
typedef struct inflate_huft_s FAR inflate_huft; table that indexes more bits of the code. op indicates whether
the entry is a pointer to another table, a literal, a length or
struct inflate_huft_s { distance, an end-of-block, or an invalid code. For a table
union { pointer, the low four bits of op is the number of index bits of
struct { that table. For a length or distance, the low four bits of op
Byte Exop; /* number of extra bits or operation */ is the number of extra bits to get after the code. bits is
Byte Bits; /* number of bits in this code or subcode */ the number of bits in this code or part of the code to drop off
} what; of the bit buffer. val is the actual byte to output in the case
uInt pad; /* pad structure to a power of 2 (4 bytes for */ of a literal, the base length or distance, or the offset from
} word; /* 16-bit, 8 bytes for 32-bit int's) */ the current table to the next table. Each entry is four bytes. */
uInt base; /* literal, length base, distance base, typedef struct {
or table offset */ unsigned char op; /* operation, extra bits, table bits */
}; unsigned char bits; /* bits in this part of the code */
unsigned short val; /* offset in table or code value */
/* Maximum size of dynamic tree. The maximum found in a long but non- } code;
exhaustive search was 1004 huft structures (850 for length/literals
and 154 for distances, the latter actually the result of an /* op values as set by inflate_table():
exhaustive search). The actual maximum is not known, but the 00000000 - literal
value below is more than safe. */ 0000tttt - table link, tttt != 0 is the number of table index bits
#define MANY 1440 0001eeee - length or distance, eeee is the number of extra bits
01100000 - end of block
extern int inflate_trees_bits OF(( 01000000 - invalid code
uIntf *, /* 19 code lengths */ */
uIntf *, /* bits tree desired/actual depth */
inflate_huft * FAR *, /* bits tree result */ /* Maximum size of dynamic tree. The maximum found in a long but non-
inflate_huft *, /* space for trees */ exhaustive search was 1004 code structures (850 for length/literals
z_streamp)); /* for messages */ and 154 for distances, the latter actually the result of an
exhaustive search). The true maximum is not known, but the value
extern int inflate_trees_dynamic OF(( below is more than safe. */
uInt, /* number of literal/length codes */ #define ENOUGH 1440
uInt, /* number of distance codes */ #define MAXD 154
uIntf *, /* that many (total) code lengths */
uIntf *, /* literal desired/actual bit depth */ /* Type of code to build for inftable() */
uIntf *, /* distance desired/actual bit depth */ typedef enum {
inflate_huft * FAR *, /* literal/length tree result */ CODES,
inflate_huft * FAR *, /* distance tree result */ LENS,
inflate_huft *, /* space for trees */ DISTS
z_streamp)); /* for messages */ } codetype;
extern int inflate_trees_fixed OF(( extern int inflate_table OF((codetype type, unsigned short FAR *lens,
uIntf *, /* literal desired/actual bit depth */ unsigned codes, code FAR * FAR *table,
uIntf *, /* distance desired/actual bit depth */ unsigned FAR *bits, unsigned short FAR *work));
inflate_huft * FAR *, /* literal/length tree result */
inflate_huft * FAR *, /* distance tree result */
z_streamp)); /* for memory allocation */

75
include/zlib/ioapi.h Normal file
View File

@ -0,0 +1,75 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
*/
#ifndef _ZLIBIOAPI_H
#define _ZLIBIOAPI_H
#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)
#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)
#ifndef ZCALLBACK
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK
#else
#define ZCALLBACK
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
#ifdef __cplusplus
}
#endif
#endif

21
include/zlib/iowin32.h Normal file
View File

@ -0,0 +1,21 @@
/* iowin32.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This IO API version uses the Win32 API (for Microsoft Windows)
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
*/
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
#ifdef __cplusplus
}
#endif

View File

@ -1,128 +1,128 @@
/* header created automatically with -DGEN_TREES_H */ /* header created automatically with -DGEN_TREES_H */
local const ct_data static_ltree[L_CODES+2] = { local const ct_data static_ltree[L_CODES+2] = {
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
}; };
local const ct_data static_dtree[D_CODES] = { local const ct_data static_dtree[D_CODES] = {
{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
}; };
const uch _dist_code[DIST_CODE_LEN] = { const uch _dist_code[DIST_CODE_LEN] = {
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
}; };
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
}; };
local const int base_length[LENGTH_CODES] = { local const int base_length[LENGTH_CODES] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
64, 80, 96, 112, 128, 160, 192, 224, 0 64, 80, 96, 112, 128, 160, 192, 224, 0
}; };
local const int base_dist[D_CODES] = { local const int base_dist[D_CODES] = {
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
}; };

View File

@ -1,275 +1,342 @@
/* unzip.h -- IO for uncompress .zip files using zlib /* unzip.h -- IO for uncompress .zip files using zlib
Version 0.15 beta, Mar 19th, 1998, Version 1.00, September 10th, 2003
Copyright (C) 1998 Gilles Vollant Copyright (C) 1998-2003 Gilles Vollant
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
WinZip, InfoZip tools and compatible. WinZip, InfoZip tools and compatible.
Encryption and multi volume ZipFile (span) are not supported. Encryption and multi volume ZipFile (span) are not supported.
Old compressions used by old PKZip 1.x are not supported Old compressions used by old PKZip 1.x are not supported
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
CAN CHANGE IN FUTURE VERSION !! I WAIT FEEDBACK at mail info@winimage.com
I WAIT FEEDBACK at mail info@winimage.com Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
Condition of use and distribution are the same than zlib :
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages
warranty. In no event will the authors be held liable for any damages arising from the use of this software.
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it
including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software
claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be
in a product, an acknowledgment in the product documentation would be appreciated but is not required.
appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.
3. This notice may not be removed or altered from any source distribution.
*/
*/
/* for more info about .ZIP format, see /* for more info about .ZIP format, see
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
PkWare has also a specification at : http://www.info-zip.org/pub/infozip/doc/
ftp://ftp.pkware.com/probdesc.zip */ PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip
#ifndef _unz_H */
#define _unz_H
#ifndef _unz_H
#ifdef __cplusplus #define _unz_H
extern "C" {
#endif #ifdef __cplusplus
extern "C" {
#ifndef _ZLIB_H #endif
#include "zlib.h"
#endif #ifndef _ZLIB_H
#include "zlib.h"
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) #endif
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */ #ifndef _ZLIBIOAPI_H
typedef struct TagunzFile__ { int unused; } unzFile__; #include "ioapi.h"
typedef unzFile__ *unzFile; #endif
#else
typedef voidp unzFile; #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
#endif /* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
#define UNZ_OK (0) typedef unzFile__ *unzFile;
#define UNZ_END_OF_LIST_OF_FILE (-100) #else
#define UNZ_ERRNO (Z_ERRNO) typedef voidp unzFile;
#define UNZ_EOF (0) #endif
#define UNZ_PARAMERROR (-102)
#define UNZ_BADZIPFILE (-103)
#define UNZ_INTERNALERROR (-104) #define UNZ_OK (0)
#define UNZ_CRCERROR (-105) #define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
/* tm_unz contain date/time info */ #define UNZ_EOF (0)
typedef struct tm_unz_s #define UNZ_PARAMERROR (-102)
{ #define UNZ_BADZIPFILE (-103)
uInt tm_sec; /* seconds after the minute - [0,59] */ #define UNZ_INTERNALERROR (-104)
uInt tm_min; /* minutes after the hour - [0,59] */ #define UNZ_CRCERROR (-105)
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */ /* tm_unz contain date/time info */
uInt tm_mon; /* months since January - [0,11] */ typedef struct tm_unz_s
uInt tm_year; /* years - [1980..2044] */ {
} tm_unz; uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
/* unz_global_info structure contain global data about the ZIPfile uInt tm_hour; /* hours since midnight - [0,23] */
These data comes from the end of central dir */ uInt tm_mday; /* day of the month - [1,31] */
typedef struct unz_global_info_s uInt tm_mon; /* months since January - [0,11] */
{ uInt tm_year; /* years - [1980..2044] */
uLong number_entry; /* total number of entries in } tm_unz;
the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */ /* unz_global_info structure contain global data about the ZIPfile
} unz_global_info; These data comes from the end of central dir */
typedef struct unz_global_info_s
{
/* unz_file_info contain information about a file in the zipfile */ uLong number_entry; /* total number of entries in
typedef struct unz_file_info_s the central dir on this disk */
{ uLong size_comment; /* size of the global comment of the zipfile */
uLong version; /* version made by 2 bytes */ } unz_global_info;
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */ /* unz_file_info contain information about a file in the zipfile */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ typedef struct unz_file_info_s
uLong crc; /* crc-32 4 bytes */ {
uLong compressed_size; /* compressed size 4 bytes */ uLong version; /* version made by 2 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */ uLong version_needed; /* version needed to extract 2 bytes */
uLong size_filename; /* filename length 2 bytes */ uLong flag; /* general purpose bit flag 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */ uLong compression_method; /* compression method 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong disk_num_start; /* disk number start 2 bytes */ uLong compressed_size; /* compressed size 4 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */ uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong external_fa; /* external file attributes 4 bytes */ uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
tm_unz tmu_date; uLong size_file_comment; /* file comment length 2 bytes */
} unz_file_info;
uLong disk_num_start; /* disk number start 2 bytes */
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, uLong internal_fa; /* internal file attributes 2 bytes */
const char* fileName2, uLong external_fa; /* external file attributes 4 bytes */
int iCaseSensitivity));
/* tm_unz tmu_date;
Compare two filename (fileName1,fileName2). } unz_file_info;
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
or strcasecmp) const char* fileName2,
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system int iCaseSensitivity));
(like 1 on Unix, 2 on Windows) /*
*/ Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
extern unzFile ZEXPORT unzOpen OF((const char *path)); or strcasecmp)
/* If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
Open a Zip file. path contain the full pathname (by example, (like 1 on Unix, 2 on Windows)
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer */
"zlib/zlib111.zip".
If the zipfile cannot be opened (file don't exist or in not valid), the
return value is NULL. extern unzFile ZEXPORT unzOpen OF((const char *path));
Else, the return value is a unzFile Handle, usable with other function /*
of this unzip package. Open a Zip file. path contain the full pathname (by example,
*/ on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
"zlib/zlib113.zip".
extern int ZEXPORT unzClose OF((unzFile file)); If the zipfile cannot be opened (file don't exist or in not valid), the
/* return value is NULL.
Close a ZipFile opened with unzipOpen. Else, the return value is a unzFile Handle, usable with other function
If there is files inside the .Zip opened with unzOpenCurrentFile (see later), of this unzip package.
these files MUST be closed with unzipCloseCurrentFile before call unzipClose. */
return UNZ_OK if there is no problem. */
extern unzFile ZEXPORT unzOpen2 OF((const char *path,
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, zlib_filefunc_def* pzlib_filefunc_def));
unz_global_info *pglobal_info)); /*
/* Open a Zip file, like unzOpen, but provide a set of file low level API
Write info about the ZipFile in the *pglobal_info structure. for read/write the zip file (see ioapi.h)
No preparation of the structure is needed */
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzClose OF((unzFile file));
/*
extern int ZEXPORT unzGetGlobalComment OF((unzFile file, Close a ZipFile opened with unzipOpen.
char *szComment, If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
uLong uSizeBuf)); these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
/* return UNZ_OK if there is no problem. */
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer. extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
return the number of byte copied or an error code <0 unz_global_info *pglobal_info));
*/ /*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
/***************************************************************************/ return UNZ_OK if there is no problem. */
/* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
/* char *szComment,
Set the current file of the zipfile to the first file. uLong uSizeBuf));
return UNZ_OK if there is no problem /*
*/ Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
extern int ZEXPORT unzGoToNextFile OF((unzFile file)); return the number of byte copied or an error code <0
/* */
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. /***************************************************************************/
*/ /* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzLocateFile OF((unzFile file, extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
const char *szFileName, /*
int iCaseSensitivity)); Set the current file of the zipfile to the first file.
/* return UNZ_OK if there is no problem
Try locate the file szFileName in the zipfile. */
For the iCaseSensitivity signification, see unzStringFileNameCompare
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
return value : /*
UNZ_OK if the file is found. It becomes the current file. Set the current file of the zipfile to the next file.
UNZ_END_OF_LIST_OF_FILE if the file is not found return UNZ_OK if there is no problem
*/ return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, extern int ZEXPORT unzLocateFile OF((unzFile file,
unz_file_info *pfile_info, const char *szFileName,
char *szFileName, int iCaseSensitivity));
uLong fileNameBufferSize, /*
void *extraField, Try locate the file szFileName in the zipfile.
uLong extraFieldBufferSize, For the iCaseSensitivity signification, see unzStringFileNameCompare
char *szComment,
uLong commentBufferSize)); return value :
/* UNZ_OK if the file is found. It becomes the current file.
Get Info about the current file UNZ_END_OF_LIST_OF_FILE if the file is not found
if pfile_info!=NULL, the *pfile_info structure will contain somes info about */
the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
(fileNameBufferSize is the size of the buffer) /* ****************************************** */
if extraField!=NULL, the extra field information will be copied in extraField /* Ryan supplied functions */
(extraFieldBufferSize is the size of the buffer). /* unz_file_info contain information about a file in the zipfile */
This is the Central-header version of the extra field typedef struct unz_file_pos_s
if szComment!=NULL, the comment string of the file will be copied in szComment {
(commentBufferSize is the size of the buffer) uLong pos_in_zip_directory; /* offset in zip file directory */
*/ uLong num_of_file; /* # of file */
} unz_file_pos;
/***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data extern int ZEXPORT unzGetFilePos(
from it, and close it (you can close it before reading all the file) unzFile file,
*/ unz_file_pos* file_pos);
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); extern int ZEXPORT unzGoToFilePos(
/* unzFile file,
Open for reading data the current file in the zipfile. unz_file_pos* file_pos);
If there is no error, the return value is UNZ_OK.
*/ /* ****************************************** */
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
/* unz_file_info *pfile_info,
Close the file in zip opened with unzOpenCurrentFile char *szFileName,
Return UNZ_CRCERROR if all the file was read but the CRC is not good uLong fileNameBufferSize,
*/ void *extraField,
uLong extraFieldBufferSize,
char *szComment,
extern int ZEXPORT unzReadCurrentFile OF((unzFile file, uLong commentBufferSize));
voidp buf, /*
unsigned len)); Get Info about the current file
/* if pfile_info!=NULL, the *pfile_info structure will contain somes info about
Read bytes from the current file (opened by unzOpenCurrentFile) the current file
buf contain buffer where data must be copied if szFileName!=NULL, the filemane string will be copied in szFileName
len the size of buf. (fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
return the number of byte copied if somes bytes are copied (extraFieldBufferSize is the size of the buffer).
return 0 if the end of file was reached This is the Central-header version of the extra field
return <0 with error code if there is an error if szComment!=NULL, the comment string of the file will be copied in szComment
(UNZ_ERRNO for IO error, or zLib error for uncompress error) (commentBufferSize is the size of the buffer)
*/ */
extern z_off_t ZEXPORT unztell OF((unzFile file)); /***************************************************************************/
/* /* for reading the content of the current zipfile, you can open it, read data
Give the current position in uncompressed data from it, and close it (you can close it before reading all the file)
*/ */
extern int ZEXPORT unzeof OF((unzFile file)); extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/* /*
return 1 if the end of file was reached, 0 elsewhere Open for reading data the current file in the zipfile.
*/ If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf, extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
unsigned len)); const char* password));
/* /*
Read extra field from the current file (opened by unzOpenCurrentFile) Open for reading data the current file in the zipfile.
This is the local-header version of the extra field (sometimes, there is password is a crypting password
more info in the local-header version than in the central-header) If there is no error, the return value is UNZ_OK.
*/
if buf==NULL, it return the size of the local extra field
extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
if buf!=NULL, len is the size of the buffer, the extra header is copied in int* method,
buf. int* level,
the return value is the number of bytes copied in buf, or (if <0) int raw));
the error code /*
*/ Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
#ifdef __cplusplus *method will receive method of compression, *level will receive level of
} compression
#endif note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
#endif /* _unz_H */ */
extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
int* method,
int* level,
int raw,
const char* password));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
*method will receive method of compression, *level will receive level of
compression
note : you can set level parameter as NULL (if you did not want known level,
but you CANNOT set method parameter as NULL
*/
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern z_off_t ZEXPORT unztell OF((unzFile file));
/*
Give the current position in uncompressed data
*/
extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
if buf==NULL, it return the size of the local extra field
if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf.
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
#ifdef __cplusplus
}
#endif
#endif /* _unz_H */

View File

@ -1,279 +1,323 @@
/* zconf.h -- configuration of the zlib compression library /* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly. * Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id: zconf.h,v 1.1 2003/10/13 21:02:38 cozman Exp $ */ /* @(#) $Id: zconf.h,v 1.2 2003/12/13 04:15:27 cozman Exp $ */
#ifndef _ZCONF_H #ifndef ZCONF_H
#define _ZCONF_H #define ZCONF_H
/* /*
* If you *really* need a unique prefix for all types and library functions, * If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/ */
#ifdef Z_PREFIX #ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_ # define deflateInit_ z_deflateInit_
# define deflate z_deflate # define deflate z_deflate
# define deflateEnd z_deflateEnd # define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_ # define inflateInit_ z_inflateInit_
# define inflate z_inflate # define inflate z_inflate
# define inflateEnd z_inflateEnd # define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_ # define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary # define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy # define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset # define deflateReset z_deflateReset
# define deflateParams z_deflateParams # define deflatePrime z_deflatePrime
# define inflateInit2_ z_inflateInit2_ # define deflateParams z_deflateParams
# define inflateSetDictionary z_inflateSetDictionary # define deflateBound z_deflateBound
# define inflateSync z_inflateSync # define inflateInit2_ z_inflateInit2_
# define inflateSyncPoint z_inflateSyncPoint # define inflateSetDictionary z_inflateSetDictionary
# define inflateReset z_inflateReset # define inflateSync z_inflateSync
# define compress z_compress # define inflateSyncPoint z_inflateSyncPoint
# define compress2 z_compress2 # define inflateCopy z_inflateCopy
# define uncompress z_uncompress # define inflateReset z_inflateReset
# define adler32 z_adler32 # define compress z_compress
# define crc32 z_crc32 # define compress2 z_compress2
# define get_crc_table z_get_crc_table # define compressBound z_compressBound
# define uncompress z_uncompress
# define Byte z_Byte # define adler32 z_adler32
# define uInt z_uInt # define crc32 z_crc32
# define uLong z_uLong # define get_crc_table z_get_crc_table
# define Bytef z_Bytef
# define charf z_charf # define Byte z_Byte
# define intf z_intf # define uInt z_uInt
# define uIntf z_uIntf # define uLong z_uLong
# define uLongf z_uLongf # define Bytef z_Bytef
# define voidpf z_voidpf # define charf z_charf
# define voidp z_voidp # define intf z_intf
#endif # define uIntf z_uIntf
# define uLongf z_uLongf
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) # define voidpf z_voidpf
# define WIN32 # define voidp z_voidp
#endif #endif
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
# ifndef __32BIT__ #if defined(__MSDOS__) && !defined(MSDOS)
# define __32BIT__ # define MSDOS
# endif #endif
#endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
#if defined(__MSDOS__) && !defined(MSDOS) # define OS2
# define MSDOS #endif
#endif #if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
/* #endif
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
* than 64k bytes at a time (needed on systems with 16-bit int). # define WIN32
*/ #endif
#if defined(MSDOS) && !defined(__32BIT__) #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# define MAXSEG_64K # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
#endif # ifndef SYS16BIT
#ifdef MSDOS # define SYS16BIT
# define UNALIGNED_OK # endif
#endif # endif
#endif
#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
# define STDC /*
#endif * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) * than 64k bytes at a time (needed on systems with 16-bit int).
# ifndef STDC */
# define STDC #ifdef SYS16BIT
# endif # define MAXSEG_64K
#endif #endif
#ifdef MSDOS
#ifndef STDC # define UNALIGNED_OK
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ #endif
# define const
# endif #ifdef __STDC_VERSION__
#endif # ifndef STDC
# define STDC
/* Some Mac compilers merge all .h files incorrectly: */ # endif
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) # if __STDC_VERSION__ >= 199901L
# define NO_DUMMY_DECL # ifndef STDC99
#endif # define STDC99
# endif
/* Old Borland C incorrectly complains about missing returns: */ # endif
#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) #endif
# define NEED_DUMMY_RETURN #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
#endif # define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
/* Maximum value for memLevel in deflateInit2 */ # define STDC
#ifndef MAX_MEM_LEVEL #endif
# ifdef MAXSEG_64K #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define MAX_MEM_LEVEL 8 # define STDC
# else #endif
# define MAX_MEM_LEVEL 9 #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# endif # define STDC
#endif #endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2. #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files # define STDC
* created by gzip. (Files created by minigzip can still be extracted by #endif
* gzip.)
*/ #ifndef STDC
#ifndef MAX_WBITS # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define MAX_WBITS 15 /* 32K LZ77 window */ # define const /* note: need a more gentle solution here */
#endif # endif
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9)) /* Some Mac compilers merge all .h files incorrectly: */
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
plus a few kilobytes for small objects. For example, if you want to reduce # define NO_DUMMY_DECL
the default memory requirements from 256K to 128K, compile with #endif
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch). /* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
The memory requirements for inflate are (in bytes) 1 << windowBits # ifdef MAXSEG_64K
that is, 32K for windowBits=15 (default value) plus a few kilobytes # define MAX_MEM_LEVEL 8
for small objects. # else
*/ # define MAX_MEM_LEVEL 9
# endif
/* Type declarations */ #endif
#ifndef OF /* function prototypes */ /* Maximum value for windowBits in deflateInit2 and inflateInit2.
# ifdef STDC * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
# define OF(args) args * created by gzip. (Files created by minigzip can still be extracted by
# else * gzip.)
# define OF(args) () */
# endif #ifndef MAX_WBITS
#endif # define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations). /* The memory requirements for deflate are (in bytes):
* This was tested only with MSC; for other MSDOS compilers you may have (1 << (windowBits+2)) + (1 << (memLevel+9))
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model, that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
* just define FAR to be empty. plus a few kilobytes for small objects. For example, if you want to reduce
*/ the default memory requirements from 256K to 128K, compile with
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
/* MSC small or medium model */ Of course this will generally degrade compression (there's no free lunch).
# define SMALL_MEDIUM
# ifdef _MSC_VER The memory requirements for inflate are (in bytes) 1 << windowBits
# define FAR _far that is, 32K for windowBits=15 (default value) plus a few kilobytes
# else for small objects.
# define FAR far */
# endif
#endif /* Type declarations */
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__ #ifndef OF /* function prototypes */
# define SMALL_MEDIUM # ifdef STDC
# define FAR _far # define OF(args) args
# endif # else
#endif # define OF(args) ()
# endif
/* Compile with -DZLIB_DLL for Windows DLL support */ #endif
#if defined(ZLIB_DLL)
# if defined(_WINDOWS) || defined(WINDOWS) /* The following definitions for FAR are needed only for MSDOS mixed
# ifdef FAR * model programming (small or medium model with some far allocations).
# undef FAR * This was tested only with MSC; for other MSDOS compilers you may have
# endif * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
# include <windows.h> * just define FAR to be empty.
# define ZEXPORT WINAPI */
# ifdef WIN32 #ifdef SYS16BIT
# define ZEXPORTVA WINAPIV # if defined(M_I86SM) || defined(M_I86MM)
# else /* MSC small or medium model */
# define ZEXPORTVA FAR _cdecl _export # define SMALL_MEDIUM
# endif # ifdef _MSC_VER
# endif # define FAR _far
# if defined (__BORLANDC__) # else
# if (__BORLANDC__ >= 0x0500) && defined (WIN32) # define FAR far
# include <windows.h> # endif
# define ZEXPORT __declspec(dllexport) WINAPI # endif
# define ZEXPORTRVA __declspec(dllexport) WINAPIV # if (defined(__SMALL__) || defined(__MEDIUM__))
# else /* Turbo C small or medium model */
# if defined (_Windows) && defined (__DLL__) # define SMALL_MEDIUM
# define ZEXPORT _export # ifdef __BORLANDC__
# define ZEXPORTVA _export # define FAR _far
# endif # else
# endif # define FAR far
# endif # endif
#endif # endif
#endif
#if defined (__BEOS__)
# if defined (ZLIB_DLL) #if defined(WINDOWS) || defined(WIN32)
# define ZEXTERN extern __declspec(dllexport) /* If building or using zlib as a DLL, define ZLIB_DLL.
# else * This is not mandatory, but it offers a little performance increase.
# define ZEXTERN extern __declspec(dllimport) */
# endif # ifdef ZLIB_DLL
#endif # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
#ifndef ZEXPORT # define ZEXTERN extern __declspec(dllexport)
# define ZEXPORT # else
#endif # define ZEXTERN extern __declspec(dllimport)
#ifndef ZEXPORTVA # endif
# define ZEXPORTVA # endif
#endif # endif /* ZLIB_DLL */
#ifndef ZEXTERN /* If building or using zlib with the WINAPI/WINAPIV calling convention,
# define ZEXTERN extern * define ZLIB_WINAPI.
#endif * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
#ifndef FAR # ifdef ZLIB_WINAPI
# define FAR # ifdef FAR
#endif # undef FAR
# endif
#if !defined(MACOS) && !defined(TARGET_OS_MAC) # include <windows.h>
typedef unsigned char Byte; /* 8 bits */ /* No need for _export, use ZLIB.DEF instead. */
#endif /* For complete Windows compatibility, use WINAPI, not __stdcall. */
typedef unsigned int uInt; /* 16 bits or more */ # define ZEXPORT WINAPI
typedef unsigned long uLong; /* 32 bits or more */ # ifdef WIN32
# define ZEXPORTVA WINAPIV
#ifdef SMALL_MEDIUM # else
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define ZEXPORTVA FAR CDECL
# define Bytef Byte FAR # endif
#else # endif
typedef Byte FAR Bytef; #endif
#endif
typedef char FAR charf; #if defined (__BEOS__)
typedef int FAR intf; # ifdef ZLIB_DLL
typedef uInt FAR uIntf; # ifdef ZLIB_INTERNAL
typedef uLong FAR uLongf; # define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
#ifdef STDC # else
typedef void FAR *voidpf; # define ZEXPORT __declspec(dllimport)
typedef void *voidp; # define ZEXPORTVA __declspec(dllimport)
#else # endif
typedef Byte FAR *voidpf; # endif
typedef Byte *voidp; #endif
#endif
#ifndef ZEXTERN
#ifdef HAVE_UNISTD_H # define ZEXTERN extern
# include <sys/types.h> /* for off_t */ #endif
# include <unistd.h> /* for SEEK_* and off_t */ #ifndef ZEXPORT
# define z_off_t off_t # define ZEXPORT
#endif #endif
#ifndef SEEK_SET #ifndef ZEXPORTVA
# define SEEK_SET 0 /* Seek from beginning of file. */ # define ZEXPORTVA
# define SEEK_CUR 1 /* Seek from current position. */ #endif
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif #ifndef FAR
#ifndef z_off_t # define FAR
# define z_off_t long #endif
#endif
#if !defined(__MACTYPES__)
/* MVS linker does not support external names larger than 8 bytes */ typedef unsigned char Byte; /* 8 bits */
#if defined(__MVS__) #endif
# pragma map(deflateInit_,"DEIN") typedef unsigned int uInt; /* 16 bits or more */
# pragma map(deflateInit2_,"DEIN2") typedef unsigned long uLong; /* 32 bits or more */
# pragma map(deflateEnd,"DEEND")
# pragma map(inflateInit_,"ININ") #ifdef SMALL_MEDIUM
# pragma map(inflateInit2_,"ININ2") /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# pragma map(inflateEnd,"INEND") # define Bytef Byte FAR
# pragma map(inflateSync,"INSY") #else
# pragma map(inflateSetDictionary,"INSEDI") typedef Byte FAR Bytef;
# pragma map(inflate_blocks,"INBL") #endif
# pragma map(inflate_blocks_new,"INBLNE") typedef char FAR charf;
# pragma map(inflate_blocks_free,"INBLFR") typedef int FAR intf;
# pragma map(inflate_blocks_reset,"INBLRE") typedef uInt FAR uIntf;
# pragma map(inflate_codes_free,"INCOFR") typedef uLong FAR uLongf;
# pragma map(inflate_codes,"INCO")
# pragma map(inflate_fast,"INFA") #ifdef STDC
# pragma map(inflate_flush,"INFLU") typedef void const *voidpc;
# pragma map(inflate_mask,"INMA") typedef void FAR *voidpf;
# pragma map(inflate_set_dictionary,"INSEDI2") typedef void *voidp;
# pragma map(inflate_copyright,"INCOPY") #else
# pragma map(inflate_trees_bits,"INTRBI") typedef Byte const *voidpc;
# pragma map(inflate_trees_dynamic,"INTRDY") typedef Byte FAR *voidpf;
# pragma map(inflate_trees_fixed,"INTRFI") typedef Byte *voidp;
# pragma map(inflate_trees_free,"INTRFR") #endif
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
#endif /* _ZCONF_H */ # include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
#define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# ifdef FAR
# undef FAR
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

323
include/zlib/zconf.in.h Normal file
View File

@ -0,0 +1,323 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: zconf.in.h,v 1.1 2003/12/13 04:15:27 cozman Exp $ */
#ifndef ZCONF_H
#define ZCONF_H
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflatePrime z_deflatePrime
# define deflateParams z_deflateParams
# define deflateBound z_deflateBound
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateCopy z_inflateCopy
# define inflateReset z_inflateReset
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table
# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
# define WIN32
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if defined(__OS400__)
#define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# ifdef FAR
# undef FAR
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
# pragma map(deflateInit_,"DEIN")
# pragma map(deflateInit2_,"DEIN2")
# pragma map(deflateEnd,"DEEND")
# pragma map(deflateBound,"DEBND")
# pragma map(inflateInit_,"ININ")
# pragma map(inflateInit2_,"ININ2")
# pragma map(inflateEnd,"INEND")
# pragma map(inflateSync,"INSY")
# pragma map(inflateSetDictionary,"INSEDI")
# pragma map(compressBound,"CMBND")
# pragma map(inflate_table,"INTABL")
# pragma map(inflate_fast,"INFA")
# pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

235
include/zlib/zip.h Normal file
View File

@ -0,0 +1,235 @@
/* zip.h -- IO for compress .zip files using zlib
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
WinZip, InfoZip tools and compatible.
Encryption and multi volume ZipFile (span) are not supported.
Old compressions used by old PKZip 1.x are not supported
For uncompress .zip file, look at unzip.h
I WAIT FEEDBACK at mail info@winimage.com
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* for more info about .ZIP format, see
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
http://www.info-zip.org/pub/infozip/doc/
PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip
*/
#ifndef _zip_H
#define _zip_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#ifndef _ZLIBIOAPI_H
#include "ioapi.h"
#endif
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagzipFile__ { int unused; } zipFile__;
typedef zipFile__ *zipFile;
#else
typedef voidp zipFile;
#endif
#define ZIP_OK (0)
#define ZIP_EOF (0)
#define ZIP_ERRNO (Z_ERRNO)
#define ZIP_PARAMERROR (-102)
#define ZIP_BADZIPFILE (-103)
#define ZIP_INTERNALERROR (-104)
#ifndef DEF_MEM_LEVEL
# if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
# else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
# endif
#endif
/* default memLevel */
/* tm_zip contain date/time info */
typedef struct tm_zip_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_zip;
typedef struct
{
tm_zip tmz_date; /* date in understandable format */
uLong dosDate; /* if dos_date == 0, tmu_date is used */
/* uLong flag; */ /* general purpose bit flag 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
} zip_fileinfo;
typedef const char* zipcharpc;
#define APPEND_STATUS_CREATE (0)
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
/*
Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
an Unix computer "zlib/zlib113.zip".
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
will be created at the end of the file.
(useful if the file contain a self extractor code)
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will
add files in existing zip (be sure you don't add file that doesn't exist)
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
*/
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of couse, you can use RAW reading and writing to copy the file you did not want delte
*/
extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
int append,
zipcharpc* globalcomment,
zlib_filefunc_def* pzlib_filefunc_def));
extern int ZEXPORT zipOpenNewFileInZip OF((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));
/*
Open a file in the ZIP for writing.
filename : the filename in zip (if NULL, '-' without quote will be used
*zipfi contain supplemental information
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local
contains the extrafield data the the local header
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global
contains the extrafield data the the local header
if comment != NULL, comment contain the comment string
method contain the compression method (0 for store, Z_DEFLATED for deflate)
level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
*/
extern int ZEXPORT zipOpenNewFileInZip2 OF((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));
/*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/
extern int ZEXPORT zipOpenNewFileInZip3 OF((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 crcForCtypting));
/*
Same than zipOpenNewFileInZip2, except
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2
password : crypting password (NULL for no crypting)
crcForCtypting : crc of file to compress (needed for crypting)
*/
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
const void* buf,
unsigned len));
/*
Write data in the zipfile
*/
extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/*
Close the current file in the zipfile
*/
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
uLong uncompressed_size,
uLong crc32));
/*
Close the current file in the zipfile, for fiel opened with
parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size
*/
extern int ZEXPORT zipClose OF((zipFile file,
const char* global_comment));
/*
Close the zipfile
*/
#ifdef __cplusplus
}
#endif
#endif /* _zip_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,220 +1,258 @@
/* zutil.h -- internal interface and configuration of the compression library /* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2002 Jean-loup Gailly. * Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* WARNING: this file should *not* be used by applications. It is /* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* @(#) $Id: zutil.h,v 1.1 2003/10/13 21:02:38 cozman Exp $ */ /* @(#) $Id: zutil.h,v 1.2 2003/12/13 04:15:27 cozman Exp $ */
#ifndef _Z_UTIL_H #ifndef ZUTIL_H
#define _Z_UTIL_H #define ZUTIL_H
#include "zlib.h" #define ZLIB_INTERNAL
#include "zlib.h"
#ifdef STDC
# include <stddef.h> #ifdef STDC
# include <string.h> # include <stddef.h>
# include <stdlib.h> # include <string.h>
#endif # include <stdlib.h>
#ifdef NO_ERRNO_H #endif
extern int errno; #ifdef NO_ERRNO_H
#else extern int errno;
# include <errno.h> #else
#endif # include <errno.h>
#endif
#ifndef local
# define local static #ifndef local
#endif # define local static
/* compile with -Dlocal if your debugger can't find static symbols */ #endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef uch FAR uchf; typedef unsigned char uch;
typedef unsigned short ush; typedef uch FAR uchf;
typedef ush FAR ushf; typedef unsigned short ush;
typedef unsigned long ulg; typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err)) #define ERR_RETURN(strm,err) \
/* To be used only when the state is known to be valid */ return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS #ifndef DEF_WBITS
#endif # define DEF_WBITS MAX_WBITS
/* default windowBits for decompression. MAX_WBITS is for compression only */ #endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8 #if MAX_MEM_LEVEL >= 8
#else # define DEF_MEM_LEVEL 8
# define DEF_MEM_LEVEL MAX_MEM_LEVEL #else
#endif # define DEF_MEM_LEVEL MAX_MEM_LEVEL
/* default memLevel */ #endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1 #define STORED_BLOCK 0
#define DYN_TREES 2 #define STATIC_TREES 1
/* The three kinds of block type */ #define DYN_TREES 2
/* The three kinds of block type */
#define MIN_MATCH 3
#define MAX_MATCH 258 #define MIN_MATCH 3
/* The minimum and maximum match lengths */ #define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */
/* target dependencies */
#ifdef MSDOS
# define OS_CODE 0x00 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# if defined(__TURBOC__) || defined(__BORLANDC__) # define OS_CODE 0x00
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if defined(__TURBOC__) || defined(__BORLANDC__)
/* Allow compilation with ANSI keywords only enabled */ # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
void _Cdecl farfree( void *block ); /* Allow compilation with ANSI keywords only enabled */
void *_Cdecl farmalloc( unsigned long nbytes ); void _Cdecl farfree( void *block );
# else void *_Cdecl farmalloc( unsigned long nbytes );
# include <alloc.h> # else
# endif # include <alloc.h>
# else /* MSC or DJGPP */ # endif
# include <malloc.h> # else /* MSC or DJGPP */
# endif # include <malloc.h>
#endif # endif
#endif
#ifdef OS2
# define OS_CODE 0x06 #ifdef AMIGA
#endif # define OS_CODE 0x01
#endif
#ifdef WIN32 /* Window 95 & Windows NT */
# define OS_CODE 0x0b #if defined(VAXC) || defined(VMS)
#endif # define OS_CODE 0x02
# define F_OPEN(name, mode) \
#if defined(VAXC) || defined(VMS) fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
# define OS_CODE 0x02 #endif
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #if defined(ATARI) || defined(atarist)
#endif # define OS_CODE 0x05
#endif
#ifdef AMIGA
# define OS_CODE 0x01 #ifdef OS2
#endif # define OS_CODE 0x06
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05 #if defined(MACOS) || defined(TARGET_OS_MAC)
#endif # define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
#if defined(MACOS) || defined(TARGET_OS_MAC) # include <unix.h> /* for fdopen */
# define OS_CODE 0x07 # else
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # ifndef fdopen
# include <unix.h> /* for fdopen */ # define fdopen(fd,mode) NULL /* No fdopen() */
# else # endif
# ifndef fdopen # endif
# define fdopen(fd,mode) NULL /* No fdopen() */ #endif
# endif
# endif #ifdef TOPS20
#endif # define OS_CODE 0x0a
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0F #ifdef WIN32
#endif # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# define OS_CODE 0x0b
#ifdef TOPS20 # endif
# define OS_CODE 0x0a #endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
#if defined(_BEOS_) || defined(RISCOS) # define OS_CODE 0x0f
# define fdopen(fd,mode) NULL /* No fdopen() */ #endif
#endif
#if defined(_BEOS_) || defined(RISCOS)
#if (defined(_MSC_VER) && (_MSC_VER > 600)) # define fdopen(fd,mode) NULL /* No fdopen() */
# define fdopen(fd,type) _fdopen(fd,type) #endif
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600))
# if defined(_WIN32_WCE)
/* Common defaults */ # define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
#ifndef OS_CODE typedef int ptrdiff_t;
# define OS_CODE 0x03 /* assume Unix */ # define _PTRDIFF_T_DEFINED
#endif # endif
# else
#ifndef F_OPEN # define fdopen(fd,type) _fdopen(fd,type)
# define F_OPEN(name, mode) fopen((name), (mode)) # endif
#endif #endif
/* functions */ /* common defaults */
#ifdef HAVE_STRERROR #ifndef OS_CODE
extern char *strerror OF((int)); # define OS_CODE 0x03 /* assume Unix */
# define zstrerror(errnum) strerror(errnum) #endif
#else
# define zstrerror(errnum) "" #ifndef F_OPEN
#endif # define F_OPEN(name, mode) fopen((name), (mode))
#endif
#if defined(pyr)
# define NO_MEMCPY /* functions */
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
/* Use our own functions for small and medium model with MSC <= 5.0. # ifndef HAVE_VSNPRINTF
* You may have to use the same strategy for Borland C (untested). # define HAVE_VSNPRINTF
* The __SC__ check is for Symantec. # endif
*/ #endif
# define NO_MEMCPY #if defined(__CYGWIN__)
#endif # ifndef HAVE_VSNPRINTF
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_VSNPRINTF
# define HAVE_MEMCPY # endif
#endif #endif
#ifdef HAVE_MEMCPY #ifndef HAVE_VSNPRINTF
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # ifdef MSDOS
# define zmemcpy _fmemcpy /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
# define zmemcmp _fmemcmp but for now we just assume it doesn't. */
# define zmemzero(dest, len) _fmemset(dest, 0, len) # define NO_vsnprintf
# else # endif
# define zmemcpy memcpy # ifdef __TURBOC__
# define zmemcmp memcmp # define NO_vsnprintf
# define zmemzero(dest, len) memset(dest, 0, len) # endif
# endif # ifdef WIN32
#else /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); # if !defined(vsnprintf) && !defined(NO_vsnprintf)
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); # define vsnprintf _vsnprintf
extern void zmemzero OF((Bytef* dest, uInt len)); # endif
#endif # endif
# ifdef __SASC
/* Diagnostic functions */ # define NO_vsnprintf
#ifdef DEBUG # endif
# include <stdio.h> #endif
extern int z_verbose;
extern void z_error OF((char *m)); #ifdef HAVE_STRERROR
# define Assert(cond,msg) {if(!(cond)) z_error(msg);} extern char *strerror OF((int));
# define Trace(x) {if (z_verbose>=0) fprintf x ;} # define zstrerror(errnum) strerror(errnum)
# define Tracev(x) {if (z_verbose>0) fprintf x ;} #else
# define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define zstrerror(errnum) ""
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} #endif
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else #if defined(pyr)
# define Assert(cond,msg) # define NO_MEMCPY
# define Trace(x) #endif
# define Tracev(x) #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
# define Tracevv(x) /* Use our own functions for small and medium model with MSC <= 5.0.
# define Tracec(c,x) * You may have to use the same strategy for Borland C (untested).
# define Tracecv(c,x) * The __SC__ check is for Symantec.
#endif */
# define NO_MEMCPY
#endif
typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
uInt len)); # define HAVE_MEMCPY
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); #endif
void zcfree OF((voidpf opaque, voidpf ptr)); #ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
#define ZALLOC(strm, items, size) \ # define zmemcpy _fmemcpy
(*((strm)->zalloc))((strm)->opaque, (items), (size)) # define zmemcmp _fmemcmp
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) # define zmemzero(dest, len) _fmemset(dest, 0, len)
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} # else
# define zmemcpy memcpy
#endif /* _Z_UTIL_H */ # define zmemcmp memcmp
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include <stdio.h>
extern int z_verbose;
extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
# define Assert(cond,msg)
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* ZUTIL_H */

View File

@ -1,48 +1,74 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream /* adler32.c -- compute the Adler-32 checksum of a data stream
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id: adler32.c,v 1.2 2003/10/13 21:07:33 cozman Exp $ */ /* @(#) $Id: adler32.c,v 1.3 2003/12/13 04:14:38 cozman Exp $ */
#include "zlib/zlib.h" #define ZLIB_INTERNAL
#include "zlib.h"
#define BASE 65521L /* largest prime smaller than 65536 */
#define NMAX 5552 #define BASE 65521UL /* largest prime smaller than 65536 */
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ #define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); #define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
#define DO16(buf) DO8(buf,0); DO8(buf,8); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
#define DO16(buf) DO8(buf,0); DO8(buf,8);
/* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len) #ifdef NO_DIVIDE
uLong adler; # define MOD(a) \
const Bytef *buf; do { \
uInt len; if (a >= (BASE << 16)) a -= (BASE << 16); \
{ if (a >= (BASE << 15)) a -= (BASE << 15); \
unsigned long s1 = adler & 0xffff; if (a >= (BASE << 14)) a -= (BASE << 14); \
unsigned long s2 = (adler >> 16) & 0xffff; if (a >= (BASE << 13)) a -= (BASE << 13); \
int k; if (a >= (BASE << 12)) a -= (BASE << 12); \
if (a >= (BASE << 11)) a -= (BASE << 11); \
if (buf == Z_NULL) return 1L; if (a >= (BASE << 10)) a -= (BASE << 10); \
if (a >= (BASE << 9)) a -= (BASE << 9); \
while (len > 0) { if (a >= (BASE << 8)) a -= (BASE << 8); \
k = len < NMAX ? len : NMAX; if (a >= (BASE << 7)) a -= (BASE << 7); \
len -= k; if (a >= (BASE << 6)) a -= (BASE << 6); \
while (k >= 16) { if (a >= (BASE << 5)) a -= (BASE << 5); \
DO16(buf); if (a >= (BASE << 4)) a -= (BASE << 4); \
buf += 16; if (a >= (BASE << 3)) a -= (BASE << 3); \
k -= 16; if (a >= (BASE << 2)) a -= (BASE << 2); \
} if (a >= (BASE << 1)) a -= (BASE << 1); \
if (k != 0) do { if (a >= BASE) a -= BASE; \
s1 += *buf++; } while (0)
s2 += s1; #else
} while (--k); # define MOD(a) a %= BASE
s1 %= BASE; #endif
s2 %= BASE;
} /* ========================================================================= */
return (s2 << 16) | s1; uLong ZEXPORT adler32(adler, buf, len)
} uLong adler;
const Bytef *buf;
uInt len;
{
unsigned long s1 = adler & 0xffff;
unsigned long s2 = (adler >> 16) & 0xffff;
int k;
if (buf == Z_NULL) return 1L;
while (len > 0) {
k = len < NMAX ? (int)len : NMAX;
len -= k;
while (k >= 16) {
DO16(buf);
buf += 16;
k -= 16;
}
if (k != 0) do {
s1 += *buf++;
s2 += s1;
} while (--k);
MOD(s1);
MOD(s2);
}
return (s2 << 16) | s1;
}

View File

@ -1,68 +1,79 @@
/* compress.c -- compress a memory buffer /* compress.c -- compress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly. * Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id: compress.c,v 1.2 2003/10/13 21:07:33 cozman Exp $ */ /* @(#) $Id: compress.c,v 1.3 2003/12/13 04:14:38 cozman Exp $ */
#include "zlib/zlib.h" #define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level /* ===========================================================================
parameter has the same meaning as in deflateInit. sourceLen is the byte Compresses the source buffer into the destination buffer. The level
length of the source buffer. Upon entry, destLen is the total size of the parameter has the same meaning as in deflateInit. sourceLen is the byte
destination buffer, which must be at least 0.1% larger than sourceLen plus length of the source buffer. Upon entry, destLen is the total size of the
12 bytes. Upon exit, destLen is the actual size of the compressed buffer. destination buffer, which must be at least 0.1% larger than sourceLen plus
12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer, compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
Z_STREAM_ERROR if the level parameter is invalid. memory, Z_BUF_ERROR if there was not enough room in the output buffer,
*/ Z_STREAM_ERROR if the level parameter is invalid.
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) */
Bytef *dest; int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
uLongf *destLen; Bytef *dest;
const Bytef *source; uLongf *destLen;
uLong sourceLen; const Bytef *source;
int level; uLong sourceLen;
{ int level;
z_stream stream; {
int err; z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen; stream.next_in = (Bytef*)source;
#ifdef MAXSEG_64K stream.avail_in = (uInt)sourceLen;
/* Check for source > 64K on 16-bit machine: */ #ifdef MAXSEG_64K
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; /* Check for source > 64K on 16-bit machine: */
#endif if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
stream.next_out = dest; #endif
stream.avail_out = (uInt)*destLen; stream.next_out = dest;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0; stream.zalloc = (alloc_func)0;
stream.opaque = (voidpf)0; stream.zfree = (free_func)0;
stream.opaque = (voidpf)0;
err = deflateInit(&stream, level);
if (err != Z_OK) return err; err = deflateInit(&stream, level);
if (err != Z_OK) return err;
err = deflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) { err = deflate(&stream, Z_FINISH);
deflateEnd(&stream); if (err != Z_STREAM_END) {
return err == Z_OK ? Z_BUF_ERROR : err; deflateEnd(&stream);
} return err == Z_OK ? Z_BUF_ERROR : err;
*destLen = stream.total_out; }
*destLen = stream.total_out;
err = deflateEnd(&stream);
return err; err = deflateEnd(&stream);
} return err;
}
/* ===========================================================================
*/ /* ===========================================================================
int ZEXPORT compress (dest, destLen, source, sourceLen) */
Bytef *dest; int ZEXPORT compress (dest, destLen, source, sourceLen)
uLongf *destLen; Bytef *dest;
const Bytef *source; uLongf *destLen;
uLong sourceLen; const Bytef *source;
{ uLong sourceLen;
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); {
} return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
/* ===========================================================================
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
uLong ZEXPORT compressBound (sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
}

View File

@ -1,162 +1,311 @@
/* crc32.c -- compute the CRC-32 of a data stream /* crc32.c -- compute the CRC-32 of a data stream
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ *
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
/* @(#) $Id: crc32.c,v 1.2 2003/10/13 21:07:33 cozman Exp $ */ * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
* tables for updating the shift register in one step with three exclusive-ors
#include "zlib/zlib.h" * instead of four steps with four exclusive-ors. This results about a factor
* of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
#define local static */
#ifdef DYNAMIC_CRC_TABLE /* @(#) $Id: crc32.c,v 1.3 2003/12/13 04:14:38 cozman Exp $ */
local int crc_table_empty = 1; #ifdef MAKECRCH
local uLongf crc_table[256]; # include <stdio.h>
local void make_crc_table OF((void)); # ifndef DYNAMIC_CRC_TABLE
# define DYNAMIC_CRC_TABLE
/* # endif /* !DYNAMIC_CRC_TABLE */
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial: #endif /* MAKECRCH */
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
#include "zutil.h" /* for STDC and FAR definitions */
Polynomials over GF(2) are represented in binary, one bit per coefficient,
with the lowest powers in the most significant bit. Then adding polynomials #define local static
is just exclusive-or, and multiplying a polynomial by x is a right shift by
one. If we call the above polynomial p, and represent a byte as the /* Find a four-byte integer type for crc32_little() and crc32_big(). */
polynomial q, also with the lowest power in the most significant bit (so the #ifndef NOBYFOUR
byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, # ifdef STDC /* need ANSI C limits.h to determine sizes */
where a mod b means the remainder after dividing a by b. # include <limits.h>
# define BYFOUR
This calculation is done using the shift-register method of multiplying and # if (UINT_MAX == 0xffffffffUL)
taking the remainder. The register is initialized to zero, and for each typedef unsigned int u4;
incoming bit, x^32 is added mod p to the register if the bit is a one (where # else
x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by # if (ULONG_MAX == 0xffffffffUL)
x (which is shifting right by one and adding x^32 mod p if the bit shifted typedef unsigned long u4;
out is a one). We start with the highest power (least significant bit) of # else
q and repeat for all eight bits of q. # if (USHRT_MAX == 0xffffffffUL)
typedef unsigned short u4;
The table is simply the CRC of all possible eight bit values. This is all # else
the information needed to generate CRC's on data a byte at a time for all # undef BYFOUR /* can't find a four-byte integer type! */
combinations of CRC register values and incoming bytes. # endif
*/ # endif
local void make_crc_table() # endif
{ # endif /* STDC */
uLong c; #endif /* !NOBYFOUR */
int n, k;
uLong poly; /* polynomial exclusive-or pattern */ /* Definitions for doing the crc four data bytes at a time. */
/* terms of polynomial defining this crc (except x^32): */ #ifdef BYFOUR
static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; # define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
/* make exclusive-or pattern from polynomial (0xedb88320L) */ local unsigned long crc32_little OF((unsigned long,
poly = 0L; const unsigned char FAR *, unsigned));
for (n = 0; n < sizeof(p)/sizeof(Byte); n++) local unsigned long crc32_big OF((unsigned long,
poly |= 1L << (31 - p[n]); const unsigned char FAR *, unsigned));
# define TBLS 8
for (n = 0; n < 256; n++) #else
{ # define TBLS 1
c = (uLong)n; #endif /* BYFOUR */
for (k = 0; k < 8; k++)
c = c & 1 ? poly ^ (c >> 1) : c >> 1; #ifdef DYNAMIC_CRC_TABLE
crc_table[n] = c;
} local int crc_table_empty = 1;
crc_table_empty = 0; local unsigned long FAR crc_table[TBLS][256];
} local void make_crc_table OF((void));
#else #ifdef MAKECRCH
/* ======================================================================== local void write_table OF((FILE *, const unsigned long FAR *));
* Table of CRC-32's of all single-byte values (made by make_crc_table) #endif /* MAKECRCH */
*/
local const uLongf crc_table[256] = { /*
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, Polynomials over GF(2) are represented in binary, one bit per coefficient,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, with the lowest powers in the most significant bit. Then adding polynomials
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, is just exclusive-or, and multiplying a polynomial by x is a right shift by
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, one. If we call the above polynomial p, and represent a byte as the
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, polynomial q, also with the lowest power in the most significant bit (so the
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, where a mod b means the remainder after dividing a by b.
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, This calculation is done using the shift-register method of multiplying and
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, taking the remainder. The register is initialized to zero, and for each
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, incoming bit, x^32 is added mod p to the register if the bit is a one (where
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, x (which is shifting right by one and adding x^32 mod p if the bit shifted
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, out is a one). We start with the highest power (least significant bit) of
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, q and repeat for all eight bits of q.
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, The first table is simply the CRC of all possible eight bit values. This is
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, all the information needed to generate CRCs on data a byte at a time for all
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, combinations of CRC register values and incoming bytes. The remaining tables
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, allow for word-at-a-time CRC calculation for both big-endian and little-
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, endian machines, where a word is four bytes.
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, */
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, local void make_crc_table()
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, {
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, unsigned long c;
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, int n, k;
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, unsigned long poly; /* polynomial exclusive-or pattern */
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, /* terms of polynomial defining this crc (except x^32): */
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, /* make exclusive-or pattern from polynomial (0xedb88320UL) */
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, poly = 0UL;
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, poly |= 1UL << (31 - p[n]);
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, /* generate a crc for every 8-bit value */
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, for (n = 0; n < 256; n++) {
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, c = (unsigned long)n;
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, for (k = 0; k < 8; k++)
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, c = c & 1 ? poly ^ (c >> 1) : c >> 1;
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, crc_table[0][n] = c;
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, }
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, #ifdef BYFOUR
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, /* generate crc for each value followed by one, two, and three zeros, and
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, then the byte reversal of those as well as the first table */
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, for (n = 0; n < 256; n++) {
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, c = crc_table[0][n];
0x2d02ef8dL crc_table[4][n] = REV(c);
}; for (k = 1; k < 4; k++) {
#endif c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
/* ========================================================================= crc_table[k + 4][n] = REV(c);
* This function can be used by asm versions of crc32() }
*/ }
const uLongf * ZEXPORT get_crc_table() #endif /* BYFOUR */
{
#ifdef DYNAMIC_CRC_TABLE crc_table_empty = 0;
if (crc_table_empty) make_crc_table();
#endif #ifdef MAKECRCH
return (const uLongf *)crc_table; /* write out CRC tables to crc32.h */
} {
FILE *out;
/* ========================================================================= */
#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); out = fopen("crc32.h", "w");
#define DO2(buf) DO1(buf); DO1(buf); if (out == NULL) return;
#define DO4(buf) DO2(buf); DO2(buf); fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
#define DO8(buf) DO4(buf); DO4(buf); fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
fprintf(out, "local const unsigned long FAR ");
/* ========================================================================= */ fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
uLong ZEXPORT crc32(crc, buf, len) write_table(out, crc_table[0]);
uLong crc; # ifdef BYFOUR
const Bytef *buf; fprintf(out, "#ifdef BYFOUR\n");
uInt len; for (k = 1; k < 8; k++) {
{ fprintf(out, " },\n {\n");
if (buf == Z_NULL) return 0L; write_table(out, crc_table[k]);
#ifdef DYNAMIC_CRC_TABLE }
if (crc_table_empty) fprintf(out, "#endif\n");
make_crc_table(); # endif /* BYFOUR */
#endif fprintf(out, " }\n};\n");
crc = crc ^ 0xffffffffL; fclose(out);
while (len >= 8) }
{ #endif /* MAKECRCH */
DO8(buf); }
len -= 8;
} #ifdef MAKECRCH
if (len) do { local void write_table(out, table)
DO1(buf); FILE *out;
} while (--len); const unsigned long FAR *table;
return crc ^ 0xffffffffL; {
} int n;
for (n = 0; n < 256; n++)
fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
}
#endif /* MAKECRCH */
#else /* !DYNAMIC_CRC_TABLE */
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
#include "crc32.h"
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
* This function can be used by asm versions of crc32()
*/
const unsigned long FAR * ZEXPORT get_crc_table()
{
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty) make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
return (const unsigned long FAR *)crc_table;
}
/* ========================================================================= */
#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
unsigned long ZEXPORT crc32(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
if (buf == Z_NULL) return 0UL;
#ifdef DYNAMIC_CRC_TABLE
if (crc_table_empty)
make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
#ifdef BYFOUR
if (sizeof(void *) == sizeof(ptrdiff_t)) {
u4 endian;
endian = 1;
if (*((unsigned char *)(&endian)))
return crc32_little(crc, buf, len);
else
return crc32_big(crc, buf, len);
}
#endif /* BYFOUR */
crc = crc ^ 0xffffffffUL;
while (len >= 8) {
DO8;
len -= 8;
}
if (len) do {
DO1;
} while (--len);
return crc ^ 0xffffffffUL;
}
#ifdef BYFOUR
/* ========================================================================= */
#define DOLIT4 c ^= *buf4++; \
c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
local unsigned long crc32_little(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = (u4)crc;
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
len--;
}
buf4 = (const u4 FAR *)buf;
while (len >= 32) {
DOLIT32;
len -= 32;
}
while (len >= 4) {
DOLIT4;
len -= 4;
}
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
} while (--len);
c = ~c;
return (unsigned long)c;
}
/* ========================================================================= */
#define DOBIG4 c ^= *++buf4; \
c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
local unsigned long crc32_big(crc, buf, len)
unsigned long crc;
const unsigned char FAR *buf;
unsigned len;
{
register u4 c;
register const u4 FAR *buf4;
c = REV((u4)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
len--;
}
buf4 = (const u4 FAR *)buf;
buf4--;
while (len >= 32) {
DOBIG32;
len -= 32;
}
while (len >= 4) {
DOBIG4;
len -= 4;
}
buf4++;
buf = (const unsigned char FAR *)buf4;
if (len) do {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
return (unsigned long)(REV(c));
}
#endif /* BYFOUR */

File diff suppressed because it is too large Load Diff

567
src/zlib/example.c Normal file
View File

@ -0,0 +1,567 @@
/* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id: example.c,v 1.1 2003/12/13 04:14:38 cozman Exp $ */
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#else
extern void exit OF((int));
#endif
#if defined(VMS) || defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
#define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \
exit(1); \
} \
}
const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */
void test_compress OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
Byte *uncompr, uLong uncomprLen));
void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[]));
/* ===========================================================================
* Test compress() and uncompress()
*/
void test_compress(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
uLong len = (uLong)strlen(hello)+1;
err = compress(compr, &comprLen, (const Bytef*)hello, len);
CHECK_ERR(err, "compress");
strcpy((char*)uncompr, "garbage");
err = uncompress(uncompr, &uncomprLen, compr, comprLen);
CHECK_ERR(err, "uncompress");
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad uncompress\n");
exit(1);
} else {
printf("uncompress(): %s\n", (char *)uncompr);
}
}
/* ===========================================================================
* Test read/write of .gz files
*/
void test_gzio(fname, uncompr, uncomprLen)
const char *fname; /* compressed file name */
Byte *uncompr;
uLong uncomprLen;
{
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else
int err;
int len = (int)strlen(hello)+1;
gzFile file;
z_off_t pos;
file = gzopen(fname, "wb");
if (file == NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
gzputc(file, 'h');
if (gzputs(file, "ello") != 4) {
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
exit(1);
}
if (gzprintf(file, ", %s!", "hello") != 8) {
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
exit(1);
}
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
gzclose(file);
file = gzopen(fname, "rb");
if (file == NULL) {
fprintf(stderr, "gzopen error\n");
exit(1);
}
strcpy((char*)uncompr, "garbage");
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
exit(1);
}
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
exit(1);
} else {
printf("gzread(): %s\n", (char*)uncompr);
}
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file));
exit(1);
}
if (gzgetc(file) != ' ') {
fprintf(stderr, "gzgetc error\n");
exit(1);
}
if (gzungetc(' ', file) != ' ') {
fprintf(stderr, "gzungetc error\n");
exit(1);
}
gzgets(file, (char*)uncompr, (int)uncomprLen);
if (strlen((char*)uncompr) != 7) { /* " hello!" */
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
exit(1);
}
if (strcmp((char*)uncompr, hello + 6)) {
fprintf(stderr, "bad gzgets after gzseek\n");
exit(1);
} else {
printf("gzgets() after gzseek: %s\n", (char*)uncompr);
}
gzclose(file);
#endif
}
/* ===========================================================================
* Test deflate() with small buffers
*/
void test_deflate(compr, comprLen)
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */
int err;
uLong len = (uLong)strlen(hello)+1;
c_stream.zalloc = (alloc_func)0;
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
c_stream.next_in = (Bytef*)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
}
/* Finish the stream, still forcing small buffers: */
for (;;) {
c_stream.avail_out = 1;
err = deflate(&c_stream, Z_FINISH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "deflate");
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with small buffers
*/
void test_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = 0;
d_stream.next_out = uncompr;
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "inflate");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad inflate\n");
exit(1);
} else {
printf("inflate(): %s\n", (char *)uncompr);
}
}
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
z_stream c_stream; /* compression stream */
int err;
c_stream.zalloc = (alloc_func)0;
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_SPEED);
CHECK_ERR(err, "deflateInit");
c_stream.next_out = compr;
c_stream.avail_out = (uInt)comprLen;
/* At this point, uncompr is still mostly zeroes, so it should compress
* very well:
*/
c_stream.next_in = uncompr;
c_stream.avail_in = (uInt)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) {
fprintf(stderr, "deflate not greedy\n");
exit(1);
}
/* Feed in already compressed data and switch to no compression: */
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
c_stream.next_in = compr;
c_stream.avail_in = (uInt)comprLen/2;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
/* Switch back to compressing mode: */
deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
c_stream.next_in = uncompr;
c_stream.avail_in = (uInt)uncomprLen;
err = deflate(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1);
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with large buffers
*/
void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
for (;;) {
d_stream.next_out = uncompr; /* discard the output */
d_stream.avail_out = (uInt)uncomprLen;
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + comprLen/2) {
fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out);
exit(1);
} else {
printf("large_inflate(): OK\n");
}
}
/* ===========================================================================
* Test deflate() with full flush
*/
void test_flush(compr, comprLen)
Byte *compr;
uLong *comprLen;
{
z_stream c_stream; /* compression stream */
int err;
uInt len = (uInt)strlen(hello)+1;
c_stream.zalloc = (alloc_func)0;
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
c_stream.next_in = (Bytef*)hello;
c_stream.next_out = compr;
c_stream.avail_in = 3;
c_stream.avail_out = (uInt)*comprLen;
err = deflate(&c_stream, Z_FULL_FLUSH);
CHECK_ERR(err, "deflate");
compr[3]++; /* force an error in first compressed block */
c_stream.avail_in = len - 3;
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
CHECK_ERR(err, "deflate");
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
*comprLen = c_stream.total_out;
}
/* ===========================================================================
* Test inflateSync()
*/
void test_sync(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
inflate(&d_stream, Z_NO_FLUSH);
CHECK_ERR(err, "inflate");
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
err = inflateSync(&d_stream); /* but skip the damaged part */
CHECK_ERR(err, "inflateSync");
err = inflate(&d_stream, Z_FINISH);
if (err != Z_DATA_ERROR) {
fprintf(stderr, "inflate should report DATA_ERROR\n");
/* Because of incorrect adler32 */
exit(1);
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
printf("after inflateSync(): hel%s\n", (char *)uncompr);
}
/* ===========================================================================
* Test deflate() with preset dictionary
*/
void test_dict_deflate(compr, comprLen)
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */
int err;
c_stream.zalloc = (alloc_func)0;
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream,
(const Bytef*)dictionary, sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary");
dictId = c_stream.adler;
c_stream.next_out = compr;
c_stream.avail_out = (uInt)comprLen;
c_stream.next_in = (Bytef*)hello;
c_stream.avail_in = (uInt)strlen(hello)+1;
err = deflate(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1);
}
err = deflateEnd(&c_stream);
CHECK_ERR(err, "deflateEnd");
}
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err;
z_stream d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0;
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
d_stream.next_in = compr;
d_stream.avail_in = (uInt)comprLen;
err = inflateInit(&d_stream);
CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr;
d_stream.avail_out = (uInt)uncomprLen;
for (;;) {
err = inflate(&d_stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
if (err == Z_NEED_DICT) {
if (d_stream.adler != dictId) {
fprintf(stderr, "unexpected dictionary");
exit(1);
}
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
sizeof(dictionary));
}
CHECK_ERR(err, "inflate with dict");
}
err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) {
fprintf(stderr, "bad inflate with dict\n");
exit(1);
} else {
printf("inflate with dictionary: %s\n", (char *)uncompr);
}
}
/* ===========================================================================
* Usage: example [output.gz [input.gz]]
*/
int main(argc, argv)
int argc;
char *argv[];
{
Byte *compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen;
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
fprintf(stderr, "incompatible zlib version\n");
exit(1);
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
fprintf(stderr, "warning: different zlib version\n");
}
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags());
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
if (compr == Z_NULL || uncompr == Z_NULL) {
printf("out of memory\n");
exit(1);
}
test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : TESTFILE),
uncompr, uncomprLen);
test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen);
test_large_deflate(compr, comprLen, uncompr, uncomprLen);
test_large_inflate(compr, comprLen, uncompr, uncomprLen);
test_flush(compr, &comprLen);
test_sync(compr, comprLen, uncompr, uncomprLen);
comprLen = uncomprLen;
test_dict_deflate(compr, comprLen);
test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
free(compr);
free(uncompr);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,183 +1,305 @@
/* inffast.c -- process literals and length/distance pairs fast /* inffast.c -- fast decoding
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zlib/zutil.h" #include "zutil.h"
#include "zlib/inftrees.h" #include "inftrees.h"
#include "zlib/infblock.h" #include "inflate.h"
#include "zlib/infcodes.h" #include "inffast.h"
#include "zlib/infutil.h"
#include "zlib/inffast.h" #ifndef ASMINF
struct inflate_codes_state {int dummy;}; /* for buggy compilers */ /* Allow machine dependent optimization for post-increment or pre-increment.
Based on testing to date,
/* simplify the use of the inflate_huft type with some defines */ Pre-increment preferred for:
#define exop word.what.Exop - PowerPC G3 (Adler)
#define bits word.what.Bits - MIPS R5000 (Randers-Pehrson)
Post-increment preferred for:
/* macros for bit input with no checking and for returning unused bytes */ - none
#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} No measurable difference:
#define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} - Pentium III (Anderson)
- 68060 (Nikl)
/* Called with number of bytes left to write in window at least 258 */
(the maximum string length) and number of input bytes available #ifdef POSTINC
at least ten. The ten bytes are six bytes for the longest length/ # define OFF 0
distance pair plus four bytes for overloading the bit buffer. */ # define PUP(a) *(a)++
#else
int inflate_fast(bl, bd, tl, td, s, z) # define OFF 1
uInt bl, bd; # define PUP(a) *++(a)
inflate_huft *tl; #endif
inflate_huft *td; /* need separate declaration for Borland C++ */
inflate_blocks_statef *s; /*
z_streamp z; Decode literal, length, and distance codes and write out the resulting
{ literal and match bytes until either not enough input or output is
inflate_huft *t; /* temporary pointer */ available, an end-of-block is encountered, or a data error is encountered.
uInt e; /* extra bits or operation */ When large enough input and output buffers are supplied to inflate(), for
uLong b; /* bit buffer */ example, a 16K input buffer and a 64K output buffer, more than 95% of the
uInt k; /* bits in bit buffer */ inflate execution time is spent in this routine.
Bytef *p; /* input data pointer */
uInt n; /* bytes available there */ Entry assumptions:
Bytef *q; /* output window write pointer */
uInt m; /* bytes to end of window or read pointer */ state->mode == LEN
uInt ml; /* mask for literal/length tree */ strm->avail_in >= 6
uInt md; /* mask for distance tree */ strm->avail_out >= 258
uInt c; /* bytes to copy */ start >= strm->avail_out
uInt d; /* distance back to copy from */ state->bits < 8
Bytef *r; /* copy source pointer */
On return, state->mode is one of:
/* load input, output, bit values */
LOAD LEN -- ran out of enough output space or enough available input
TYPE -- reached end of block code, inflate() to interpret next block
/* initialize masks */ BAD -- error in block data
ml = inflate_mask[bl];
md = inflate_mask[bd]; Notes:
/* do until not enough input or output space for fast loop */ - The maximum input bits used by a length/distance pair is 15 bits for the
do { /* assume called with m >= 258 && n >= 10 */ length code, 5 bits for the length extra, 15 bits for the distance code,
/* get literal/length code */ and 13 bits for the distance extra. This totals 48 bits, or six bytes.
GRABBITS(20) /* max bits for literal/length code */ Therefore if strm->avail_in >= 6, then there is enough input to avoid
if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) checking for available input while decoding.
{
DUMPBITS(t->bits) - The maximum bytes that a single length/distance pair can output is 258
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? bytes, which is the maximum length that can be coded. inflate_fast()
"inflate: * literal '%c'\n" : requires strm->avail_out >= 258 for each loop to avoid checking for
"inflate: * literal 0x%02x\n", t->base)); output space.
*q++ = (Byte)t->base; */
m--; void inflate_fast(strm, start)
continue; z_streamp strm;
} unsigned start; /* inflate()'s starting value for strm->avail_out */
do { {
DUMPBITS(t->bits) struct inflate_state FAR *state;
if (e & 16) unsigned char FAR *in; /* local strm->next_in */
{ unsigned char FAR *last; /* while in < last, enough input available */
/* get extra bits for length */ unsigned char FAR *out; /* local strm->next_out */
e &= 15; unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
c = t->base + ((uInt)b & inflate_mask[e]); unsigned char FAR *end; /* while out < end, enough space available */
DUMPBITS(e) unsigned wsize; /* window size or zero if not using window */
Tracevv((stderr, "inflate: * length %u\n", c)); unsigned whave; /* valid bytes in the window */
unsigned write; /* window write index */
/* decode distance base of block to copy */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
GRABBITS(15); /* max bits for distance code */ unsigned long hold; /* local strm->hold */
e = (t = td + ((uInt)b & md))->exop; unsigned bits; /* local strm->bits */
do { code const FAR *lcode; /* local strm->lencode */
DUMPBITS(t->bits) code const FAR *dcode; /* local strm->distcode */
if (e & 16) unsigned lmask; /* mask for first level of length codes */
{ unsigned dmask; /* mask for first level of distance codes */
/* get extra bits to add to distance base */ code this; /* retrieved table entry */
e &= 15; unsigned op; /* code bits, operation, extra bits, or */
GRABBITS(e) /* get extra bits (up to 13) */ /* window position, window bytes to copy */
d = t->base + ((uInt)b & inflate_mask[e]); unsigned len; /* match length, unused bytes */
DUMPBITS(e) unsigned dist; /* match distance */
Tracevv((stderr, "inflate: * distance %u\n", d)); unsigned char FAR *from; /* where to copy match from */
/* do the copy */ /* copy state to local variables */
m -= c; state = (struct inflate_state FAR *)strm->state;
r = q - d; in = strm->next_in - OFF;
if (r < s->window) /* wrap if needed */ last = in + (strm->avail_in - 5);
{ out = strm->next_out - OFF;
do { beg = out - (start - strm->avail_out);
r += s->end - s->window; /* force pointer in window */ end = out + (strm->avail_out - 257);
} while (r < s->window); /* covers invalid distances */ wsize = state->wsize;
e = s->end - r; whave = state->whave;
if (c > e) write = state->write;
{ window = state->window;
c -= e; /* wrapped copy */ hold = state->hold;
do { bits = state->bits;
*q++ = *r++; lcode = state->lencode;
} while (--e); dcode = state->distcode;
r = s->window; lmask = (1U << state->lenbits) - 1;
do { dmask = (1U << state->distbits) - 1;
*q++ = *r++;
} while (--c); /* decode literals and length/distances until end-of-block or not enough
} input data or output space */
else /* normal copy */ do {
{ if (bits < 15) {
*q++ = *r++; c--; hold += (unsigned long)(PUP(in)) << bits;
*q++ = *r++; c--; bits += 8;
do { hold += (unsigned long)(PUP(in)) << bits;
*q++ = *r++; bits += 8;
} while (--c); }
} this = lcode[hold & lmask];
} dolen:
else /* normal copy */ op = (unsigned)(this.bits);
{ hold >>= op;
*q++ = *r++; c--; bits -= op;
*q++ = *r++; c--; op = (unsigned)(this.op);
do { if (op == 0) { /* literal */
*q++ = *r++; Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
} while (--c); "inflate: literal '%c'\n" :
} "inflate: literal 0x%02x\n", this.val));
break; PUP(out) = (unsigned char)(this.val);
} }
else if ((e & 64) == 0) else if (op & 16) { /* length base */
{ len = (unsigned)(this.val);
t += t->base; op &= 15; /* number of extra bits */
e = (t += ((uInt)b & inflate_mask[e]))->exop; if (op) {
} if (bits < op) {
else hold += (unsigned long)(PUP(in)) << bits;
{ bits += 8;
z->msg = (char*)"invalid distance code"; }
UNGRAB len += (unsigned)hold & ((1U << op) - 1);
UPDATE hold >>= op;
return Z_DATA_ERROR; bits -= op;
} }
} while (1); Tracevv((stderr, "inflate: length %u\n", len));
break; if (bits < 15) {
} hold += (unsigned long)(PUP(in)) << bits;
if ((e & 64) == 0) bits += 8;
{ hold += (unsigned long)(PUP(in)) << bits;
t += t->base; bits += 8;
if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) }
{ this = dcode[hold & dmask];
DUMPBITS(t->bits) dodist:
Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? op = (unsigned)(this.bits);
"inflate: * literal '%c'\n" : hold >>= op;
"inflate: * literal 0x%02x\n", t->base)); bits -= op;
*q++ = (Byte)t->base; op = (unsigned)(this.op);
m--; if (op & 16) { /* distance base */
break; dist = (unsigned)(this.val);
} op &= 15; /* number of extra bits */
} if (bits < op) {
else if (e & 32) hold += (unsigned long)(PUP(in)) << bits;
{ bits += 8;
Tracevv((stderr, "inflate: * end of block\n")); if (bits < op) {
UNGRAB hold += (unsigned long)(PUP(in)) << bits;
UPDATE bits += 8;
return Z_STREAM_END; }
} }
else dist += (unsigned)hold & ((1U << op) - 1);
{ hold >>= op;
z->msg = (char*)"invalid literal/length code"; bits -= op;
UNGRAB Tracevv((stderr, "inflate: distance %u\n", dist));
UPDATE op = (unsigned)(out - beg); /* max distance in output */
return Z_DATA_ERROR; if (dist > op) { /* see if copy from window */
} op = dist - op; /* distance back in window */
} while (1); if (op > whave) {
} while (m >= 258 && n >= 10); strm->msg = (char *)"invalid distance too far back";
state->mode = BAD;
/* not enough input or output--restore pointers and return */ break;
UNGRAB }
UPDATE from = window - OFF;
return Z_OK; if (write == 0) { /* very common case */
} from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
else if (write < op) { /* wrap around window */
from += wsize + write - op;
op -= write;
if (op < len) { /* some from end of window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = window - OFF;
if (write < len) { /* some from start of window */
op = write;
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
}
else { /* contiguous in window */
from += write - op;
if (op < len) { /* some from window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = out - dist; /* rest from output */
}
}
while (len > 2) {
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
}
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
else {
from = out - dist; /* copy direct from output */
do { /* minimum length is three */
PUP(out) = PUP(from);
PUP(out) = PUP(from);
PUP(out) = PUP(from);
len -= 3;
} while (len > 2);
if (len) {
PUP(out) = PUP(from);
if (len > 1)
PUP(out) = PUP(from);
}
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
this = dcode[this.val + (hold & ((1U << op) - 1))];
goto dodist;
}
else {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
this = lcode[this.val + (hold & ((1U << op) - 1))];
goto dolen;
}
else if (op & 32) { /* end-of-block */
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
else {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
} while (in < last && out < end);
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
len = bits >> 3;
in -= len;
bits -= len << 3;
hold &= (1U << bits) - 1;
/* update state and return */
strm->next_in = in + OFF;
strm->next_out = out + OFF;
strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
strm->avail_out = (unsigned)(out < end ?
257 + (end - out) : 257 - (out - end));
state->hold = hold;
state->bits = bits;
return;
}
/*
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
- Three separate decoding do-loops for direct, window, and write == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
- Swapping literal/length else
- Swapping window/direct else
- Larger unrolled copy loops (three is about right)
- Moving len -= 3 statement into middle of loop
*/
#endif /* !ASMINF */

File diff suppressed because it is too large Load Diff

View File

@ -1,454 +1,321 @@
/* inftrees.c -- generate Huffman trees for efficient decoding /* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2002 Mark Adler * Copyright (C) 1995-2003 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
#include "zlib/zutil.h" #include "zutil.h"
#include "zlib/inftrees.h" #include "inftrees.h"
#if !defined(BUILDFIXED) && !defined(STDC) #define MAXBITS 15
# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */
#endif const char inflate_copyright[] =
" inflate 1.2.1 Copyright 1995-2003 Mark Adler ";
const char inflate_copyright[] = /*
" inflate 1.1.4 Copyright 1995-2002 Mark Adler "; If you use the zlib library in a product, an acknowledgment is welcome
/* in the documentation of your product. If for some reason you cannot
If you use the zlib library in a product, an acknowledgment is welcome include such an acknowledgment, I would appreciate that you keep this
in the documentation of your product. If for some reason you cannot copyright string in the executable of your product.
include such an acknowledgment, I would appreciate that you keep this */
copyright string in the executable of your product.
*/ /*
struct internal_state {int dummy;}; /* for buggy compilers */ Build a set of tables to decode the provided canonical Huffman code.
The code lengths are lens[0..codes-1]. The result starts at *table,
/* simplify the use of the inflate_huft type with some defines */ whose indices are 0..2^bits-1. work is a writable array of at least
#define exop word.what.Exop lens shorts, which is used as a work area. type is the type of code
#define bits word.what.Bits to be generated, CODES, LENS, or DISTS. On return, zero is success,
-1 is an invalid code, and +1 means that ENOUGH isn't enough. table
on return points to the next available entry's address. bits is the
local int huft_build OF(( requested root table index bits, and on return it is the actual root
uIntf *, /* code lengths in bits */ table index bits. It will differ if the request is greater than the
uInt, /* number of codes */ longest code or if it is less than the shortest code.
uInt, /* number of "simple" codes */ */
const uIntf *, /* list of base values for non-simple codes */ int inflate_table(type, lens, codes, table, bits, work)
const uIntf *, /* list of extra bits for non-simple codes */ codetype type;
inflate_huft * FAR*,/* result: starting table */ unsigned short FAR *lens;
uIntf *, /* maximum lookup bits (returns actual) */ unsigned codes;
inflate_huft *, /* space for trees */ code FAR * FAR *table;
uInt *, /* hufts used in space */ unsigned FAR *bits;
uIntf * )); /* space for values */ unsigned short FAR *work;
{
/* Tables for deflate from PKZIP's appnote.txt. */ unsigned len; /* a code's length in bits */
local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ unsigned sym; /* index of code symbols */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, unsigned min, max; /* minimum and maximum code lengths */
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; unsigned root; /* number of index bits for root table */
/* see note #13 above about 258 */ unsigned curr; /* number of index bits for current table */
local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ unsigned drop; /* code bits to drop for sub-table */
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, int left; /* number of prefix codes available */
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ unsigned used; /* code entries in table used */
local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ unsigned huff; /* Huffman code */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, unsigned incr; /* for incrementing code, index */
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, unsigned fill; /* index for replicating entries */
8193, 12289, 16385, 24577}; unsigned low; /* low bits for current root entry */
local const uInt cpdext[30] = { /* Extra bits for distance codes */ unsigned mask; /* mask for low root bits */
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, code this; /* table entry for duplication */
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, code FAR *next; /* next available space in table */
12, 12, 13, 13}; const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
/* int end; /* use base and extra for symbol > end */
Huffman code decoding is performed using a multi-level table lookup. unsigned short count[MAXBITS+1]; /* number of codes of each length */
The fastest way to decode is to simply build a lookup table whose unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
size is determined by the longest code. However, the time it takes static const unsigned short lbase[31] = { /* Length codes 257..285 base */
to build this table can also be a factor if the data being decoded 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
is not very long. The most common codes are necessarily the 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
shortest codes, so those codes dominate the decoding time, and hence static const unsigned short lext[31] = { /* Length codes 257..285 extra */
the speed. The idea is you can have a shorter table that decodes the 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
shorter, more probable codes, and then point to subsidiary tables for 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 76, 66};
the longer codes. The time it costs to decode the longer codes is static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
then traded against the time it takes to make longer tables. 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,
This results of this trade are in the variables lbits and dbits 8193, 12289, 16385, 24577, 0, 0};
below. lbits is the number of bits the first level table for literal/ static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
length codes can decode in one step, and dbits is the same thing for 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
the distance codes. Subsequent tables are also less than or equal to 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
those sizes. These values may be adjusted either when all of the 28, 28, 29, 29, 64, 64};
codes are shorter than that, in which case the longest code length in
bits is used, or when the shortest code is *longer* than the requested /*
table size, in which case the length of the shortest code in bits is Process a set of code lengths to create a canonical Huffman code. The
used. code lengths are lens[0..codes-1]. Each length corresponds to the
symbols 0..codes-1. The Huffman code is generated by first sorting the
There are two different values for the two tables, since they code a symbols by length from short to long, and retaining the symbol order
different number of possibilities each. The literal/length table for codes with equal lengths. Then the code starts with all zero bits
codes 286 possible values, or in a flat code, a little over eight for the first code of the shortest length, and the codes are integer
bits. The distance table codes 30 possible values, or a little less increments for the same length, and zeros are appended as the length
than five bits, flat. The optimum values for speed end up being increases. For the deflate format, these bits are stored backwards
about one bit more than those, so lbits is 8+1 and dbits is 5+1. from their more natural integer increment ordering, and so when the
The optimum values may differ though from machine to machine, and decoding tables are built in the large loop below, the integer codes
possibly even between compilers. Your mileage may vary. are incremented backwards.
*/
This routine assumes, but does not check, that all of the entries in
lens[] are in the range 0..MAXBITS. The caller must assure this.
/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ 1..MAXBITS is interpreted as that code length. zero means that that
#define BMAX 15 /* maximum bit length of any code */ symbol does not occur in this code.
local int huft_build(b, n, s, d, e, t, m, hp, hn, v) The codes are sorted by computing a count of codes for each length,
uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ creating from that a table of starting indices for each length in the
uInt n; /* number of codes (assumed <= 288) */ sorted table, and then entering the symbols in order in the sorted
uInt s; /* number of simple-valued codes (0..s-1) */ table. The sorted table is work[], with that space being provided by
const uIntf *d; /* list of base values for non-simple codes */ the caller.
const uIntf *e; /* list of extra bits for non-simple codes */
inflate_huft * FAR *t; /* result: starting table */ The length counts are used for other purposes as well, i.e. finding
uIntf *m; /* maximum lookup bits, returns actual */ the minimum and maximum length codes, determining if there are any
inflate_huft *hp; /* space for trees */ codes at all, checking for a valid set of lengths, and looking ahead
uInt *hn; /* hufts used in space */ at length counts to determine sub-table sizes when building the
uIntf *v; /* working area: values in order of bit length */ decoding tables.
/* Given a list of code lengths and a maximum table size, make a set of */
tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
if the given code set is incomplete (the tables are still built in this /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
case), or Z_DATA_ERROR if the input is invalid. */ for (len = 0; len <= MAXBITS; len++)
{ count[len] = 0;
for (sym = 0; sym < codes; sym++)
uInt a; /* counter for codes of length k */ count[lens[sym]]++;
uInt c[BMAX+1]; /* bit length count table */
uInt f; /* i repeats in table every f entries */ /* bound code lengths, force root to be within code lengths */
int g; /* maximum code length */ root = *bits;
int h; /* table level */ for (max = MAXBITS; max >= 1; max--)
register uInt i; /* counter, current code */ if (count[max] != 0) break;
register uInt j; /* counter */ if (root > max) root = max;
register int k; /* number of bits in current code */ if (max == 0) return -1; /* no codes! */
int l; /* bits per table (returned in m) */ for (min = 1; min <= MAXBITS; min++)
uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ if (count[min] != 0) break;
register uIntf *p; /* pointer into c[], b[], or v[] */ if (root < min) root = min;
inflate_huft *q; /* points to current table */
struct inflate_huft_s r; /* table entry for structure assignment */ /* check for an over-subscribed or incomplete set of lengths */
inflate_huft *u[BMAX]; /* table stack */ left = 1;
register int w; /* bits before this table == (l * h) */ for (len = 1; len <= MAXBITS; len++) {
uInt x[BMAX+1]; /* bit offsets, then code stack */ left <<= 1;
uIntf *xp; /* pointer into x */ left -= count[len];
int y; /* number of dummy codes added */ if (left < 0) return -1; /* over-subscribed */
uInt z; /* number of entries in current table */ }
if (left > 0 && (type == CODES || (codes - count[0] != 1)))
return -1; /* incomplete set */
/* Generate counts for each bit length */
p = c; /* generate offsets into symbol table for each length for sorting */
#define C0 *p++ = 0; offs[1] = 0;
#define C2 C0 C0 C0 C0 for (len = 1; len < MAXBITS; len++)
#define C4 C2 C2 C2 C2 offs[len + 1] = offs[len] + count[len];
C4 /* clear c[]--assume BMAX+1 is 16 */
p = b; i = n; /* sort symbols by length, by symbol order within each length */
do { for (sym = 0; sym < codes; sym++)
c[*p++]++; /* assume all entries <= BMAX */ if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
} while (--i);
if (c[0] == n) /* null input--all zero length codes */ /*
{ Create and fill in decoding tables. In this loop, the table being
*t = (inflate_huft *)Z_NULL; filled is at next and has curr index bits. The code being used is huff
*m = 0; with length len. That code is converted to an index by dropping drop
return Z_OK; bits off of the bottom. For codes where len is less than drop + curr,
} those top drop + curr - len bits are incremented through all values to
fill the table with replicated entries.
/* Find minimum and maximum length, bound *m by those */ root is the number of index bits for the root table. When len exceeds
l = *m; root, sub-tables are created pointed to by the root entry with an index
for (j = 1; j <= BMAX; j++) of the low root bits of huff. This is saved in low to check for when a
if (c[j]) new sub-table should be started. drop is zero when the root table is
break; being filled, and drop is root when sub-tables are being filled.
k = j; /* minimum code length */
if ((uInt)l < j) When a new sub-table is needed, it is necessary to look ahead in the
l = j; code lengths to determine what size sub-table is needed. The length
for (i = BMAX; i; i--) counts are used for this, and so count[] is decremented as codes are
if (c[i]) entered in the tables.
break;
g = i; /* maximum code length */ used keeps track of how many table entries have been allocated from the
if ((uInt)l > i) provided *table space. It is checked when a LENS table is being made
l = i; against the space in *table, ENOUGH, minus the maximum space needed by
*m = l; the worst case distance code, MAXD. This should never happen, but the
sufficiency of ENOUGH has not been proven exhaustively, hence the check.
This assumes that when type == LENS, bits == 9.
/* Adjust last length count to fill out codes, if needed */
for (y = 1 << j; j < i; j++, y <<= 1) sym increments through all symbols, and the loop terminates when
if ((y -= c[j]) < 0) all codes of length max, i.e. all codes, have been processed. This
return Z_DATA_ERROR; routine permits incomplete codes, so another loop after this one fills
if ((y -= c[i]) < 0) in the rest of the decoding tables with invalid code markers.
return Z_DATA_ERROR; */
c[i] += y;
/* set up for code type */
switch (type) {
/* Generate starting offsets into the value table for each length */ case CODES:
x[1] = j = 0; base = extra = work; /* dummy value--not used */
p = c + 1; xp = x + 2; end = 19;
while (--i) { /* note that i == g from above */ break;
*xp++ = (j += *p++); case LENS:
} base = lbase;
base -= 257;
extra = lext;
/* Make a table of values in order of bit lengths */ extra -= 257;
p = b; i = 0; end = 256;
do { break;
if ((j = *p++) != 0) default: /* DISTS */
v[x[j]++] = i; base = dbase;
} while (++i < n); extra = dext;
n = x[g]; /* set n to length of v */ end = -1;
}
/* Generate the Huffman codes and for each, make the table entries */ /* initialize state for loop */
x[0] = i = 0; /* first Huffman code is zero */ huff = 0; /* starting code */
p = v; /* grab values in bit order */ sym = 0; /* starting code symbol */
h = -1; /* no tables yet--level -1 */ len = min; /* starting code length */
w = -l; /* bits decoded == (l * h) */ next = *table; /* current table to fill in */
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ curr = root; /* current table index bits */
q = (inflate_huft *)Z_NULL; /* ditto */ drop = 0; /* current bits to drop from code for index */
z = 0; /* ditto */ low = (unsigned)(-1); /* trigger new sub-table when len > root */
used = 1U << root; /* use root table entries */
/* go through the bit lengths (k already is bits in shortest code) */ mask = used - 1; /* mask for comparing low */
for (; k <= g; k++)
{ /* check available table space */
a = c[k]; if (type == LENS && used >= ENOUGH - MAXD)
while (a--) return 1;
{
/* here i is the Huffman code of length k bits for value *p */ /* process all codes and make table entries */
/* make tables up to required level */ for (;;) {
while (k > w + l) /* create table entry */
{ this.bits = (unsigned char)(len - drop);
h++; if ((int)(work[sym]) < end) {
w += l; /* previous table always l bits */ this.op = (unsigned char)0;
this.val = work[sym];
/* compute minimum size table less than or equal to l bits */ }
z = g - w; else if ((int)(work[sym]) > end) {
z = z > (uInt)l ? l : z; /* table size upper limit */ this.op = (unsigned char)(extra[work[sym]]);
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ this.val = base[work[sym]];
{ /* too few codes for k-w bit table */ }
f -= a + 1; /* deduct codes from patterns left */ else {
xp = c + k; this.op = (unsigned char)(32 + 64); /* end of block */
if (j < z) this.val = 0;
while (++j < z) /* try smaller tables up to z bits */ }
{
if ((f <<= 1) <= *++xp) /* replicate for those indices with low len bits equal to huff */
break; /* enough codes to use up j bits */ incr = 1U << (len - drop);
f -= *xp; /* else deduct codes from patterns */ fill = 1U << curr;
} do {
} fill -= incr;
z = 1 << j; /* table entries for j-bit table */ next[(huff >> drop) + fill] = this;
} while (fill != 0);
/* allocate new table */
if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ /* backwards increment the len-bit code huff */
return Z_DATA_ERROR; /* overflow of MANY */ incr = 1U << (len - 1);
u[h] = q = hp + *hn; while (huff & incr)
*hn += z; incr >>= 1;
if (incr != 0) {
/* connect to last table, if there is one */ huff &= incr - 1;
if (h) huff += incr;
{ }
x[h] = i; /* save pattern for backing up */ else
r.bits = (Byte)l; /* bits to dump before this table */ huff = 0;
r.exop = (Byte)j; /* bits in this table */
j = i >> (w - l); /* go to next symbol, update count, len */
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ sym++;
u[h-1][j] = r; /* connect to last table */ if (--(count[len]) == 0) {
} if (len == max) break;
else len = lens[work[sym]];
*t = q; /* first table is returned result */ }
}
/* create new sub-table if needed */
/* set up table entry in r */ if (len > root && (huff & mask) != low) {
r.bits = (Byte)(k - w); /* if first time, transition to sub-tables */
if (p >= v + n) if (drop == 0)
r.exop = 128 + 64; /* out of values--invalid code */ drop = root;
else if (*p < s)
{ /* increment past last table */
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ next += 1U << curr;
r.base = *p++; /* simple code is just the value */
} /* determine length of next table */
else curr = len - drop;
{ left = (int)(1 << curr);
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ while (curr + drop < max) {
r.base = d[*p++ - s]; left -= count[curr + drop];
} if (left <= 0) break;
curr++;
/* fill code-like entries with r */ left <<= 1;
f = 1 << (k - w); }
for (j = i >> w; j < z; j += f)
q[j] = r; /* check for enough space */
used += 1U << curr;
/* backwards increment the k-bit code i */ if (type == LENS && used >= ENOUGH - MAXD)
for (j = 1 << (k - 1); i & j; j >>= 1) return 1;
i ^= j;
i ^= j; /* point entry in root table to sub-table */
low = huff & mask;
/* backup over finished tables */ (*table)[low].op = (unsigned char)curr;
mask = (1 << w) - 1; /* needed on HP, cc -O bug */ (*table)[low].bits = (unsigned char)root;
while ((i & mask) != x[h]) (*table)[low].val = (unsigned short)(next - *table);
{ }
h--; /* don't need to update q */ }
w -= l;
mask = (1 << w) - 1; /*
} Fill in rest of table for incomplete codes. This loop is similar to the
} loop above in incrementing huff for table indices. It is assumed that
} len is equal to curr + drop, so there is no loop needed to increment
through high index bits. When the current sub-table is filled, the loop
drops back to the root table to fill in any remaining entries there.
/* Return Z_BUF_ERROR if we were given an incomplete table */ */
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; this.op = (unsigned char)64; /* invalid code marker */
} this.bits = (unsigned char)(len - drop);
this.val = (unsigned short)0;
while (huff != 0) {
int inflate_trees_bits(c, bb, tb, hp, z) /* when done with sub-table, drop back to root table */
uIntf *c; /* 19 code lengths */ if (drop != 0 && (huff & mask) != low) {
uIntf *bb; /* bits tree desired/actual depth */ drop = 0;
inflate_huft * FAR *tb; /* bits tree result */ len = root;
inflate_huft *hp; /* space for trees */ next = *table;
z_streamp z; /* for messages */ curr = root;
{ this.bits = (unsigned char)len;
int r; }
uInt hn = 0; /* hufts used in space */
uIntf *v; /* work area for huft_build */ /* put invalid code marker in table */
next[huff >> drop] = this;
if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
return Z_MEM_ERROR; /* backwards increment the len-bit code huff */
r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, incr = 1U << (len - 1);
tb, bb, hp, &hn, v); while (huff & incr)
if (r == Z_DATA_ERROR) incr >>= 1;
z->msg = (char*)"oversubscribed dynamic bit lengths tree"; if (incr != 0) {
else if (r == Z_BUF_ERROR || *bb == 0) huff &= incr - 1;
{ huff += incr;
z->msg = (char*)"incomplete dynamic bit lengths tree"; }
r = Z_DATA_ERROR; else
} huff = 0;
ZFREE(z, v); }
return r;
} /* set return parameters */
*table += used;
*bits = root;
int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) return 0;
uInt nl; /* number of literal/length codes */ }
uInt nd; /* number of distance codes */
uIntf *c; /* that many (total) code lengths */
uIntf *bl; /* literal desired/actual bit depth */
uIntf *bd; /* distance desired/actual bit depth */
inflate_huft * FAR *tl; /* literal/length tree result */
inflate_huft * FAR *td; /* distance tree result */
inflate_huft *hp; /* space for trees */
z_streamp z; /* for messages */
{
int r;
uInt hn = 0; /* hufts used in space */
uIntf *v; /* work area for huft_build */
/* allocate work area */
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
return Z_MEM_ERROR;
/* build literal/length tree */
r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
if (r != Z_OK || *bl == 0)
{
if (r == Z_DATA_ERROR)
z->msg = (char*)"oversubscribed literal/length tree";
else if (r != Z_MEM_ERROR)
{
z->msg = (char*)"incomplete literal/length tree";
r = Z_DATA_ERROR;
}
ZFREE(z, v);
return r;
}
/* build distance tree */
r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
if (r != Z_OK || (*bd == 0 && nl > 257))
{
if (r == Z_DATA_ERROR)
z->msg = (char*)"oversubscribed distance tree";
else if (r == Z_BUF_ERROR) {
#ifdef PKZIP_BUG_WORKAROUND
r = Z_OK;
}
#else
z->msg = (char*)"incomplete distance tree";
r = Z_DATA_ERROR;
}
else if (r != Z_MEM_ERROR)
{
z->msg = (char*)"empty distance tree with lengths";
r = Z_DATA_ERROR;
}
ZFREE(z, v);
return r;
#endif
}
/* done */
ZFREE(z, v);
return Z_OK;
}
/* build fixed tables only once--keep them here */
#ifdef BUILDFIXED
local int fixed_built = 0;
#define FIXEDH 544 /* number of hufts used by fixed tables */
local inflate_huft fixed_mem[FIXEDH];
local uInt fixed_bl;
local uInt fixed_bd;
local inflate_huft *fixed_tl;
local inflate_huft *fixed_td;
#else
#include "zlib/inffixed.h"
#endif
int inflate_trees_fixed(bl, bd, tl, td, z)
uIntf *bl; /* literal desired/actual bit depth */
uIntf *bd; /* distance desired/actual bit depth */
inflate_huft * FAR *tl; /* literal/length tree result */
inflate_huft * FAR *td; /* distance tree result */
z_streamp z; /* for memory allocation */
{
#ifdef BUILDFIXED
/* build fixed tables if not already */
if (!fixed_built)
{
int k; /* temporary variable */
uInt f = 0; /* number of hufts used in fixed_mem */
uIntf *c; /* length list for huft_build */
uIntf *v; /* work area for huft_build */
/* allocate memory */
if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
return Z_MEM_ERROR;
if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
{
ZFREE(z, c);
return Z_MEM_ERROR;
}
/* literal table */
for (k = 0; k < 144; k++)
c[k] = 8;
for (; k < 256; k++)
c[k] = 9;
for (; k < 280; k++)
c[k] = 7;
for (; k < 288; k++)
c[k] = 8;
fixed_bl = 9;
huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
fixed_mem, &f, v);
/* distance table */
for (k = 0; k < 30; k++)
c[k] = 5;
fixed_bd = 5;
huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd,
fixed_mem, &f, v);
/* done */
ZFREE(z, v);
ZFREE(z, c);
fixed_built = 1;
}
#endif
*bl = fixed_bl;
*bd = fixed_bd;
*tl = fixed_tl;
*td = fixed_td;
return Z_OK;
}

177
src/zlib/ioapi.c Normal file
View File

@ -0,0 +1,177 @@
/* ioapi.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include "ioapi.h"
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
voidpf ZCALLBACK fopen_file_func OF((
voidpf opaque,
const char* filename,
int mode));
uLong ZCALLBACK fread_file_func OF((
voidpf opaque,
voidpf stream,
void* buf,
uLong size));
uLong ZCALLBACK fwrite_file_func OF((
voidpf opaque,
voidpf stream,
const void* buf,
uLong size));
long ZCALLBACK ftell_file_func OF((
voidpf opaque,
voidpf stream));
long ZCALLBACK fseek_file_func OF((
voidpf opaque,
voidpf stream,
uLong offset,
int origin));
int ZCALLBACK fclose_file_func OF((
voidpf opaque,
voidpf stream));
int ZCALLBACK ferror_file_func OF((
voidpf opaque,
voidpf stream));
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
{
FILE* file = NULL;
const char* mode_fopen = NULL;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
mode_fopen = "rb";
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
mode_fopen = "r+b";
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
mode_fopen = "wb";
if ((filename!=NULL) && (mode_fopen != NULL))
file = fopen(filename, mode_fopen);
return file;
}
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
{
uLong ret;
ret = fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
{
uLong ret;
ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
}
long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
long ret;
ret = ftell((FILE *)stream);
return ret;
}
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
{
int fseek_origin=0;
long ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
fseek_origin = SEEK_CUR;
break;
case ZLIB_FILEFUNC_SEEK_END :
fseek_origin = SEEK_END;
break;
case ZLIB_FILEFUNC_SEEK_SET :
fseek_origin = SEEK_SET;
break;
default: return -1;
}
ret = 0;
fseek((FILE *)stream, offset, fseek_origin);
return ret;
}
int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret;
ret = fclose((FILE *)stream);
return ret;
}
int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret;
ret = ferror((FILE *)stream);
return ret;
}
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func;
pzlib_filefunc_def->ztell_file = ftell_file_func;
pzlib_filefunc_def->zseek_file = fseek_file_func;
pzlib_filefunc_def->zclose_file = fclose_file_func;
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}

270
src/zlib/iowin32.c Normal file
View File

@ -0,0 +1,270 @@
/* iowin32.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
This IO API version uses the Win32 API (for Microsoft Windows)
Version 1.00, September 10th, 2003
Copyright (C) 1998-2003 Gilles Vollant
*/
#include <stdlib.h>
#include "zlib.h"
#include "ioapi.h"
#include "iowin32.h"
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE (0xFFFFFFFF)
#endif
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
#endif
voidpf ZCALLBACK win32_open_file_func OF((
voidpf opaque,
const char* filename,
int mode));
uLong ZCALLBACK win32_read_file_func OF((
voidpf opaque,
voidpf stream,
void* buf,
uLong size));
uLong ZCALLBACK win32_write_file_func OF((
voidpf opaque,
voidpf stream,
const void* buf,
uLong size));
long ZCALLBACK win32_tell_file_func OF((
voidpf opaque,
voidpf stream));
long ZCALLBACK win32_seek_file_func OF((
voidpf opaque,
voidpf stream,
uLong offset,
int origin));
int ZCALLBACK win32_close_file_func OF((
voidpf opaque,
voidpf stream));
int ZCALLBACK win32_error_file_func OF((
voidpf opaque,
voidpf stream));
typedef struct
{
HANDLE hf;
int error;
} WIN32FILE_IOWIN;
voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
{
const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = 0;
voidpf ret=NULL;
dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
{
dwDesiredAccess = GENERIC_READ;
dwCreationDisposition = OPEN_EXISTING;
dwShareMode = FILE_SHARE_READ;
}
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
{
dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
dwCreationDisposition = OPEN_EXISTING;
}
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
{
dwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
dwCreationDisposition = CREATE_ALWAYS;
}
if ((filename!=NULL) && (dwDesiredAccess != 0))
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL,
dwCreationDisposition, dwFlagsAndAttributes, NULL);
if (hFile == INVALID_HANDLE_VALUE)
hFile = NULL;
if (hFile != NULL)
{
WIN32FILE_IOWIN w32fiow;
w32fiow.hf = hFile;
w32fiow.error = 0;
ret = malloc(sizeof(WIN32FILE_IOWIN));
if (ret==NULL)
CloseHandle(hFile);
else *((WIN32FILE_IOWIN*)ret) = w32fiow;
}
return ret;
}
uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
{
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
if (!ReadFile(hFile, buf, size, &ret, NULL))
{
DWORD dwErr = GetLastError();
if (dwErr == ERROR_HANDLE_EOF)
dwErr = 0;
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
}
return ret;
}
uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
{
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile !=NULL)
if (!WriteFile(hFile, buf, size, &ret, NULL))
{
DWORD dwErr = GetLastError();
if (dwErr == ERROR_HANDLE_EOF)
dwErr = 0;
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
}
return ret;
}
long ZCALLBACK win32_tell_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT);
if (dwSet == INVALID_SET_FILE_POINTER)
{
DWORD dwErr = GetLastError();
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
ret = -1;
}
else
ret=(long)dwSet;
}
return ret;
}
long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
{
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
if (stream!=NULL)
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
dwMoveMethod = FILE_CURRENT;
break;
case ZLIB_FILEFUNC_SEEK_END :
dwMoveMethod = FILE_END;
break;
case ZLIB_FILEFUNC_SEEK_SET :
dwMoveMethod = FILE_BEGIN;
break;
default: return -1;
}
if (hFile != NULL)
{
DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod);
if (dwSet == INVALID_SET_FILE_POINTER)
{
DWORD dwErr = GetLastError();
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr;
ret = -1;
}
else
ret=0;
}
return ret;
}
int ZCALLBACK win32_close_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret=-1;
if (stream!=NULL)
{
HANDLE hFile;
hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
if (hFile != NULL)
{
CloseHandle(hFile);
ret=0;
}
free(stream);
}
return ret;
}
int ZCALLBACK win32_error_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
{
int ret=-1;
if (stream!=NULL)
{
ret = ((WIN32FILE_IOWIN*)stream) -> error;
}
return ret;
}
void fill_win32_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = win32_open_file_func;
pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func;
pzlib_filefunc_def->ztell_file = win32_tell_file_func;
pzlib_filefunc_def->zseek_file = win32_seek_file_func;
pzlib_filefunc_def->zclose_file = win32_close_file_func;
pzlib_filefunc_def->zerror_file = win32_error_file_func;
pzlib_filefunc_def->opaque=NULL;
}

322
src/zlib/minigzip.c Normal file
View File

@ -0,0 +1,322 @@
/* minigzip.c -- simulate gzip using the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
* minigzip is a minimal implementation of the gzip utility. This is
* only an example of using zlib and isn't meant to replace the
* full-featured gzip. No attempt is made to deal with file systems
* limiting names to 14 or 8+3 characters, etc... Error checking is
* very limited. So use minigzip only for testing; use gzip for the
* real thing. On MSDOS, use only on file names without extension
* or in pipe mode.
*/
/* @(#) $Id: minigzip.c,v 1.1 2003/12/13 04:14:38 cozman Exp $ */
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#else
extern void exit OF((int));
#endif
#ifdef USE_MMAP
# include <sys/types.h>
# include <sys/mman.h>
# include <sys/stat.h>
#endif
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
#ifdef VMS
# define unlink delete
# define GZ_SUFFIX "-gz"
#endif
#ifdef RISCOS
# define unlink remove
# define GZ_SUFFIX "-gz"
# define fileno(file) file->__file
#endif
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fileno */
#endif
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *));
#endif
#ifndef GZ_SUFFIX
# define GZ_SUFFIX ".gz"
#endif
#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1)
#define BUFLEN 16384
#define MAX_NAME_LEN 1024
#ifdef MAXSEG_64K
# define local static
/* Needed for systems with limitation on stack size. */
#else
# define local
#endif
char *prog;
void error OF((const char *msg));
void gz_compress OF((FILE *in, gzFile out));
#ifdef USE_MMAP
int gz_compress_mmap OF((FILE *in, gzFile out));
#endif
void gz_uncompress OF((gzFile in, FILE *out));
void file_compress OF((char *file, char *mode));
void file_uncompress OF((char *file));
int main OF((int argc, char *argv[]));
/* ===========================================================================
* Display error message and exit
*/
void error(msg)
const char *msg;
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
/* ===========================================================================
* Compress input to output then close both files.
*/
void gz_compress(in, out)
FILE *in;
gzFile out;
{
local char buf[BUFLEN];
int len;
int err;
#ifdef USE_MMAP
/* Try first compressing with mmap. If mmap fails (minigzip used in a
* pipe), use the normal fread loop.
*/
if (gz_compress_mmap(in, out) == Z_OK) return;
#endif
for (;;) {
len = (int)fread(buf, 1, sizeof(buf), in);
if (ferror(in)) {
perror("fread");
exit(1);
}
if (len == 0) break;
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
}
fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose");
}
#ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
/* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise.
*/
int gz_compress_mmap(in, out)
FILE *in;
gzFile out;
{
int len;
int err;
int ifd = fileno(in);
caddr_t buf; /* mmap'ed buffer for the entire input file */
off_t buf_len; /* length of the input file */
struct stat sb;
/* Determine the size of the file, needed for mmap: */
if (fstat(ifd, &sb) < 0) return Z_ERRNO;
buf_len = sb.st_size;
if (buf_len <= 0) return Z_ERRNO;
/* Now do the actual mmap: */
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
if (buf == (caddr_t)(-1)) return Z_ERRNO;
/* Compress the whole file at once: */
len = gzwrite(out, (char *)buf, (unsigned)buf_len);
if (len != (int)buf_len) error(gzerror(out, &err));
munmap(buf, buf_len);
fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose");
return Z_OK;
}
#endif /* USE_MMAP */
/* ===========================================================================
* Uncompress input to output then close both files.
*/
void gz_uncompress(in, out)
gzFile in;
FILE *out;
{
local char buf[BUFLEN];
int len;
int err;
for (;;) {
len = gzread(in, buf, sizeof(buf));
if (len < 0) error (gzerror(in, &err));
if (len == 0) break;
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
error("failed fwrite");
}
}
if (fclose(out)) error("failed fclose");
if (gzclose(in) != Z_OK) error("failed gzclose");
}
/* ===========================================================================
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
void file_compress(file, mode)
char *file;
char *mode;
{
local char outfile[MAX_NAME_LEN];
FILE *in;
gzFile out;
strcpy(outfile, file);
strcat(outfile, GZ_SUFFIX);
in = fopen(file, "rb");
if (in == NULL) {
perror(file);
exit(1);
}
out = gzopen(outfile, mode);
if (out == NULL) {
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
exit(1);
}
gz_compress(in, out);
unlink(file);
}
/* ===========================================================================
* Uncompress the given file and remove the original.
*/
void file_uncompress(file)
char *file;
{
local char buf[MAX_NAME_LEN];
char *infile, *outfile;
FILE *out;
gzFile in;
uInt len = (uInt)strlen(file);
strcpy(buf, file);
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
infile = file;
outfile = buf;
outfile[len-3] = '\0';
} else {
outfile = file;
infile = buf;
strcat(infile, GZ_SUFFIX);
}
in = gzopen(infile, "rb");
if (in == NULL) {
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
exit(1);
}
out = fopen(outfile, "wb");
if (out == NULL) {
perror(file);
exit(1);
}
gz_uncompress(in, out);
unlink(infile);
}
/* ===========================================================================
* Usage: minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...]
* -d : decompress
* -f : compress with Z_FILTERED
* -h : compress with Z_HUFFMAN_ONLY
* -r : compress with Z_RLE
* -1 to -9 : compression level
*/
int main(argc, argv)
int argc;
char *argv[];
{
int uncompr = 0;
gzFile file;
char outmode[20];
strcpy(outmode, "wb6 ");
prog = argv[0];
argc--, argv++;
while (argc > 0) {
if (strcmp(*argv, "-d") == 0)
uncompr = 1;
else if (strcmp(*argv, "-f") == 0)
outmode[3] = 'f';
else if (strcmp(*argv, "-h") == 0)
outmode[3] = 'h';
else if (strcmp(*argv, "-r") == 0)
outmode[3] = 'R';
else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' &&
(*argv)[2] == 0)
outmode[2] = (*argv)[1];
else
break;
argc--, argv++;
}
if (argc == 0) {
SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout);
if (uncompr) {
file = gzdopen(fileno(stdin), "rb");
if (file == NULL) error("can't gzdopen stdin");
gz_uncompress(file, stdout);
} else {
file = gzdopen(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout");
gz_compress(stdin, file);
}
} else {
do {
if (uncompr) {
file_uncompress(*argv);
} else {
file_compress(*argv, outmode);
}
} while (argv++, --argc);
}
return 0;
}

556
src/zlib/miniunz.c Normal file
View File

@ -0,0 +1,556 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#ifdef unix
# include <unistd.h>
# include <utime.h>
#else
# include <direct.h>
# include <io.h>
#endif
#include "unzip.h"
#define CASESENSITIVITY (0)
#define WRITEBUFFERSIZE (8192)
#define MAXFILENAME (256)
#ifdef WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
/*
mini unzip, demo of unzip package
usage :
Usage : miniunz [-exvlo] file.zip [file_to_extract]
list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
if it exists
*/
/* change_file_date : change the date/time of a file
filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDos format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
void change_file_date(filename,dosdate,tmu_date)
const char *filename;
uLong dosdate;
tm_unz tmu_date;
{
#ifdef WIN32
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE,
0,NULL,OPEN_EXISTING,0,NULL);
GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite);
DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal);
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
#ifdef unix
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
newdate.tm_min=tmu_date.tm_min;
newdate.tm_hour=tmu_date.tm_hour;
newdate.tm_mday=tmu_date.tm_mday;
newdate.tm_mon=tmu_date.tm_mon;
if (tmu_date.tm_year > 1900)
newdate.tm_year=tmu_date.tm_year - 1900;
else
newdate.tm_year=tmu_date.tm_year ;
newdate.tm_isdst=-1;
ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut);
#endif
#endif
}
/* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */
int mymkdir(dirname)
const char* dirname;
{
int ret=0;
#ifdef WIN32
ret = mkdir(dirname);
#else
#ifdef unix
ret = mkdir (dirname,0775);
#endif
#endif
return ret;
}
int makedir (newdir)
char *newdir;
{
char *buffer ;
char *p;
int len = (int)strlen(newdir);
if (len <= 0)
return 0;
buffer = (char*)malloc(len+1);
strcpy(buffer,newdir);
if (buffer[len-1] == '/') {
buffer[len-1] = '\0';
}
if (mymkdir(buffer) == 0)
{
free(buffer);
return 1;
}
p = buffer+1;
while (1)
{
char hold;
while(*p && *p != '\\' && *p != '/')
p++;
hold = *p;
*p = 0;
if ((mymkdir(buffer) == -1) && (errno == ENOENT))
{
printf("couldn't create directory %s\n",buffer);
free(buffer);
return 0;
}
if (hold == 0)
break;
*p++ = hold;
}
free(buffer);
return 1;
}
void do_banner()
{
printf("MiniUnz 1.00, demo of zLib + Unz package written by Gilles Vollant\n");
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
}
void do_help()
{
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \
" -e Extract without pathname (junk paths)\n" \
" -x Extract with pathname\n" \
" -v list files\n" \
" -l list files\n" \
" -o overwrite files without prompting\n" \
" -p extract crypted file using password\n\n");
}
int do_list(uf)
unzFile uf;
{
uLong i;
unz_global_info gi;
int err;
err = unzGetGlobalInfo (uf,&gi);
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
printf(" Length Method Size Ratio Date Time CRC-32 Name\n");
printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
for (i=0;i<gi.number_entry;i++)
{
char filename_inzip[256];
unz_file_info file_info;
uLong ratio=0;
const char *string_method;
char charCrypt=' ';
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
break;
}
if (file_info.uncompressed_size>0)
ratio = (file_info.compressed_size*100)/file_info.uncompressed_size;
/* display a '*' if the file is crypted */
if ((file_info.flag & 1) != 0)
charCrypt='*';
if (file_info.compression_method==0)
string_method="Stored";
else
if (file_info.compression_method==Z_DEFLATED)
{
uInt iLevel=(uInt)((file_info.flag & 0x6)/2);
if (iLevel==0)
string_method="Defl:N";
else if (iLevel==1)
string_method="Defl:X";
else if ((iLevel==2) || (iLevel==3))
string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
}
else
string_method="Unkn. ";
printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n",
file_info.uncompressed_size,string_method,
charCrypt,
file_info.compressed_size,
ratio,
(uLong)file_info.tmu_date.tm_mon + 1,
(uLong)file_info.tmu_date.tm_mday,
(uLong)file_info.tmu_date.tm_year % 100,
(uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min,
(uLong)file_info.crc,filename_inzip);
if ((i+1)<gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGoToNextFile\n",err);
break;
}
}
}
return 0;
}
int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
unzFile uf;
const int* popt_extract_without_path;
int* popt_overwrite;
const char* password;
{
char filename_inzip[256];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;
FILE *fout=NULL;
void* buf;
uInt size_buf;
unz_file_info file_info;
uLong ratio=0;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
return err;
}
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
printf("Error allocating memory\n");
return UNZ_INTERNALERROR;
}
p = filename_withoutpath = filename_inzip;
while ((*p) != '\0')
{
if (((*p)=='/') || ((*p)=='\\'))
filename_withoutpath = p+1;
p++;
}
if ((*filename_withoutpath)=='\0')
{
if ((*popt_extract_without_path)==0)
{
printf("creating directory: %s\n",filename_inzip);
mymkdir(filename_inzip);
}
}
else
{
const char* write_filename;
int skip=0;
if ((*popt_extract_without_path)==0)
write_filename = filename_inzip;
else
write_filename = filename_withoutpath;
err = unzOpenCurrentFilePassword(uf,password);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err);
}
if (((*popt_overwrite)==0) && (err==UNZ_OK))
{
char rep=0;
FILE* ftestexist;
ftestexist = fopen(write_filename,"rb");
if (ftestexist!=NULL)
{
fclose(ftestexist);
do
{
char answer[128];
printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
scanf("%1s",answer);
rep = answer[0] ;
if ((rep>='a') && (rep<='z'))
rep -= 0x20;
}
while ((rep!='Y') && (rep!='N') && (rep!='A'));
}
if (rep == 'N')
skip = 1;
if (rep == 'A')
*popt_overwrite=1;
}
if ((skip==0) && (err==UNZ_OK))
{
fout=fopen(write_filename,"wb");
/* some zipfile don't contain directory alone before file */
if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
(filename_withoutpath!=(char*)filename_inzip))
{
char c=*(filename_withoutpath-1);
*(filename_withoutpath-1)='\0';
makedir(write_filename);
*(filename_withoutpath-1)=c;
fout=fopen(write_filename,"wb");
}
if (fout==NULL)
{
printf("error opening %s\n",write_filename);
}
}
if (fout!=NULL)
{
printf(" extracting: %s\n",write_filename);
do
{
err = unzReadCurrentFile(uf,buf,size_buf);
if (err<0)
{
printf("error %d with zipfile in unzReadCurrentFile\n",err);
break;
}
if (err>0)
if (fwrite(buf,err,1,fout)!=1)
{
printf("error in writing extracted file\n");
err=UNZ_ERRNO;
break;
}
}
while (err>0);
if (fout)
fclose(fout);
if (err==0)
change_file_date(write_filename,file_info.dosDate,
file_info.tmu_date);
}
if (err==UNZ_OK)
{
err = unzCloseCurrentFile (uf);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzCloseCurrentFile\n",err);
}
}
else
unzCloseCurrentFile(uf); /* don't lose the error */
}
free(buf);
return err;
}
int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
unzFile uf;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
uLong i;
unz_global_info gi;
int err;
FILE* fout=NULL;
err = unzGetGlobalInfo (uf,&gi);
if (err!=UNZ_OK)
printf("error %d with zipfile in unzGetGlobalInfo \n",err);
for (i=0;i<gi.number_entry;i++)
{
if (do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password) != UNZ_OK)
break;
if ((i+1)<gi.number_entry)
{
err = unzGoToNextFile(uf);
if (err!=UNZ_OK)
{
printf("error %d with zipfile in unzGoToNextFile\n",err);
break;
}
}
}
return 0;
}
int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
unzFile uf;
const char* filename;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
int err = UNZ_OK;
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{
printf("file %s not found in the zipfile\n",filename);
return 2;
}
if (do_extract_currentfile(uf,&opt_extract_without_path,
&opt_overwrite,
password) == UNZ_OK)
return 0;
else
return 1;
}
int main(argc,argv)
int argc;
char *argv[];
{
const char *zipfilename=NULL;
const char *filename_to_extract=NULL;
const char *password=NULL;
char filename_try[MAXFILENAME+16] = "";
int i;
int opt_do_list=0;
int opt_do_extract=1;
int opt_do_extract_withoutpath=0;
int opt_overwrite=0;
unzFile uf=NULL;
do_banner();
if (argc==1)
{
do_help();
return 0;
}
else
{
for (i=1;i<argc;i++)
{
if ((*argv[i])=='-')
{
const char *p=argv[i]+1;
while ((*p)!='\0')
{
char c=*(p++);;
if ((c=='l') || (c=='L'))
opt_do_list = 1;
if ((c=='v') || (c=='V'))
opt_do_list = 1;
if ((c=='x') || (c=='X'))
opt_do_extract = 1;
if ((c=='e') || (c=='E'))
opt_do_extract = opt_do_extract_withoutpath = 1;
if ((c=='o') || (c=='O'))
opt_overwrite=1;
if (((c=='p') || (c=='P')) && (i+1<argc))
{
password=argv[i+1];
i++;
}
}
}
else
{
if (zipfilename == NULL)
zipfilename = argv[i];
else if (filename_to_extract==NULL)
filename_to_extract = argv[i] ;
}
}
}
if (zipfilename!=NULL)
{
# ifdef USEWIN32IOAPI
zlib_filefunc_def ffunc;
# endif
strncpy(filename_try, zipfilename,MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
# ifdef USEWIN32IOAPI
fill_win32_filefunc(&ffunc);
uf = unzOpen2(zipfilename,&ffunc);
# else
uf = unzOpen(zipfilename);
# endif
if (uf==NULL)
{
strcat(filename_try,".zip");
# ifdef USEWIN32IOAPI
uf = unzOpen2(filename_try,&ffunc);
# else
uf = unzOpen(filename_try);
# endif
}
}
if (uf==NULL)
{
printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename);
return 1;
}
printf("%s opened\n",filename_try);
if (opt_do_list==1)
return do_list(uf);
else if (opt_do_extract==1)
{
if (filename_to_extract == NULL)
return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
else
return do_extract_onefile(uf,filename_to_extract,
opt_do_extract_withoutpath,opt_overwrite,password);
}
unzCloseCurrentFile(uf);
return 0;
}

397
src/zlib/minizip.c Normal file
View File

@ -0,0 +1,397 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#ifdef unix
# include <unistd.h>
# include <utime.h>
# include <sys/types.h>
# include <sys/stat.h>
#else
# include <direct.h>
# include <io.h>
#endif
#include "zip.h"
#ifdef WIN32
#define USEWIN32IOAPI
#include "iowin32.h"
#endif
#define WRITEBUFFERSIZE (16384)
#define MAXFILENAME (256)
#ifdef WIN32
uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
int ret = 0;
{
FILETIME ftLocal;
HANDLE hFind;
WIN32_FIND_DATA ff32;
hFind = FindFirstFile(f,&ff32);
if (hFind != INVALID_HANDLE_VALUE)
{
FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
FindClose(hFind);
ret = 1;
}
}
return ret;
}
#else
#ifdef unix
uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
int ret=0;
struct stat s; /* results of stat() */
struct tm* filedate;
time_t tm_t=0;
if (strcmp(f,"-")!=0)
{
char name[MAXFILENAME+1];
int len = strlen(f);
strncpy(name, f,MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */
name[ MAXFILENAME ] = '\0';
if (name[len - 1] == '/')
name[len - 1] = '\0';
/* not all systems allow stat'ing a file with / appended */
if (stat(name,&s)==0)
{
tm_t = s.st_mtime;
ret = 1;
}
}
filedate = localtime(&tm_t);
tmzip->tm_sec = filedate->tm_sec;
tmzip->tm_min = filedate->tm_min;
tmzip->tm_hour = filedate->tm_hour;
tmzip->tm_mday = filedate->tm_mday;
tmzip->tm_mon = filedate->tm_mon ;
tmzip->tm_year = filedate->tm_year;
return ret;
}
#else
uLong filetime(f, tmzip, dt)
char *f; /* name of file to get info on */
tm_zip *tmzip; /* return value: access, modific. and creation times */
uLong *dt; /* dostime */
{
return 0;
}
#endif
#endif
int check_exist_file(filename)
const char* filename;
{
FILE* ftestexist;
int ret = 1;
ftestexist = fopen(filename,"rb");
if (ftestexist==NULL)
ret = 0;
else
fclose(ftestexist);
return ret;
}
void do_banner()
{
printf("MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant\n");
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
}
void do_help()
{
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \
" -o Overwrite existing file.zip\n" \
" -a Append to existing file.zip\n" \
" -0 Store only\n" \
" -1 Compress faster\n" \
" -9 Compress better\n\n");
}
/* calculate the CRC32 of a file,
because to encrypt a file, we need known the CRC32 of the file before */
int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
{
unsigned long calculate_crc=0;
int err=ZIP_OK;
FILE * fin = fopen(filenameinzip,"rb");
unsigned long size_read = 0;
unsigned long total_read = 0;
if (fin==NULL)
{
err = ZIP_ERRNO;
}
if (err == ZIP_OK)
do
{
err = ZIP_OK;
size_read = (int)fread(buf,1,size_buf,fin);
if (size_read < size_buf)
if (feof(fin)==0)
{
printf("error in reading %s\n",filenameinzip);
err = ZIP_ERRNO;
}
if (size_read>0)
calculate_crc = crc32(calculate_crc,buf,size_read);
total_read += size_read;
} while ((err == ZIP_OK) && (size_read>0));
if (fin)
fclose(fin);
*result_crc=calculate_crc;
printf("file %s crc %x\n",filenameinzip,calculate_crc);
return err;
}
int main(argc,argv)
int argc;
char *argv[];
{
int i;
int opt_overwrite=0;
int opt_compress_level=Z_DEFAULT_COMPRESSION;
int zipfilenamearg = 0;
char filename_try[MAXFILENAME+16];
int zipok;
int err=0;
int size_buf=0;
void* buf=NULL;
const char* password=NULL;
do_banner();
if (argc==1)
{
do_help();
return 0;
}
else
{
for (i=1;i<argc;i++)
{
if ((*argv[i])=='-')
{
const char *p=argv[i]+1;
while ((*p)!='\0')
{
char c=*(p++);;
if ((c=='o') || (c=='O'))
opt_overwrite = 1;
if ((c=='a') || (c=='A'))
opt_overwrite = 2;
if ((c>='0') && (c<='9'))
opt_compress_level = c-'0';
if (((c=='p') || (c=='P')) && (i+1<argc))
{
password=argv[i+1];
i++;
}
}
}
else
if (zipfilenamearg == 0)
zipfilenamearg = i ;
}
}
size_buf = WRITEBUFFERSIZE;
buf = (void*)malloc(size_buf);
if (buf==NULL)
{
printf("Error allocating memory\n");
return ZIP_INTERNALERROR;
}
if (zipfilenamearg==0)
zipok=0;
else
{
int i,len;
int dot_found=0;
zipok = 1 ;
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
len=(int)strlen(filename_try);
for (i=0;i<len;i++)
if (filename_try[i]=='.')
dot_found=1;
if (dot_found==0)
strcat(filename_try,".zip");
if (opt_overwrite==2)
{
/* if the file don't exist, we not append file */
if (check_exist_file(filename_try)==0)
opt_overwrite=1;
}
else
if (opt_overwrite==0)
if (check_exist_file(filename_try)!=0)
{
char rep=0;
do
{
char answer[128];
printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
scanf("%1s",answer);
rep = answer[0] ;
if ((rep>='a') && (rep<='z'))
rep -= 0x20;
}
while ((rep!='Y') && (rep!='N') && (rep!='A'));
if (rep=='N')
zipok = 0;
if (rep=='A')
opt_overwrite = 2;
}
}
if (zipok==1)
{
zipFile zf;
int errclose;
# ifdef USEWIN32IOAPI
zlib_filefunc_def ffunc;
fill_win32_filefunc(&ffunc);
zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc);
# else
zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0);
# endif
if (zf == NULL)
{
printf("error opening %s\n",filename_try);
err= ZIP_ERRNO;
}
else
printf("creating %s\n",filename_try);
for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
{
if (((*(argv[i]))!='-') && ((*(argv[i]))!='/'))
{
FILE * fin;
int size_read;
const char* filenameinzip = argv[i];
zip_fileinfo zi;
unsigned long crcFile=0;
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
zi.dosDate = 0;
zi.internal_fa = 0;
zi.external_fa = 0;
filetime(filenameinzip,&zi.tmz_date,&zi.dosDate);
/*
err = zipOpenNewFileInZip(zf,filenameinzip,&zi,
NULL,0,NULL,0,NULL / * comment * /,
(opt_compress_level != 0) ? Z_DEFLATED : 0,
opt_compress_level);
*/
if ((password != NULL) && (err==ZIP_OK))
err = getFileCrc(filenameinzip,buf,size_buf,&crcFile);
err = zipOpenNewFileInZip3(zf,filenameinzip,&zi,
NULL,0,NULL,0,NULL /* comment*/,
(opt_compress_level != 0) ? Z_DEFLATED : 0,
opt_compress_level,0,
/* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
password,crcFile);
if (err != ZIP_OK)
printf("error in opening %s in zipfile\n",filenameinzip);
else
{
fin = fopen(filenameinzip,"rb");
if (fin==NULL)
{
err=ZIP_ERRNO;
printf("error in opening %s for reading\n",filenameinzip);
}
}
if (err == ZIP_OK)
do
{
err = ZIP_OK;
size_read = (int)fread(buf,1,size_buf,fin);
if (size_read < size_buf)
if (feof(fin)==0)
{
printf("error in reading %s\n",filenameinzip);
err = ZIP_ERRNO;
}
if (size_read>0)
{
err = zipWriteInFileInZip (zf,buf,size_read);
if (err<0)
{
printf("error in writing %s in the zipfile\n",
filenameinzip);
}
}
} while ((err == ZIP_OK) && (size_read>0));
if (fin)
fclose(fin);
if (err<0)
err=ZIP_ERRNO;
else
{
err = zipCloseFileInZip(zf);
if (err!=ZIP_OK)
printf("error in closing %s in the zipfile\n",
filenameinzip);
}
}
}
errclose = zipClose(zf,NULL);
if (errclose != ZIP_OK)
printf("error in closing %s\n",filename_try);
}
free(buf);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,58 +1,61 @@
/* uncompr.c -- decompress a memory buffer /* uncompr.c -- decompress a memory buffer
* Copyright (C) 1995-2002 Jean-loup Gailly. * Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id: uncompr.c,v 1.2 2003/10/13 21:07:33 cozman Exp $ */ /* @(#) $Id: uncompr.c,v 1.3 2003/12/13 04:14:38 cozman Exp $ */
#include "zlib/zlib.h" #define ZLIB_INTERNAL
#include "zlib.h"
/* ===========================================================================
Decompresses the source buffer into the destination buffer. sourceLen is /* ===========================================================================
the byte length of the source buffer. Upon entry, destLen is the total Decompresses the source buffer into the destination buffer. sourceLen is
size of the destination buffer, which must be large enough to hold the the byte length of the source buffer. Upon entry, destLen is the total
entire uncompressed data. (The size of the uncompressed data must have size of the destination buffer, which must be large enough to hold the
been saved previously by the compressor and transmitted to the decompressor entire uncompressed data. (The size of the uncompressed data must have
by some mechanism outside the scope of this compression library.) been saved previously by the compressor and transmitted to the decompressor
Upon exit, destLen is the actual size of the compressed buffer. by some mechanism outside the scope of this compression library.)
This function can be used to decompress a whole file at once if the Upon exit, destLen is the actual size of the compressed buffer.
input file is mmap'ed. This function can be used to decompress a whole file at once if the
input file is mmap'ed.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
buffer, or Z_DATA_ERROR if the input data was corrupted. enough memory, Z_BUF_ERROR if there was not enough room in the output
*/ buffer, or Z_DATA_ERROR if the input data was corrupted.
int ZEXPORT uncompress (dest, destLen, source, sourceLen) */
Bytef *dest; int ZEXPORT uncompress (dest, destLen, source, sourceLen)
uLongf *destLen; Bytef *dest;
const Bytef *source; uLongf *destLen;
uLong sourceLen; const Bytef *source;
{ uLong sourceLen;
z_stream stream; {
int err; z_stream stream;
int err;
stream.next_in = (Bytef*)source;
stream.avail_in = (uInt)sourceLen; stream.next_in = (Bytef*)source;
/* Check for source > 64K on 16-bit machine: */ stream.avail_in = (uInt)sourceLen;
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; /* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
stream.next_out = dest;
stream.avail_out = (uInt)*destLen; stream.next_out = dest;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.avail_out = (uInt)*destLen;
if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0; stream.zalloc = (alloc_func)0;
stream.zfree = (free_func)0;
err = inflateInit(&stream);
if (err != Z_OK) return err; err = inflateInit(&stream);
if (err != Z_OK) return err;
err = inflate(&stream, Z_FINISH);
if (err != Z_STREAM_END) { err = inflate(&stream, Z_FINISH);
inflateEnd(&stream); if (err != Z_STREAM_END) {
return err == Z_OK ? Z_BUF_ERROR : err; inflateEnd(&stream);
} if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
*destLen = stream.total_out; return Z_DATA_ERROR;
return err;
err = inflateEnd(&stream); }
return err; *destLen = stream.total_out;
}
err = inflateEnd(&stream);
return err;
}

File diff suppressed because it is too large Load Diff

1170
src/zlib/zip.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,225 +1,319 @@
/* zutil.c -- target dependent utility functions for the compression library /* zutil.c -- target dependent utility functions for the compression library
* Copyright (C) 1995-2002 Jean-loup Gailly. * Copyright (C) 1995-2003 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id: zutil.c,v 1.2 2003/10/13 21:07:33 cozman Exp $ */ /* @(#) $Id: zutil.c,v 1.3 2003/12/13 04:14:38 cozman Exp $ */
#include "zlib/zutil.h" #include "zutil.h"
struct internal_state {int dummy;}; /* for buggy compilers */ #ifndef NO_DUMMY_DECL
struct internal_state {int dummy;}; /* for buggy compilers */
#ifndef STDC #endif
extern void exit OF((int));
#endif #ifndef STDC
extern void exit OF((int));
const char *z_errmsg[10] = { #endif
"need dictionary", /* Z_NEED_DICT 2 */
"stream end", /* Z_STREAM_END 1 */ const char * const z_errmsg[10] = {
"", /* Z_OK 0 */ "need dictionary", /* Z_NEED_DICT 2 */
"file error", /* Z_ERRNO (-1) */ "stream end", /* Z_STREAM_END 1 */
"stream error", /* Z_STREAM_ERROR (-2) */ "", /* Z_OK 0 */
"data error", /* Z_DATA_ERROR (-3) */ "file error", /* Z_ERRNO (-1) */
"insufficient memory", /* Z_MEM_ERROR (-4) */ "stream error", /* Z_STREAM_ERROR (-2) */
"buffer error", /* Z_BUF_ERROR (-5) */ "data error", /* Z_DATA_ERROR (-3) */
"incompatible version",/* Z_VERSION_ERROR (-6) */ "insufficient memory", /* Z_MEM_ERROR (-4) */
""}; "buffer error", /* Z_BUF_ERROR (-5) */
"incompatible version",/* Z_VERSION_ERROR (-6) */
""};
const char * ZEXPORT zlibVersion()
{
return ZLIB_VERSION; const char * ZEXPORT zlibVersion()
} {
return ZLIB_VERSION;
#ifdef DEBUG }
# ifndef verbose uLong ZEXPORT zlibCompileFlags()
# define verbose 0 {
# endif uLong flags;
int z_verbose = verbose;
flags = 0;
void z_error (m) switch (sizeof(uInt)) {
char *m; case 2: break;
{ case 4: flags += 1; break;
fprintf(stderr, "%s\n", m); case 8: flags += 2; break;
exit(1); default: flags += 3;
} }
#endif switch (sizeof(uLong)) {
case 2: break;
/* exported to allow conversion of error code to string for compress() and case 4: flags += 1 << 2; break;
* uncompress() case 8: flags += 2 << 2; break;
*/ default: flags += 3 << 2;
const char * ZEXPORT zError(err) }
int err; switch (sizeof(voidpf)) {
{ case 2: break;
return ERR_MSG(err); case 4: flags += 1 << 4; break;
} case 8: flags += 2 << 4; break;
default: flags += 3 << 4;
}
#ifndef HAVE_MEMCPY switch (sizeof(z_off_t)) {
case 2: break;
void zmemcpy(dest, source, len) case 4: flags += 1 << 6; break;
Bytef* dest; case 8: flags += 2 << 6; break;
const Bytef* source; default: flags += 3 << 6;
uInt len; }
{ #ifdef DEBUG
if (len == 0) return; flags += 1 << 8;
do { #endif
*dest++ = *source++; /* ??? to be unrolled */ #if defined(ASMV) || defined(ASMINF)
} while (--len != 0); flags += 1 << 9;
} #endif
#ifdef ZLIB_WINAPI
int zmemcmp(s1, s2, len) flags += 1 << 10;
const Bytef* s1; #endif
const Bytef* s2; #ifdef BUILDFIXED
uInt len; flags += 1 << 12;
{ #endif
uInt j; #ifdef DYNAMIC_CRC_TABLE
flags += 1 << 13;
for (j = 0; j < len; j++) { #endif
if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; #ifdef NO_GZCOMPRESS
} flags += 1 << 16;
return 0; #endif
} #ifdef NO_GZIP
flags += 1 << 17;
void zmemzero(dest, len) #endif
Bytef* dest; #ifdef PKZIP_BUG_WORKAROUND
uInt len; flags += 1 << 20;
{ #endif
if (len == 0) return; #ifdef FASTEST
do { flags += 1 << 21;
*dest++ = 0; /* ??? to be unrolled */ #endif
} while (--len != 0); #ifdef STDC
} # ifdef NO_vsnprintf
#endif flags += 1 << 25;
# ifdef HAS_vsprintf_void
#ifdef __TURBOC__ flags += 1 << 26;
#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) # endif
/* Small and medium model in Turbo C are for now limited to near allocation # else
* with reduced MAX_WBITS and MAX_MEM_LEVEL # ifdef HAS_vsnprintf_void
*/ flags += 1 << 26;
# define MY_ZCALLOC # endif
# endif
/* Turbo C malloc() does not allow dynamic allocation of 64K bytes #else
* and farmalloc(64K) returns a pointer with an offset of 8, so we flags += 1 << 24;
* must fix the pointer. Warning: the pointer must be put back to its # ifdef NO_snprintf
* original form in order to free it, use zcfree(). flags += 1 << 25;
*/ # ifdef HAS_sprintf_void
flags += 1 << 26;
#define MAX_PTR 10 # endif
/* 10*64K = 640K */ # else
# ifdef HAS_snprintf_void
local int next_ptr = 0; flags += 1 << 26;
# endif
typedef struct ptr_table_s { # endif
voidpf org_ptr; #endif
voidpf new_ptr; return flags;
} ptr_table; }
local ptr_table table[MAX_PTR]; #ifdef DEBUG
/* This table is used to remember the original form of pointers
* to large buffers (64K). Such pointers are normalized with a zero offset. # ifndef verbose
* Since MSDOS is not a preemptive multitasking OS, this table is not # define verbose 0
* protected from concurrent access. This hack doesn't work anyway on # endif
* a protected system like OS/2. Use Microsoft C instead. int z_verbose = verbose;
*/
void z_error (m)
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) char *m;
{ {
voidpf buf = opaque; /* just to make some compilers happy */ fprintf(stderr, "%s\n", m);
ulg bsize = (ulg)items*size; exit(1);
}
/* If we allocate less than 65520 bytes, we assume that farmalloc #endif
* will return a usable pointer which doesn't have to be normalized.
*/ /* exported to allow conversion of error code to string for compress() and
if (bsize < 65520L) { * uncompress()
buf = farmalloc(bsize); */
if (*(ush*)&buf != 0) return buf; const char * ZEXPORT zError(err)
} else { int err;
buf = farmalloc(bsize + 16L); {
} return ERR_MSG(err);
if (buf == NULL || next_ptr >= MAX_PTR) return NULL; }
table[next_ptr].org_ptr = buf;
#if defined(_WIN32_WCE)
/* Normalize the pointer to seg:0 */ /* does not exist on WCE */
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; int errno = 0;
*(ush*)&buf = 0; #endif
table[next_ptr++].new_ptr = buf;
return buf; #ifndef HAVE_MEMCPY
}
void zmemcpy(dest, source, len)
void zcfree (voidpf opaque, voidpf ptr) Bytef* dest;
{ const Bytef* source;
int n; uInt len;
if (*(ush*)&ptr != 0) { /* object < 64K */ {
farfree(ptr); if (len == 0) return;
return; do {
} *dest++ = *source++; /* ??? to be unrolled */
/* Find the original pointer */ } while (--len != 0);
for (n = 0; n < next_ptr; n++) { }
if (ptr != table[n].new_ptr) continue;
int zmemcmp(s1, s2, len)
farfree(table[n].org_ptr); const Bytef* s1;
while (++n < next_ptr) { const Bytef* s2;
table[n-1] = table[n]; uInt len;
} {
next_ptr--; uInt j;
return;
} for (j = 0; j < len; j++) {
ptr = opaque; /* just to make some compilers happy */ if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
Assert(0, "zcfree: ptr not found"); }
} return 0;
#endif }
#endif /* __TURBOC__ */
void zmemzero(dest, len)
Bytef* dest;
#if defined(M_I86) && !defined(__32BIT__) uInt len;
/* Microsoft C in 16-bit mode */ {
if (len == 0) return;
# define MY_ZCALLOC do {
*dest++ = 0; /* ??? to be unrolled */
#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) } while (--len != 0);
# define _halloc halloc }
# define _hfree hfree #endif
#endif
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) #ifdef SYS16BIT
{
if (opaque) opaque = 0; /* to make compiler happy */ #ifdef __TURBOC__
return _halloc((long)items, size); /* Turbo C in 16-bit mode */
}
# define MY_ZCALLOC
void zcfree (voidpf opaque, voidpf ptr)
{ /* Turbo C malloc() does not allow dynamic allocation of 64K bytes
if (opaque) opaque = 0; /* to make compiler happy */ * and farmalloc(64K) returns a pointer with an offset of 8, so we
_hfree(ptr); * must fix the pointer. Warning: the pointer must be put back to its
} * original form in order to free it, use zcfree().
*/
#endif /* MSC */
#define MAX_PTR 10
/* 10*64K = 640K */
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
local int next_ptr = 0;
#ifndef STDC
extern voidp calloc OF((uInt items, uInt size)); typedef struct ptr_table_s {
extern void free OF((voidpf ptr)); voidpf org_ptr;
#endif voidpf new_ptr;
} ptr_table;
voidpf zcalloc (opaque, items, size)
voidpf opaque; local ptr_table table[MAX_PTR];
unsigned items; /* This table is used to remember the original form of pointers
unsigned size; * to large buffers (64K). Such pointers are normalized with a zero offset.
{ * Since MSDOS is not a preemptive multitasking OS, this table is not
if (opaque) items += size - size; /* make compiler happy */ * protected from concurrent access. This hack doesn't work anyway on
return (voidpf)calloc(items, size); * a protected system like OS/2. Use Microsoft C instead.
} */
void zcfree (opaque, ptr) voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
voidpf opaque; {
voidpf ptr; voidpf buf = opaque; /* just to make some compilers happy */
{ ulg bsize = (ulg)items*size;
free(ptr);
if (opaque) return; /* make compiler happy */ /* If we allocate less than 65520 bytes, we assume that farmalloc
} * will return a usable pointer which doesn't have to be normalized.
*/
#endif /* MY_ZCALLOC */ if (bsize < 65520L) {
buf = farmalloc(bsize);
if (*(ush*)&buf != 0) return buf;
} else {
buf = farmalloc(bsize + 16L);
}
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
table[next_ptr].org_ptr = buf;
/* Normalize the pointer to seg:0 */
*((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
*(ush*)&buf = 0;
table[next_ptr++].new_ptr = buf;
return buf;
}
void zcfree (voidpf opaque, voidpf ptr)
{
int n;
if (*(ush*)&ptr != 0) { /* object < 64K */
farfree(ptr);
return;
}
/* Find the original pointer */
for (n = 0; n < next_ptr; n++) {
if (ptr != table[n].new_ptr) continue;
farfree(table[n].org_ptr);
while (++n < next_ptr) {
table[n-1] = table[n];
}
next_ptr--;
return;
}
ptr = opaque; /* just to make some compilers happy */
Assert(0, "zcfree: ptr not found");
}
#endif /* __TURBOC__ */
#ifdef M_I86
/* Microsoft C in 16-bit mode */
# define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc
# define _hfree hfree
#endif
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
{
if (opaque) opaque = 0; /* to make compiler happy */
return _halloc((long)items, size);
}
void zcfree (voidpf opaque, voidpf ptr)
{
if (opaque) opaque = 0; /* to make compiler happy */
_hfree(ptr);
}
#endif /* M_I86 */
#endif /* SYS16BIT */
#ifndef MY_ZCALLOC /* Any system without a special alloc function */
#ifndef STDC
extern voidp malloc OF((uInt size));
extern voidp calloc OF((uInt items, uInt size));
extern void free OF((voidpf ptr));
#endif
voidpf zcalloc (opaque, items, size)
voidpf opaque;
unsigned items;
unsigned size;
{
if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}
void zcfree (opaque, ptr)
voidpf opaque;
voidpf ptr;
{
free(ptr);
if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */

126
zlib-1.2.1.txt Normal file
View File

@ -0,0 +1,126 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.1 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
and rfc1952.txt (gzip format). These documents are also available in other
formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
of the library is given in the file example.c which also tests that the library
is working correctly. Another example is given in the file minigzip.c. The
compression library itself is composed of all source files except example.c and
minigzip.c.
To compile all files and run the test program, follow the instructions given at
the top of Makefile. In short "make test; make install" should work for most
machines. For Unix: "./configure; make test; make install" For MSDOS, use one
of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or
descrip.mms.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
please check this site to verify that you have the latest version of zlib;
otherwise get the latest version and check whether the problem still exists or
not.
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available in
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
The changes made in version 1.2.1 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory "contrib".
A Java implementation of zlib is available in the Java Development Kit
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
See the zlib home page http://www.zlib.org for details.
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
CPAN (Comprehensive Perl Archive Network) sites
http://www.cpan.org/modules/by-module/Compress/
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> is
available in Python 1.5 and later versions, see
http://www.python.org/doc/lib/module-zlib.html
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
contrib/minizip directory of zlib.
Notes for some targets:
- For Windows DLL versions, please see win32/DLL_FAQ.txt
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
compiler flag). The compiler bug has been reported to SGI.
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
- For PalmOs, see http://palmzlib.sourceforge.net/
- When building a shared, i.e. dynamic library on Mac OS X, the library must be
installed before testing (do "make install" before "make test"), since the
library location is specified in the library.
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib;
they are too numerous to cite here.
Copyright notice:
(C) 1995-2003 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not*
receiving lengthy legal documents to sign. The sources are provided
for free but without warranty of any kind. The library has been
entirely written by Jean-loup Gailly and Mark Adler; it does not
include third-party code.
If you redistribute modified sources, we would appreciate that you include
in the file ChangeLog history information documenting your changes. Please
read the FAQ for more information on the distribution of modified source
versions.