/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Note: Lifted from uncrunch.c from jdk sources
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <strings.h>
#endif
#include "defines.h"
#include "bytes.h"
#include "utils.h"
#include "constants.h"
#include "unpack.h"
#include "zip.h"
#ifdef NO_ZLIB
return false;
}
#else // Have ZLIB
#include <zlib.h>
#endif // End of ZLIB
#ifdef sparc
#define SWAP_BYTES(a) \
((((a) << 8) & 0xff00) | 0x00ff) & (((a) >> 8) | 0xff00)
#else
#define SWAP_BYTES(a) (a)
#endif
#define GET_INT_LO(a) \
SWAP_BYTES(a & 0xFFFF)
#define GET_INT_HI(a) \
u = u_;
u->jarout = this;
}
// Write data to the ZIP output stream.
while (len > 0) {
if (rc <= 0) {
}
output_file_offset += rc;
}
}
// required version
// flags 02 = maximum sub-compression flag
// Compression method 8=deflate.
// Last modified date and time.
// CRC
// Compressed length:
// Uncompressed length.
// Filename length
// So called "extra field" length.
header[15] = 0;
// So called "comment" length.
header[16] = 0;
// Disk number start
header[17] = 0;
// File flags => binary
header[18] = 0;
// More file flags
header[19] = 0;
header[20] = 0;
// Offset within ZIP file.
// Copy the whole thing into the central directory.
// Copy the fname to the header.
}
// ZIP LOC magic.
// Version
// flags 02 = maximum sub-compression flag
// Compression method = deflate
// Last modified date and time.
// CRC
// Compressed length:
// Uncompressed length.
// Filename length
// So called "extra field" length.
header[14] = 0;
// Write the LOC header to the output file.
// Copy the fname to the header.
}
// Create the End of Central Directory structure.
// disk numbers
header[2] = 0;
header[3] = 0;
// Number of entries in central directory.
// Size of the central directory}
// Offset of central directory within disk.
// zipfile comment length;
// Write the central directory.
// Write the End of Central Directory structure.
// Write the comment.
write_data(mc);
}
// Public API
// Open a Jar file and initialize.
if (!jarfp) {
if (!jarfp) {
}
}
}
// Add a ZIP entry and copy the file data
bool deflate_hint, int modtime,
int clen = 0;
if (deflate) {
deflate = false;
}
}
if (deflate) {
write_data(deflated.b);
} else {
}
}
// Add a ZIP entry for a directory name no data
bool store = true;
}
// Write out the central directory and close the jar file.
if (jarfp) {
if (central) write_central_directory();
}
reset();
}
/* Convert the date y/n/d and time h:m:s to a four byte DOS date and
* time (date in high two bytes, time in low two bytes allowing magnitude
* comparison).
*/
inline
}
#ifdef _REENTRANT // solaris
#else
#endif
/*
* Return the Unix time in DOS format
*/
// see defines.h
return dostime_cache;
if (modtime != 0 && default_modtime == 0)
//printf("modtime %d => %d\n", modtime_cache, dostime_cache);
return dostime_cache;
}
#ifndef NO_ZLIB
/* Returns true on success, and will set the clen to the compressed
length, the caller should verify if true and clen less than the
input data
*/
// NOTE: the window size should always be -MAX_WBITS normally -15.
// unzip/zipup.c and java/Deflater.c
switch (error) {
case Z_MEM_ERROR:
break;
case Z_STREAM_ERROR:
break;
case Z_VERSION_ERROR:
break;
default:
}
return false;
}
}
}
}
if (error == Z_STREAM_END) {
deflateEnd(&zs);
return true;
}
deflateEnd(&zs);
return false;
}
deflateEnd(&zs);
return false;
}
// Callback for fetching data from a GZIP input stream
}
u->abort("error inflating input");
break;
}
if (error == Z_STREAM_END) {
// skip 8-byte trailer
} else {
// Bug: 5023768,we read past the TRAILER_LEN to see if there is
// any extraneous data, as we dont support concatenated .gz
// files just yet.
}
// %%% should check final CRC and length here
// %%% should check for concatenated *.gz files here
u->abort("garbage after end of deflated input stream");
// pop this filter off:
break;
}
}
//fprintf(u->errstrm, "readInputFn(%d,%d) => %d (gunzip)\n",
// (int)minlen, (int)maxlen, (int)numread);
return numread;
}
u = u_;
read_input_fn = (void*)u->read_input_fn;
u->gzin = this;
}
enum {
};
char gz_ignore;
// do not save extra, name, comment
}
}
int null_terms = 0;
for (; null_terms; null_terms--) {
for (;;) {
gz_ignore = 0;
if (gz_ignore == 0) break;
}
}
if (aborting()) return;
// now the input stream is ready to read into the inflater
}
mtrace('f', this, 0);
::free(this);
}
if (aborting()) return;
u->abort("short stream header");
}
#else // NO_ZLIB
}
#endif // NO_ZLIB