2 * PROMPT.C - prompt handling.
7 * 14/01/95 (Tim Normal)
10 * 08/08/95 (Matt Rains)
11 * i have cleaned up the source code. changes now bring this source
12 * into guidelines for recommended programming practice.
14 * 01/06/96 (Tim Norman)
15 * added day of the week printing (oops, forgot about that!)
17 * 08/07/96 (Steffan Kaiser)
18 * small changes for speed
20 * 20-Jul-1998 (John P Price <linux-guru@gcfl.net>)
21 * removed redundant day strings. Use ones defined in date.c.
23 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
24 * added config.h include
26 * 28-Jul-1998 (John P Price <linux-guru@gcfl.net>)
27 * moved cmd_prompt from internal.c to here
29 * 09-Dec-1998 (Eric Kohl)
30 * Added help text ("/?").
32 * 14-Dec-1998 (Eric Kohl)
35 * 09-Jan-1999 (Eric Kohl)
36 * Added "$A", "$C" and "$F" option.
37 * Added locale support.
40 * 20-Jan-1999 (Eric Kohl)
41 * Unicode and redirection safe!
43 * 24-Jan-1999 (Eric Kohl)
44 * Fixed Win32 environment handling.
46 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
47 * Remove all hardcode string to En.rc
52 * print the command-line prompt
54 VOID
PrintPrompt(VOID
)
56 static TCHAR default_pr
[] = _T("$P$G");
60 if (GetEnvironmentVariable (_T("PROMPT"), szPrompt
, 256))
75 switch (_totupper (*pr
))
94 ConOutChar (_T('\x1B'));
102 ConOutChar (_T('>'));
106 ConOutChar (_T('\x08'));
107 ConOutChar (_T(' '));
108 ConOutChar (_T('\x08'));
112 ConOutChar (_T('<'));
117 TCHAR szPath
[MAX_PATH
];
118 GetCurrentDirectory (MAX_PATH
, szPath
);
119 ConOutChar (szPath
[0]);
125 TCHAR szPath
[MAX_PATH
];
126 GetCurrentDirectory (MAX_PATH
, szPath
);
127 ConOutPrintf (_T("%s"), szPath
);
132 ConOutChar (_T('='));
136 ConOutChar (_T(' '));
143 ConOutPrintf(_T("%02d%c%02d%c%02d%c%02d\n"),t
.wHour
, cTimeSeparator
,t
.wMinute
, cTimeSeparator
,
144 t
.wSecond
, cDecimalSeparator
, t
.wMilliseconds
);
149 switch (osvi
.dwPlatformId
)
151 case VER_PLATFORM_WIN32_WINDOWS
:
152 if (osvi
.dwMajorVersion
== 4 &&
153 osvi
.dwMinorVersion
== 1)
154 ConOutPrintf (_T("Windows 98"));
156 ConOutPrintf (_T("Windows 95"));
160 case VER_PLATFORM_WIN32_NT
:
161 ConOutPrintf (_T("Windows NT Version %lu.%lu"),
162 osvi
.dwMajorVersion
, osvi
.dwMinorVersion
);
168 ConOutChar (_T('\n'));
172 ConOutChar (_T('$'));
175 #ifdef FEATURE_DIRECTORY_STACK
179 for (i
= 0; i
< GetDirectoryStackDepth (); i
++)
180 ConOutChar (_T('+'));
191 #ifdef INCLUDE_CMD_PROMPT
193 INT
cmd_prompt (LPTSTR cmd
, LPTSTR param
)
195 if (!_tcsncmp (param
, _T("/?"), 2))
197 ConOutResPaging(TRUE
,STRING_PROMPT_HELP1
);
199 #ifdef FEATURE_DIRECTORY_STACK
200 ConOutResPaging(FALSE
,STRING_PROMPT_HELP2
);
202 ConOutResPaging(FALSE
,STRING_PROMPT_HELP3
);
206 /* if it is null, then it needs to set to default,
207 because that means the user entered "prompt" only.
208 so even if param is null you _must_ still set prompt
209 to the default. There seems to be some kinda difference
210 between winxp and 2k in this matter and this way will
211 cover both. Do not use fixed size of szParam for param the buffer are 8192bytes
212 and will later change to dymatic buffer */
214 /* set PROMPT environment variable */
215 if (param
[0] != _T('\0'))
217 if (!SetEnvironmentVariable (_T("PROMPT"), param
))
223 _tcscpy(szParam
,_T("$P$G"));
224 if (!SetEnvironmentVariable (_T("PROMPT"),szParam
))