/*++ Copyright (c) 1991 Microsoft Corporation Module Name: tee.c Abstract: Utility program to read stdin and write it to stdout and a file. Author: Steve Wood (stevewo) 01-Feb-1992 Revision History: --*/ #include #include #include #include #include #include void Usage() { printf("Usage: tee [-a] OutputFileName(s)...\n" ); exit(1); } #define MAX_OUTPUT_FILES 8 __cdecl main( argc, argv ) int argc; char *argv[]; { int i, c; char *s, *OpenFlags; int NumberOfOutputFiles; FILE *OutputFiles[ MAX_OUTPUT_FILES ]; if (argc < 2) { Usage(); } NumberOfOutputFiles = 0; OpenFlags = "wb"; for (i=1; i= MAX_OUTPUT_FILES) { fprintf( stderr, "TEE: too many output files specified - %s\n", s ); } else if (!(OutputFiles[NumberOfOutputFiles] = fopen( s, OpenFlags ))) { fprintf( stderr, "TEE: unable to open file - %s\n", s ); } else { NumberOfOutputFiles++; } } if (NumberOfOutputFiles == 0) { fprintf( stderr, "TEE: no output files specified.\n" ); } while ((c = getchar()) != EOF) { putchar( c ); for (i=0; i