summaryrefslogtreecommitdiff
path: root/Build/source/libs/zziplib/zziplib-src/bins/zzcat.c
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
committerKarl Berry <karl@freefriends.org>2021-02-25 19:22:25 +0000
commitad547a6b5986815fda458221149728d9d9ab1d87 (patch)
tree16296910eb3eca724371474ea9aea3994dc69614 /Build/source/libs/zziplib/zziplib-src/bins/zzcat.c
parent947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff)
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/zziplib/zziplib-src/bins/zzcat.c')
-rw-r--r--Build/source/libs/zziplib/zziplib-src/bins/zzcat.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/Build/source/libs/zziplib/zziplib-src/bins/zzcat.c b/Build/source/libs/zziplib/zziplib-src/bins/zzcat.c
new file mode 100644
index 00000000000..63026e048c7
--- /dev/null
+++ b/Build/source/libs/zziplib/zziplib-src/bins/zzcat.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2000,2001,2002 Guido Draheim <guidod@gmx.de>
+ * Use freely under the restrictions of the ZLIB License
+ */
+
+#include <zzip/zzip.h>
+#include <stdio.h>
+#include <string.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 || ! strcmp (argv[1], "--help"))
+ {
+ printf (usage);
+ return 0;
+ }
+ if (! strcmp (argv[1], "--version"))
+ {
+ printf (__FILE__ " version " ZZIP_PACKAGE_NAME " " ZZIP_PACKAGE_VERSION "\n");
+ return 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:
+ */