From bed85f565b853b13576258adcd585c9753e3e10f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 25 Aug 2010 23:40:39 -0600 Subject: Core/Dep: Added libzip which IS needed by G3D Fixes compile on Windows and Linux (if you didn't have libzip installed for some reason). --HG-- branch : trunk --- dep/libzip/src/CMakeLists.txt | 10 + dep/libzip/src/Makefile.am | 10 + dep/libzip/src/Makefile.in | 568 ++++++++++++++++++++++++++++++++++++++++++ dep/libzip/src/zipcmp.c | 332 ++++++++++++++++++++++++ dep/libzip/src/zipmerge.c | 291 ++++++++++++++++++++++ dep/libzip/src/ziptorrent.c | 165 ++++++++++++ 6 files changed, 1376 insertions(+) create mode 100644 dep/libzip/src/CMakeLists.txt create mode 100644 dep/libzip/src/Makefile.am create mode 100644 dep/libzip/src/Makefile.in create mode 100644 dep/libzip/src/zipcmp.c create mode 100644 dep/libzip/src/zipmerge.c create mode 100644 dep/libzip/src/ziptorrent.c (limited to 'dep/libzip/src') diff --git a/dep/libzip/src/CMakeLists.txt b/dep/libzip/src/CMakeLists.txt new file mode 100644 index 00000000000..c5b76a4668b --- /dev/null +++ b/dep/libzip/src/CMakeLists.txt @@ -0,0 +1,10 @@ +# $NiH$ + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../lib + ${CMAKE_CURRENT_BINARY_DIR}/..) + +ADD_EXECUTABLE(zipcmp zipcmp.c) +TARGET_LINK_LIBRARIES(zipcmp zip) + +ADD_EXECUTABLE(zipmerge zipmerge.c) +TARGET_LINK_LIBRARIES(zipmerge zip) diff --git a/dep/libzip/src/Makefile.am b/dep/libzip/src/Makefile.am new file mode 100644 index 00000000000..2bd9a1bdd79 --- /dev/null +++ b/dep/libzip/src/Makefile.am @@ -0,0 +1,10 @@ +bin_PROGRAMS=zipcmp zipmerge ziptorrent + +zipcmp_CPPFLAGS=-I${top_srcdir}/lib +zipcmp_LDADD=${top_builddir}/lib/libzip.la +zipmerge_CPPFLAGS=-I${top_srcdir}/lib +zipmerge_LDADD=${top_builddir}/lib/libzip.la +ziptorrent_CPPFLAGS=-I${top_srcdir}/lib +ziptorrent_LDADD=${top_builddir}/lib/libzip.la + +EXTRA_DIST= CMakeLists.txt diff --git a/dep/libzip/src/Makefile.in b/dep/libzip/src/Makefile.in new file mode 100644 index 00000000000..b8f1378b048 --- /dev/null +++ b/dep/libzip/src/Makefile.in @@ -0,0 +1,568 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = zipcmp$(EXEEXT) zipmerge$(EXEEXT) ziptorrent$(EXEEXT) +subdir = src +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +zipcmp_SOURCES = zipcmp.c +zipcmp_OBJECTS = zipcmp-zipcmp.$(OBJEXT) +zipcmp_DEPENDENCIES = ${top_builddir}/lib/libzip.la +zipmerge_SOURCES = zipmerge.c +zipmerge_OBJECTS = zipmerge-zipmerge.$(OBJEXT) +zipmerge_DEPENDENCIES = ${top_builddir}/lib/libzip.la +ziptorrent_SOURCES = ziptorrent.c +ziptorrent_OBJECTS = ziptorrent-ziptorrent.$(OBJEXT) +ziptorrent_DEPENDENCIES = ${top_builddir}/lib/libzip.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = zipcmp.c zipmerge.c ziptorrent.c +DIST_SOURCES = zipcmp.c zipmerge.c ziptorrent.c +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANFMT = @MANFMT@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +zipcmp_CPPFLAGS = -I${top_srcdir}/lib +zipcmp_LDADD = ${top_builddir}/lib/libzip.la +zipmerge_CPPFLAGS = -I${top_srcdir}/lib +zipmerge_LDADD = ${top_builddir}/lib/libzip.la +ziptorrent_CPPFLAGS = -I${top_srcdir}/lib +ziptorrent_LDADD = ${top_builddir}/lib/libzip.la +EXTRA_DIST = CMakeLists.txt +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +zipcmp$(EXEEXT): $(zipcmp_OBJECTS) $(zipcmp_DEPENDENCIES) + @rm -f zipcmp$(EXEEXT) + $(LINK) $(zipcmp_OBJECTS) $(zipcmp_LDADD) $(LIBS) +zipmerge$(EXEEXT): $(zipmerge_OBJECTS) $(zipmerge_DEPENDENCIES) + @rm -f zipmerge$(EXEEXT) + $(LINK) $(zipmerge_OBJECTS) $(zipmerge_LDADD) $(LIBS) +ziptorrent$(EXEEXT): $(ziptorrent_OBJECTS) $(ziptorrent_DEPENDENCIES) + @rm -f ziptorrent$(EXEEXT) + $(LINK) $(ziptorrent_OBJECTS) $(ziptorrent_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipcmp-zipcmp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zipmerge-zipmerge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ziptorrent-ziptorrent.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +zipcmp-zipcmp.o: zipcmp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipcmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zipcmp-zipcmp.o -MD -MP -MF $(DEPDIR)/zipcmp-zipcmp.Tpo -c -o zipcmp-zipcmp.o `test -f 'zipcmp.c' || echo '$(srcdir)/'`zipcmp.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/zipcmp-zipcmp.Tpo $(DEPDIR)/zipcmp-zipcmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zipcmp.c' object='zipcmp-zipcmp.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipcmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zipcmp-zipcmp.o `test -f 'zipcmp.c' || echo '$(srcdir)/'`zipcmp.c + +zipcmp-zipcmp.obj: zipcmp.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipcmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zipcmp-zipcmp.obj -MD -MP -MF $(DEPDIR)/zipcmp-zipcmp.Tpo -c -o zipcmp-zipcmp.obj `if test -f 'zipcmp.c'; then $(CYGPATH_W) 'zipcmp.c'; else $(CYGPATH_W) '$(srcdir)/zipcmp.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/zipcmp-zipcmp.Tpo $(DEPDIR)/zipcmp-zipcmp.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zipcmp.c' object='zipcmp-zipcmp.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipcmp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zipcmp-zipcmp.obj `if test -f 'zipcmp.c'; then $(CYGPATH_W) 'zipcmp.c'; else $(CYGPATH_W) '$(srcdir)/zipcmp.c'; fi` + +zipmerge-zipmerge.o: zipmerge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipmerge_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zipmerge-zipmerge.o -MD -MP -MF $(DEPDIR)/zipmerge-zipmerge.Tpo -c -o zipmerge-zipmerge.o `test -f 'zipmerge.c' || echo '$(srcdir)/'`zipmerge.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/zipmerge-zipmerge.Tpo $(DEPDIR)/zipmerge-zipmerge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zipmerge.c' object='zipmerge-zipmerge.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipmerge_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zipmerge-zipmerge.o `test -f 'zipmerge.c' || echo '$(srcdir)/'`zipmerge.c + +zipmerge-zipmerge.obj: zipmerge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipmerge_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT zipmerge-zipmerge.obj -MD -MP -MF $(DEPDIR)/zipmerge-zipmerge.Tpo -c -o zipmerge-zipmerge.obj `if test -f 'zipmerge.c'; then $(CYGPATH_W) 'zipmerge.c'; else $(CYGPATH_W) '$(srcdir)/zipmerge.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/zipmerge-zipmerge.Tpo $(DEPDIR)/zipmerge-zipmerge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zipmerge.c' object='zipmerge-zipmerge.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zipmerge_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o zipmerge-zipmerge.obj `if test -f 'zipmerge.c'; then $(CYGPATH_W) 'zipmerge.c'; else $(CYGPATH_W) '$(srcdir)/zipmerge.c'; fi` + +ziptorrent-ziptorrent.o: ziptorrent.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ziptorrent_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ziptorrent-ziptorrent.o -MD -MP -MF $(DEPDIR)/ziptorrent-ziptorrent.Tpo -c -o ziptorrent-ziptorrent.o `test -f 'ziptorrent.c' || echo '$(srcdir)/'`ziptorrent.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ziptorrent-ziptorrent.Tpo $(DEPDIR)/ziptorrent-ziptorrent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ziptorrent.c' object='ziptorrent-ziptorrent.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ziptorrent_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ziptorrent-ziptorrent.o `test -f 'ziptorrent.c' || echo '$(srcdir)/'`ziptorrent.c + +ziptorrent-ziptorrent.obj: ziptorrent.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ziptorrent_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ziptorrent-ziptorrent.obj -MD -MP -MF $(DEPDIR)/ziptorrent-ziptorrent.Tpo -c -o ziptorrent-ziptorrent.obj `if test -f 'ziptorrent.c'; then $(CYGPATH_W) 'ziptorrent.c'; else $(CYGPATH_W) '$(srcdir)/ziptorrent.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ziptorrent-ziptorrent.Tpo $(DEPDIR)/ziptorrent-ziptorrent.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ziptorrent.c' object='ziptorrent-ziptorrent.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ziptorrent_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ziptorrent-ziptorrent.obj `if test -f 'ziptorrent.c'; then $(CYGPATH_W) 'ziptorrent.c'; else $(CYGPATH_W) '$(srcdir)/ziptorrent.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags distclean distclean-compile \ + distclean-generic distclean-libtool distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-binPROGRAMS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/dep/libzip/src/zipcmp.c b/dep/libzip/src/zipcmp.c new file mode 100644 index 00000000000..81988bbc718 --- /dev/null +++ b/dep/libzip/src/zipcmp.c @@ -0,0 +1,332 @@ +/* + zipcmp.c -- compare zip files + Copyright (C) 2003-2007 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "zip.h" + +struct entry { + char *name; + unsigned int size; + unsigned int crc; +}; + + + +const char *prg; + +#define PROGRAM "zipmerge" + +char *usage = "usage: %s [-hiqtVv] zip1 zip2\n"; + +char help_head[] = + PROGRAM " (" PACKAGE ") by Dieter Baron and Thomas Klausner\n\n"; + +char help[] = "\n\ + -h display this help message\n\ + -V display version number\n\ + -i compare names ignoring case distinctions\n\ + -q be quiet\n\ + -t test zip files\n\ + -v be verbose (print differences, default)\n\ +\n\ +Report bugs to .\n"; + +char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\ +Copyright (C) 2007 Dieter Baron and Thomas Klausner\n\ +" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n"; + +#define OPTIONS "hViqtv" + + + +static int entry_cmp(const void *p1, const void *p2); +static void entry_print(const void *p); +static int compare_list(char * const name[], int verbose, + const void *l[], const int n[], int size, + int (*cmp)(const void *, const void *), + void print(const void *)); +static int compare_zip(char * const zn[], int verbose); +static int test_file(struct zip *za, int idx, off_t size, unsigned int crc); + +int ignore_case, test_files; + + + +int +main(int argc, char * const argv[]) +{ + int verbose; + int c; + + prg = argv[0]; + + ignore_case = 0; + test_files = 0; + verbose = 1; + + while ((c=getopt(argc, argv, OPTIONS)) != -1) { + switch (c) { + case 'i': + ignore_case = 1; + break; + case 'q': + verbose = 0; + break; + case 't': + test_files = 1; + break; + case 'v': + verbose = 1; + break; + + case 'h': + fputs(help_head, stdout); + printf(usage, prg); + fputs(help, stdout); + exit(0); + case 'V': + fputs(version_string, stdout); + exit(0); + + default: + fprintf(stderr, usage, prg); + exit(2); + } + } + + if (argc != optind+2) { + fprintf(stderr, usage, prg); + exit(2); + } + + exit((compare_zip(argv+optind, verbose) == 0) ? 0 : 1); +} + + + +static int +compare_zip(char * const zn[], int verbose) +{ + struct zip *za; + struct zip_stat st; + struct entry *e[2]; + int n[2]; + int i, j; + int err; + char errstr[1024]; + + for (i=0; i<2; i++) { + if ((za=zip_open(zn[i], 0, &err)) == NULL) { + zip_error_to_str(errstr, sizeof(errstr), err, errno); + fprintf(stderr, "%s: cannot open zip archive `%s': %s\n", + prg, zn[i], errstr); + return -1; + } + + n[i] = zip_get_num_files(za); + + if ((e[i]=malloc(sizeof(*e[i]) * n[i])) == NULL) { + fprintf(stderr, "%s: malloc failure\n", prg); + exit(1); + } + + for (j=0; jname, e2->name)) != 0) + return c; + if (e1->size != e2->size) + return e1->size - e2->size; + if (e1->crc != e2->crc) + return e1->crc - e2->crc; + + return 0; +} + + + +static void +entry_print(const void *p) +{ + const struct entry *e; + + e = p; + + printf("%10u %08x %s\n", e->size, e->crc, e->name); +} + + + +static int +test_file(struct zip *za, int idx, off_t size, unsigned int crc) +{ + struct zip_file *zf; + char buf[8192]; + int n, nsize; + unsigned int ncrc; + + if ((zf=zip_fopen_index(za, idx, 0)) == NULL) { + fprintf(stderr, "%s: cannot open file %d in archive: %s\n", + prg, idx, zip_strerror(za)); + return -1; + } + + ncrc = crc32(0, NULL, 0); + nsize = 0; + + while ((n=zip_fread(zf, buf, sizeof(buf))) > 0) { + nsize += n; + ncrc = crc32(ncrc, (const Bytef *)buf, n); + } + + if (n < 0) { + fprintf(stderr, "%s: error reading file %d in archive: %s\n", + prg, idx, zip_file_strerror(zf)); + zip_fclose(zf); + return -1; + } + + zip_fclose(zf); + + if (nsize != size) { + /* XXX: proper printf identifier */ + fprintf(stderr, "%s: file %d: unexpected length %ld (should be %ld)\n", + prg, idx, (long)nsize, (long)size); + return -2; + } + if (ncrc != crc) { + fprintf(stderr, "%s: file %d: unexpected length %x (should be %x)\n", + prg, idx, ncrc, crc); + return -2; + } + + return 0; +} diff --git a/dep/libzip/src/zipmerge.c b/dep/libzip/src/zipmerge.c new file mode 100644 index 00000000000..03af58ade86 --- /dev/null +++ b/dep/libzip/src/zipmerge.c @@ -0,0 +1,291 @@ +/* + zipmerge.c -- merge zip archives + Copyright (C) 2004-2008 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + + +#include +#include +#include +#include +#include + +#include "config.h" + +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "zip.h" + + + +char *prg; + +#define PROGRAM "zipmerge" + +char *usage = "usage: %s [-DhIiSsV] target-zip zip...\n"; + +char help_head[] = + PROGRAM " (" PACKAGE ") by Dieter Baron and Thomas Klausner\n\n"; + +char help[] = "\n\ + -h display this help message\n\ + -V display version number\n\ + -D ignore directory component in file names\n\ + -I ignore case in file names\n\ + -i ask before overwriting files\n\ + -S don't overwrite identical files\n\ + -s overwrite identical files without asking\n\ +\n\ +Report bugs to .\n"; + +char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\ +Copyright (C) 2008 Dieter Baron and Thomas Klausner\n\ +" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n"; + +#define OPTIONS "hVDiIsS" + +#define CONFIRM_ALL_YES 0x001 +#define CONFIRM_ALL_NO 0x002 +#define CONFIRM_SAME_YES 0x010 +#define CONFIRM_SAME_NO 0x020 + +int confirm; +int name_flags; + +static int confirm_replace(struct zip *, const char *, int, + struct zip *, const char *, int); +static int merge_zip(struct zip *za, const char *, const char *, struct zip **); + + + +int +main(int argc, char *argv[]) +{ + struct zip *za; + struct zip **zs; + int c, err, i; + char errstr[1024], *tname; + + prg = argv[0]; + + confirm = CONFIRM_ALL_YES; + name_flags = 0; + + while ((c=getopt(argc, argv, OPTIONS)) != -1) { + switch (c) { + case 'D': + name_flags |= ZIP_FL_NODIR; + break; + case 'i': + confirm &= ~CONFIRM_ALL_YES; + break; + case 'I': + name_flags |= ZIP_FL_NOCASE; + break; + case 's': + confirm &= ~CONFIRM_SAME_NO; + confirm |= CONFIRM_SAME_YES; + break; + case 'S': + confirm &= ~CONFIRM_SAME_YES; + confirm |= CONFIRM_SAME_NO; + break; + + case 'h': + fputs(help_head, stdout); + printf(usage, prg); + fputs(help, stdout); + exit(0); + case 'V': + fputs(version_string, stdout); + exit(0); + + default: + fprintf(stderr, usage, prg); + exit(2); + } + } + + if (argc < optind+2) { + fprintf(stderr, usage, prg); + exit(2); + } + + tname = argv[optind++]; + + if ((zs=malloc(sizeof(zs[0])*(argc-optind))) == NULL) { + fprintf(stderr, "%s: out of memory\n", prg); + exit(1); + } + + if ((za=zip_open(tname, ZIP_CREATE, &err)) == NULL) { + zip_error_to_str(errstr, sizeof(errstr), err, errno); + fprintf(stderr, "%s: cannot open zip archive `%s': %s\n", + prg, tname, errstr); + exit(1); + } + + for (i=0; i + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + + +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "zip.h" + + + +#define FLAG_DRYRUN 1 +#define FLAG_VERBOSE 2 + +const char *prg; + +#define PROGRAM "ziptorrent" + +char *usage = "usage: %s [-hnVv] zip [...]\n"; + +char help_head[] = + PROGRAM " (" PACKAGE ") by Dieter Baron and Thomas Klausner\n\n"; + +char help[] = "\n\ + -h display this help message\n\ + -n don't actually change archives, just print what would be done\n\ + -V display version number\n\ + -v verbose\n\ +\n\ +Report bugs to .\n"; + +char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\ +Copyright (C) 2008 Dieter Baron and Thomas Klausner\n\ +" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n"; + +#define OPTIONS "hnVv" + +static int torrentzip(const char *, int); + + + +int +main(int argc, char * const argv[]) +{ + int err; + int c; + int flags; + + prg = argv[0]; + flags = 0; + + while ((c=getopt(argc, argv, OPTIONS)) != -1) { + switch (c) { + case 'h': + fputs(help_head, stdout); + printf(usage, prg); + fputs(help, stdout); + exit(0); + case 'n': + flags |= FLAG_DRYRUN|FLAG_VERBOSE; + break; + case 'V': + fputs(version_string, stdout); + exit(0); + case 'v': + flags |= FLAG_VERBOSE; + break; + + default: + fprintf(stderr, usage, prg); + exit(2); + } + } + + if (argc == optind) { + fprintf(stderr, usage, prg); + exit(2); + } + + err = 0; + while (optind < argc) { + err |= torrentzip(argv[optind++], flags); + } + + return (err ? 1 : 0); +} + + + +static int +torrentzip(const char *fname, int flags) +{ + struct zip *za; + int err; + char errstr[1024]; + + if ((za=zip_open(fname, 0, &err)) == NULL) { + zip_error_to_str(errstr, sizeof(errstr), err, errno); + fprintf(stderr, "%s: cannot open zip archive `%s': %s\n", + prg, fname, errstr); + return -1; + } + + if (flags & FLAG_VERBOSE) { + if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) + printf("%s: already torrentzipped\n", fname); + else + printf("%s: torrentzipping\n", fname); + } + + if ((flags & FLAG_DRYRUN) == 0) { + if (zip_set_archive_flag(za, ZIP_AFL_TORRENT, 1) < 0) { + fprintf(stderr, "%s: cannot set torrentzip flag in `%s': %s\n", + prg, fname, zip_strerror(za)); + zip_close(za); + return -1; + } + } + + if (zip_close(za) < 0) { + fprintf(stderr, "%s: cannot torrentzip `%s': %s\n", + prg, fname, zip_strerror(za)); + zip_unchange_all(za); + zip_close(za); + return -1; + } + + return 0; +} -- cgit v1.2.3