DEFS = @DEFS@ -I$(top_builddir) -I$(top_srcdir) # also for automake 1.4
bin_PROGRAMS = zzcat zzdir zzxorcat zzxordir zzxorcopy \
- unzzip unzzipdir unzzipcat unzzipcat-seeko \
- unzzipdir-mem unzzipcat-mem unzip-mem
+ unzzip unzzip-mix unzzip-mem unzzip-big unzip-mem
noinst_PROGRAMS = zziptest zzobfuscated zzip
aclocaldir = $(datadir)/aclocal
aclocal_DATA = zziplib.m4
WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt
-EXTRA_DIST = $(aclocal_DATA)
+EXTRA_DIST = $(aclocal_DATA) unzzip.h
CLEANFILES = $(WCC10_CLEAN)
-unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
-# these use the simplified mmapped disk version
-unzzipdir_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipcat_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipdir_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipcat_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
+unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
+unzzip_SOURCES = unzzip.c unzzipcat-zip.c unzzipdir-zip.c
+unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
+unzzip_mix_SOURCES = unzzip.c unzzipcat-mix.c unzzipdir-mix.c
+unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
+unzzip_mem_SOURCES = unzzip.c unzzipcat-mem.c unzzipdir-mem.c
+unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz
+unzzip_big_SOURCES = unzzip.c unzzipcat-big.c unzzipdir-big.c
+
unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-# and this uses the simplified fseeko stdio version
-unzzipcat_seeko_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz
../zzip/libzzip.la : @top_srcdir@/zzip/*.c
(cd ../zzip && $(MAKE) `basename $@`)
target_triplet = @target@
bin_PROGRAMS = zzcat$(EXEEXT) zzdir$(EXEEXT) zzxorcat$(EXEEXT) \
zzxordir$(EXEEXT) zzxorcopy$(EXEEXT) unzzip$(EXEEXT) \
- unzzipdir$(EXEEXT) unzzipcat$(EXEEXT) unzzipcat-seeko$(EXEEXT) \
- unzzipdir-mem$(EXEEXT) unzzipcat-mem$(EXEEXT) \
+ unzzip-mix$(EXEEXT) unzzip-mem$(EXEEXT) unzzip-big$(EXEEXT) \
unzip-mem$(EXEEXT)
noinst_PROGRAMS = zziptest$(EXEEXT) zzobfuscated$(EXEEXT) \
zzip$(EXEEXT)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
-unzzip_SOURCES = unzzip.c
-unzzip_OBJECTS = unzzip.$(OBJEXT)
+am_unzzip_OBJECTS = unzzip.$(OBJEXT) unzzipcat-zip.$(OBJEXT) \
+ unzzipdir-zip.$(OBJEXT)
+unzzip_OBJECTS = $(am_unzzip_OBJECTS)
unzzip_DEPENDENCIES = ../zzip/libzzip.la
-unzzipcat_SOURCES = unzzipcat.c
-unzzipcat_OBJECTS = unzzipcat.$(OBJEXT)
-unzzipcat_DEPENDENCIES = ../zzip/libzzipmmapped.la
-unzzipcat_mem_SOURCES = unzzipcat-mem.c
-unzzipcat_mem_OBJECTS = unzzipcat-mem.$(OBJEXT)
-unzzipcat_mem_DEPENDENCIES = ../zzip/libzzipmmapped.la
-unzzipcat_seeko_SOURCES = unzzipcat-seeko.c
-unzzipcat_seeko_OBJECTS = unzzipcat-seeko.$(OBJEXT)
-unzzipcat_seeko_DEPENDENCIES = ../zzip/libzzipfseeko.la
-unzzipdir_SOURCES = unzzipdir.c
-unzzipdir_OBJECTS = unzzipdir.$(OBJEXT)
-unzzipdir_DEPENDENCIES = ../zzip/libzzipmmapped.la
-unzzipdir_mem_SOURCES = unzzipdir-mem.c
-unzzipdir_mem_OBJECTS = unzzipdir-mem.$(OBJEXT)
-unzzipdir_mem_DEPENDENCIES = ../zzip/libzzipmmapped.la
+am_unzzip_big_OBJECTS = unzzip.$(OBJEXT) unzzipcat-big.$(OBJEXT) \
+ unzzipdir-big.$(OBJEXT)
+unzzip_big_OBJECTS = $(am_unzzip_big_OBJECTS)
+unzzip_big_DEPENDENCIES = ../zzip/libzzipfseeko.la
+am_unzzip_mem_OBJECTS = unzzip.$(OBJEXT) unzzipcat-mem.$(OBJEXT) \
+ unzzipdir-mem.$(OBJEXT)
+unzzip_mem_OBJECTS = $(am_unzzip_mem_OBJECTS)
+unzzip_mem_DEPENDENCIES = ../zzip/libzzipmmapped.la
+am_unzzip_mix_OBJECTS = unzzip.$(OBJEXT) unzzipcat-mix.$(OBJEXT) \
+ unzzipdir-mix.$(OBJEXT)
+unzzip_mix_OBJECTS = $(am_unzzip_mix_OBJECTS)
+unzzip_mix_DEPENDENCIES = ../zzip/libzzip.la
zzcat_SOURCES = zzcat.c
zzcat_OBJECTS = zzcat.$(OBJEXT)
zzcat_DEPENDENCIES = ../zzip/libzzip.la
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = unzip-mem.c unzzip.c unzzipcat.c unzzipcat-mem.c \
- unzzipcat-seeko.c unzzipdir.c unzzipdir-mem.c zzcat.c zzdir.c \
+SOURCES = unzip-mem.c $(unzzip_SOURCES) $(unzzip_big_SOURCES) \
+ $(unzzip_mem_SOURCES) $(unzzip_mix_SOURCES) zzcat.c zzdir.c \
zzip.c zziptest.c zzobfuscated.c zzxorcat.c zzxorcopy.c \
zzxordir.c
-DIST_SOURCES = unzip-mem.c unzzip.c unzzipcat.c unzzipcat-mem.c \
- unzzipcat-seeko.c unzzipdir.c unzzipdir-mem.c zzcat.c zzdir.c \
+DIST_SOURCES = unzip-mem.c $(unzzip_SOURCES) $(unzzip_big_SOURCES) \
+ $(unzzip_mem_SOURCES) $(unzzip_mix_SOURCES) zzcat.c zzdir.c \
zzip.c zziptest.c zzobfuscated.c zzxorcat.c zzxorcopy.c \
zzxordir.c
am__can_run_installinfo = \
aclocal_DATA = zziplib.m4
#
WCC10_CLEAN = *.obj *.lk1 *.mk1 *.mk *.sym *.tgt
-EXTRA_DIST = $(aclocal_DATA)
+EXTRA_DIST = $(aclocal_DATA) unzzip.h
CLEANFILES = $(WCC10_CLEAN)
-unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zziptest_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzxorcat_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzxordir_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
zzobfuscated_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
-
-# these use the simplified mmapped disk version
-unzzipdir_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipcat_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipdir_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-unzzipcat_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
+unzzip_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
+unzzip_SOURCES = unzzip.c unzzipcat-zip.c unzzipdir-zip.c
+unzzip_mix_LDADD = ../zzip/libzzip.la @RESOLVES@ -lz
+unzzip_mix_SOURCES = unzzip.c unzzipcat-mix.c unzzipdir-mix.c
+unzzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
+unzzip_mem_SOURCES = unzzip.c unzzipcat-mem.c unzzipdir-mem.c
+unzzip_big_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz
+unzzip_big_SOURCES = unzzip.c unzzipcat-big.c unzzipdir-big.c
unzip_mem_LDADD = ../zzip/libzzipmmapped.la @RESOLVES@ -lz
-# and this uses the simplified fseeko stdio version
-unzzipcat_seeko_LDADD = ../zzip/libzzipfseeko.la @RESOLVES@ -lz
all: all-am
.SUFFIXES:
@rm -f unzzip$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(unzzip_OBJECTS) $(unzzip_LDADD) $(LIBS)
-unzzipcat$(EXEEXT): $(unzzipcat_OBJECTS) $(unzzipcat_DEPENDENCIES) $(EXTRA_unzzipcat_DEPENDENCIES)
- @rm -f unzzipcat$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(unzzipcat_OBJECTS) $(unzzipcat_LDADD) $(LIBS)
-
-unzzipcat-mem$(EXEEXT): $(unzzipcat_mem_OBJECTS) $(unzzipcat_mem_DEPENDENCIES) $(EXTRA_unzzipcat_mem_DEPENDENCIES)
- @rm -f unzzipcat-mem$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(unzzipcat_mem_OBJECTS) $(unzzipcat_mem_LDADD) $(LIBS)
-
-unzzipcat-seeko$(EXEEXT): $(unzzipcat_seeko_OBJECTS) $(unzzipcat_seeko_DEPENDENCIES) $(EXTRA_unzzipcat_seeko_DEPENDENCIES)
- @rm -f unzzipcat-seeko$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(unzzipcat_seeko_OBJECTS) $(unzzipcat_seeko_LDADD) $(LIBS)
+unzzip-big$(EXEEXT): $(unzzip_big_OBJECTS) $(unzzip_big_DEPENDENCIES) $(EXTRA_unzzip_big_DEPENDENCIES)
+ @rm -f unzzip-big$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(unzzip_big_OBJECTS) $(unzzip_big_LDADD) $(LIBS)
-unzzipdir$(EXEEXT): $(unzzipdir_OBJECTS) $(unzzipdir_DEPENDENCIES) $(EXTRA_unzzipdir_DEPENDENCIES)
- @rm -f unzzipdir$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(unzzipdir_OBJECTS) $(unzzipdir_LDADD) $(LIBS)
+unzzip-mem$(EXEEXT): $(unzzip_mem_OBJECTS) $(unzzip_mem_DEPENDENCIES) $(EXTRA_unzzip_mem_DEPENDENCIES)
+ @rm -f unzzip-mem$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(unzzip_mem_OBJECTS) $(unzzip_mem_LDADD) $(LIBS)
-unzzipdir-mem$(EXEEXT): $(unzzipdir_mem_OBJECTS) $(unzzipdir_mem_DEPENDENCIES) $(EXTRA_unzzipdir_mem_DEPENDENCIES)
- @rm -f unzzipdir-mem$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(unzzipdir_mem_OBJECTS) $(unzzipdir_mem_LDADD) $(LIBS)
+unzzip-mix$(EXEEXT): $(unzzip_mix_OBJECTS) $(unzzip_mix_DEPENDENCIES) $(EXTRA_unzzip_mix_DEPENDENCIES)
+ @rm -f unzzip-mix$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(unzzip_mix_OBJECTS) $(unzzip_mix_LDADD) $(LIBS)
zzcat$(EXEEXT): $(zzcat_OBJECTS) $(zzcat_DEPENDENCIES) $(EXTRA_zzcat_DEPENDENCIES)
@rm -f zzcat$(EXEEXT)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzip-mem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-big.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-mem.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-seeko.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-mix.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipcat-zip.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir-big.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir-mem.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir-mix.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzzipdir-zip.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzcat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzdir.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zzip.Po@am__quote@
#include <zzip/zzip.h>
#include <stdio.h>
#include <string.h>
+#include "unzzip.h"
-#ifdef ZZIP_HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef ZZIP_HAVE_IO_H
-#include <io.h>
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
+extern int unzzip_list(int argc, char** argv);
+extern int unzzip_print(int argc, char** argv);
+extern int unzzip_extract(int argc, char** argv);
static const char usage[] =
{
"unzzip <dir>.. \n"
" - unzzip the files contained in a zip archive.\n"
+ " -p print content of files to pipe\n"
+ " -l list names in archive (short format)\n"
};
+static int unzzip_version(void)
+{
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return 0;
+}
+
+static int unzzip_help(void)
+{
+ printf (usage);
+ return 0;
+}
+
int
main (int argc, char ** argv)
{
if (argc <= 1 || ! strcmp (argv[1], "--help"))
{
- printf (usage);
- return 0;
+ return unzzip_help();
}
if (! strcmp (argv[1], "--version"))
{
- printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
+ return unzzip_version();
}
-
- for (argn=1; argn < argc; argn++)
+ if (! strcmp (argv[1], "-l") || ! strcmp(argv[1], "--list"))
{
- ZZIP_DIR * dir;
- ZZIP_DIRENT d;
-
- dir = zzip_dir_open(argv[argn], &error);
- if (! dir)
- {
- fprintf (stderr, "did not open %s: \n", argv[argn]);
- fprintf (stderr, "%s: %s\n", argv[argn], zzip_strerror(error));
- exitcode++;
- continue;
- }
-
- if (argc > 2) printf ("%s: \n", argv[argn]);
-
- /* read each dir entry and show one line of info per file */
- while (zzip_dir_read (dir, &d))
- {
- int output;
- ZZIP_FILE* input = zzip_file_open (dir, d.d_name, O_RDONLY);
- if (! input)
- {
- fprintf (stderr, "|did not open %s: \n", d.d_name);
- fprintf (stderr, "|%s: %s\n", d.d_name, zzip_strerror_of(dir));
- continue;
- }
-
- output = creat (d.d_name, 0664);
- if (output == -1)
- {
- fprintf (stderr, "|output file %s: \n", d.d_name);
- perror(d.d_name);
- zzip_file_close (input);
- continue;
- }
-
- printf("%s\n", d.d_name);
-
- {
- char buf[17]; zzip_ssize_t n;
- /* read chunks of 16 bytes into buf */
- while (0 < (n = zzip_read (input, buf, 16)))
- {
- write (output, buf, n);
- }
-
- if (n == -1)
- perror (d.d_name);
- }
- close (output);
- zzip_file_close (input);
- }
+ argc -= 1; argv += 1;
+ return unzzip_list(argc, argv);
+ }
+ if (! strcmp (argv[1], "-v") || ! strcmp(argv[1], "--versions"))
+ {
+ if (argc == 2)
+ return unzzip_version(); /* compatible with info-zip */
+ argc -= 1; argv += 1;
+ return unzzip_list(argc, argv); /* short format here */
+ }
+ if (! strcmp (argv[1], "-p") || ! strcmp(argv[1], "--pipe"))
+ {
+ argc -= 1; argv += 1;
+ return unzzip_print(argc, argv);
+ }
- zzip_dir_close(dir);
+ if (! strcmp (argv[1], "-"))
+ {
+ fprintf(stderr, "unknown option %s", argv[1]);
+ return -1;
}
-
- return exitcode;
+
+ return unzzip_extract(argc, argv);
}
/*
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzip api usage.
+ */
+
+extern int unzzip_list(int argc, char** argv);
+extern int unzzip_print(int argc, char** argv);
+extern int unzzip_extract(int argc, char** argv);
+
#include <zzip/fseeko.h>
#include <stdlib.h>
#include <string.h>
+#include "unzzip.h"
#ifdef ZZIP_HAVE_FNMATCH_H
#include <fnmatch.h>
#define debug3(msg, arg1, arg2)
#endif
-static const char usage[] =
-{
- "unzzipcat-seeko <zip> [names].. \n"
- " - unzzip data content of files contained in a zip archive.\n"
-};
-
-static void zzip_entry_fprint(ZZIP_ENTRY* entry, FILE* out)
+static void unzzip_big_entry_fprint(ZZIP_ENTRY* entry, FILE* out)
{
ZZIP_ENTRY_FILE* file = zzip_entry_fopen (entry, 0);
if (file)
}
}
-static void zzip_cat_file(FILE* disk, char* name, FILE* out)
+static void unzzip_cat_file(FILE* disk, char* name, FILE* out)
{
ZZIP_ENTRY_FILE* file = zzip_entry_ffile (disk, name);
if (file)
}
}
-int
-main (int argc, char ** argv)
+
+static FILE* create_fopen(char* name, char* mode, int subdirs)
+{
+ if (subdirs)
+ {
+ char* p = strrchr(name, '/');
+ if (p) {
+ char* dir_name = strndup(name, p-name);
+ // makedirs(dir_name); // TODO
+ free (dir_name);
+ }
+ }
+ return fopen(name, mode);
+}
+
+
+static int unzzip_cat (int argc, char ** argv, int extract)
{
int argn;
FILE* disk;
- if (argc <= 1 || ! strcmp (argv[1], "--help"))
- {
- printf (usage);
- return 0;
- }
- if (! strcmp (argv[1], "--version"))
- {
- printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
- }
-
disk = fopen (argv[1], "r");
if (! disk) {
perror(argv[1]);
for (; entry ; entry = zzip_entry_findnext(entry))
{
char* name = zzip_entry_strdup_name (entry);
- printf ("%s\n", name);
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
free (name);
}
return 0;
}
- if (argc == 3)
+ if (argc == 3 && !extract)
{ /* list from one spec */
ZZIP_ENTRY* entry = 0;
while ((entry = zzip_entry_findmatch(disk, argv[2], entry, 0, 0)))
{
- zzip_entry_fprint (entry, stdout);
+ unzzip_big_entry_fprint (entry, stdout);
}
return 0;
}
debug3(".. check '%s' to zip '%s'", argv[argn], name);
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
- zzip_cat_file (disk, name, stdout);
+ {
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ break; /* match loop */
+ }
free (name);
}
}
return 0;
}
+int unzzip_print (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 0);
+}
+
+int unzzip_extract (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 1);
+}
+
/*
* Local variables:
* c-file-style: "stroustrup"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "unzzip.h"
#ifdef ZZIP_HAVE_UNISTD_H
#include <unistd.h>
#define O_BINARY 0
#endif
-static const char usage[] =
-{
- "unzzipdir-mem <zip> [names].. \n"
- " - unzzip data content of files contained in a zip archive.\n"
-};
-
-static void zzip_mem_entry_fprint(ZZIP_MEM_DISK* disk,
+static void unzzip_mem_entry_fprint(ZZIP_MEM_DISK* disk,
ZZIP_MEM_ENTRY* entry, FILE* out)
{
ZZIP_DISK_FILE* file = zzip_mem_entry_fopen (disk, entry);
}
}
-static void zzip_mem_disk_cat_file(ZZIP_MEM_DISK* disk, char* name, FILE* out)
+static void unzzip_mem_disk_cat_file(ZZIP_MEM_DISK* disk, char* name, FILE* out)
{
ZZIP_DISK_FILE* file = zzip_mem_disk_fopen (disk, name);
if (file)
}
}
-int
-main (int argc, char ** argv)
+static FILE* create_fopen(char* name, char* mode, int subdirs)
+{
+ if (subdirs)
+ {
+ char* p = strrchr(name, '/');
+ if (p) {
+ char* dir_name = strndup(name, p-name);
+ // makedirs(dir_name); // TODO
+ free (dir_name);
+ }
+ }
+ return fopen(name, mode);
+}
+
+
+static int unzzip_cat (int argc, char ** argv, int extract)
{
int argn;
ZZIP_MEM_DISK* disk;
- if (argc <= 1 || ! strcmp (argv[1], "--help"))
- {
- printf (usage);
- return 0;
- }
- if (! strcmp (argv[1], "--version"))
+ if (argc == 1)
{
printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
+ return -1; /* better provide an archive argument */
}
disk = zzip_mem_disk_open (argv[1]);
for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
{
char* name = zzip_mem_entry_to_name (entry);
- printf ("%s\n", name);
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_mem_disk_cat_file (disk, name, out);
+ if (extract) fclose(out);
}
return 0;
}
- if (argc == 3)
+ if (argc == 3 && !extract)
{ /* list from one spec */
ZZIP_MEM_ENTRY* entry = 0;
while ((entry = zzip_mem_disk_findmatch(disk, argv[2], entry, 0, 0)))
{
- zzip_mem_entry_fprint (disk, entry, stdout);
+ unzzip_mem_entry_fprint (disk, entry, stdout);
}
return 0;
char* name = zzip_mem_entry_to_name (entry);
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
- zzip_mem_disk_cat_file (disk, name, stdout);
+ {
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_mem_disk_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ break; /* match loop */
+ }
}
}
return 0;
}
+int unzzip_print (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 0);
+}
+
+int unzzip_extract (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 1);
+}
+
/*
* Local variables:
* c-file-style: "stroustrup"
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzip api usage.
+ */
+
+#include <zzip/lib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unzzip.h"
+
+#ifdef ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef ZZIP_HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(x,y,z) strcmp(x,y)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static void unzzip_cat_file(ZZIP_DIR* disk, char* name, FILE* out)
+{
+ ZZIP_FILE* file = zzip_fopen(name, "r");
+ if (file)
+ {
+ char buffer[1024]; int len;
+ while ((len = zzip_fread (buffer, 1, 1024, file)))
+ {
+ fwrite (buffer, 1, len, out);
+ }
+
+ zzip_fclose (file);
+ }
+}
+
+static FILE* create_fopen(char* name, char* mode, int subdirs)
+{
+ if (subdirs)
+ {
+ char* p = strrchr(name, '/');
+ if (p) {
+ char* dir_name = strndup(name, p-name);
+ // makedirs(dir_name); // TODO
+ free (dir_name);
+ }
+ }
+ return fopen(name, mode);
+}
+
+
+static int unzzip_cat (int argc, char ** argv, int extract)
+{
+ int argn;
+ ZZIP_DIR* disk;
+
+ if (argc == 1)
+ {
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return -1; /* better provide an archive argument */
+ }
+
+ disk = zzip_opendir (argv[1]);
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* list all */
+ ZZIP_DIRENT* entry = zzip_readdir(disk);
+ while((entry = zzip_readdir(disk)))
+ {
+ char* name = entry->d_name;
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ }
+ }
+ else
+ { /* list only the matching entries - in order of zip directory */
+ ZZIP_DIRENT* entry = 0;
+ while((entry = zzip_readdir(disk)))
+ {
+ char* name = entry->d_name;
+ for (argn=1; argn < argc; argn++)
+ {
+ if (! fnmatch (argv[argn], name,
+ FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
+ {
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ break; /* match loop */
+ }
+ }
+ }
+ }
+ zzip_closedir(disk);
+ return 0;
+}
+
+int unzzip_print (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 0);
+}
+
+int unzzip_extract (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 1);
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzip api usage.
+ */
+
+#include <zzip/lib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unzzip.h"
+
+#ifdef ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef ZZIP_HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(x,y,z) strcmp(x,y)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static void unzzip_cat_file(ZZIP_DIR* disk, char* name, FILE* out)
+{
+ ZZIP_FILE* file = zzip_file_open (disk, name, 0);
+ if (file)
+ {
+ char buffer[1024]; int len;
+ while ((len = zzip_file_read (file, buffer, 1024)))
+ {
+ fwrite (buffer, 1, len, out);
+ }
+
+ zzip_file_close (file);
+ }
+}
+
+static FILE* create_fopen(char* name, char* mode, int subdirs)
+{
+ if (subdirs)
+ {
+ char* p = strrchr(name, '/');
+ if (p) {
+ char* dir_name = strndup(name, p-name);
+ // makedirs(dir_name); // TODO
+ free (dir_name);
+ }
+ }
+ return fopen(name, mode);
+}
+
+
+static int unzzip_cat (int argc, char ** argv, int extract)
+{
+ int argn;
+ ZZIP_DIR* disk;
+ zzip_error_t error;
+
+ if (argc == 1)
+ {
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return -1; /* better provide an archive argument */
+ }
+
+ disk = zzip_dir_open (argv[1], &error);
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* list all */
+ ZZIP_DIRENT entry;
+ while(zzip_dir_read(disk, &entry))
+ {
+ char* name = entry.d_name;
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ }
+ }
+ else
+ { /* list only the matching entries - in order of zip directory */
+ ZZIP_DIRENT entry;
+ while(zzip_dir_read(disk, &entry))
+ {
+ char* name = entry.d_name;
+ for (argn=1; argn < argc; argn++)
+ {
+ if (! fnmatch (argv[argn], name,
+ FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
+ {
+ FILE* out = stdout;
+ if (extract) out = create_fopen(name, "w", 1);
+ unzzip_cat_file (disk, name, out);
+ if (extract) fclose(out);
+ break; /* match loop */
+ }
+ }
+ }
+ }
+ zzip_dir_close(disk);
+ return 0;
+}
+
+int unzzip_print (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 0);
+}
+
+int unzzip_extract (int argc, char ** argv)
+{
+ return unzzip_cat(argc, argv, 1);
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
+++ /dev/null
-/*
- * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
- * Use freely under the restrictions of the ZLIB license.
- *
- * This file is used as an example to clarify zzipmmap api usage.
- */
-
-#include <zzip/mmapped.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef ZZIP_HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef ZZIP_HAVE_IO_H
-#include <io.h>
-#endif
-
-#ifdef ZZIP_HAVE_FNMATCH_H
-#include <fnmatch.h>
-#else
-#define fnmatch(x,y,z) strcmp(x,y)
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-static const char usage[] =
-{
- "unzzipdir <zip> [names].. \n"
- " - unzzip data content of files contained in a zip archive.\n"
-};
-
-static void zzip_disk_entry_fprint(ZZIP_DISK* disk,
- ZZIP_DISK_ENTRY* entry, FILE* out)
-{
- ZZIP_DISK_FILE* file = zzip_disk_entry_fopen (disk, entry);
- if (file)
- {
- char buffer[1024]; int len;
- while ((len = zzip_disk_fread (buffer, 1024, 1, file)))
- fwrite (buffer, len, 1, out);
-
- zzip_disk_fclose (file);
- }
-}
-
-static void zzip_disk_cat_file(ZZIP_DISK* disk, char* name, FILE* out)
-{
- ZZIP_DISK_FILE* file = zzip_disk_fopen (disk, name);
- if (file)
- {
- char buffer[1024]; int len;
- while ((len = zzip_disk_fread (buffer, 1, 1024, file)))
- {
- fwrite (buffer, 1, len, out);
- }
-
- zzip_disk_fclose (file);
- }
-}
-
-int
-main (int argc, char ** argv)
-{
- int argn;
- ZZIP_DISK* disk;
-
- if (argc <= 1 || ! strcmp (argv[1], "--help"))
- {
- printf (usage);
- return 0;
- }
- if (! strcmp (argv[1], "--version"))
- {
- printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
- }
-
- disk = zzip_disk_open (argv[1]);
- if (! disk) {
- perror(argv[1]);
- return -1;
- }
-
- if (argc == 2)
- { /* print directory list */
- ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
- for (; entry ; entry = zzip_disk_findnext(disk, entry))
- {
- char* name = zzip_disk_entry_strdup_name (disk, entry);
- if (name)
- {
- printf ("%s\n", name);
- free (name);
- }
- }
- return 0;
- }
-
- if (argc == 3)
- { /* list from one spec */
- ZZIP_DISK_ENTRY* entry = 0;
- while ((entry = zzip_disk_findmatch(disk, argv[2], entry, 0, 0)))
- zzip_disk_entry_fprint (disk, entry, stdout);
-
- return 0;
- }
-
- for (argn=1; argn < argc; argn++)
- { /* list only the matching entries - each in order of commandline */
- ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
- for (; entry ; entry = zzip_disk_findnext(disk, entry))
- {
- char* name = zzip_disk_entry_strdup_name (disk, entry);
- if (name)
- {
- if (! fnmatch (argv[argn], name,
- FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
- zzip_disk_cat_file (disk, name, stdout);
- free (name);
- }
- }
- }
- return 0;
-}
-
-/*
- * Local variables:
- * c-file-style: "stroustrup"
- * End:
- */
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzipfseeko api usage.
+ */
+
+#include <zzip/fseeko.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unzzip.h"
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(x,y,z) strcmp(x,y)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#ifdef DEBUG
+#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0)
+#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0)
+#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0)
+#else
+#define debug1(msg)
+#define debug2(msg, arg1)
+#define debug3(msg, arg1, arg2)
+#endif
+
+int unzzip_list (int argc, char ** argv)
+{
+ int argn;
+ FILE* disk;
+
+ disk = fopen (argv[1], "r");
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* print directory list */
+ ZZIP_ENTRY* entry = zzip_entry_findfirst(disk);
+ for (; entry ; entry = zzip_entry_findnext(entry))
+ {
+ char* name = zzip_entry_strdup_name (entry);
+ printf (" %s \n", name);
+ free (name);
+ }
+ return 0;
+ }
+
+ for (argn=1; argn < argc; argn++)
+ { /* list only the matching entries - each in order of commandline */
+ ZZIP_ENTRY* entry = zzip_entry_findfirst(disk);
+ for (; entry ; entry = zzip_entry_findnext(entry))
+ {
+ char* name = zzip_entry_strdup_name (entry);
+ printf (" %s \n", name);
+ free (name);
+ }
+ }
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "unzzip.h"
#ifdef ZZIP_HAVE_UNISTD_H
#include <unistd.h>
#define O_BINARY 0
#endif
-static const char usage[] =
-{
- "unzzipdir <zip> [names].. \n"
- " - unzzip a listing of files contained in a zip archive.\n"
-};
int
-main (int argc, char ** argv)
+unzzip_list (int argc, char ** argv)
{
int argn;
ZZIP_MEM_DISK* disk;
-
- if (argc <= 1 || ! strcmp (argv[1], "--help"))
- {
- printf (usage);
- return 0;
- }
- if (! strcmp (argv[1], "--version"))
+
+ if (argc == 1)
{
- printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return -1; /* better provide an archive argument */
}
-
+
disk = zzip_mem_disk_open (argv[1]);
if (! disk) {
perror(argv[1]);
for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
{
char* name = zzip_mem_entry_to_name (entry);
- printf ("%s\n", name);
+ int compr = entry->zz_compr;
+ long long usize = entry->zz_usize;
+ long long csize = entry->zz_csize;
+ char* defl = compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", csize, usize, defl, name);
}
return 0;
}
while ((entry = zzip_mem_disk_findmatch(disk, argv[2], entry, 0, 0)))
{
char* name = zzip_mem_entry_to_name (entry);
- printf ("%s\n", name);
+ int compr = entry->zz_compr;
+ long long usize = entry->zz_usize;
+ long long csize = entry->zz_csize;
+ char* defl = compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", csize, usize, defl, name);
}
return 0;
}
{
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
- printf ("%s\n", name);
+ {
+ int compr = entry->zz_compr;
+ long long usize = entry->zz_usize;
+ long long csize = entry->zz_csize;
+ char* defl = compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", csize, usize, defl, name);
+ break; /* match loop */
+ }
}
}
return 0;
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzip api usage.
+ */
+
+#include <zzip/lib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unzzip.h"
+
+#ifdef ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef ZZIP_HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(x,y,z) strcmp(x,y)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
+int
+unzzip_list (int argc, char ** argv)
+{
+ int argn;
+ ZZIP_DIR* disk;
+
+ if (argc == 1)
+ {
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return -1; /* better provide an archive argument */
+ }
+
+ disk = zzip_opendir (argv[1]);
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* list all */
+ ZZIP_DIRENT* entry = zzip_readdir(disk);
+ while((entry = zzip_readdir(disk)))
+ {
+ char* name = entry->d_name;
+ long long csize = entry->d_csize;
+ long long usize = entry->st_size;
+ char* defl = entry->d_compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", usize, csize, defl, name);
+ }
+ }
+ else
+ { /* list only the matching entries - in order of zip directory */
+ ZZIP_DIRENT* entry = 0;
+ while((entry = zzip_readdir(disk)))
+ {
+ char* name = entry->d_name;
+ for (argn=1; argn < argc; argn++)
+ {
+ if (! fnmatch (argv[argn], name,
+ FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
+ {
+ long long csize = entry->d_csize;
+ long long usize = entry->st_size;
+ char* defl = entry->d_compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", usize, csize, defl, name);
+ break; /* match loop */
+ }
+ }
+ }
+ }
+ zzip_closedir(disk);
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
--- /dev/null
+/*
+ * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB license.
+ *
+ * This file is used as an example to clarify zzip api usage.
+ */
+
+#include <zzip/lib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "unzzip.h"
+
+#ifdef ZZIP_HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef ZZIP_HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef ZZIP_HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(x,y,z) strcmp(x,y)
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+
+int
+unzzip_list (int argc, char ** argv)
+{
+ int argn;
+ ZZIP_DIR* disk;
+ zzip_error_t error;
+
+ if (argc == 1)
+ {
+ printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
+ return -1; /* better provide an archive argument */
+ }
+
+ disk = zzip_dir_open (argv[1], &error);
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* list all */
+ ZZIP_DIRENT entry;
+ while(zzip_dir_read(disk, &entry))
+ {
+ char* name = entry.d_name;
+ long long csize = entry.d_csize;
+ long long usize = entry.st_size;
+ char* defl = entry.d_compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", usize, csize, defl, name);
+ }
+ }
+ else
+ { /* list only the matching entries - in order of zip directory */
+ ZZIP_DIRENT entry;
+ while(zzip_dir_read(disk, &entry))
+ {
+ char* name = entry.d_name;
+ for (argn=1; argn < argc; argn++)
+ {
+ if (! fnmatch (argv[argn], name,
+ FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
+ {
+ long long csize = entry.d_csize;
+ long long usize = entry.st_size;
+ char* defl = entry.d_compr ? "deflated" : "stored";
+ printf ("%lli/%lli %s %s \n", usize, csize, defl, name);
+ break; /* match loop */
+ }
+ }
+ }
+ }
+ zzip_dir_close(disk);
+ return 0;
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
+++ /dev/null
-/*
- * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
- * Use freely under the restrictions of the ZLIB license.
- *
- * This file is used as an example to clarify zzipmmap api usage.
- */
-
-#include <zzip/mmapped.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef ZZIP_HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef ZZIP_HAVE_IO_H
-#include <io.h>
-#endif
-
-#ifdef ZZIP_HAVE_FNMATCH_H
-#include <fnmatch.h>
-#else
-#define fnmatch(x,y,z) strcmp(x,y)
-#endif
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-static const char usage[] =
-{
- "unzzipdir <zip> [names].. \n"
- " - unzzip a listing of files contained in a zip archive.\n"
-};
-
-int
-main (int argc, char ** argv)
-{
- int argn;
- ZZIP_DISK* disk;
-
- if (argc <= 1 || ! strcmp (argv[1], "--help"))
- {
- printf (usage);
- return 0;
- }
- if (! strcmp (argv[1], "--version"))
- {
- printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
- return 0;
- }
-
- disk = zzip_disk_open (argv[1]);
- if (! disk) {
- perror(argv[1]);
- return -1;
- }
-
- if (argc == 2)
- { /* list all */
- ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
- for (; entry ; entry = zzip_disk_findnext(disk, entry))
- {
- char* name = zzip_disk_entry_strdup_name (disk, entry);
- printf ("%s\n", name);
- free (name);
- }
- return 0;
- }
-
- if (argc == 3)
- { /* list from one spec */
- ZZIP_DISK_ENTRY* entry = 0;
- while ((entry = zzip_disk_findmatch(disk, argv[2], entry, 0, 0)))
- {
- char* name = zzip_disk_entry_strdup_name (disk, entry);
- printf ("%s\n", name);
- free (name);
- }
- return 0;
- }
-
- { /* list only the matching entries - in order of zip directory */
- ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
- for (; entry ; entry = zzip_disk_findnext(disk, entry))
- {
- char* name = zzip_disk_entry_strdup_name (disk, entry);
- for (argn=1; argn < argc; argn++)
- {
- if (! fnmatch (argv[argn], name,
- FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
- printf ("%s\n", name);
- }
- free (name);
- }
- return 0;
- }
-}
-
-/*
- * Local variables:
- * c-file-style: "stroustrup"
- * End:
- */
zipfile = "test0.zip"
getfile = "README"
logfile = "test0.readme.seeko.txt"
- exe = self.bins("unzzipcat-seeko")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-big")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
def test_401_zzcat_seeko_test1_zip(self):
zipfile = "test1.zip"
getfile = "README"
logfile = "test1.readme.seeko.txt"
- exe = self.bins("unzzipcat-seeko")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-big")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.1"
- run = shell("{exe} {zipfile} {getfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
self.assertEqual("file-1\n", run.output)
def test_402_zzcat_seeko_seeko_test2_zip(self):
""" run zzcat-seeke on test.zip using just archive README """
zipfile = "test2.zip"
getfile = "README"
logfile = "test2.readme.seeko.txt"
- exe = self.bins("unzzipcat-seeko")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-big")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.22"
- run = shell("{exe} {zipfile} {getfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
self.assertEqual("file-22\n", run.output)
def test_410_zzcat_test0_zip(self):
""" run zzcat-mem on test.zip using just archive README """
zipfile = "test0.zip"
getfile = "README"
logfile = "test0.readme.mmapped.txt"
- exe = self.bins("unzzipcat-mem")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
def test_411_zzcat_test1_zip(self):
zipfile = "test1.zip"
getfile = "README"
logfile = "test1.readme.mmapped.txt"
- exe = self.bins("unzzipcat-mem")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.1"
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertEqual("file-1\n", run.output)
def test_412_zzcat_test2_zip(self):
""" run zzcat-mem on test.zip using archive README """
zipfile = "test2.zip"
getfile = "README"
logfile = "test2.readme.mmapped.txt"
- exe = self.bins("unzzipcat-mem")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.22"
- run = shell("{exe} {zipfile} {getfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
self.assertEqual("file-22\n", run.output)
def test_413_zzcat_test3_zip(self):
""" run zzcat-mem on test.zip using archive README """
zipfile = "test3.zip"
getfile = "README"
logfile = "test3.readme.mmapped.txt"
- exe = self.bins("unzzipcat-mem")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.999"
- run = shell("{exe} {zipfile} {getfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
self.assertEqual("file-999\n", run.output)
def test_414_zzcat_test4_zip(self):
""" run zzcat-mem on test.zip using archive README """
zipfile = "test4.zip"
getfile = "README"
logfile = "test4.readme.mmapped.txt"
- exe = self.bins("unzzipcat-mem")
- run = shell("{exe} {zipfile} {getfile} | tee {logfile}".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -p {zipfile} {getfile} | tee {logfile}".format(**locals()))
self.assertGreater(os.path.getsize(logfile), 10)
self.assertEqual(run.output.split("\n"), self.readme().split("\n"))
getfile = "file.999"
- run = shell("{exe} {zipfile} {getfile}".format(**locals()))
+ run = shell("{exe} -p {zipfile} {getfile}".format(**locals()))
self.assertEqual("file-999\n", run.output)
def test_420_zzdir_test0_zip(self):
""" run zzdir-me on test0.zip """
zipfile = "test0.zip"
getfile = "test0.zip"
- exe = self.bins("zzdir")
- run = shell("{exe} {getfile} ".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -l {getfile} ".format(**locals()))
self.assertIn(' README ', run.output)
self.assertIn(' deflated ', run.output)
self.assertLess(len(run.output), 30)
""" run zzdir-mem on test1.zip """
zipfile = "test1.zip"
getfile = "test1.zip"
- exe = self.bins("zzdir")
- run = shell("{exe} {getfile} ".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -l {getfile} ".format(**locals()))
self.assertIn(' file.1 ', run.output)
self.assertIn(' file.2 ', run.output)
self.assertIn(' file.9 ', run.output)
""" run zzdir-mem on test2.zip """
zipfile = "test2.zip"
getfile = "test2.zip"
- exe = self.bins("zzdir")
- run = shell("{exe} {getfile} ".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -l {getfile} ".format(**locals()))
self.assertIn(' file.01 ', run.output)
self.assertIn(' file.22 ', run.output)
self.assertIn(' file.99 ', run.output)
""" run zzdir-mem on test3.zip """
zipfile = "test3.zip"
getfile = "test3.zip"
- exe = self.bins("zzdir")
- run = shell("{exe} {getfile} ".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -l {getfile} ".format(**locals()))
self.assertIn(' file.001 ', run.output)
self.assertIn(' file.222 ', run.output)
self.assertIn(' file.999 ', run.output)
""" run zzdir-mem on test4.zip """
zipfile = "test4.zip"
getfile = "test4.zip"
- exe = self.bins("zzdir")
- run = shell("{exe} {getfile} ".format(**locals()))
+ exe = self.bins("unzzip-mem")
+ run = shell("{exe} -l {getfile} ".format(**locals()))
self.assertIn(' file.001 ', run.output)
self.assertIn(' file.222 ', run.output)
self.assertIn(' file.999 ', run.output)