start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / test / consolemodes.c
blob3dd3fa1da8bf63cec0b749aee7cda7e255bb291d
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/types.h>
7 #include <proto/exec.h>
8 #include <proto/dos.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <ctype.h>
13 int main(int argc, char **argv) {
14 BPTR in, out;
15 TEXT something[64];
16 int i;
18 in = Input();
19 out = Output();
21 SetMode(in, 0);
23 Printf("in normal (cooked) mode\n");
24 Printf("type something: ");
25 Flush(out);
27 FGets(out, something, 64);
28 *(strchr(something, '\n')) = '\0';
30 Printf("you typed: %s\n", something);
32 SetMode(in, 1);
34 Printf("in raw mode\n");
35 Printf("type something: ");
36 Flush(out);
38 something[63] = '\0';
39 i = 0;
40 while (i < 63) {
41 WaitForChar(in, 1000000000);
42 Read(in, &(something[i]), 1);
43 if (something[i] == 0x0d) {
44 something[i] = '\0';
45 break;
47 if (! isprint(something[i]))
48 continue;
49 i++;
52 Printf("\nyou typed: %s\n", something);
54 /* TODO: Switch to cooked mode */
56 Printf("in cooked mode with no echoing\n");
57 Printf("type something: ");
58 Flush(out);
60 FGets(out, something, 64);
61 *(strchr(something, '\n')) = '\0';
63 Printf("you typed: %s\n", something);
65 SetMode(in, 0);
67 Printf("restored normal (cooked) mode\n");
69 return 0;