zip fixes

svn path=/trunk/boinc/; revision=7481
This commit is contained in:
David Anderson 2005-08-25 21:33:28 +00:00
parent b2ca67a47b
commit 137e3d2b2d
22 changed files with 71 additions and 66 deletions

View File

@ -10939,3 +10939,9 @@ Rom 24 Aug 2005
client/
net_xfer_curl.C, .h
David 25 Aug 2005
- zip fixes (from Carl C)
zip/
(various files)

View File

@ -4,7 +4,7 @@
SUBDIRS = zip unzip
AM_CPPFLAGS = -I$(top_srcdir)/zlib -I$(top_srcdir)/lib -I$(top_srcdir)/zip -I$(top_srcdir)/zip/zip -I$(top_srcdir)/zip/unzip -DUNIX -DUSE_ZLIB
AM_CPPFLAGS = -I$(top_srcdir)/zlib -I$(top_srcdir)/lib -I$(top_srcdir)/zip -I$(top_srcdir)/zip/zip -I$(top_srcdir)/zip/unzip -DUNIX
##noinst_PROGRAMS = test
lib_LIBRARIES = libboinc_zip.a

View File

@ -88,5 +88,5 @@ also be run (the "ziptest.cpp") on Unix & Mac to experiment
with how boinc_zip work (just g++ with the boinc/lib/filesys.C & util.C as
described above).
NB -- this library can now "co-exist" with zlib (libz) as of 15/08/2005
using the USE_ZLIB define in the VC project & Makefile.am
NB -- this library can now "co-exist" with zlib (libz) as of 19/08/2005
took out the USE_ZLIB -- causing conflicts, so now this InfoZip based boinc_zip is "independent" of any zlib use/linkage you may have/need.

View File

@ -23,7 +23,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\lib,..\,.\,..\..\zlib"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;USE_ZLIB"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/boinc_zip.pch"
@ -74,7 +74,7 @@
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\lib,..\,.\,..\..\zlib"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_ZLIB"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"

View File

@ -46,7 +46,7 @@ ulg crc32(crc, buf, len)
if (buf == NULL) return 0L;
crc_table = get_crc_table();
crc_table = get_crc_table_boinc();
crc = crc ^ 0xffffffffL;
#ifndef NO_UNROLLED_LOOPS

View File

@ -46,7 +46,7 @@
*/
#if defined(NO_UNDERLINE) || defined(__ELF__)
# define _crc32 crc32
# define _get_crc_table get_crc_table
# define _get_crc_table get_crc_table_boinc
#endif
/* Use 16-byte alignment if your assembler supports it. Warning: gas
* uses a log(x) parameter (.align 4 means 16-byte alignment). On SVR4

View File

@ -197,9 +197,9 @@ local ZCONST ulg near crc_table[256] = {
/* use "OF((void))" here to work around a Borland TC++ 1.0 problem */
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table OF((void))
ZCONST uLongf *get_crc_table_boinc OF((void))
#else
ZCONST ulg near *get_crc_table OF((void))
ZCONST ulg near *get_crc_table_boinc OF((void))
#endif
{
#ifdef DYNAMIC_CRC_TABLE

View File

@ -216,7 +216,9 @@ static ZCONST char Far ErrUnzipFile[] = " error: %s%s %s\n";
static ZCONST char Far ErrUnzipNoFile[] = "\n error: %s%s\n";
static ZCONST char Far NotEnoughMem[] = "not enough memory to ";
static ZCONST char Far InvalidComprData[] = "invalid compressed data to ";
static ZCONST char Far Inflate[] = "inflate";
static ZCONST char Far Inflate[] = "inflate_boinc";
extern int inflate_boinc(__G__ is_defl64);
#ifndef SFX
static ZCONST char Far Explode[] = "explode";
@ -1568,7 +1570,7 @@ static int extract_or_test_member(__G) /* return PK-type error code */
"" : (G.pInfo->textfile? txt : bin), uO.cflag? NEWLINE : ""));
}
#ifndef USE_ZLIB /* zlib's function is called inflate(), too */
# define UZinflate inflate
# define UZinflate inflate_boinc
#endif
if ((r = UZinflate(__G__
(G.lrec.compression_method == ENHDEFLATED)))

View File

@ -219,12 +219,12 @@ __GDEF
#if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table()
ZCONST uLongf *get_crc_table_boinc()
{
return (ZCONST uLongf *)crc_32_tab;
}
#else /* !USE_ZLIB */
ZCONST ulg near *get_crc_table()
ZCONST ulg near *get_crc_table_boinc()
{
return crc_32_tab;
}
@ -453,7 +453,7 @@ char **argv;
}
#if (defined(USE_ZLIB) && !defined(USE_OWN_CRCTAB))
/* initialize crc_32_tab pointer for decryption */
CRC_32_TAB = (ZCONST ulg Far *)get_crc_table();
CRC_32_TAB = (ZCONST ulg Far *)get_crc_table_boinc();
#endif
init_keys(p);
for (i = 0; i < RAND_HEAD_LEN; i++)

View File

@ -87,7 +87,7 @@
c14l 9 Apr 94 G. Roelofs fixed split comments on preprocessor lines
to avoid bug in Encore compiler.
c14m 7 Jul 94 P. Kienitz modified to allow assembler version of
inflate_codes() (define ASM_INFLATECODES)
inflate_codes_boinc() (define ASM_INFLATECODES)
c14n 22 Jul 94 G. Roelofs changed fprintf to macro for DLL versions
c14o 23 Aug 94 C. Spieler added a newline to a debug statement;
G. Roelofs added another typecast to avoid MSC warning
@ -96,7 +96,7 @@
c14r 1 Nov 94 G. Roelofs fixed possible redefinition of CHECK_EOF
c14s 7 May 95 S. Maxwell OS/2 DLL globals stuff incorporated;
P. Kienitz "fixed" ASM_INFLATECODES macro/prototype
c14t 18 Aug 95 G. Roelofs added UZinflate() to use zlib functions;
c14t 18 Aug 95 G. Roelofs added UZinflate_boinc() to use zlib functions;
changed voidp to zvoid; moved huft_build()
and huft_free() to end of file
c14u 1 Oct 95 G. Roelofs moved G into definition of MESSAGE macro
@ -322,7 +322,7 @@
/*
GRR: return values for both original inflate() and UZinflate()
GRR: return values for both original inflate_boinc() and UZinflate_boinc()
0 OK
1 incomplete table(?)
2 bad input
@ -330,10 +330,10 @@
*/
/**************************/
/* Function UZinflate() */
/* Function UZinflate_boinc() */
/**************************/
int UZinflate(__G__ is_defl64)
int UZinflate_boinc(__G__ is_defl64)
__GDEF
int is_defl64;
/* decompress an inflated entry using the zlib routines */
@ -380,7 +380,7 @@ int UZinflate(__G__ is_defl64)
G.dstrm.zalloc = (alloc_func)Z_NULL;
G.dstrm.zfree = (free_func)Z_NULL;
Trace((stderr, "initializing inflate()\n"));
Trace((stderr, "initializing inflate_boinc()\n"));
err = inflateInit2(&G.dstrm, -windowBits);
if (err == Z_MEM_ERROR)
@ -397,14 +397,14 @@ int UZinflate(__G__ is_defl64)
Trace((stderr, "first loop: G.csize = %ld\n", G.csize));
#endif /* ?FUNZIP */
while (G.dstrm.avail_out > 0) {
err = inflate(&G.dstrm, Z_PARTIAL_FLUSH);
err = inflate_boinc(&G.dstrm, Z_PARTIAL_FLUSH);
if (err == Z_DATA_ERROR) {
retval = 2; goto uzinflate_cleanup_exit;
} else if (err == Z_MEM_ERROR) {
retval = 3; goto uzinflate_cleanup_exit;
} else if (err != Z_OK && err != Z_STREAM_END)
Trace((stderr, "oops! (inflate(first loop) err = %d)\n", err));
Trace((stderr, "oops! (inflate_boinc(first loop) err = %d)\n", err));
#ifdef FUNZIP
if (err == Z_STREAM_END) /* "END-of-entry-condition" ? */
@ -437,18 +437,18 @@ int UZinflate(__G__ is_defl64)
/* no more input, so loop until we have all output */
Trace((stderr, "beginning final loop: err = %d\n", err));
while (err != Z_STREAM_END) {
err = inflate(&G.dstrm, Z_PARTIAL_FLUSH);
err = inflate_boinc(&G.dstrm, Z_PARTIAL_FLUSH);
if (err == Z_DATA_ERROR) {
retval = 2; goto uzinflate_cleanup_exit;
} else if (err == Z_MEM_ERROR) {
retval = 3; goto uzinflate_cleanup_exit;
} else if (err == Z_BUF_ERROR) { /* DEBUG */
Trace((stderr,
"zlib inflate() did not detect stream end (%s, %s)\n",
"zlib inflate_boinc() did not detect stream end (%s, %s)\n",
G.zipfn, G.filename));
break;
} else if (err != Z_OK && err != Z_STREAM_END) {
Trace((stderr, "oops! (inflate(final loop) err = %d)\n", err));
Trace((stderr, "oops! (inflate_boinc(final loop) err = %d)\n", err));
DESTROYGLOBALS();
EXIT(PK_MEM3);
}
@ -488,7 +488,7 @@ uzinflate_cleanup_exit:
# define OF(a) ()
# endif
#endif /* !OF */
int inflate_codes OF((__GPRO__ struct huft *tl, struct huft *td,
int inflate_codes_boinc OF((__GPRO__ struct huft *tl, struct huft *td,
int bl, int bd));
static int inflate_stored OF((__GPRO));
static int inflate_fixed OF((__GPRO));
@ -589,7 +589,7 @@ ZCONST ush near mask_bits[] = {
#endif /* 0 */
/* Macros for inflate() bit peeking and grabbing.
/* Macros for inflate_boinc() bit peeking and grabbing.
The usage is:
NEEDBITS(j)
@ -669,7 +669,7 @@ static ZCONST int dbits = 6; /* bits in base distance lookup table */
#ifndef ASM_INFLATECODES
int inflate_codes(__G__ tl, td, bl, bd)
int inflate_codes_boinc(__G__ tl, td, bl, bd)
__GDEF
struct huft *tl, *td; /* literal/length and distance decoder tables */
int bl, bd; /* number of bits decoded by tl[] and td[] */
@ -926,7 +926,7 @@ static int inflate_fixed(__G)
}
/* decompress until an end-of-block code */
return inflate_codes(__G__ G.fixed_tl, G.fixed_td,
return inflate_codes_boinc(__G__ G.fixed_tl, G.fixed_td,
G.fixed_bl, G.fixed_bd);
}
@ -1096,7 +1096,7 @@ static int inflate_dynamic(__G)
}
/* decompress until an end-of-block code */
retval = inflate_codes(__G__ tl, td, bl, bd);
retval = inflate_codes_boinc(__G__ tl, td, bl, bd);
cleanup_and_exit:
/* free the decoding tables, return */
@ -1158,7 +1158,7 @@ cleanup_and_exit:
int inflate(__G__ is_defl64)
int inflate_boinc(__G__ is_defl64)
__GDEF
int is_defl64;
/* decompress an inflated entry */
@ -1205,7 +1205,7 @@ int inflate(__G__ is_defl64)
* compiled with inconsistent option setting. Handle this by
* returning with "bad input" error code.
*/
Trace((stderr, "\nThis inflate() cannot handle Deflate64!\n"));
Trace((stderr, "\nThis inflate_boinc() cannot handle Deflate64!\n"));
return 2;
}
#endif /* ?USE_DEFLATE64 */

View File

@ -609,7 +609,7 @@ static int do_seekable(__G__ lastchance) /* return PK-type error code */
/* initialize the CRC table pointer (once) */
if (CRC_32_TAB == NULL) {
if ((CRC_32_TAB = get_crc_table()) == NULL) {
if ((CRC_32_TAB = get_crc_table_boinc()) == NULL) {
CLOSE_INFILE();
return PK_MEM;
}

View File

@ -1188,7 +1188,7 @@
# define explode_nolit8 XXnl8
# define explode_nolit4 XXnl4
# define cpdist8 XXcpdist8
# define inflate_codes XXic
# define inflate_codes_boinc XXic
# define inflate_stored XXis
# define inflate_fixed XXif
# define inflate_dynamic XXid
@ -2027,7 +2027,7 @@ int iswild OF((ZCONST char *p)); /* match.c */
void free_crc_table OF((void)); /* crctab.c */
#endif
#ifndef USE_ZLIB
ZCONST ulg near *get_crc_table OF((void)); /* funzip.c, crctab.c */
ZCONST ulg near *get_crc_table_boinc OF((void)); /* funzip.c, crctab.c */
ulg crc32 OF((ulg crc, ZCONST uch *buf, extent len));
#endif /* !USE_ZLIB */ /* assembler source or crc32.c */

View File

@ -46,7 +46,7 @@
*/
#if defined(NO_UNDERLINE) || defined(__ELF__)
# define _crc32 crc32
# define _get_crc_table get_crc_table
# define _get_crc_table get_crc_table_boinc
#endif
/* Use 16-byte alignment if your assembler supports it. Warning: gas
* uses a log(x) parameter (.align 4 means 16-byte alignment). On SVR4

View File

@ -59,7 +59,7 @@
* void lm_init (int pack_level, ush *flags)
* Initialize the "longest match" routines for a new file
*
* ulg deflate (void)
* ulg deflate_boinc (void)
* Processes a new input file and return its compressed length. Sets
* the compressed length, crc, deflate flags and internal file
* attributes.
@ -258,7 +258,7 @@ local config configuration_table[10] = {
local void fill_window OF((void));
local ulg deflate_fast OF((void));
int longest_match OF((IPos cur_match));
int longest_match_batch OF((IPos cur_match));
//#if defined(ASMV) && !defined(RISCOS)
// void match_init OF((void)); /* asm code initialization */
//#endif
@ -410,7 +410,7 @@ void lm_free()
* match.S. The code is functionally equivalent, so you can use the C version
* if desired.
*/
int longest_match(cur_match)
int longest_match_boinc(cur_match)
IPos cur_match; /* current match */
{
unsigned chain_length = max_chain_length; /* max hash chain length */
@ -696,8 +696,8 @@ local ulg deflate_fast()
*/
if ((unsigned)nice_match > lookahead) nice_match = (int)lookahead;
# endif
match_length = longest_match (hash_head);
/* longest_match() sets match_start */
match_length = longest_match_boinc (hash_head);
/* longest_match_boinc() sets match_start */
if (match_length > lookahead) match_length = lookahead;
#endif
}
@ -764,7 +764,7 @@ local ulg deflate_fast()
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
ulg deflate()
ulg deflate_boinc()
{
IPos hash_head = NIL; /* head of hash chain */
IPos prev_match; /* previous match */
@ -805,8 +805,8 @@ ulg deflate()
*/
if ((unsigned)nice_match > lookahead) nice_match = (int)lookahead;
# endif
match_length = longest_match (hash_head);
/* longest_match() sets match_start */
match_length = longest_match_boinc (hash_head);
/* longest_match_boinc() sets match_start */
if (match_length > lookahead) match_length = lookahead;
#endif

View File

@ -204,7 +204,7 @@ int getch_win32(void);
# ifdef __386__
# ifdef ASMV
# pragma aux match_init "_*" parm caller [] modify []
# pragma aux longest_match "_*" parm caller [] value [eax] \
# pragma aux longest_match_boinc "_*" parm caller [] value [eax] \
modify [eax ecx edx]
# endif
# if defined(ASM_CRC) && !defined(USE_ZLIB)

View File

@ -46,7 +46,7 @@ ulg crc32(crc, buf, len)
if (buf == NULL) return 0L;
crc_table = get_crc_table();
crc_table = get_crc_table_boinc();
crc = crc ^ 0xffffffffL;
#ifndef NO_UNROLLED_LOOPS

View File

@ -197,9 +197,9 @@ local ZCONST ulg near crc_table[256] = {
/* use "OF((void))" here to work around a Borland TC++ 1.0 problem */
#ifdef USE_ZLIB
ZCONST uLongf *get_crc_table OF((void))
ZCONST uLongf *get_crc_table_boinc OF((void))
#else
ZCONST ulg near *get_crc_table OF((void))
ZCONST ulg near *get_crc_table_boinc OF((void))
#endif
{
#ifdef DYNAMIC_CRC_TABLE

View File

@ -1748,7 +1748,7 @@ nextarg: ;
#if CRYPT
/* Initialize the crc_32_tab pointer, when encryption was requested. */
if (key != NULL)
crc_32_tab = get_crc_table();
crc_32_tab = get_crc_table_boinc();
#endif /* CRYPT */
/* Before we get carried away, make sure zip file is writeable. This

View File

@ -506,7 +506,7 @@ ulg crc32 OF((ulg, ZCONST uch *, extent));
#endif /* !UTIL */
/* in crctab.c */
ZCONST ulg near *get_crc_table OF((void));
ZCONST ulg near *get_crc_table_boinc OF((void));
#ifdef DYNALLOC_CRCTAB
void free_crc_table OF((void));
#endif
@ -517,7 +517,7 @@ void free_crc_table OF((void));
/* in deflate.c */
void lm_init OF((int, ush *));
void lm_free OF((void));
ulg deflate OF((void));
ulg deflate_boinc OF((void));
/* in trees.c */
void ct_init OF((ush *, int *));

View File

@ -225,7 +225,7 @@ int main(argc, argv)
init_upper(); /* build case map table */
crc_32_tab = get_crc_table();
crc_32_tab = get_crc_table_boinc();
/* initialize crc table for crypt */
/* Go through args */

View File

@ -844,7 +844,7 @@ local int zl_deflate_init(pack_level)
zstrm.zalloc = (alloc_func)Z_NULL;
zstrm.zfree = (free_func)Z_NULL;
Trace((stderr, "initializing deflate()\n"));
Trace((stderr, "initializing deflate_boinc()\n"));
err = deflateInit2(&zstrm, pack_level, Z_DEFLATED, -windowBits, 8, 0);
if (err == Z_MEM_ERROR) {
@ -1012,7 +1012,7 @@ local ulg filecompress(z_entry, zipfile, cmpr_method)
zstrm.avail_out = OBUF_SZ;
if (!maybe_stored) while (zstrm.avail_in != 0 && zstrm.avail_in != EOF) {
err = deflate(&zstrm, Z_NO_FLUSH);
err = deflate_boinc(&zstrm, Z_NO_FLUSH);
if (err != Z_OK && err != Z_STREAM_END) {
sprintf(errbuf, "unexpected zlib deflate error %d", err);
ziperr(ZE_LOGIC, errbuf);
@ -1045,7 +1045,7 @@ local ulg filecompress(z_entry, zipfile, cmpr_method)
}
do {
err = deflate(&zstrm, Z_FINISH);
err = deflate_boinc(&zstrm, Z_FINISH);
if (maybe_stored) {
if (err == Z_STREAM_END && zstrm.total_out >= zstrm.total_in &&
fseekable(zipfile)) {
@ -1093,7 +1093,7 @@ local ulg filecompress(z_entry, zipfile, cmpr_method)
bi_init(file_outbuf, sizeof(file_outbuf), TRUE);
ct_init(&z_entry->att, cmpr_method);
lm_init(level, &z_entry->flg);
return deflate();
return deflate_boinc();
#endif /* ?USE_ZLIB */
}
@ -1138,7 +1138,7 @@ ulg memcompress(tgt, tgtsize, src, srcsize)
zstrm.next_out = (Bytef *)(tgt + out_total);
zstrm.avail_out = (uInt)tgtsize - (uInt)out_total;
err = deflate(&zstrm, Z_FINISH);
err = deflate_boinc(&zstrm, Z_FINISH);
if (err != Z_STREAM_END)
error("output buffer too small for in-memory compression");
out_total += (unsigned)zstrm.total_out;
@ -1156,7 +1156,7 @@ ulg memcompress(tgt, tgtsize, src, srcsize)
bi_init(tgt + (2 + 4), (unsigned)(tgtsize - (2 + 4)), FALSE);
ct_init(&att, NULL);
lm_init((level != 0 ? level : 1), &flags);
out_total += (unsigned)deflate();
out_total += (unsigned)deflate_boinc();
window_size = 0L; /* was updated by lm_init() */
#endif /* ?USE_ZLIB */

View File

@ -48,20 +48,17 @@ int main(int argc, char* argv[])
boinc_filelist("/tmp/junk", "", &zflist, SORT_NAME | SORT_ASCENDING);
#endif
int jj;
char strTmp[128];
char strTmp[128], strTmp2[128];
for (jj = 0; jj < zflist.size(); jj++) {
printf("%s %d\n", zflist[jj].c_str(), zflist[jj].m_statFile.st_mtime);
// now gzip it, silly but see how it goes!
sprintf(strTmp, "%s.gz", zflist[jj].c_str());
sprintf(strTmp2, "%s.zip", strTmp);
printf("infile=%s outfile=%s\n", strTmp, strTmp2);
do_gzip(strTmp, zflist[jj].c_str());
boinc_zip(ZIP_IT, strTmp2, strTmp);
}
#ifdef _WIN32
boinc_filelist("c:\\temp", "", &zflist, SORT_NAME | SORT_ASCENDING);
boinc_zip(ZIP_IT, "c:\\temp\\newzip", &zflist);
#else
boinc_filelist("/tmp/junk/", "", &zflist, SORT_NAME | SORT_ASCENDING);
boinc_zip(ZIP_IT, "./ziptest.zip", &zflist);
#endif
boinc_zip(UNZIP_IT, "/tmp/boinc_zip.zip", "/tmp/junk/boinc_zip");
return 0;
}