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 zzipfseeko api usage.
8 #define _ZZIP_ENTRY_STRUCT 1
10 #include <zzip/fseeko.h>
11 #include <zzip/fetch.h>
12 #include <zzip/__fnmatch.h>
15 #include "unzzipdir-zip.h"
16 #include "unzzip-states.h"
18 static const char* comprlevel[] = {
19 "stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4",
20 "impl:N", "toknze", "defl:N", "defl:B", "impl:B" };
22 static int exitcode(int e)
28 unzzip_list (int argc, char ** argv, int verbose)
33 disk = fopen (argv[1], "rb");
36 return exitcode(errno);
40 { /* print directory list */
41 ZZIP_ENTRY* entry = zzip_entry_findfirst(disk);
42 for (; entry ; entry = zzip_entry_findnext(entry))
44 char* name = zzip_entry_strdup_name (entry);
45 unsigned compr = zzip_entry_compr(entry);
46 const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
47 printf (" %s %s\n", defl, name);
53 for (argn=1; argn < argc; argn++)
54 { /* list only the matching entries - each in order of commandline */
55 ZZIP_ENTRY* entry = zzip_entry_findfirst(disk);
56 for (; entry ; entry = zzip_entry_findnext(entry))
58 char* name = zzip_entry_strdup_name (entry);
59 unsigned compr = zzip_entry_compr(entry);
60 const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
61 printf (" %s %s\n", defl, name);
69 unzzip_long_list (int argc, char ** argv)
71 return unzzip_list(argc, argv, 1);
75 unzzip_show_list (int argc, char ** argv)
77 return unzzip_list(argc, argv, 0);
82 * c-file-style: "stroustrup"