aboutsummaryrefslogtreecommitdiffstats
path: root/catrw.c
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2005-03-12 00:27:55 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2005-03-12 00:27:55 (GMT)
commit77b250bfb63a28a8fe8a8da67de7354bce6e61ff (patch)
treee28f72c18305016c19c608f5fce4432529e7673d /catrw.c
parent5dfb1906b299bf7c8a1ee3ba5cd1c9ea40648d89 (diff)
downloadpowwow-77b250bfb63a28a8fe8a8da67de7354bce6e61ff.zip
powwow-77b250bfb63a28a8fe8a8da67de7354bce6e61ff.tar.gz
powwow-77b250bfb63a28a8fe8a8da67de7354bce6e61ff.tar.bz2
Initial revisionv1.2.7
Diffstat (limited to 'catrw.c')
-rw-r--r--catrw.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/catrw.c b/catrw.c
new file mode 100644
index 0000000..164d2a3
--- /dev/null
+++ b/catrw.c
@@ -0,0 +1,39 @@
+/*
+ * catrw.c -- open a file with O_RDWR and print it.
+ *
+ * This file is placed in the public domain.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#define BUFSIZE 4096
+char buf[BUFSIZE];
+
+void catrw(int fd) {
+ int i;
+ for (;;) {
+ while ( (i = read(fd, buf, BUFSIZE)) < 0 && errno == EINTR)
+ ;
+ if (i <= 0)
+ break;
+ write(1, buf, i);
+ }
+}
+
+int main(int argc, char *argv[]) {
+ int fd;
+ if (argc == 1)
+ catrw(0);
+ else {
+ while (--argc && (fd = open(*++argv, O_RDWR))) {
+ catrw(fd);
+ close(fd);
+ }
+ }
+ return 0;
+}
+