1 MODULE LinTermios ["libc.so.90"];
3 (*
4 A. V. Shiryaev, 2012.11, 2013.08, 2015.09
6 OpenBSD 6.2
7 32-bit
8 *)
10 CONST
11 VEOF* = 0; (* ICANON *)
12 VEOL* = 1; (* ICANON *)
13 VERASE* = 3; (* ICANON *)
14 VKILL* = 5; (* ICANON *)
15 VINTR* = 8; (* ISIG *)
16 VQUIT* = 9; (* ISIG *)
17 VSUSP* = 10; (* ISIG *)
18 VSTART* = 12; (* IXON, IXOFF *)
19 VSTOP* = 13; (* IXON, IXOFF *)
20 VMIN* = 16; (* !ICANON *)
21 VTIME* = 17; (* !ICANON *)
22 NCCS* = 20;
23 IGNBRK* = 00000001H; (* {0} *) (* ignore BREAK condition *)
24 BRKINT* = 00000002H; (* {1} *) (* map BREAK to SIGINT *)
25 IGNPAR* = 00000004H; (* {2} *) (* ignore (discard) parity errors *)
26 PARMRK* = 00000008H; (* {3} *) (* mark parity and framing errors *)
27 INPCK* = 00000010H; (* {4} *) (* enable checking of parity errors *)
28 ISTRIP* = 00000020H; (* {5} *) (* strip 8th bit off chars *)
29 INLCR* = 00000040H; (* {6} *) (* map NL into CR *)
30 IGNCR* = 00000080H; (* {7} *) (* ignore CR *)
31 ICRNL* = 00000100H; (* {8} *) (* map CR to NL (ala CRMOD) *)
32 IXON* = 00000200H; (* {9} *) (* enable output flow control *)
33 IXOFF* = 00000400H; (* {10} *) (* enable input flow control *)
34 OPOST* = 00000001H; (* {0} *) (* enable following output processing *)
35 CSIZE* = 00000300H; (* {8,9} *) (* character size mask *)
36 CS5* = 00000000H; (* {} *) (* 5 bits (pseudo) *)
37 CS6* = 00000100H; (* {8} *) (* 6 bits *)
38 CS7* = 00000200H; (* {9} *) (* 7 bits *)
39 CS8* = 00000300H; (* {8,9} *) (* 8 bits *)
40 CSTOPB* = 00000400H; (* {10} *) (* send 2 stop bits *)
41 CREAD* = 00000800H; (* {11} *) (* enable receiver *)
42 PARENB* = 00001000H; (* {12} *) (* parity enable *)
43 PARODD* = 00002000H; (* {13} *) (* odd parity, else even *)
44 HUPCL* = 00004000H; (* {14} *) (* hang up on last close *)
45 CLOCAL* = 00008000H; (* {15} *) (* ignore modem status lines *)
46 ECHOE* = 00000002H; (* {1} *) (* visually erase chars *)
47 ECHOK* = 00000004H; (* {2} *) (* echo NL after line kill *)
48 ECHO* = 00000008H; (* {3} *) (* enable echoing *)
49 ECHONL* = 00000010H; (* {4} *) (* echo NL even if ECHO is off *)
50 ISIG* = 00000080H; (* {7} *) (* enable signals INTR, QUIT, [D]SUSP *)
51 ICANON* = 00000100H; (* {8} *) (* canonicalize input lines *)
52 IEXTEN* = 00000400H; (* {10} *) (* enable DISCARD and LNEXT *)
53 EXTPROC* = 00000800H; (* {11} *) (* external processing *)
54 TOSTOP* = 00400000H; (* {22} *) (* stop background jobs from output *)
55 NOFLSH* = 80000000H; (* {31} *) (* don't flush after interrupt *)
56 TCSANOW* = 0; (* make change immediate *)
57 TCSADRAIN* = 1; (* drain output, then change *)
58 TCSAFLUSH* = 2; (* drain output, flush input *)
59 B0* = 0;
60 B50* = 50;
61 B75* = 75;
62 B110* = 110;
63 B134* = 134;
64 B150* = 150;
65 B200* = 200;
66 B300* = 300;
67 B600* = 600;
68 B1200* = 1200;
69 B1800* = 1800;
70 B2400* = 2400;
71 B4800* = 4800;
72 B9600* = 9600;
73 B19200* = 19200;
74 B38400* = 38400;
75 VEOL2* = 2; (* ICANON *)
76 VWERASE* = 4; (* ICANON *)
77 VREPRINT* = 6; (* ICANON *)
78 VDSUSP* = 11; (* ISIG *)
79 VLNEXT* = 14; (* IEXTEN *)
80 VDISCARD* = 15; (* IEXTEN *)
81 VSTATUS* = 18; (* ICANON *)
82 IXANY* = 00000800H; (* {11} *) (* any char will restart after stop *)
83 IUCLC* = 00001000H; (* {12} *) (* translate upper to lower case *)
84 IMAXBEL* = 00002000H; (* {13} *) (* ring bell on input queue full *)
85 ONLCR* = 00000002H; (* {1} *) (* map NL to CR-NL (ala CRMOD) *)
86 OXTABS* = 00000004H; (* {2} *) (* expand tabs to spaces *)
87 ONOEOT* = 00000008H; (* {3} *) (* discard EOT's (^D) on output *)
88 OCRNL* = 00000010H; (* {4} *) (* map CR to NL *)
89 OLCUC* = 00000020H; (* {5} *) (* translate lower case to upper case *)
90 ONOCR* = 00000040H; (* {6} *) (* No CR output at column 0 *)
91 ONLRET* = 00000080H; (* {7} *) (* NL performs the CR function *)
92 CIGNORE* = 00000001H; (* {0} *) (* ignore control flags *)
93 CRTSCTS* = 00010000H; (* {16} *) (* RTS/CTS full-duplex flow control *)
94 MDMBUF* = 00100000H; (* {20} *) (* DTR/DCD hardware flow control *)
95 ECHOKE* = 00000001H; (* {0} *) (* visual erase for line kill *)
96 ECHOPRT* = 00000020H; (* {5} *) (* visual erase mode for hardcopy *)
97 ECHOCTL* = 00000040H; (* {6} *) (* echo control chars as ^(Char) *)
98 ALTWERASE* = 00000200H; (* {9} *) (* use alternate WERASE algorithm *)
99 FLUSHO* = 00800000H; (* {23} *) (* output being flushed (state) *)
100 XCASE* = 01000000H; (* {24} *) (* canonical upper/lower case *)
101 NOKERNINFO* = 02000000H; (* {25} *) (* no kernel output from VSTATUS *)
102 PENDIN* = 20000000H; (* {29} *) (* XXX retype pending input (state) *)
103 TCSASOFT* = 10H; (* {4} *) (* flag - don't alter h.w. state *)
104 B7200* = 7200;
105 B14400* = 14400;
106 B28800* = 28800;
107 B57600* = 57600;
108 B76800* = 76800;
109 B115200* = 115200;
110 B230400* = 230400;
111 EXTA* = 19200;
112 EXTB* = 38400;
113 TCIFLUSH* = 1;
114 TCOFLUSH* = 2;
115 TCIOFLUSH* = 3;
116 TCOOFF* = 1;
117 TCOON* = 2;
118 TCIOFF* = 3;
119 TCION* = 4;
121 TYPE
122 tcflag_t* = INTEGER; (* unsigned int *)
123 cc_t* = SHORTCHAR; (* unsigned char *)
124 speed_t* = INTEGER; (* unsigned int *)
125 termios* = RECORD [untagged]
126 c_iflag*: tcflag_t; (* input flags *)
127 c_oflag*: tcflag_t; (* output flags *)
128 c_cflag*: tcflag_t; (* control flags *)
129 c_lflag*: tcflag_t; (* local flags *)
130 c_cc*: ARRAY [untagged] NCCS OF cc_t; (* control chars *)
131 c_ispeed*: INTEGER; (* input speed *)
132 c_ospeed*: INTEGER; (* output speed *)
133 END;
135 (* POSIX.1 *)
136 PROCEDURE [ccall] cfgetispeed* (VAR tp: termios): speed_t;
137 PROCEDURE [ccall] cfsetispeed* (VAR tp: termios; ispeed: speed_t): INTEGER;
138 PROCEDURE [ccall] cfgetospeed* (VAR tp: termios): speed_t;
139 PROCEDURE [ccall] cfsetospeed* (VAR tp: termios; ospeed: speed_t): INTEGER;
140 PROCEDURE [ccall] tcgetattr* (fd: INTEGER; VAR tp: termios): INTEGER;
141 PROCEDURE [ccall] tcsetattr* (fd: INTEGER; action: INTEGER; VAR tp: termios): INTEGER;
143 PROCEDURE [ccall] tcdrain* (fd: INTEGER): INTEGER;
144 PROCEDURE [ccall] tcflow* (fd: INTEGER; action: INTEGER): INTEGER;
145 PROCEDURE [ccall] tcflush* (fd: INTEGER; action: INTEGER): INTEGER;
146 PROCEDURE [ccall] tcsendbreak* (fd: INTEGER; len: INTEGER): INTEGER;
148 (* extensions *)
149 (*
150 PROCEDURE [ccall] cfsetspeed* (VAR tp: termios; speed: speed_t): INTEGER;
151 PROCEDURE [ccall] cfmakeraw* (VAR tp: termios);
152 *)
154 END LinTermios.