migrate substitution keywords to SVN
[reactos.git] / reactos / subsys / system / cmd / echo.c
1 /* $Id$
2 *
3 * ECHO.C - internal echo commands.
4 *
5 *
6 * History:
7 *
8 * 16 Jul 1998 (Hans B Pufal)
9 * Started.
10 *
11 * 16 Jul 1998 (John P Price)
12 * Separated commands into individual files.
13 *
14 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
15 * Added config.h include
16 *
17 * 08-Dec-1998 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
18 * Added help text ("/?").
19 *
20 * 19-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
21 * Unicode and redirection ready!
22 *
23 * 13-Jul-2000 (Eric Kohl <ekohl@rz-online.de>)
24 * Implemented 'echo.' and 'echoerr.'.
25 */
26
27 #include "precomp.h"
28
29
30 INT CommandEcho (LPTSTR cmd, LPTSTR param)
31 {
32 #ifdef _DEBUG
33 DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);
34 #endif
35
36 if (!_tcsncmp (param, _T("/?"), 2))
37 {
38 ConOutPuts (_T("Displays a message or switches command echoing on or off.\n"
39 "\n"
40 " ECHO [ON | OFF]\n"
41 " ECHO [message]\n"
42 " ECHO. prints an empty line\n"
43 "\n"
44 "Type ECHO without a parameter to display the current ECHO setting."));
45 return 0;
46 }
47
48 if (_tcsicmp (cmd, _T("echo.")) == 0)
49 {
50 if (param[0] == 0)
51 ConOutChar (_T('\n'));
52 else
53 ConOutPuts (param);
54 }
55 else
56 {
57 if (_tcsicmp (param, D_OFF) == 0)
58 bEcho = FALSE;
59 else if (_tcsicmp (param, D_ON) == 0)
60 bEcho = TRUE;
61 else if (*param)
62 ConOutPuts (param);
63 else
64 ConOutPrintf (_T("ECHO is %s\n"), bEcho ? D_ON : D_OFF);
65 }
66
67 return 0;
68 }
69
70 INT CommandEchos (LPTSTR cmd, LPTSTR param)
71 {
72 #ifdef _DEBUG
73 DebugPrintf (_T("CommandEchos '%s' : '%s'\n"), cmd, param);
74 #endif
75
76 if (!_tcsncmp (param, _T("/?"), 2))
77 {
78 ConOutPuts (_T("Display a messages without trailing carridge return and line feed.\n"
79 "\n"
80 " ECHOS message"));
81 return 0;
82 }
83
84 if (*param)
85 ConOutPrintf (_T("%s"), param);
86
87 return 0;
88 }
89
90
91 INT CommandEchoerr (LPTSTR cmd, LPTSTR param)
92 {
93 #ifdef _DEBUG
94 DebugPrintf (_T("CommandEchoerr '%s' : '%s'\n"), cmd, param);
95 #endif
96
97 if (!_tcsncmp (param, _T("/?"), 2))
98 {
99 ConOutPuts (_T("Displays a message to the standard error.\n"
100 "\n"
101 " ECHOERR message\n"
102 " ECHOERR. prints an empty line"));
103 return 0;
104 }
105
106 if (_tcsicmp (cmd, _T("echoerr.")) == 0)
107 {
108 if (param[0] == 0)
109 ConErrChar (_T('\n'));
110 else
111 ConErrPuts (param);
112 }
113 else if (*param)
114 {
115 ConErrPuts (param);
116 }
117
118 return 0;
119 }
120
121 INT CommandEchoserr (LPTSTR cmd, LPTSTR param)
122 {
123 #ifdef _DEBUG
124 DebugPrintf (_T("CommandEchoserr '%s' : '%s'\n"), cmd, param);
125 #endif
126
127 if (!_tcsncmp (param, _T("/?"), 2))
128 {
129 ConOutPuts (_T("Prints a messages to standard error output without trailing carridge return and line feed.\n"
130 "\n"
131 " ECHOSERR message"));
132 return 0;
133 }
134
135 if (*param)
136 ConOutPrintf (_T("%s"), param);
137
138 return 0;
139 }
140
141 /* EOF */