#include "unzzipcat-zip.h"
#include "unzzipdir-zip.h"
-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"
if (! strcmp (argv[1], "-l") || ! strcmp(argv[1], "--list"))
{
argc -= 1; argv += 1;
- return unzzip_list(argc, argv);
+ return unzzip_show_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 */
+ return unzzip_long_list(argc, argv);
}
if (! strcmp (argv[1], "-p") || ! strcmp(argv[1], "--pipe"))
{
"stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4",
"impl:N", "toknze", "defl:N", "defl:B", "impl:B" };
-int unzzip_list (int argc, char ** argv)
+static int
+unzzip_list (int argc, char ** argv, int verbose)
{
int argn;
FILE* disk;
return 0;
}
+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"
"stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4",
"impl:N", "toknze", "defl:N", "defl:B", "impl:B" };
-int
-unzzip_list (int argc, char ** argv)
+static int
+unzzip_list (int argc, char ** argv, int verbose)
{
int argn;
ZZIP_MEM_DISK* disk;
{
char* name = zzip_mem_entry_to_name (entry);
long long usize = entry->zz_usize;
- 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);
+ 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;
}
{
char* name = zzip_mem_entry_to_name (entry);
long long usize = entry->zz_usize;
- 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);
+ 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;
}
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
{
+ char* name = zzip_mem_entry_to_name (entry);
long long usize = entry->zz_usize;
- 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);
+ 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 */
}
}
}
}
+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"
"stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4",
"impl:N", "toknze", "defl:N", "defl:B", "impl:B" };
-int
-unzzip_list (int argc, char ** argv)
+
+
+static int
+unzzip_list (int argc, char ** argv, int verbose)
{
int argn;
ZZIP_DIR* disk;
while((entry = zzip_readdir(disk)))
{
char* name = entry->d_name;
- long long csize = entry->d_csize;
long long usize = entry->st_size;
- unsigned compr = entry->d_compr;
- const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
- printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ if (!verbose)
+ {
+ printf ("%22lli %s\n", usize, name);
+ } else
+ {
+ long long csize = entry->d_csize;
+ unsigned compr = entry->d_compr;
+ const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
+ printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ }
}
}
else
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
{
- long long csize = entry->d_csize;
long long usize = entry->st_size;
- unsigned compr = entry->d_compr;
- const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
- printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ if (!verbose)
+ {
+ printf ("%22lli %s\n", usize, name);
+ } else
+ {
+ long long csize = entry->d_csize;
+ unsigned compr = entry->d_compr;
+ const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
+ printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ }
break; /* match loop */
}
}
return 0;
}
+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"
"stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4",
"impl:N", "toknze", "defl:N", "defl:B", "impl:B" };
-int
-unzzip_list (int argc, char ** argv)
+
+static int
+unzzip_list (int argc, char ** argv, int verbose)
{
int argn;
ZZIP_DIR* disk;
while(zzip_dir_read(disk, &entry))
{
char* name = entry.d_name;
- long long csize = entry.d_csize;
long long usize = entry.st_size;
- unsigned compr = entry.d_compr;
- const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
- printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ if (!verbose)
+ {
+ printf ("%22lli %s\n", usize, name);
+ } else
+ {
+ long long csize = entry.d_csize;
+ unsigned compr = entry.d_compr;
+ const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
+ printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ }
}
}
else
if (! fnmatch (argv[argn], name,
FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD))
{
- long long csize = entry.d_csize;
long long usize = entry.st_size;
- unsigned compr = entry.d_compr;
- const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
- printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ if (!verbose)
+ {
+ printf ("%22lli %s\n", usize, name);
+ } else
+ {
+ long long csize = entry.d_csize;
+ unsigned compr = entry.d_compr;
+ const char* defl = (compr < sizeof(comprlevel)) ? comprlevel[compr] : "(redu)";
+ printf ("%lli/%lli %s %s\n", usize, csize, defl, name);
+ }
break; /* match loop */
}
}
return 0;
}
+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"
* This file is used as an example to clarify zzip api usage.
*/
-extern int unzzip_list(int argc, char** argv);
+extern int unzzip_show_list(int argc, char** argv);
+extern int unzzip_long_list(int argc, char** argv);
zipfile = "test0.zip"
getfile = "test0.zip"
exe = self.bins("unzzip-mem")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' README\n', run.output)
self.assertIn(' defl:N ', run.output)
self.assertLess(len(run.output), 30)
zipfile = "test1.zip"
getfile = "test1.zip"
exe = self.bins("unzzip-mem")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.1\n', run.output)
self.assertIn(' file.2\n', run.output)
self.assertIn(' file.9\n', run.output)
zipfile = "test2.zip"
getfile = "test2.zip"
exe = self.bins("unzzip-mem")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.01\n', run.output)
self.assertIn(' file.22\n', run.output)
self.assertIn(' file.99\n', run.output)
zipfile = "test3.zip"
getfile = "test3.zip"
exe = self.bins("unzzip-mem")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)
zipfile = "test4.zip"
getfile = "test4.zip"
exe = self.bins("unzzip-mem")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)
zipfile = "test0.zip"
getfile = "test0.zip"
exe = self.bins("unzzip-mix")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' README\n', run.output)
self.assertIn(' defl:N ', run.output)
self.assertLess(len(run.output), 30)
zipfile = "test1.zip"
getfile = "test1.zip"
exe = self.bins("unzzip-mix")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.1\n', run.output)
self.assertIn(' file.2\n', run.output)
self.assertIn(' file.9\n', run.output)
zipfile = "test2.zip"
getfile = "test2.zip"
exe = self.bins("unzzip-mix")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.01\n', run.output)
self.assertIn(' file.22\n', run.output)
self.assertIn(' file.99\n', run.output)
zipfile = "test3.zip"
getfile = "test3.zip"
exe = self.bins("unzzip-mix")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)
zipfile = "test4.zip"
getfile = "test4.zip"
exe = self.bins("unzzip-mix")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)
zipfile = "test0.zip"
getfile = "test0.zip"
exe = self.bins("unzzip")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' README\n', run.output)
self.assertIn(' defl:N ', run.output)
self.assertLess(len(run.output), 30)
zipfile = "test1.zip"
getfile = "test1.zip"
exe = self.bins("unzzip")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.1\n', run.output)
self.assertIn(' file.2\n', run.output)
self.assertIn(' file.9\n', run.output)
zipfile = "test2.zip"
getfile = "test2.zip"
exe = self.bins("unzzip")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.01\n', run.output)
self.assertIn(' file.22\n', run.output)
self.assertIn(' file.99\n', run.output)
zipfile = "test3.zip"
getfile = "test3.zip"
exe = self.bins("unzzip")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)
zipfile = "test4.zip"
getfile = "test4.zip"
exe = self.bins("unzzip")
- run = shell("{exe} -l {getfile} ".format(**locals()))
+ run = shell("{exe} -v {getfile} ".format(**locals()))
self.assertIn(' file.001\n', run.output)
self.assertIn(' file.222\n', run.output)
self.assertIn(' file.999\n', run.output)