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/zipmerge.c | 291 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 291 insertions(+) create mode 100644 dep/libzip/src/zipmerge.c (limited to 'dep/libzip/src/zipmerge.c') 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