Usermode - POSIX and C conformance changes
[tpg/acess2.git] / Usermode / Libraries / libposix.so_src / include_exp / termios.h
1 /*
2  * Acess2 POSIX Emulation
3  * - By John Hodge (thePowersGang)
4  *
5  * termios.h
6  * - Terminal Control
7  */
8 #ifndef _LIBPOSIX__TERMIOS_H_
9 #define _LIBPOSIX__TERMIOS_H_
10
11 typedef unsigned char   cc_t;
12 typedef unsigned long   speed_t;
13 typedef unsigned short  tcflag_t;
14
15 // c_iflag
16 #define IGNBRK  (1 << 0)
17 #define BRKINT  (1 << 1)
18 #define IGNPAR  (1 << 2)        // Ignore parity failures
19 #define PARMRK  (1 << 3)        // Mark parity failures with FFh 00h
20 #define INPCK   (1 << 4)        // Enable input parity checks
21 #define ISTRIP  (1 << 5)        // strip 8th bit
22 #define INLCR   (1 << 6)        // Translate input newline into CR
23 #define IGNCR   (1 << 7)        // Ignore input CR
24 #define ICRNL   (1 << 8)        // Translate input CR into NL
25 // (Linux) IUCLC        // Map upper to lower case
26 #define IXON    (1 <<10)        // Enable input XON/XOFF
27 #define IXANY   (1 <<11)        // Any character will restart input
28 #define IXOFF   IXON
29 // (Linux) IMAXBEL
30 // (Linux) IUTF8
31
32 // c_oflag
33 #define OPOST   (1 << 0)        // Output processing
34 // (Linux) OLCUC
35 #define ONLCR   (1 << 2)        // (XSI) NL->CR
36 #define OCRNL   (1 << 3)        // CR->NL
37 #define ONOCR   (1 << 4)        // Don't output CR at column 0
38 #define ONLRET  (1 << 5)        // Don't output CR
39 #define OFILL   (1 << 6)        // Send fill chars for a delay, instead of timing
40 // (Linux) OFDEL
41 #define NLDLY   (1 << 8)        // Newline delay mask (NL0/NL1)
42 #define NL0     (0 << 8)
43 #define NL1     (1 << 8)
44 #define NCDLY   (3 << 9)        // Carriage return delay mask (CR0-CR3)
45 #define CR0     (0 << 9)
46 #define CR1     (1 << 9)
47 #define CR2     (2 << 9)
48 #define CR3     (3 << 9)
49 #define TABDLY  (3 << 11)       // Horizontal tab delay mask
50 #define TAB0    (0 << 11)
51 #define TAB1    (1 << 11)
52 #define TAB2    (2 << 11)
53 #define TAB3    (3 << 11)
54 #define BSDLY   (1 << 13)       // Backspace delay
55 #define BS0     (0 << 13)
56 #define BS1     (1 << 13)
57 #define VTDLY   (1 << 14)       // Vertical tab delay
58 #define VT0     (0 << 14)
59 #define VT1     (1 << 14)
60 #define FFDLY   (1 << 15)       // Form feed delay
61 #define FF0     (0 << 15)
62 #define VFF1    (1 << 15)
63
64 // c_cflag
65 #define CBAUD   (037 << 0)      // Baud speed
66 #define CSIZE   (3 << 5)        // Character size mask
67 #define CS5     (0 << 5)
68 #define CS6     (1 << 5)
69 #define CS7     (2 << 5)
70 #define CS8     (3 << 5)
71 #define CSTOPB  (1 << 7)        // 1/2 stop bits
72 #define CREAD   (1 << 8)        // Enable receiver
73 #define PARENB  (1 << 9)        // Enable parity generation / checking
74 #define PARODD  (1 << 10)       // Odd parity
75 #define HUPCL   (1 << 11)       // Hang up on close
76 #define CLOCAL  (1 << 12)       // Ignore modem control lines
77 // LOBLK
78 // CIBAUD
79 // CMSPAR
80 // CRTSCTS
81
82 // c_lflag
83 #define ISIG    (1 << 0)        // Generate signals for INTR, QUIT, SUSP and DSUSP
84 #define ICANON  (1 << 1)        // Input canonical mode
85 // XCASE
86 #define ECHO    (1 << 3)        // Echo input characters
87 #define ECHOE   (1 << 4)        // Enable ERASE and WERASE on echoed input [ICANON]
88 #define ECHOK   (1 << 5)        // Enable KILL char on echoed input [ICANON]
89 #define ECHONL  (1 << 6)        // Echo NL even if ECHO is unset [ICANON]
90 #define ECHOCTL (1 << 7)        // (non-POSIX) If ECHO set specials are echoed as val+0x40 (BS=^H)
91 // ECHOPRT
92 #define ECHOKE  (1 << 9)        // (non-POSIX) KILL implimented by sequential erase [ICANON]
93 // DEFECHO
94 // FLUSHO
95 #define NOFLSH  (1 << 11)       // Disable flush of IO when generating INT, QUIT and SUSP
96 #define TOSTOP  (1 << 12)       // ?
97 // PENDIN
98 #define IEXTEN  (1 << 14)
99
100 // - Indexes for c_cc
101 enum
102 {
103         VDISCARD,
104         VDSUSP,
105         VEOF,
106         VEOL,
107         VEOL2,
108         VERASE,
109         VINTR,
110         VKILL,
111         VLNEXT,
112         VMIN,
113         VQUIT,
114         // VREPRINT, // (non-POSIX)
115         VSTART,
116         // VSTATUS, // (non-POSIX)
117         VSTOP,
118         VSUSP,
119         // VSWITCH, // (non-POSIX)
120         VTIME,
121         VWERASE,
122         NCCS
123 };
124
125 struct termios
126 {
127         tcflag_t        c_iflag;
128         tcflag_t        c_oflag;
129         tcflag_t        c_cflag;
130         tcflag_t        c_lflag;
131         cc_t    c_cc[NCCS];
132 };
133
134 extern int tcgetattr(int fd, struct termios *termios_p);
135
136 #define TCSANOW         0x01
137 #define TCSADRAIN       0x02
138 #define TCSAFLUSH       0x04
139 extern int tcsetattr(int fd, int optional_actions, const struct termios *termios_p);
140
141 // ioctl() calls for terminals
142 enum
143 {
144         TIOCGWINSZ,
145         TIOCSWINSZ
146 };
147
148 struct winsize {
149         unsigned short ws_row;
150         unsigned short ws_col;
151         unsigned short ws_xpixel;   /* unused */
152         unsigned short ws_ypixel;   /* unused */
153 };
154
155
156 #endif
157

UCC git Repository :: git.ucc.asn.au