grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / c / Shell / cliPrompt.c
blobc8cb8c2919939fb084053bbd7a636c5f40c21005
1 /*
2 Copyright (C) 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/dos.h>
8 #include <string.h>
10 #include "Shell.h"
12 void cliPrompt(ShellState *ss)
14 struct CommandLineInterface *cli = Cli();
15 BSTR prompt = cli->cli_Prompt;
16 LONG length = AROS_BSTR_strlen(prompt);
17 BPTR output = Output();
18 ULONG i;
20 if (cli->cli_Background)
21 return;
23 for (i = 0; i < length; i++)
25 if (AROS_BSTR_getchar(prompt, i) == '%')
27 if (++i == length)
28 break;
30 switch (AROS_BSTR_getchar(prompt, i))
32 case 'N': case 'n':
33 Printf("%ld", ss->cliNumber);
34 break;
35 case 'R': case 'r':
36 Printf("%ld", cli->cli_ReturnCode);
37 break;
38 case 'S': case 's':
39 FPuts(output, AROS_BSTR_ADDR(cli->cli_SetName));
40 break;
41 default:
42 FPutC(output, '%');
43 FPutC(output, AROS_BSTR_getchar(prompt, i));
44 break;
47 else
48 FPutC(output, AROS_BSTR_getchar(prompt, i));
51 Flush(output);