From owner-p4-projects@FreeBSD.ORG Thu Dec 11 07:38:10 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CACB41065677; Thu, 11 Dec 2008 07:38:09 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73F0C106564A for ; Thu, 11 Dec 2008 07:38:09 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from kientzle.com (kientzle.com [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id 2CAF78FC08 for ; Thu, 11 Dec 2008 07:38:09 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from [10.123.2.178] (p53.kientzle.com [66.166.149.53]) by kientzle.com (8.12.9/8.12.9) with ESMTP id mBB6xjtv069618; Wed, 10 Dec 2008 22:59:45 -0800 (PST) (envelope-from kientzle@freebsd.org) Message-ID: <4940BA5C.1030804@freebsd.org> Date: Wed, 10 Dec 2008 22:59:40 -0800 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060422 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Anselm Strauss References: <200812091600.mB9G0wwI029886@repoman.freebsd.org> In-Reply-To: <200812091600.mB9G0wwI029886@repoman.freebsd.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: Perforce Change Reviews Subject: Re: PERFORCE change 154398 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Dec 2008 07:38:10 -0000 Anselm, Glad to see you working on this again. This looks like good progress. You're seeing linking problems? I'm not seeing those here. Could you send me details? Maybe I can help figure those out. I am seeing a lot of test failures here. I haven't looked into them closely yet, but I did notice that you have the wrong value for "COMPRESSION_DEFLATE"; it should be 8, not 6. Tim Anselm Strauss wrote: > http://perforce.freebsd.org/chv.cgi?CH=154398 > > Change 154398 by strauss@strauss_silversurfer on 2008/12/09 16:00:15 > > Added deflate compression, still compile problems (linking) > > Affected files ... > > .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#42 edit > > Differences ... > > ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#42 (text+ko) ==== > > @@ -76,6 +76,11 @@ > #define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */ > #define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */ > > +enum compression { > + COMPRESSION_STORE = 0, > + COMPRESSION_DEFLATE = 6 > +}; > + > static ssize_t archive_write_zip_data(struct archive_write *, const void *buff, size_t s); > static int archive_write_zip_finish(struct archive_write *); > static int archive_write_zip_destroy(struct archive_write *); > @@ -177,11 +182,6 @@ > char comment_length[2]; > }; > > -static enum compression { > - COMPRESSION_STORE = 0, > - COMPRESSION_DEFLATE = 6 > -}; > - > int > archive_write_set_format_zip(struct archive *_a) > { > @@ -294,7 +294,7 @@ > zip_encode(path_length(entry), &h.filename_length, sizeof(h.filename_length)); > zip_encode(sizeof(e), &h.extra_length, sizeof(h.extra_length)); > > - if (zip->compression = COMPRESSION_STORE) { > + if (zip->compression == COMPRESSION_STORE) { > /* Setting compressed and uncompressed sizes even when specification says > * to set to zero when using data descriptors. Otherwise the end of the > * data for an entry is rather difficult to find. */ > @@ -342,35 +342,62 @@ > struct zip *zip = a->format_data; > struct zip_file_header_link *l = zip->central_directory_end; > z_stream stream; > + size_t chunk = sizeof(*buff); > + unsigned char buff_out[chunk]; > > if (s > zip->remaining_data_bytes) > s = zip->remaining_data_bytes; > + > + if (s == 0) return 0; > > switch (zip->compression) { > > case COMPRESSION_STORE: > > ret = (a->compressor.write)(a, buff, s); > + if (ret < 0) return (ret); > + zip->written_bytes += s; > + zip->remaining_data_bytes -= s; > + l->crc32 = crc32(l->crc32, buff, s); > + return (ret); > > case COMPRESSION_DEFLATE: > > - deflateInit2( > - stream, > - > - ); > + stream.zalloc = Z_NULL; > + stream.zfree = Z_NULL; > + stream.opaque = Z_NULL; > + ret = deflateInit(&stream, Z_DEFAULT_COMPRESSION); > + if (ret != Z_OK) return (ARCHIVE_FATAL); > + stream.next_in = (unsigned char*) buff; > + stream.avail_in = s; > + do { > + stream.next_out = buff_out; > + stream.avail_out = chunk; > + ret = deflate(&stream, Z_FINISH); > + if (ret == Z_STREAM_ERROR) { > + deflateEnd(&stream); > + return (ARCHIVE_FATAL); > + } > + ret = (a->compressor.write)(a, buff_out, stream.avail_out); > + if (ret < 0) { > + deflateEnd(&stream); > + return (ret); > + } > + zip->written_bytes += ret; > + } while (stream.avail_out == 0); > + zip->remaining_data_bytes -= s; > + l->crc32 = crc32(l->crc32, buff, s); > + deflateEnd(&stream); > + return (s); > > + default: > + > + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid ZIP compression type"); > + return ARCHIVE_FATAL; > } > > /* TODO: set compressed size in data descriptor and local file header link */ > > - if (ret >= 0) { > - zip->written_bytes += s; > - zip->remaining_data_bytes -= s; > - l->crc32 = crc32(l->crc32, buff, s); > - return (s); > - } else { > - return (ret); > - } > } > > static int > @@ -434,7 +461,7 @@ > zip_encode(dos_time(archive_entry_mtime(l->entry)), &h.timedate, sizeof(h.timedate)); > zip_encode(l->crc32, &h.crc32, sizeof(h.crc32)); > /* TODO: write compressed size */ > - zip_encode(archive_entry_size(entry), &h.uncompressed_size, sizeof(h.uncompressed_size)); > + zip_encode(archive_entry_size(l->entry), &h.uncompressed_size, sizeof(h.uncompressed_size)); > zip_encode(path_length(l->entry), &h.filename_length, sizeof(h.filename_length)); > zip_encode(sizeof(e), &h.extra_length, sizeof(h.extra_length)); > mode = archive_entry_mode(l->entry); > @@ -588,7 +615,7 @@ > set_compression(struct archive_write *a, enum compression compression) > { > /* TODO: check archive state, should not switch between header and data */ > - /* TODO: check if valid compression? */ > > - a->format_data->compression = compression; > + struct zip *zip = a->format_data; > + zip->compression = compression; > } > >