Blob


1 /*
2 * cat standard input until you get a zero byte
3 */
5 #include <u.h>
6 #include <libc.h>
8 void
9 main(void)
10 {
11 char buf[4096];
12 char *p;
13 int n;
15 while((n = read(0, buf, sizeof(buf))) > 0){
16 p = memchr(buf, 0, n);
17 if(p != nil)
18 n = p-buf;
19 if(n > 0)
20 write(1, buf, n);
21 if(p != nil)
22 break;
23 }
24 exits(0);
25 }