summaryrefslogtreecommitdiff
path: root/testx.c
diff options
context:
space:
mode:
Diffstat (limited to 'testx.c')
-rw-r--r--testx.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/testx.c b/testx.c
new file mode 100644
index 0000000..d705e4c
--- /dev/null
+++ b/testx.c
@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include "zio.h"
+
+int main(int argc, char *argv[])
+{
+ FILE *file;
+ char line[1<<13];
+ size_t len;
+
+ if (!(file = fdzopen(fileno(stdout), "w", argc > 1 ? argv[1] : "g"))) {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return 1;
+ }
+
+ while ((len = fread(line, sizeof(char), sizeof (line), stdin))) {
+ size_t ret = fwrite(line, sizeof(char), len, file);
+ if ((ret != len) && ferror(stdout)) {
+ clearerr(stdout);
+ }
+ }
+
+ fclose(file);
+
+ return 0;
+}