]> granicus.if.org Git - zziplib/commitdiff
This commit was generated by cvs2svn to compensate for changes in r23, which
authorGuido Draheim <guidod@gmx.de>
Wed, 18 Dec 2002 13:22:53 +0000 (13:22 +0000)
committerGuido Draheim <guidod@gmx.de>
Wed, 18 Dec 2002 13:22:53 +0000 (13:22 +0000)
included commits to RCS files with non-trunk default branches.

bins/zzcat.c [new file with mode: 0644]
bins/zzdir.c [new file with mode: 0644]

diff --git a/bins/zzcat.c b/bins/zzcat.c
new file mode 100644 (file)
index 0000000..07481aa
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *     Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
+ *      Use freely under the restrictions of the ZLIB License
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <zzip/zzip.h>
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static const char usage[] = 
+{
+    " zzcat <file>... \n"
+    "  - prints the file to stdout, so you may want to redirect the output; \n"
+    " the file can be a normal file or an inflated part of a zip-archive, \n"
+    " to get 'README' from dist.zip you may write \n"
+    "    zzcat dist/README \n"
+};
+
+int 
+main (int argc, char ** argv)
+{
+    int argn;
+    if (argc <= 1)
+    {
+        printf (usage);
+        exit (0);
+    }
+    
+    for (argn=1; argn < argc; argn++)
+    {
+        ZZIP_FILE* fp = zzip_open (argv[argn], O_RDONLY|O_BINARY);
+
+        if (! fp)
+        {
+            perror (argv[argn]);
+            continue;
+        }else{
+            char buf[17];
+            int n;
+
+           /* read chunks of 16 bytes into buf and print them to stdout */
+            while (0 < (n = zzip_read(fp, buf, 16)))
+            {
+                buf[n] = '\0';
+#            ifdef STDOUT_FILENO
+                write (STDOUT_FILENO, buf, n);
+#            else
+                fwrite (buf, 1, n, stdout);
+#             endif
+            }
+
+            if (n == -1) 
+                perror (argv[argn]);
+        }
+    }
+    
+    return 0;
+} 
+
+/* 
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */
diff --git a/bins/zzdir.c b/bins/zzdir.c
new file mode 100644 (file)
index 0000000..1d6540f
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *     Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
+ *      Use freely under the restrictions of the ZLIB license.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <zzip/zzip.h>
+
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static const char usage[] = 
+{
+    "zzdir <dir>.. \n"
+    "  - prints a content table to stdout, but the dir can also be a zip-arch."
+    "\n"
+    " To show the contents of a zip-archive named 'test.zip', you may write \n"
+    "     zzdir test \n"
+};
+
+int 
+main (int argc, char ** argv)
+{
+    int argn;
+    int exitcode = 0; 
+    if (argc <= 1)
+    {
+        printf (usage);
+        exit(0);
+    }
+    
+    for (argn=1; argn < argc; argn++)
+    {
+        ZZIP_DIR * dir;
+        ZZIP_DIRENT * d;
+  
+        dir = zzip_opendir(argv[argn]);
+        if (! dir)
+        {
+            fprintf (stderr, "did not open %s: ", argv[argn]);
+            perror(argv[argn]);
+           exitcode++;
+            continue;
+        }
+  
+        if (argc > 2) printf ("%s: \n", argv[argn]);
+
+       /* read each dir entry and show one line of info per file */
+        while ((d = zzip_readdir (dir)))
+        {
+           /* orignalsize / compression-type / compression-ratio / filename */
+            if (d->st_size > 999999)
+            {
+                printf ("%5dK %-9s %2d%% %s \n", 
+                       d->st_size>>10, 
+                       zzip_compr_str(d->d_compr), 
+                       100 - (d->d_csize|1)/((d->st_size/100)|1),
+                       d->d_name);
+            }else{
+                printf ("%6d %-9s %2d%% %s \n", 
+                       d->st_size, 
+                       zzip_compr_str(d->d_compr), 
+                       100 - (d->d_csize|1)*100/(d->st_size|1),
+                       d->d_name);
+            }
+        }
+
+        zzip_closedir(dir);
+    }
+    
+    return exitcode;
+} 
+
+/* 
+ * Local variables:
+ * c-file-style: "stroustrup"
+ * End:
+ */