2006-02-16 23:23:37 +00:00
|
|
|
/*
|
|
|
|
* ECHO.C - internal echo commands.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
*
|
|
|
|
* 16 Jul 1998 (Hans B Pufal)
|
|
|
|
* Started.
|
|
|
|
*
|
|
|
|
* 16 Jul 1998 (John P Price)
|
|
|
|
* Separated commands into individual files.
|
|
|
|
*
|
|
|
|
* 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
|
|
|
|
* Added config.h include
|
|
|
|
*
|
2007-05-05 11:32:25 +00:00
|
|
|
* 08-Dec-1998 (Eric Kohl)
|
2006-02-16 23:23:37 +00:00
|
|
|
* Added help text ("/?").
|
|
|
|
*
|
2007-05-05 11:32:25 +00:00
|
|
|
* 19-Jan-1999 (Eric Kohl)
|
2006-02-16 23:23:37 +00:00
|
|
|
* Unicode and redirection ready!
|
|
|
|
*
|
2007-05-05 11:32:25 +00:00
|
|
|
* 13-Jul-2000 (Eric Kohl)
|
2006-02-16 23:23:37 +00:00
|
|
|
* Implemented 'echo.' and 'echoerr.'.
|
|
|
|
*
|
2013-06-30 13:23:30 +00:00
|
|
|
* 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
|
2013-06-30 00:08:43 +00:00
|
|
|
* Remove all hardcoded strings in En.rc
|
2006-02-16 23:23:37 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2009-03-26 01:14:25 +00:00
|
|
|
BOOL
|
|
|
|
OnOffCommand(LPTSTR param, LPBOOL flag, INT message)
|
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TCHAR *p2;
|
|
|
|
if (_tcsnicmp(param, D_OFF, sizeof(D_OFF)/sizeof(TCHAR) - 1) == 0)
|
|
|
|
{
|
|
|
|
p2 = param + sizeof(D_OFF)/sizeof(TCHAR) - 1;
|
|
|
|
while (_istspace(*p2))
|
|
|
|
p2++;
|
|
|
|
if (*p2 == _T('\0'))
|
|
|
|
{
|
|
|
|
*flag = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (_tcsnicmp(param, D_ON, sizeof(D_ON)/sizeof(TCHAR) - 1) == 0)
|
|
|
|
{
|
|
|
|
p2 = param + sizeof(D_ON)/sizeof(TCHAR) - 1;
|
|
|
|
while (_istspace(*p2))
|
|
|
|
p2++;
|
|
|
|
if (*p2 == _T('\0'))
|
|
|
|
{
|
|
|
|
*flag = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*param == _T('\0'))
|
|
|
|
{
|
|
|
|
ConOutResPrintf(message, *flag ? D_ON : D_OFF);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2009-03-26 01:14:25 +00:00
|
|
|
}
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandEcho (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
LPTSTR p1;
|
|
|
|
|
|
|
|
TRACE ("CommandEcho: '%s'\n", debugstr_aw(param));
|
|
|
|
|
|
|
|
/* skip all spaces for the check of '/?', 'ON' and 'OFF' */
|
|
|
|
p1 = param;
|
|
|
|
while(_istspace(*p1))
|
|
|
|
p1++;
|
|
|
|
|
|
|
|
if (!_tcsncmp (p1, _T("/?"), 2))
|
|
|
|
{
|
|
|
|
ConOutResPaging(TRUE,STRING_ECHO_HELP4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!OnOffCommand(p1, &bEcho, STRING_ECHO_HELP5))
|
|
|
|
{
|
|
|
|
/* skip the first character */
|
|
|
|
ConOutPuts(param + 1);
|
2013-07-02 23:07:15 +00:00
|
|
|
ConOutChar(_T('\n'));
|
2013-06-30 00:08:43 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandEchos (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TRACE ("CommandEchos: '%s'\n", debugstr_aw(param));
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
if (!_tcsncmp (param, _T("/?"), 2))
|
|
|
|
{
|
|
|
|
ConOutResPuts(STRING_ECHO_HELP1);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
ConOutPrintf (_T("%s"), param);
|
|
|
|
return 0;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandEchoerr (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TRACE ("CommandEchoerr: '%s'\n", debugstr_aw(param));
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
if (!_tcsncmp (param, _T("/?"), 2))
|
|
|
|
{
|
|
|
|
ConOutResPuts(STRING_ECHO_HELP2);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrPuts (param);
|
|
|
|
return 0;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-25 23:22:03 +00:00
|
|
|
INT CommandEchoserr (LPTSTR param)
|
2006-02-16 23:23:37 +00:00
|
|
|
{
|
2013-06-30 00:08:43 +00:00
|
|
|
TRACE ("CommandEchoserr: '%s'\n", debugstr_aw(param));
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
if (!_tcsncmp (param, _T("/?"), 2))
|
|
|
|
{
|
|
|
|
ConOutResPuts(STRING_ECHO_HELP3);
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-16 23:23:37 +00:00
|
|
|
|
2013-06-30 00:08:43 +00:00
|
|
|
ConErrPrintf (_T("%s"), param);
|
|
|
|
return 0;
|
2006-02-16 23:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|