2 * Copyright (c) 2000,2001 Guido Draheim <guidod@gmx.de>
3 * Use freely under the restrictions of the ZLIB license.
5 * Modified by Andreas Schiffler, 2001, for the zzipwrap feature
6 * Modified by Guido Draheim in 2002 for the plugin_io feature
11 #include <stdlib.h> /* exit */
13 #include <zzip/zzip.h>
14 /* #incl <zzip/wrap.h> */
21 static const char usage
[] =
24 " - prints a content table to stdout, but the dir can also be a zip-arch."
26 " To show the contents of a zip-archive named 'test.zip', you may write \n"
30 /* This is a demo block callback routine that has access to the buffer */
31 /* that was just read BEFORE it is used by zziplib. */
32 static void demo_block_callback (void *buffer
, int buffersize
, void *data
)
35 "demo_block_callback( buffer-pointer=%p"
36 " buffer-size=%i data='%s' )\n",
37 buffer
,buffersize
,(char*)data
);
41 main (int argc
, char ** argv
)
52 /* Enable blocked (32 bytes) memory buffered IO routines with a */
53 /* demo callback routine. */
54 io
= zzipwrap_use_memory_io(32, demo_block_callback
,
55 (void*) "Some callback data");
58 fprintf(stderr
, "could not initialize memory-io");
62 for (argn
=1; argn
< argc
; argn
++)
67 dir
= zzip_opendir_ext_io(argv
[argn
], 0, 0, io
);
70 fprintf (stderr
, "did not open %s:", argv
[argn
]);
75 if (argc
> 2) printf ("%s:\n", argv
[argn
]);
77 /* read each dir entry and show one line of info per file */
78 while ((d
= zzip_readdir (dir
)))
80 /* orignalsize / compression-type / compression-ratio / filename */
81 if (d
->st_size
> 999999)
83 printf ("%5dK %-9s %2d%% %s\n",
85 zzip_compr_str(d
->d_compr
),
86 100 - (d
->d_csize
|1)/((d
->st_size
/100)|1),
89 printf ("%6d %-9s %2d%% %s\n",
91 zzip_compr_str(d
->d_compr
),
92 100 - (d
->d_csize
|1)*100/(d
->st_size
|1),