TaggedOpenLibrary constants off by one fix.
[AROS.git] / test / consolemodes.c
blob0ba170813ba0488c50e7679c7dcf9622ccb97b3b
1 #include <exec/types.h>
2 #include <proto/exec.h>
3 #include <proto/dos.h>
4 #include <dos/filesystem.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <ctype.h>
9 int main(int argc, char **argv) {
10 BPTR in, out;
11 TEXT something[64];
12 int i;
13 struct IOFileSys iofs;
14 struct FileHandle *fh;
16 in = Input();
17 out = Output();
19 SetMode(in, 0);
21 Printf("in normal (cooked) mode\n");
22 Printf("type something: ");
23 Flush(out);
25 FGets(out, something, 64);
26 *(strchr(something, '\n')) = '\0';
28 Printf("you typed: %s\n", something);
30 SetMode(in, 1);
32 Printf("in raw mode\n");
33 Printf("type something: ");
34 Flush(out);
36 something[63] = '\0';
37 i = 0;
38 while (i < 63) {
39 WaitForChar(in, 0);
40 Read(in, &(something[i]), 1);
41 if (something[i] == 0x0d) {
42 something[i] = '\0';
43 break;
45 if (! isprint(something[i]))
46 continue;
47 i++;
50 Printf("\nyou typed: %s\n", something);
52 #ifdef AROS_DOS_PACKETS
53 /* TODO: Switch to cooked mode */
54 #else
55 fh = (struct FileHandle *) in;
57 iofs.IOFS.io_Message.mn_Node.ln_Type = NT_REPLYMSG;
58 iofs.IOFS.io_Message.mn_ReplyPort = &(((struct Process *) FindTask(NULL))->pr_MsgPort);
59 iofs.IOFS.io_Message.mn_Length = sizeof(struct IOFileSys);
61 iofs.IOFS.io_Device = fh->fh_Device;
62 iofs.IOFS.io_Unit = fh->fh_Unit;
63 iofs.IOFS.io_Command = FSA_CONSOLE_MODE;
64 iofs.IOFS.io_Flags = 0;
66 iofs.io_Union.io_CONSOLE_MODE.io_ConsoleMode = FCM_NOECHO;
68 DoIO(&(iofs.IOFS));
69 #endif
71 Printf("in cooked mode with no echoing\n");
72 Printf("type something: ");
73 Flush(out);
75 FGets(out, something, 64);
76 *(strchr(something, '\n')) = '\0';
78 Printf("you typed: %s\n", something);
80 SetMode(in, 0);
82 Printf("restored normal (cooked) mode\n");
84 return 0;