diff options
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c')
-rw-r--r-- | Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c b/Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c index bb060794217..79d64911844 100644 --- a/Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c +++ b/Build/source/libs/zziplib/zziplib-src/bins/unzzipdir-mem.c @@ -6,10 +6,12 @@ */ #include <zzip/memdisk.h> +#include <zzip/__debug.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "unzzip.h" +#include "unzzipdir-zip.h" +#include "unzzip-states.h" #ifdef ZZIP_HAVE_UNISTD_H #include <unistd.h> @@ -24,13 +26,17 @@ #define fnmatch(x,y,z) strcmp(x,y) #endif -#ifndef O_BINARY -#define O_BINARY 0 -#endif +static const char* comprlevel[] = { + "stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4", + "impl:N", "toknze", "defl:N", "defl:B", "impl:B" }; +static int exitcode(int e) +{ + return EXIT_ERRORS; +} -int -unzzip_list (int argc, char ** argv) +static int +unzzip_list (int argc, char ** argv, int verbose) { int argn; ZZIP_MEM_DISK* disk; @@ -38,26 +44,34 @@ unzzip_list (int argc, char ** argv) if (argc == 1) { printf (__FILE__" version "ZZIP_PACKAGE" "ZZIP_VERSION"\n"); - return -1; /* better provide an archive argument */ + return EXIT_OK; /* better provide an archive argument */ } disk = zzip_mem_disk_open (argv[1]); if (! disk) { + DBG3("disk_open failed [%i] %s", errno, strerror(errno)); perror(argv[1]); - return -1; + return exitcode(errno); } if (argc == 2) { /* list all */ ZZIP_MEM_ENTRY* entry = zzip_mem_disk_findfirst(disk); + DBG2("findfirst %p", entry); for (; entry ; entry = zzip_mem_disk_findnext(disk, entry)) { char* name = zzip_mem_entry_to_name (entry); - 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); + if (!verbose) + { + printf ("%22lli %s\n", usize, name); + } else + { + long long csize = entry->zz_csize; + unsigned compr = entry->zz_compr; + const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)"; + printf ("%lli/%lli %s %s\n", csize, usize, defl, name); + } } return 0; } @@ -68,11 +82,17 @@ unzzip_list (int argc, char ** argv) while ((entry = zzip_mem_disk_findmatch(disk, argv[2], entry, 0, 0))) { char* name = zzip_mem_entry_to_name (entry); - 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); + if (!verbose) + { + printf ("%22lli %s\n", usize, name); + } else + { + long long csize = entry->zz_csize; + unsigned compr = entry->zz_compr; + const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)"; + printf ("%lli/%lli %s %s\n", csize, usize, defl, name); + } } return 0; } @@ -87,11 +107,18 @@ unzzip_list (int argc, char ** argv) if (! fnmatch (argv[argn], name, FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD)) { - int compr = entry->zz_compr; + char* name = zzip_mem_entry_to_name (entry); 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); + if (!verbose) + { + printf ("%22lli %s\n", usize, name); + } else + { + long long csize = entry->zz_csize; + unsigned compr = entry->zz_compr; + const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)"; + printf ("%lli/%lli %s %s\n", csize, usize, defl, name); + } break; /* match loop */ } } @@ -100,6 +127,18 @@ unzzip_list (int argc, char ** argv) } } +int +unzzip_long_list (int argc, char ** argv) +{ + return unzzip_list(argc, argv, 1); +} + +int +unzzip_show_list (int argc, char ** argv) +{ + return unzzip_list(argc, argv, 0); +} + /* * Local variables: * c-file-style: "stroustrup" |