2 * Copyright (c) 2003 Guido Draheim <guidod@gmx.de>
3 * Use freely under the restrictions of the ZLIB license.
5 * This file is used as an example to clarify zzipmmap api usage.
8 #include <zzip/mmapped.h>
13 #ifdef ZZIP_HAVE_UNISTD_H
20 #ifdef ZZIP_HAVE_FNMATCH_H
23 #define fnmatch(x,y,z) strcmp(x,y)
30 static const char usage[] =
32 "unzzipdir <zip> [names].. \n"
33 " - unzzip a listing of files contained in a zip archive.\n"
37 main (int argc, char ** argv)
42 if (argc <= 1 || ! strcmp (argv[1], "--help"))
47 if (! strcmp (argv[1], "--version"))
49 printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n");
53 disk = zzip_disk_open (argv[1]);
61 ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
62 for (; entry ; entry = zzip_disk_findnext(disk, entry))
64 char* name = zzip_disk_entry_strdup_name (disk, entry);
65 printf ("%s\n", name);
72 { /* list from one spec */
73 ZZIP_DISK_ENTRY* entry = 0;
74 while ((entry = zzip_disk_findmatch(disk, argv[2], entry, 0, 0)))
76 char* name = zzip_disk_entry_strdup_name (disk, entry);
77 printf ("%s\n", name);
83 { /* list only the matching entries - in order of zip directory */
84 ZZIP_DISK_ENTRY* entry = zzip_disk_findfirst(disk);
85 for (; entry ; entry = zzip_disk_findnext(disk, entry))
87 char* name = zzip_disk_entry_strdup_name (disk, entry);
88 for (argn=1; argn < argc; argn++)
90 if (! fnmatch (argv[argn], name,
91 FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
92 printf ("%s\n", name);
102 * c-file-style: "stroustrup"