myecho.exe [-fg color] [-bg color] "string to echo"
color can be: blue, red, green, yellow, cyan, violet, pink, black, white
- brightblue, brightred, brightgreen, brightyellow,
+ brightblue, brightred, brightgreen, brightyellow,
brightviolet, brightpink, brightblack, gray, grey, or
brightwhite
Author:
- Scott Gasch (scott@wannabe.guru.org) 22 Aug 2002
+ Scott Gasch (scott@gasch.org) 22 Aug 2002
Revision History:
--*/
-#include <stdlib.h>
+#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
-WORD
+WORD
MakeColor(BOOL fBg, char *sz)
/*++
//
// bright
- //
+ //
if (strstr(sz, "bright"))
{
w = FOREGROUND_INTENSITY;
//
// colors
- //
+ //
if (strstr(sz, "blue"))
{
w |= FOREGROUND_BLUE;
}
-int __cdecl
+int __cdecl
main(int argc, char *argv[])
/*++
--*/
{
- CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+ CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hStdOut;
WORD wAttr;
int x;
//
// open stdout
- //
+ //
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (INVALID_HANDLE_VALUE == hStdOut)
{
GetLastError());
exit(1);
}
-
+
//
- // Save the current text colors.
- //
- if (0 == GetConsoleScreenBufferInfo(hStdOut, &csbiInfo))
+ // Save the current text colors.
+ //
+ if (0 == GetConsoleScreenBufferInfo(hStdOut, &csbiInfo))
{
- fprintf(stderr, "Failed to save current text attr, error=%u\n",
+ fprintf(stderr, "Failed to save current text attr, error=%u\n",
GetLastError());
exit(1);
}
//
// echo the string(s)
- //
+ //
x = 1;
while (x < argc)
{
//
// restore the old text colors
- //
+ //
(void)SetConsoleTextAttribute(hStdOut, csbiInfo.wAttributes);
}