| 1 |
(* termios.def provides a procedural interface to termios. |
| 2 |
|
| 3 |
Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE termios ; |
| 28 |
|
| 29 |
FROM SYSTEM IMPORT ADDRESS ; |
| 30 |
|
| 31 |
TYPE |
| 32 |
TERMIOS = ADDRESS ; |
| 33 |
|
| 34 |
ControlChar = (vintr, vquit, verase, vkill, veof, vtime, vmin, |
| 35 |
vswtc, vstart, vstop, vsusp, veol, vreprint, vdiscard, |
| 36 |
vwerase, vlnext, veol2) ; |
| 37 |
|
| 38 |
Flag = ( |
| 39 |
(* input flag bits *) |
| 40 |
ignbrk, ibrkint, ignpar, iparmrk, inpck, istrip, inlcr, |
| 41 |
igncr, icrnl, iuclc, ixon, ixany, ixoff, imaxbel, |
| 42 |
(* output flag bits *) |
| 43 |
opost, olcuc, onlcr, ocrnl, onocr, onlret, ofill, ofdel, |
| 44 |
onl0, onl1, ocr0, ocr1, ocr2, ocr3, |
| 45 |
otab0, otab1, otab2, otab3, obs0, obs1, off0, off1, ovt0, ovt1, |
| 46 |
(* baud rate *) |
| 47 |
b0, b50, b75, b110, b135, b150, b200, b300, b600, b1200, |
| 48 |
b1800, b2400, b4800, b9600, b19200, b38400, |
| 49 |
b57600, b115200, b240400, b460800, b500000, b576000, |
| 50 |
b921600, b1000000, b1152000, b1500000, b2000000, b2500000, |
| 51 |
b3000000, b3500000, b4000000, maxbaud, crtscts, |
| 52 |
(* character size *) |
| 53 |
cs5, cs6, cs7, cs8, cstopb, cread, parenb, parodd, hupcl, clocal, |
| 54 |
(* local flags *) |
| 55 |
lisig, licanon, lxcase, lecho, lechoe, lechok, lechonl, lnoflsh, |
| 56 |
ltopstop, lechoctl, lechoprt, lechoke, lflusho, lpendin, liexten) ; |
| 57 |
|
| 58 |
|
| 59 |
(* |
| 60 |
InitTermios - new data structure. |
| 61 |
*) |
| 62 |
|
| 63 |
PROCEDURE InitTermios () : TERMIOS ; |
| 64 |
|
| 65 |
|
| 66 |
(* |
| 67 |
KillTermios - delete data structure. |
| 68 |
*) |
| 69 |
|
| 70 |
PROCEDURE KillTermios (t: TERMIOS) : TERMIOS ; |
| 71 |
|
| 72 |
|
| 73 |
(* |
| 74 |
cfgetospeed - return output baud rate. |
| 75 |
*) |
| 76 |
|
| 77 |
PROCEDURE cfgetospeed (t: TERMIOS) : INTEGER ; |
| 78 |
|
| 79 |
|
| 80 |
(* |
| 81 |
cfgetispeed - return input baud rate. |
| 82 |
*) |
| 83 |
|
| 84 |
PROCEDURE cfgetispeed (t: TERMIOS) : INTEGER ; |
| 85 |
|
| 86 |
|
| 87 |
(* |
| 88 |
cfsetospeed - set output baud rate. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE cfsetospeed (t: TERMIOS; b: CARDINAL) : INTEGER ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
cfsetispeed - set input baud rate. |
| 96 |
*) |
| 97 |
|
| 98 |
PROCEDURE cfsetispeed (t: TERMIOS; b: CARDINAL) : INTEGER ; |
| 99 |
|
| 100 |
|
| 101 |
(* |
| 102 |
cfsetspeed - set input and output baud rate. |
| 103 |
*) |
| 104 |
|
| 105 |
PROCEDURE cfsetspeed (t: TERMIOS; b: CARDINAL) : INTEGER ; |
| 106 |
|
| 107 |
|
| 108 |
(* |
| 109 |
tcgetattr - get state of, fd, into, t. |
| 110 |
*) |
| 111 |
|
| 112 |
PROCEDURE tcgetattr (fd: INTEGER; t: TERMIOS) : INTEGER ; |
| 113 |
|
| 114 |
|
| 115 |
(* |
| 116 |
The following three functions return the different option values. |
| 117 |
*) |
| 118 |
|
| 119 |
PROCEDURE tcsnow () : INTEGER ; (* alter fd now *) |
| 120 |
PROCEDURE tcsdrain () : INTEGER ; (* alter when all output has been sent *) |
| 121 |
PROCEDURE tcsflush () : INTEGER ; (* like drain, except discard any pending input *) |
| 122 |
|
| 123 |
|
| 124 |
(* |
| 125 |
tcsetattr - set state of, fd, to, t, using option. |
| 126 |
*) |
| 127 |
|
| 128 |
PROCEDURE tcsetattr (fd: INTEGER; option: INTEGER; t: TERMIOS) : INTEGER ; |
| 129 |
|
| 130 |
|
| 131 |
(* |
| 132 |
cfmakeraw - sets, t, to raw mode. |
| 133 |
*) |
| 134 |
|
| 135 |
PROCEDURE cfmakeraw (t: TERMIOS) ; |
| 136 |
|
| 137 |
|
| 138 |
(* |
| 139 |
tcsendbreak - send zero bits for duration. |
| 140 |
*) |
| 141 |
|
| 142 |
PROCEDURE tcsendbreak (fd: INTEGER; duration: INTEGER) : INTEGER ; |
| 143 |
|
| 144 |
|
| 145 |
(* |
| 146 |
tcdrain - waits for pending output to be written on, fd. |
| 147 |
*) |
| 148 |
|
| 149 |
PROCEDURE tcdrain (fd: INTEGER) : INTEGER ; |
| 150 |
|
| 151 |
|
| 152 |
(* |
| 153 |
tcflushi - flush input. |
| 154 |
*) |
| 155 |
|
| 156 |
PROCEDURE tcflushi (fd: INTEGER) : INTEGER ; |
| 157 |
|
| 158 |
|
| 159 |
(* |
| 160 |
tcflusho - flush output. |
| 161 |
*) |
| 162 |
|
| 163 |
PROCEDURE tcflusho (fd: INTEGER) : INTEGER ; |
| 164 |
|
| 165 |
|
| 166 |
(* |
| 167 |
tcflushio - flush input and output. |
| 168 |
*) |
| 169 |
|
| 170 |
PROCEDURE tcflushio (fd: INTEGER) : INTEGER ; |
| 171 |
|
| 172 |
|
| 173 |
(* |
| 174 |
tcflowoni - restart input on, fd. |
| 175 |
*) |
| 176 |
|
| 177 |
PROCEDURE tcflowoni (fd: INTEGER) : INTEGER ; |
| 178 |
|
| 179 |
|
| 180 |
(* |
| 181 |
tcflowoffi - stop input on, fd. |
| 182 |
*) |
| 183 |
|
| 184 |
PROCEDURE tcflowoffi (fd: INTEGER) : INTEGER ; |
| 185 |
|
| 186 |
|
| 187 |
(* |
| 188 |
tcflowono - restart output on, fd. |
| 189 |
*) |
| 190 |
|
| 191 |
PROCEDURE tcflowono (fd: INTEGER) : INTEGER ; |
| 192 |
|
| 193 |
|
| 194 |
(* |
| 195 |
tcflowoffo - stop output on, fd. |
| 196 |
*) |
| 197 |
|
| 198 |
PROCEDURE tcflowoffo (fd: INTEGER) : INTEGER ; |
| 199 |
|
| 200 |
|
| 201 |
(* |
| 202 |
GetFlag - sets a flag value from, t, in, b, and returns TRUE |
| 203 |
if, t, supports, f. |
| 204 |
*) |
| 205 |
|
| 206 |
PROCEDURE GetFlag (t: TERMIOS; f: Flag; VAR b: BOOLEAN) : BOOLEAN ; |
| 207 |
|
| 208 |
|
| 209 |
(* |
| 210 |
SetFlag - sets a flag value in, t, to, b, and returns TRUE if |
| 211 |
this flag value is supported. |
| 212 |
*) |
| 213 |
|
| 214 |
PROCEDURE SetFlag (t: TERMIOS; f: Flag; b: BOOLEAN) : BOOLEAN ; |
| 215 |
|
| 216 |
|
| 217 |
(* |
| 218 |
GetChar - sets a CHAR, ch, value from, t, and returns TRUE if |
| 219 |
this value is supported. |
| 220 |
*) |
| 221 |
|
| 222 |
PROCEDURE GetChar (t: TERMIOS; c: ControlChar; VAR ch: CHAR) : BOOLEAN ; |
| 223 |
|
| 224 |
|
| 225 |
(* |
| 226 |
SetChar - sets a CHAR value in, t, and returns TRUE if, c, |
| 227 |
is supported. |
| 228 |
*) |
| 229 |
|
| 230 |
PROCEDURE SetChar (t: TERMIOS; c: ControlChar; ch: CHAR) : BOOLEAN ; |
| 231 |
|
| 232 |
|
| 233 |
END termios. |