Remove torrentzip support.
torrentzip depends on a particular zlib version which is by now quite
old. Additionally, there were some bugs in the libzip implementation
which we never got motivated enough to fix.
diff --git a/.hgignore b/.hgignore
index 9b8a917..954f6d8 100644
--- a/.hgignore
+++ b/.hgignore
@@ -47,7 +47,6 @@
^regress/tryopen$
^src/zipcmp$
^src/zipmerge$
-^src/ziptorrent$
^stamp-h1$
^test-driver$
^xcode/libzip\.xcodeproj/project\.xcworkspace/xcuserdata
diff --git a/API-CHANGES b/API-CHANGES
index a1c0f10..a83b183 100644
--- a/API-CHANGES
+++ b/API-CHANGES
@@ -43,6 +43,10 @@
This means you can use "zip_t" instead of "struct zip", etc.
+** torrentzip support removed
+
+torrentzip depends on a particular zlib version which is by now quite
+old.
* 0.11
diff --git a/NEWS b/NEWS
index c337435..62d8a4d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
* Support setting last modification time for file.
* zip_error_t
* more typedefs for structs
+* removed support for torrentzip
0.11.2 [2013/12/19]
diff --git a/TODO b/TODO
index 6ebe697..a603f73 100644
--- a/TODO
+++ b/TODO
@@ -69,19 +69,15 @@
Bugs
====
* support InfoZIP encryption header extension (copy data descriptor for encrypted files)
-* embed stripped down old zlib for torrentzip
! ensure that nentries is small enough not to cause overflow (size_t for entry, uint64 for CD on disk)
* Xcode 32bit build uses 64bit config.h
* fix OpenSUSE i686 regression failures
* fix open_filename_duplicate_consistency.test to fail
-* split zip archive torrentzip state from user requested torrentzip state
* check for limits imposed by format (central dir size, file size, extra fields, ...)
* _zip_u2d_time: handle localtime(3) failure
* POSIX: zip_open: check whether file can be created and fail if not
* fix inconsistent usage of valid flags (not checked in many places)
* cdr == NULL -> ER_NOENT vs. idx > cdir->nentry -> ER_INVAL inconsistent (still there?)
-* torrentzip broken on NetBSD/amd64 6.99
-* torrentzip: check behaviour of files with empty name (size 0; file size > 0)
Cleanup
=======
diff --git a/lib/zip.h b/lib/zip.h
index c418012..22ad475 100644
--- a/lib/zip.h
+++ b/lib/zip.h
@@ -91,7 +91,6 @@
/* archive global flags flags */
-#define ZIP_AFL_TORRENT 1u /* torrent zipped */
#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */
diff --git a/lib/zip_close.c b/lib/zip_close.c
index 0fe58ee..526dcae 100644
--- a/lib/zip_close.c
+++ b/lib/zip_close.c
@@ -59,7 +59,6 @@
static int copy_data(zip_t *, zip_uint64_t);
static int copy_source(zip_t *, zip_source_t *);
static int write_cdir(zip_t *, const zip_filelist_t *, zip_uint64_t);
-static int _zip_torrentzip_cmp(const void *, const void *);
ZIP_EXTERN int
@@ -69,7 +68,6 @@
zip_int64_t off;
int error;
zip_filelist_t *filelist;
- int new_torrentzip;
int changed;
if (za == NULL)
@@ -102,17 +100,6 @@
if ((filelist=(zip_filelist_t *)malloc(sizeof(filelist[0])*(size_t)survivors)) == NULL)
return -1;
- /* archive comment is special for torrentzip */
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
- /* TODO: use internal function when zip_set_archive_comment clears TORRENT flag */
- if (zip_set_archive_comment(za, TORRENT_SIG "XXXXXXXX", TORRENT_SIG_LEN + TORRENT_CRC_LEN) < 0) {
- free(filelist);
- return -1;
- }
- }
- /* TODO: if no longer torrentzip and archive comment not changed by user, delete it */
-
-
/* create list of files with index into original archive */
for (i=j=0; i<za->nentry; i++) {
if (za->entry[i].deleted)
@@ -125,7 +112,6 @@
}
filelist[j].idx = i;
- filelist[j].name = zip_get_name(za, i, 0);
j++;
}
if (j < survivors) {
@@ -140,13 +126,6 @@
return -1;
}
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
- qsort(filelist, (size_t)survivors, sizeof(filelist[0]),
- _zip_torrentzip_cmp);
-
- new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
- && zip_get_archive_flag(za, ZIP_AFL_TORRENT,
- ZIP_FL_UNCHANGED) == 0);
error = 0;
for (j=0; j<survivors; j++) {
int new_data;
@@ -156,7 +135,7 @@
i = filelist[j].idx;
entry = za->entry+i;
- new_data = (ZIP_ENTRY_DATA_CHANGED(entry) || new_torrentzip || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_COMP_METHOD));
+ new_data = (ZIP_ENTRY_DATA_CHANGED(entry) || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_COMP_METHOD));
/* create new local directory entry */
if (entry->changes == NULL) {
@@ -173,9 +152,6 @@
break;
}
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
- _zip_dirent_torrent_normalize(entry->changes);
-
if ((off = zip_source_tell_write(za->src)) < 0) {
error = 1;
break;
@@ -337,7 +313,6 @@
return -1;
}
- /* TODO: deflate 0-byte files for torrentzip? */
if (de->comp_method != ZIP_CM_STORE && ((st.valid & ZIP_STAT_SIZE) == 0 || st.size != 0)) {
if ((comp_impl=_zip_get_compression_implementation(de->comp_method)) == NULL) {
zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
@@ -398,9 +373,6 @@
de->uncomp_size = st.size;
de->comp_size = (zip_uint64_t)(offend - offdata);
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
- _zip_dirent_torrent_normalize(de);
-
if ((ret=_zip_dirent_write(za, de, flags)) < 0)
return -1;
@@ -478,8 +450,6 @@
write_cdir(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors)
{
zip_int64_t cd_start, end, size;
- uLong crc;
- zip_uint8_t buf[TORRENT_CRC_LEN+1];
if ((cd_start = zip_source_tell_write(za->src)) < 0) {
return -1;
@@ -493,24 +463,6 @@
return -1;
}
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 0)
- return 0;
-
- /* fix up torrentzip comment */
- if (_zip_filerange_crc(za->src, (zip_uint64_t)cd_start, (zip_uint64_t)size, &crc, &za->error) < 0)
- return -1;
-
- snprintf((char *)buf, sizeof(buf), "%08lX", (long)crc);
-
- if (zip_source_seek_write(za->src, end-TORRENT_CRC_LEN, SEEK_SET) < 0) {
- _zip_error_set_from_source(&za->error, za->src);
- return -1;
- }
-
- if (_zip_write(za, buf, TORRENT_CRC_LEN) < 0) {
- return -1;
- }
-
return 0;
}
@@ -539,19 +491,3 @@
return changed;
}
-
-
-
-static int
-_zip_torrentzip_cmp(const void *a, const void *b)
-{
- const char *aname = ((const zip_filelist_t *)a)->name;
- const char *bname = ((const zip_filelist_t *)b)->name;
-
- if (aname == NULL)
- return (bname != NULL) * -1;
- else if (bname == NULL)
- return 1;
-
- return strcasecmp(aname, bname);
-}
diff --git a/lib/zip_dirent.c b/lib/zip_dirent.c
index 3025079..40787c4 100644
--- a/lib/zip_dirent.c
+++ b/lib/zip_dirent.c
@@ -598,59 +598,6 @@
}
-/* _zip_dirent_torrent_normalize(de);
- Set values suitable for torrentzip.
-*/
-
-void
-_zip_dirent_torrent_normalize(zip_dirent_t *de)
-{
- static struct tm torrenttime;
- static time_t last_mod = 0;
-
- if (last_mod == 0) {
-#ifdef HAVE_STRUCT_TM_TM_ZONE
- time_t now;
- struct tm *l;
-#endif
-
- torrenttime.tm_sec = 0;
- torrenttime.tm_min = 32;
- torrenttime.tm_hour = 23;
- torrenttime.tm_mday = 24;
- torrenttime.tm_mon = 11;
- torrenttime.tm_year = 96;
- torrenttime.tm_wday = 0;
- torrenttime.tm_yday = 0;
- torrenttime.tm_isdst = 0;
-
-#ifdef HAVE_STRUCT_TM_TM_ZONE
- time(&now);
- l = localtime(&now);
- torrenttime.tm_gmtoff = l->tm_gmtoff;
- torrenttime.tm_zone = l->tm_zone;
-#endif
-
- last_mod = mktime(&torrenttime);
- }
-
- de->version_madeby = 0;
- de->version_needed = 20; /* 2.0 */
- de->bitflags = 2; /* maximum compression */
- de->comp_method = ZIP_CM_DEFLATE;
- de->last_mod = last_mod;
-
- de->disk_number = 0;
- de->int_attrib = 0;
- de->ext_attrib = 0;
-
- _zip_ef_free(de->extra_fields);
- de->extra_fields = NULL;
- _zip_string_free(de->comment);
- de->comment = NULL;
-}
-
-
/* _zip_dirent_write
Writes zip directory entry.
diff --git a/lib/zip_open.c b/lib/zip_open.c
index a60ac57..7a8f5c6 100644
--- a/lib/zip_open.c
+++ b/lib/zip_open.c
@@ -49,7 +49,6 @@
} exists_t;
static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error);
static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error);
-static void _zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir);
static zip_cdir_t *_zip_find_central_dir(zip_t *za, zip_uint64_t len);
static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error);
static int _zip_headercomp(const zip_dirent_t *, const zip_dirent_t *);
@@ -225,8 +224,6 @@
za->nentry_alloc = cdir->nentry_alloc;
za->comment_orig = cdir->comment;
- _zip_check_torrentzip(za, cdir);
-
za->ch_flags = za->flags;
free(cdir);
@@ -473,39 +470,6 @@
}
-/* _zip_check_torrentzip:
- check whether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
-
-static void
-_zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir)
-{
- uLong crc_got, crc_should;
- char buf[8+1];
- char *end;
-
- if (cdir == NULL)
- return;
-
- if (_zip_string_length(cdir->comment) != TORRENT_SIG_LEN+8
- || strncmp((const char *)cdir->comment->raw, TORRENT_SIG, TORRENT_SIG_LEN) != 0)
- return;
-
- memcpy(buf, cdir->comment->raw+TORRENT_SIG_LEN, 8);
- buf[8] = '\0';
- errno = 0;
- crc_should = strtoul(buf, &end, 16);
- if ((crc_should == UINT_MAX && errno != 0) || (end && *end))
- return;
-
- if (_zip_filerange_crc(za->src, cdir->offset, cdir->size, &crc_got, NULL) < 0)
- return;
-
- if (crc_got == crc_should)
- za->flags |= ZIP_AFL_TORRENT;
-}
-
-
-
/* _zip_headercomp:
compares a central directory entry and a local file header
Return 0 if they are consistent, -1 if not. */
diff --git a/lib/zip_source_deflate.c b/lib/zip_source_deflate.c
index 7960a1b..dde9fc6 100644
--- a/lib/zip_source_deflate.c
+++ b/lib/zip_source_deflate.c
@@ -77,10 +77,7 @@
ctx->is_stored = false;
ctx->can_store = ZIP_CM_IS_DEFAULT(cm);
if (flags & ZIP_CODEC_ENCODE) {
- if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
- ctx->mem_level = TORRENT_MEM_LEVEL;
- else
- ctx->mem_level = MAX_MEM_LEVEL;
+ ctx->mem_level = MAX_MEM_LEVEL;
}
if ((s2=zip_source_layered(za, src,
diff --git a/lib/zipint.h b/lib/zipint.h
index 10ffff1..3bf9c33 100644
--- a/lib/zipint.h
+++ b/lib/zipint.h
@@ -150,10 +150,6 @@
#define DATADES_MAGIC "PK\7\8"
#define EOCD64LOC_MAGIC "PK\6\7"
#define EOCD64_MAGIC "PK\6\6"
-#define TORRENT_SIG "TORRENTZIPPED-"
-#define TORRENT_SIG_LEN 14
-#define TORRENT_CRC_LEN 8
-#define TORRENT_MEM_LEVEL 8
#define CDENTRYSIZE 46u
#define LENTRYSIZE 30
#define MAXCOMLEN 65536
@@ -410,11 +406,11 @@
zip_uint64_t offset;
};
-/* which files to write, and in which order (name is for torrentzip sorting) */
+/* which files to write in which order */
struct zip_filelist {
zip_uint64_t idx;
- const char *name;
+// TODO const char *name;
};
typedef struct zip_filelist zip_filelist_t;
@@ -469,7 +465,6 @@
zip_dirent_t *_zip_dirent_new(void);
zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error);
zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *);
-void _zip_dirent_torrent_normalize(zip_dirent_t *);
int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags);
zip_extra_field_t *_zip_ef_clone(const zip_extra_field_t *, zip_error_t *);
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
index 715be7d..1564e48 100644
--- a/man/CMakeLists.txt
+++ b/man/CMakeLists.txt
@@ -85,7 +85,6 @@
SET(MDOC1_PAGES
zipcmp.mdoc
zipmerge.mdoc
- ziptorrent.mdoc
)
SET(MDOC_PAGES ${MDOC1_PAGES} ${MDOC3_PAGES})
STRING(REGEX REPLACE .mdoc "" MAN1_PAGES "${MDOC1_PAGES}")
diff --git a/man/Makefile.am b/man/Makefile.am
index 7837eca..963294f 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -5,7 +5,7 @@
DISTCLEANFILES=${HTML}
EXTRA_DIST=${MANDOC} ${MAN} CMakeLists.txt handle_links links
-MAN1= zipcmp.mdoc zipmerge.mdoc ziptorrent.mdoc
+MAN1= zipcmp.mdoc zipmerge.mdoc
MAN3= \
ZIP_SOURCE_GET_ARGS.mdoc \
libzip.mdoc \
diff --git a/man/mkdocset.pl b/man/mkdocset.pl
index b1af97f..4fe9110 100755
--- a/man/mkdocset.pl
+++ b/man/mkdocset.pl
@@ -12,7 +12,7 @@
my @files = @ARGV;
my $docset = 'at.nih.libzip.docset';
-my @sh_nodes = qw(zipcmp zipmerge ziptorrent);
+my @sh_nodes = qw(zipcmp zipmerge);
(system('rm', '-rf', $docset) == 0) or die "can't remove old version of docset: $!";
diff --git a/man/zip_get_archive_flag.mdoc b/man/zip_get_archive_flag.mdoc
index 546c52f..b800f4e 100644
--- a/man/zip_get_archive_flag.mdoc
+++ b/man/zip_get_archive_flag.mdoc
@@ -29,7 +29,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 22, 2012
+.Dd April 29, 2015
.Dt ZIP_GET_ARCHIVE_FLAG 3
.Os
.Sh NAME
@@ -57,9 +57,9 @@
the original unchanged flags are tested.
.Pp
Supported flags are:
-.Bl -tag -width XZIPXAFLXTORRENTXXX
-.It Dv ZIP_AFL_TORRENT
-The archive is torrent-zipped.
+.Bl -tag -width XZIPXAFLXRDONLYXXX
+.It Dv ZIP_AFL_RDONLY
+The archive is read-only.
.El
.Sh RETURN VALUES
.Fn zip_get_archive_flag
diff --git a/man/zip_set_archive_flag.mdoc b/man/zip_set_archive_flag.mdoc
index 349f85c..295253f 100644
--- a/man/zip_set_archive_flag.mdoc
+++ b/man/zip_set_archive_flag.mdoc
@@ -29,7 +29,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd July 22, 2012
+.Dd April 29, 2015
.Dt ZIP_SET_ARCHIVE_FLAG 3
.Os
.Sh NAME
@@ -51,16 +51,7 @@
to the value
.Ar value .
.Pp
-Supported flags are:
-.Bl -tag -width XZIPXAFLXTORRENTXXX
-.It Dv ZIP_AFL_TORRENT
-Create a torrent-zipped archive.
-This restricts the values that can be set from the application side.
-In particular, time stamps are not saved and the order of the files in
-the archive is alphabetical.
-No file comments or extended attributes are allowed and the archive
-comment can not be chosen.
-.El
+Currently there are no supported flags.
.Sh RETURN VALUES
Upon successful completion 0 is returned, and \-1 if an error
occurred.
diff --git a/man/zipcmp.mdoc b/man/zipcmp.mdoc
index 7824c25..c01a5dd 100644
--- a/man/zipcmp.mdoc
+++ b/man/zipcmp.mdoc
@@ -29,7 +29,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 29, 2014
+.Dd April 29, 2015
.Dt ZIPCMP 1
.Os
.Sh NAME
@@ -78,7 +78,6 @@
and \*[Gt]1 if an error occurred.
.Sh SEE ALSO
.Xr zipmerge 1 ,
-.Xr ziptorrent 1 ,
.Xr libzip 3
.Sh AUTHORS
.An -nosplit
diff --git a/man/zipmerge.mdoc b/man/zipmerge.mdoc
index 1c1518a..7aebeaa 100644
--- a/man/zipmerge.mdoc
+++ b/man/zipmerge.mdoc
@@ -29,7 +29,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 4, 2008
+.Dd April 29, 2015
.Dt ZIPMERGE 1
.Os
.Sh NAME
@@ -77,7 +77,6 @@
exits 0 on success and \*[Gt]1 if an error occurred.
.Sh SEE ALSO
.Xr zipcmp 1 ,
-.Xr ziptorrent 1 ,
.Xr libzip 3
.Sh AUTHORS
.An -nosplit
diff --git a/regress/CMakeLists.txt b/regress/CMakeLists.txt
index 98ae6cb..cfd22dd 100644
--- a/regress/CMakeLists.txt
+++ b/regress/CMakeLists.txt
@@ -109,7 +109,6 @@
stat_index_utf8_strict.test
stat_index_utf8_unmarked_strict.test
stat_index_zip64.test
- torrent-already.test
utf-8-standardization.test
zip64_creation.test
zip64_stored_creation.test
diff --git a/regress/Makefile.am b/regress/Makefile.am
index 7dffa86..d85e75a 100644
--- a/regress/Makefile.am
+++ b/regress/Makefile.am
@@ -33,6 +33,7 @@
encrypt_plus_extra_modified_c.zip \
encrypt_plus_extra_modified_l.zip \
filename_duplicate.zip \
+ filename_duplicate_empty.zip \
filename_empty.zip \
fileorder.zip \
firstsecond.zip \
@@ -105,10 +106,8 @@
testfile-plus-extra.zip \
testfile-UTF8.zip \
testfile2014.zip \
- testnottorrent.zip \
teststdin.zip \
teststored.zip \
- testtorrent.tzip \
utf-8-standardization-input.zip \
utf-8-standardization-output.zip \
zip64.zip
@@ -206,16 +205,13 @@
stat_index_utf8_strict.test \
stat_index_utf8_unmarked_strict.test \
stat_index_zip64.test \
- torrent-already.test \
- torrent-new.test \
utf-8-standardization.test \
zip64_creation.test \
zip64_stored_creation.test
XFAIL_TESTS= \
open_filename_duplicate_consistency.test \
- open_filename_duplicate_empty_consistency.test \
- torrent-new.test
+ open_filename_duplicate_empty_consistency.test
AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib -I${top_srcdir}/src
LDADD=${top_builddir}/lib/libzip.la
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index de80164..8906e81 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,7 +13,3 @@
ADD_EXECUTABLE(zipmerge zipmerge.c ${SRC_EXTRA_FILES})
TARGET_LINK_LIBRARIES(zipmerge zip)
INSTALL(TARGETS zipmerge RUNTIME DESTINATION bin)
-
-ADD_EXECUTABLE(ziptorrent ziptorrent.c ${SRC_EXTRA_FILES})
-TARGET_LINK_LIBRARIES(ziptorrent zip)
-INSTALL(TARGETS ziptorrent RUNTIME DESTINATION bin)
diff --git a/src/Makefile.am b/src/Makefile.am
index d1ca9b9..16ade70 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-bin_PROGRAMS=zipcmp zipmerge ziptorrent
+bin_PROGRAMS=zipcmp zipmerge
zipcmp_SOURCES=zipcmp.c
@@ -6,7 +6,5 @@
zipcmp_LDADD=${top_builddir}/lib/libzip.la
zipmerge_CPPFLAGS=-I${top_srcdir}/lib -I../lib
zipmerge_LDADD=${top_builddir}/lib/libzip.la
-ziptorrent_CPPFLAGS=-I${top_srcdir}/lib -I../lib
-ziptorrent_LDADD=${top_builddir}/lib/libzip.la
EXTRA_DIST= CMakeLists.txt getopt.c getopt.h compat.h