2004-08-16 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / subsys / system / cmd / echo.c
1 /* $Id: echo.c,v 1.4 2004/08/15 22:15:23 chorns Exp $
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 "config.h"
28
29 #include "precomp.h"
30 #include <tchar.h>
31 #include <string.h>
32
33 #include "batch.h"
34
35
36 INT CommandEcho (LPTSTR cmd, LPTSTR param)
37 {
38 #ifdef _DEBUG
39 DebugPrintf (_T("CommandEcho '%s' : '%s'\n"), cmd, param);
40 #endif
41
42 if (!_tcsncmp (param, _T("/?"), 2))
43 {
44 ConOutPuts (_T("Displays a message or switches command echoing on or off.\n"
45 "\n"
46 " ECHO [ON | OFF]\n"
47 " ECHO [message]\n"
48 " ECHO. prints an empty line\n"
49 "\n"
50 "Type ECHO without a parameter to display the current ECHO setting."));
51 return 0;
52 }
53
54 if (_tcsicmp (cmd, _T("echo.")) == 0)
55 {
56 if (param[0] == 0)
57 ConOutChar (_T('\n'));
58 else
59 ConOutPuts (param);
60 }
61 else
62 {
63 if (_tcsicmp (param, D_OFF) == 0)
64 bEcho = FALSE;
65 else if (_tcsicmp (param, D_ON) == 0)
66 bEcho = TRUE;
67 else if (*param)
68 ConOutPuts (param);
69 else
70 ConOutPrintf (_T("ECHO is %s\n"), bEcho ? D_ON : D_OFF);
71 }
72
73 return 0;
74 }
75
76 INT CommandEchos (LPTSTR cmd, LPTSTR param)
77 {
78 #ifdef _DEBUG
79 DebugPrintf (_T("CommandEchos '%s' : '%s'\n"), cmd, param);
80 #endif
81
82 if (!_tcsncmp (param, _T("/?"), 2))
83 {
84 ConOutPuts (_T("Display a messages without trailing carridge return and line feed.\n"
85 "\n"
86 " ECHOS message"));
87 return 0;
88 }
89
90 if (*param)
91 ConOutPrintf (_T("%s"), param);
92
93 return 0;
94 }
95
96
97 INT CommandEchoerr (LPTSTR cmd, LPTSTR param)
98 {
99 #ifdef _DEBUG
100 DebugPrintf (_T("CommandEchoerr '%s' : '%s'\n"), cmd, param);
101 #endif
102
103 if (!_tcsncmp (param, _T("/?"), 2))
104 {
105 ConOutPuts (_T("Displays a message to the standard error.\n"
106 "\n"
107 " ECHOERR message\n"
108 " ECHOERR. prints an empty line"));
109 return 0;
110 }
111
112 if (_tcsicmp (cmd, _T("echoerr.")) == 0)
113 {
114 if (param[0] == 0)
115 ConErrChar (_T('\n'));
116 else
117 ConErrPuts (param);
118 }
119 else if (*param)
120 {
121 ConErrPuts (param);
122 }
123
124 return 0;
125 }
126
127 INT CommandEchoserr (LPTSTR cmd, LPTSTR param)
128 {
129 #ifdef _DEBUG
130 DebugPrintf (_T("CommandEchoserr '%s' : '%s'\n"), cmd, param);
131 #endif
132
133 if (!_tcsncmp (param, _T("/?"), 2))
134 {
135 ConOutPuts (_T("Prints a messages to standard error output without trailing carridge return and line feed.\n"
136 "\n"
137 " ECHOSERR message"));
138 return 0;
139 }
140
141 if (*param)
142 ConOutPrintf (_T("%s"), param);
143
144 return 0;
145 }
146
147 /* EOF */