summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2009-03-20 07:47:30 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2009-03-20 07:47:30 +0000
commitc813488f91d3e5e4ed45ec061a9aca493d389083 (patch)
treeec07a8d28bb40e6c4238d431c2c0a2d9b31b3be7 /Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c
parent9c241c5d2d9413361d32567876c35b2b9e2754c9 (diff)
new build system
git-svn-id: svn://tug.org/texlive/trunk@12447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c b/Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c
new file mode 100644
index 00000000000..dc020772309
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/zziplib/bins/unzzipdir-mem.c
@@ -0,0 +1,101 @@
+/*
+ * 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/memdisk.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_MEM_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_mem_disk_open (argv[1]);
+ if (! disk) {
+ perror(argv[1]);
+ return -1;
+ }
+
+ if (argc == 2)
+ { /* list all */
+ ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfirst(disk);
+ for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
+ {
+ char* name = zzip_mem_entry_to_name (entry);
+ printf ("%s\n", name);
+ }
+ return 0;
+ }
+
+ if (argc == 3)
+ { /* list from one spec */
+ ZZIP_MEM_ENTRY* entry = 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);
+ }
+ return 0;
+ }
+
+ { /* list only the matching entries - in order of zip directory */
+ ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfirst(disk);
+ for (; entry ; entry = zzip_mem_disk_findnext(disk, entry))
+ {
+ char* name = zzip_mem_entry_to_name (entry);
+ for (argn=1; argn < argc; argn++)
+ {
+ if (! fnmatch (argv[argn], name,
+ FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
+ printf ("%s\n", name);
+ }
+ }
+ return 0;
+ }
+}
+
+/*
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */