- Added a minimal replacement for tee.

- Some other miscellaneous cleanup.

svn path=/trunk/tools/RosBE-Windows/; revision=451
This commit is contained in:
Peter Ward 2007-10-25 07:14:03 +00:00
parent a0cc28d81c
commit 00440394ce
5 changed files with 84 additions and 12 deletions

View File

@ -82,9 +82,7 @@ int main()
}
CommandLineBuffer[0] = 0;
//strcat(CommandLineBuffer, "\"");
strcat(CommandLineBuffer, CommandLine);
//strcat(CommandLineBuffer, "\"");
//
// Grab the starting timestamp.

View File

@ -25,7 +25,7 @@ int main(int argc, char* argv[])
if (argc > 3)
{
printf("%s: Error too many parameters specified.\n", argv[0]);
fprintf(stderr, "%s: Error too many parameters specified.\n", argv[0]);
return -1;
}
if ((argc == 1) ||
@ -43,19 +43,20 @@ int main(int argc, char* argv[])
FILE1 = fopen(argv[1], "r");
if (!FILE1)
{
printf("%s: Error file \"%s\" doesn't seem to exist.\n", argv[0], argv[1]);
fprintf(stderr, "%s: Error file \"%s\" doesn't seem to exist.\n", argv[0], argv[1]);
return -1;
}
else
{
if (fclose(FILE1))
{
printf("%s: Error closing file \"%s\"\n", argv[0], argv[1]);
fprintf(stderr, "%s: Error closing file \"%s\"\n", argv[0], argv[1]);
return -1;
}
file1time = getfmodtime(argv[1]);
if (!file1time)
{
printf("%s: Error unable to aquire stats for file: %s\n", argv[0], argv[1]);
fprintf(stderr, "%s: Error unable to aquire stats for file: %s\n", argv[0], argv[1]);
return -1;
}
}
@ -63,19 +64,20 @@ int main(int argc, char* argv[])
FILE2 = fopen(argv[2], "r");
if (!FILE2)
{
printf("%s: Error file \"%s\" doesn't seem to exist.\n", argv[0], argv[2]);
fprintf(stderr, "%s: Error file \"%s\" doesn't seem to exist.\n", argv[0], argv[2]);
return -1;
}
else
{
if (fclose(FILE2))
{
printf("%s: Error closing file \"%s\"\n", argv[0], argv[2]);
fprintf(stderr, "%s: Error closing file \"%s\"\n", argv[0], argv[2]);
return -1;
}
file2time = getfmodtime(argv[2]);
if (!file2time)
{
printf("%s: Error unable to aquire stats for file: %s\n", argv[0], argv[2]);
fprintf(stderr, "%s: Error unable to aquire stats for file: %s\n", argv[0], argv[2]);
return -1;
}
}

View File

@ -17,7 +17,7 @@ int main(int argc, char* argv[])
if (argc > 2)
{
printf("%s: Error too many parameters specified.\n", argv[0]);
fprintf(stderr, "%s: Error too many parameters specified.\n", argv[0]);
return -1;
}
if ((argc == 1) ||

View File

@ -7,7 +7,7 @@ CFLAGS := ${HOST_CFLAGS} -Wall -O2 -o
LFLAGS := -s
WINVER := 0x502
all: buildtime chknewer chkslash cpucount echoh flash getdate
all: buildtime chknewer chkslash cpucount echoh flash getdate tee
buildtime: buildtime.c
${CC} ${CFLAGS} buildtime buildtime.c
@ -30,5 +30,8 @@ flash: flash.c
getdate: getdate.c
${CC} ${CFLAGS} getdate getdate.c
tee: tee.c
${CC} ${CFLAGS} tee tee.c
clean:
del /f buildtime.exe chknewer.exe chkslash.exe cpucount.exe echoh.exe flash.exe getdate.exe
del /f buildtime.exe chknewer.exe chkslash.exe cpucount.exe echoh.exe flash.exe getdate.exe tee.exe

69
RosBE-Windows/Tools/tee.c Normal file
View File

@ -0,0 +1,69 @@
/*
* PROJECT: RosBE - ReactOS Build Environment for Windows.
* LICENSE: GPL - See LICENSE.txt in the top level directory.
* FILE: Tools/tee.c
* PURPOSE: Spit stdin to stdout and a file.
* COPYRIGHT: Copyright 2007 Peter Ward <dralnix@gmail.com>
*
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
unsigned char charbuff;
FILE *FILE;
if (argc > 2)
{
fprintf(stderr, "%s: Error too many parameters specified.\n", argv[0]);
return -1;
}
if ((argc == 1) ||
(!strncmp(argv[1], "/?", 2)) ||
(!strncmp(argv[1], "-h", 2)) ||
(!strncmp(argv[1], "--help", 6)))
{
printf("Usage: %s FILE\n", argv[0]);
printf("Takes standard input and sends it to standard output\n");
printf("and FILE.\n\n");
return 0;
}
FILE = fopen(argv[1], "r");
if (FILE)
{
fprintf(stderr, "%s: Error file \"%s\" already exists.\n", argv[0], argv[1]);
if (fclose(FILE))
{
fprintf(stderr, "%s: Error closing file \"%s\"\n", argv[0], argv[1]);
}
return -1;
}
else
{
FILE = fopen(argv[1], "w");
if (!FILE)
{
fprintf(stderr, "%s: Error cannot create file \"%s\".\n", argv[0], argv[1]);
return -1;
}
while (!feof(stdin))
{
charbuff = fgetc(stdin);
if (!feof(stdin))
{
fputc(charbuff, stdout);
fputc(charbuff, FILE);
}
}
if (fclose(FILE))
{
fprintf(stderr, "%s: Error closing file \"%s\"\n", argv[0], argv[1]);
return -1;
}
}
return 0;
}