From 9439fcd8ee88da7419974c67e0169c7e868f1d39 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 21 May 2015 23:37:50 +0100 Subject: [PATCH] tee: remove stdio --- Applications/util/tee.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Applications/util/tee.c b/Applications/util/tee.c index 57018680..eda25c28 100644 --- a/Applications/util/tee.c +++ b/Applications/util/tee.c @@ -34,18 +34,26 @@ */ /* tee - pipe fitting Author: Paul Polderman */ +/* stdio use removed Alan Cox 2015 */ + #include #include #include #include #include #include +#include #define MAXFD 18 #define CHUNK_SIZE 4096 int fd[MAXFD]; +void writes(const char *p) +{ + write(2, p, strlen(p)); +} + int main(int argc, char *argv[]) { char iflag = 0, aflag = 0; @@ -64,7 +72,7 @@ int main(int argc, char *argv[]) aflag++; break; default: - fprintf(stderr,"Usage: tee [-i] [-a] [files].\n"); + writes("Usage: tee [-i] [-a] [files].\n"); exit(1); } argv++; @@ -78,9 +86,9 @@ int main(int argc, char *argv[]) } else { if ((fd[s] = creat(*argv, 0666)) >= 0) continue; } - fprintf(stderr,"Cannot open output file: "); - fprintf(stderr,*argv); - fprintf(stderr,"\n"); + writes("Cannot open output file: "); + writes(*argv); + writes("\n"); exit(2); } -- 2.34.1