Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 1 | /* termiosmodule.c -- POSIX terminal I/O module implementation. */ |
| 2 | |
Guido van Rossum | ca6954a | 1999-01-14 19:31:42 +0000 | [diff] [blame] | 3 | #include "Python.h" |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 4 | |
| 5 | #define PyInit_termios inittermios |
| 6 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 7 | #include <termios.h> |
Fred Drake | d3908e2 | 2001-04-05 18:26:31 +0000 | [diff] [blame] | 8 | /* XXX Some systems need this to get all the symbols, while |
| 9 | this breaks for others. |
Fred Drake | 9b3bc49 | 2001-04-04 21:19:26 +0000 | [diff] [blame] | 10 | #include <sys/ioctl.h> |
Fred Drake | d3908e2 | 2001-04-05 18:26:31 +0000 | [diff] [blame] | 11 | */ |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 12 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 13 | static char termios__doc__[] = "\ |
| 14 | This module provides an interface to the Posix calls for tty I/O control.\n\ |
| 15 | For a complete description of these calls, see the Posix or Unix manual\n\ |
| 16 | pages. It is only available for those Unix versions that support Posix\n\ |
| 17 | termios style tty I/O control (and then only if configured at installation\n\ |
| 18 | time).\n\ |
| 19 | \n\ |
| 20 | All functions in this module take a file descriptor fd as their first\n\ |
| 21 | argument. This must be an integer file descriptor, such as returned by\n\ |
| 22 | sys.stdin.fileno().\n\ |
| 23 | \n\ |
| 24 | This module should be used in conjunction with the TERMIOS module,\n\ |
| 25 | which defines the relevant symbolic constants."; |
| 26 | |
| 27 | |
Guido van Rossum | bcc2074 | 1998-08-04 22:53:56 +0000 | [diff] [blame] | 28 | #ifdef __BEOS__ |
| 29 | #include <unistd.h> |
| 30 | #endif |
| 31 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 32 | #define BAD "bad termios argument" |
| 33 | |
| 34 | static PyObject *TermiosError; |
| 35 | |
| 36 | /* termios = tcgetattr(fd) |
| 37 | termios is |
| 38 | [iflag, oflag, cflag, lflag, ispeed, ospeed, [cc[0], ..., cc[NCCS]]] |
| 39 | |
| 40 | Return the attributes of the terminal device. */ |
| 41 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 42 | static char termios_tcgetattr__doc__[] = "\ |
| 43 | tcgetattr(fd) -> list_of_attrs\n\ |
| 44 | Get the tty attributes for file descriptor fd, as follows:\n\ |
| 45 | [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\ |
| 46 | of the tty special characters (each a string of length 1, except the items\n\ |
| 47 | with indices VMIN and VTIME, which are integers when these fields are\n\ |
| 48 | defined). The interpretation of the flags and the speeds as well as the\n\ |
| 49 | indexing in the cc array must be done using the symbolic constants defined\n\ |
| 50 | in the TERMIOS module."; |
| 51 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 52 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 53 | termios_tcgetattr(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 54 | { |
| 55 | int fd; |
| 56 | struct termios mode; |
| 57 | PyObject *cc; |
| 58 | speed_t ispeed, ospeed; |
| 59 | PyObject *v; |
| 60 | int i; |
| 61 | char ch; |
| 62 | |
| 63 | if (!PyArg_Parse(args, "i", &fd)) |
| 64 | return NULL; |
| 65 | |
| 66 | if (tcgetattr(fd, &mode) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 67 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 68 | |
| 69 | ispeed = cfgetispeed(&mode); |
| 70 | ospeed = cfgetospeed(&mode); |
| 71 | |
| 72 | cc = PyList_New(NCCS); |
| 73 | if (cc == NULL) |
| 74 | return NULL; |
| 75 | for (i = 0; i < NCCS; i++) { |
| 76 | ch = (char)mode.c_cc[i]; |
| 77 | v = PyString_FromStringAndSize(&ch, 1); |
| 78 | if (v == NULL) |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 79 | goto err; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 80 | PyList_SetItem(cc, i, v); |
| 81 | } |
| 82 | |
| 83 | /* Convert the MIN and TIME slots to integer. On some systems, the |
| 84 | MIN and TIME slots are the same as the EOF and EOL slots. So we |
| 85 | only do this in noncanonical input mode. */ |
Guido van Rossum | 36dd0d2 | 1996-12-10 15:23:00 +0000 | [diff] [blame] | 86 | if ((mode.c_lflag & ICANON) == 0) { |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 87 | v = PyInt_FromLong((long)mode.c_cc[VMIN]); |
| 88 | if (v == NULL) |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 89 | goto err; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 90 | PyList_SetItem(cc, VMIN, v); |
| 91 | v = PyInt_FromLong((long)mode.c_cc[VTIME]); |
| 92 | if (v == NULL) |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 93 | goto err; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 94 | PyList_SetItem(cc, VTIME, v); |
| 95 | } |
| 96 | |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 97 | if (!(v = PyList_New(7))) |
| 98 | goto err; |
| 99 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 100 | PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag)); |
| 101 | PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag)); |
| 102 | PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag)); |
| 103 | PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag)); |
| 104 | PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed)); |
| 105 | PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed)); |
| 106 | PyList_SetItem(v, 6, cc); |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 107 | if (PyErr_Occurred()){ |
| 108 | Py_DECREF(v); |
| 109 | goto err; |
| 110 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 111 | return v; |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 112 | err: |
| 113 | Py_DECREF(cc); |
| 114 | return NULL; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | /* tcsetattr(fd, when, termios) |
| 118 | Set the attributes of the terminal device. */ |
| 119 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 120 | static char termios_tcsetattr__doc__[] = "\ |
| 121 | tcsetattr(fd, when, attributes) -> None\n\ |
| 122 | Set the tty attributes for file descriptor fd.\n\ |
| 123 | The attributes to be set are taken from the attributes argument, which\n\ |
| 124 | is a list like the one returned by tcgetattr(). The when argument\n\ |
| 125 | determines when the attributes are changed: TERMIOS.TCSANOW to\n\ |
| 126 | change immediately, TERMIOS.TCSADRAIN to change after transmitting all\n\ |
| 127 | queued output, or TERMIOS.TCSAFLUSH to change after transmitting all\n\ |
| 128 | queued output and discarding all queued input. "; |
| 129 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 130 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 131 | termios_tcsetattr(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 132 | { |
| 133 | int fd, when; |
| 134 | struct termios mode; |
| 135 | speed_t ispeed, ospeed; |
| 136 | PyObject *term, *cc, *v; |
| 137 | int i; |
| 138 | |
| 139 | if (!PyArg_Parse(args, "(iiO)", &fd, &when, &term)) |
| 140 | return NULL; |
| 141 | if (!PyList_Check(term) || PyList_Size(term) != 7) { |
| 142 | PyErr_SetString(PyExc_TypeError, BAD); |
| 143 | return NULL; |
| 144 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 145 | |
Guido van Rossum | e7c4193 | 1998-06-12 14:26:18 +0000 | [diff] [blame] | 146 | /* Get the old mode, in case there are any hidden fields... */ |
| 147 | if (tcgetattr(fd, &mode) == -1) |
| 148 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 149 | mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); |
| 150 | mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); |
| 151 | mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2)); |
| 152 | mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3)); |
| 153 | ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4)); |
| 154 | ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5)); |
| 155 | cc = PyList_GetItem(term, 6); |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 156 | if (PyErr_Occurred()) |
| 157 | return NULL; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 158 | |
| 159 | if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) { |
| 160 | PyErr_SetString(PyExc_TypeError, BAD); |
| 161 | return NULL; |
| 162 | } |
| 163 | |
| 164 | for (i = 0; i < NCCS; i++) { |
| 165 | v = PyList_GetItem(cc, i); |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 166 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 167 | if (PyString_Check(v) && PyString_Size(v) == 1) |
| 168 | mode.c_cc[i] = (cc_t) * PyString_AsString(v); |
| 169 | else if (PyInt_Check(v)) |
| 170 | mode.c_cc[i] = (cc_t) PyInt_AsLong(v); |
| 171 | else { |
| 172 | PyErr_SetString(PyExc_TypeError, BAD); |
| 173 | return NULL; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (cfsetispeed(&mode, (speed_t) ispeed) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 178 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 179 | if (cfsetospeed(&mode, (speed_t) ospeed) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 180 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 181 | if (tcsetattr(fd, when, &mode) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 182 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 183 | |
| 184 | Py_INCREF(Py_None); |
| 185 | return Py_None; |
| 186 | } |
| 187 | |
| 188 | /* tcsendbreak(fd, duration) |
| 189 | Generate a break condition. */ |
| 190 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 191 | static char termios_tcsendbreak__doc__[] = "\ |
| 192 | tcsendbreak(fd, duration) -> None\n\ |
| 193 | Send a break on file descriptor fd.\n\ |
| 194 | A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration \n\ |
| 195 | has a system dependent meaning. "; |
| 196 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 197 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 198 | termios_tcsendbreak(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 199 | { |
| 200 | int fd, duration; |
| 201 | |
| 202 | if (!PyArg_Parse(args, "(ii)", &fd, &duration)) |
| 203 | return NULL; |
| 204 | if (tcsendbreak(fd, duration) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 205 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 206 | |
| 207 | Py_INCREF(Py_None); |
| 208 | return Py_None; |
| 209 | } |
| 210 | |
| 211 | /* tcdrain(fd) |
| 212 | Wait until all queued output to the terminal has been |
| 213 | transmitted. */ |
| 214 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 215 | static char termios_tcdrain__doc__[] = "\ |
| 216 | tcdrain(fd) -> None\n\ |
| 217 | Wait until all output written to file descriptor fd has been transmitted. "; |
| 218 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 219 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 220 | termios_tcdrain(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 221 | { |
| 222 | int fd; |
| 223 | |
| 224 | if (!PyArg_Parse(args, "i", &fd)) |
| 225 | return NULL; |
| 226 | if (tcdrain(fd) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 227 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 228 | |
| 229 | Py_INCREF(Py_None); |
| 230 | return Py_None; |
| 231 | } |
| 232 | |
| 233 | /* tcflush(fd, queue) |
| 234 | Clear the input and/or output queues associated with |
| 235 | the terminal. */ |
| 236 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 237 | static char termios_tcflush__doc__[] = "\ |
| 238 | tcflush(fd, queue) -> None\n\ |
| 239 | Discard queued data on file descriptor fd.\n\ |
| 240 | The queue selector specifies which queue: TERMIOS.TCIFLUSH for the input\n\ |
| 241 | queue, TERMIOS.TCOFLUSH for the output queue, or TERMIOS.TCIOFLUSH for\n\ |
| 242 | both queues. "; |
| 243 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 244 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 245 | termios_tcflush(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 246 | { |
| 247 | int fd, queue; |
| 248 | |
| 249 | if (!PyArg_Parse(args, "(ii)", &fd, &queue)) |
| 250 | return NULL; |
| 251 | if (tcflush(fd, queue) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 252 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 253 | |
| 254 | Py_INCREF(Py_None); |
| 255 | return Py_None; |
| 256 | } |
| 257 | |
| 258 | /* tcflow(fd, action) |
| 259 | Perform operations relating to XON/XOFF flow control on |
| 260 | the terminal. */ |
| 261 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 262 | static char termios_tcflow__doc__[] = "\ |
| 263 | tcflow(fd, action) -> None\n\ |
| 264 | Suspend or resume input or output on file descriptor fd.\n\ |
| 265 | The action argument can be TERMIOS.TCOOFF to suspend output,\n\ |
| 266 | TERMIOS.TCOON to restart output, TERMIOS.TCIOFF to suspend input,\n\ |
| 267 | or TERMIOS.TCION to restart input. "; |
| 268 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 269 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 270 | termios_tcflow(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 271 | { |
| 272 | int fd, action; |
| 273 | |
| 274 | if (!PyArg_Parse(args, "(ii)", &fd, &action)) |
| 275 | return NULL; |
| 276 | if (tcflow(fd, action) == -1) |
Guido van Rossum | b8ad024 | 1997-07-17 22:55:06 +0000 | [diff] [blame] | 277 | return PyErr_SetFromErrno(TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 278 | |
| 279 | Py_INCREF(Py_None); |
| 280 | return Py_None; |
| 281 | } |
| 282 | |
| 283 | static PyMethodDef termios_methods[] = |
| 284 | { |
Andrew M. Kuchling | a1abb72 | 2000-08-03 02:34:44 +0000 | [diff] [blame] | 285 | {"tcgetattr", termios_tcgetattr, |
| 286 | METH_OLDARGS, termios_tcgetattr__doc__}, |
| 287 | {"tcsetattr", termios_tcsetattr, |
| 288 | METH_OLDARGS, termios_tcsetattr__doc__}, |
| 289 | {"tcsendbreak", termios_tcsendbreak, |
| 290 | METH_OLDARGS, termios_tcsendbreak__doc__}, |
| 291 | {"tcdrain", termios_tcdrain, |
| 292 | METH_OLDARGS, termios_tcdrain__doc__}, |
| 293 | {"tcflush", termios_tcflush, |
| 294 | METH_OLDARGS, termios_tcflush__doc__}, |
| 295 | {"tcflow", termios_tcflow, |
| 296 | METH_OLDARGS, termios_tcflow__doc__}, |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 297 | {NULL, NULL} |
| 298 | }; |
| 299 | |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 300 | |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 301 | #if defined(VSWTCH) && !defined(VSWTC) |
| 302 | #define VSWTC VSWTCH |
| 303 | #endif |
| 304 | |
| 305 | #if defined(VSWTC) && !defined(VSWTCH) |
| 306 | #define VSWTCH VSWTC |
| 307 | #endif |
| 308 | |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 309 | static struct constant { |
| 310 | char *name; |
| 311 | long value; |
| 312 | } termios_constants[] = { |
| 313 | /* cfgetospeed(), cfsetospeed() constants */ |
| 314 | {"B0", B0}, |
| 315 | {"B50", B50}, |
| 316 | {"B75", B75}, |
| 317 | {"B110", B110}, |
| 318 | {"B134", B134}, |
| 319 | {"B150", B150}, |
| 320 | {"B200", B200}, |
| 321 | {"B300", B300}, |
| 322 | {"B600", B600}, |
| 323 | {"B1200", B1200}, |
| 324 | {"B1800", B1800}, |
| 325 | {"B2400", B2400}, |
| 326 | {"B4800", B4800}, |
| 327 | {"B9600", B9600}, |
| 328 | {"B19200", B19200}, |
| 329 | {"B38400", B38400}, |
| 330 | {"B57600", B57600}, |
| 331 | {"B115200", B115200}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 332 | #ifdef B230400 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 333 | {"B230400", B230400}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 334 | #endif |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 335 | #ifdef CBAUDEX |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 336 | {"CBAUDEX", CBAUDEX}, |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 337 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 338 | |
| 339 | /* tcsetattr() constants */ |
| 340 | {"TCSANOW", TCSANOW}, |
| 341 | {"TCSADRAIN", TCSADRAIN}, |
| 342 | {"TCSAFLUSH", TCSAFLUSH}, |
| 343 | |
| 344 | /* tcflush() constants */ |
| 345 | {"TCIFLUSH", TCIFLUSH}, |
| 346 | {"TCOFLUSH", TCOFLUSH}, |
| 347 | {"TCIOFLUSH", TCIOFLUSH}, |
| 348 | |
| 349 | /* tcflow() constants */ |
| 350 | {"TCOOFF", TCOOFF}, |
| 351 | {"TCOON", TCOON}, |
| 352 | {"TCIOFF", TCIOFF}, |
| 353 | {"TCION", TCION}, |
| 354 | |
| 355 | /* struct termios.c_iflag constants */ |
| 356 | {"IGNBRK", IGNBRK}, |
| 357 | {"BRKINT", BRKINT}, |
| 358 | {"IGNPAR", IGNPAR}, |
| 359 | {"PARMRK", PARMRK}, |
| 360 | {"INPCK", INPCK}, |
| 361 | {"ISTRIP", ISTRIP}, |
| 362 | {"INLCR", INLCR}, |
| 363 | {"IGNCR", IGNCR}, |
| 364 | {"ICRNL", ICRNL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 365 | #ifdef IUCLC |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 366 | {"IUCLC", IUCLC}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 367 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 368 | {"IXON", IXON}, |
| 369 | {"IXANY", IXANY}, |
| 370 | {"IXOFF", IXOFF}, |
| 371 | {"IMAXBEL", IMAXBEL}, |
| 372 | |
| 373 | /* struct termios.c_oflag constants */ |
| 374 | {"OPOST", OPOST}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 375 | #ifdef OLCUC |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 376 | {"OLCUC", OLCUC}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 377 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 378 | {"ONLCR", ONLCR}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 379 | #ifdef OCRNL |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 380 | {"OCRNL", OCRNL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 381 | #endif |
| 382 | #ifdef ONOCR |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 383 | {"ONOCR", ONOCR}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 384 | #endif |
| 385 | #ifdef ONLRET |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 386 | {"ONLRET", ONLRET}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 387 | #endif |
| 388 | #ifdef OFILL |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 389 | {"OFILL", OFILL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 390 | #endif |
| 391 | #ifdef OFDEL |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 392 | {"OFDEL", OFDEL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 393 | #endif |
| 394 | #ifdef NLDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 395 | {"NLDLY", NLDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 396 | #endif |
| 397 | #ifdef CRDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 398 | {"CRDLY", CRDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 399 | #endif |
| 400 | #ifdef TABDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 401 | {"TABDLY", TABDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 402 | #endif |
| 403 | #ifdef BSDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 404 | {"BSDLY", BSDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 405 | #endif |
| 406 | #ifdef VTDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 407 | {"VTDLY", VTDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 408 | #endif |
| 409 | #ifdef FFDLY |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 410 | {"FFDLY", FFDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 411 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 412 | |
| 413 | /* struct termios.c_oflag-related values (delay mask) */ |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 414 | #ifdef NL0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 415 | {"NL0", NL0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 416 | #endif |
| 417 | #ifdef NL1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 418 | {"NL1", NL1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 419 | #endif |
| 420 | #ifdef CR0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 421 | {"CR0", CR0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 422 | #endif |
| 423 | #ifdef CR1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 424 | {"CR1", CR1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 425 | #endif |
| 426 | #ifdef CR2 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 427 | {"CR2", CR2}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 428 | #endif |
| 429 | #ifdef CR3 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 430 | {"CR3", CR3}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 431 | #endif |
| 432 | #ifdef TAB0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 433 | {"TAB0", TAB0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 434 | #endif |
| 435 | #ifdef TAB1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 436 | {"TAB1", TAB1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 437 | #endif |
| 438 | #ifdef TAB2 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 439 | {"TAB2", TAB2}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 440 | #endif |
| 441 | #ifdef TAB3 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 442 | {"TAB3", TAB3}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 443 | #endif |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 444 | #ifdef XTABS |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 445 | {"XTABS", XTABS}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 446 | #endif |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 447 | #ifdef BS0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 448 | {"BS0", BS0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 449 | #endif |
| 450 | #ifdef BS1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 451 | {"BS1", BS1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 452 | #endif |
| 453 | #ifdef VT0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 454 | {"VT0", VT0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 455 | #endif |
| 456 | #ifdef VT1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 457 | {"VT1", VT1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 458 | #endif |
| 459 | #ifdef FF0 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 460 | {"FF0", FF0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 461 | #endif |
| 462 | #ifdef FF1 |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 463 | {"FF1", FF1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 464 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 465 | |
| 466 | /* struct termios.c_cflag constants */ |
| 467 | {"CSIZE", CSIZE}, |
| 468 | {"CSTOPB", CSTOPB}, |
| 469 | {"CREAD", CREAD}, |
| 470 | {"PARENB", PARENB}, |
| 471 | {"PARODD", PARODD}, |
| 472 | {"HUPCL", HUPCL}, |
| 473 | {"CLOCAL", CLOCAL}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 474 | #ifdef CIBAUD |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 475 | {"CIBAUD", CIBAUD}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 476 | #endif |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 477 | #ifdef CRTSCTS |
| 478 | {"CRTSCTS", (long)CRTSCTS}, |
| 479 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 480 | |
| 481 | /* struct termios.c_cflag-related values (character size) */ |
| 482 | {"CS5", CS5}, |
| 483 | {"CS6", CS6}, |
| 484 | {"CS7", CS7}, |
| 485 | {"CS8", CS8}, |
| 486 | |
| 487 | /* struct termios.c_lflag constants */ |
| 488 | {"ISIG", ISIG}, |
| 489 | {"ICANON", ICANON}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 490 | #ifdef XCASE |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 491 | {"XCASE", XCASE}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 492 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 493 | {"ECHO", ECHO}, |
| 494 | {"ECHOE", ECHOE}, |
| 495 | {"ECHOK", ECHOK}, |
| 496 | {"ECHONL", ECHONL}, |
| 497 | {"ECHOCTL", ECHOCTL}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 498 | #ifdef ECHOPRT |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 499 | {"ECHOPRT", ECHOPRT}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 500 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 501 | {"ECHOKE", ECHOKE}, |
| 502 | {"FLUSHO", FLUSHO}, |
| 503 | {"NOFLSH", NOFLSH}, |
| 504 | {"TOSTOP", TOSTOP}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 505 | #ifdef PENDIN |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 506 | {"PENDIN", PENDIN}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 507 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 508 | {"IEXTEN", IEXTEN}, |
| 509 | |
| 510 | /* indexes into the control chars array returned by tcgetattr() */ |
| 511 | {"VINTR", VINTR}, |
| 512 | {"VQUIT", VQUIT}, |
| 513 | {"VERASE", VERASE}, |
| 514 | {"VKILL", VKILL}, |
| 515 | {"VEOF", VEOF}, |
| 516 | {"VTIME", VTIME}, |
| 517 | {"VMIN", VMIN}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 518 | #ifdef VSWTC |
| 519 | /* The #defines above ensure that if either is defined, both are, |
| 520 | * but both may be omitted by the system headers. ;-( */ |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 521 | {"VSWTC", VSWTC}, |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 522 | {"VSWTCH", VSWTCH}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 523 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 524 | {"VSTART", VSTART}, |
| 525 | {"VSTOP", VSTOP}, |
| 526 | {"VSUSP", VSUSP}, |
| 527 | {"VEOL", VEOL}, |
| 528 | {"VREPRINT", VREPRINT}, |
| 529 | {"VDISCARD", VDISCARD}, |
| 530 | {"VWERASE", VWERASE}, |
| 531 | {"VLNEXT", VLNEXT}, |
| 532 | {"VEOL2", VEOL2}, |
| 533 | |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 534 | |
| 535 | #ifdef B460800 |
| 536 | {"B460800", B460800}, |
| 537 | #endif |
| 538 | #ifdef CBAUD |
| 539 | {"CBAUD", CBAUD}, |
| 540 | #endif |
| 541 | #ifdef CDEL |
| 542 | {"CDEL", CDEL}, |
| 543 | #endif |
| 544 | #ifdef CDSUSP |
| 545 | {"CDSUSP", CDSUSP}, |
| 546 | #endif |
| 547 | #ifdef CEOF |
| 548 | {"CEOF", CEOF}, |
| 549 | #endif |
| 550 | #ifdef CEOL |
| 551 | {"CEOL", CEOL}, |
| 552 | #endif |
| 553 | #ifdef CEOL2 |
| 554 | {"CEOL2", CEOL2}, |
| 555 | #endif |
| 556 | #ifdef CEOT |
| 557 | {"CEOT", CEOT}, |
| 558 | #endif |
| 559 | #ifdef CERASE |
| 560 | {"CERASE", CERASE}, |
| 561 | #endif |
| 562 | #ifdef CESC |
| 563 | {"CESC", CESC}, |
| 564 | #endif |
| 565 | #ifdef CFLUSH |
| 566 | {"CFLUSH", CFLUSH}, |
| 567 | #endif |
| 568 | #ifdef CINTR |
| 569 | {"CINTR", CINTR}, |
| 570 | #endif |
| 571 | #ifdef CKILL |
| 572 | {"CKILL", CKILL}, |
| 573 | #endif |
| 574 | #ifdef CLNEXT |
| 575 | {"CLNEXT", CLNEXT}, |
| 576 | #endif |
| 577 | #ifdef CNUL |
| 578 | {"CNUL", CNUL}, |
| 579 | #endif |
| 580 | #ifdef COMMON |
| 581 | {"COMMON", COMMON}, |
| 582 | #endif |
| 583 | #ifdef CQUIT |
| 584 | {"CQUIT", CQUIT}, |
| 585 | #endif |
| 586 | #ifdef CRPRNT |
| 587 | {"CRPRNT", CRPRNT}, |
| 588 | #endif |
| 589 | #ifdef CSTART |
| 590 | {"CSTART", CSTART}, |
| 591 | #endif |
| 592 | #ifdef CSTOP |
| 593 | {"CSTOP", CSTOP}, |
| 594 | #endif |
| 595 | #ifdef CSUSP |
| 596 | {"CSUSP", CSUSP}, |
| 597 | #endif |
| 598 | #ifdef CSWTCH |
| 599 | {"CSWTCH", CSWTCH}, |
| 600 | #endif |
| 601 | #ifdef CWERASE |
| 602 | {"CWERASE", CWERASE}, |
| 603 | #endif |
| 604 | #ifdef EXTA |
| 605 | {"EXTA", EXTA}, |
| 606 | #endif |
| 607 | #ifdef EXTB |
| 608 | {"EXTB", EXTB}, |
| 609 | #endif |
| 610 | #ifdef FIOASYNC |
| 611 | {"FIOASYNC", FIOASYNC}, |
| 612 | #endif |
| 613 | #ifdef FIOCLEX |
| 614 | {"FIOCLEX", FIOCLEX}, |
| 615 | #endif |
| 616 | #ifdef FIONBIO |
| 617 | {"FIONBIO", FIONBIO}, |
| 618 | #endif |
| 619 | #ifdef FIONCLEX |
| 620 | {"FIONCLEX", FIONCLEX}, |
| 621 | #endif |
| 622 | #ifdef FIONREAD |
| 623 | {"FIONREAD", FIONREAD}, |
| 624 | #endif |
| 625 | #ifdef IBSHIFT |
| 626 | {"IBSHIFT", IBSHIFT}, |
| 627 | #endif |
| 628 | #ifdef INIT_C_CC |
| 629 | {"INIT_C_CC", INIT_C_CC}, |
| 630 | #endif |
| 631 | #ifdef IOCSIZE_MASK |
| 632 | {"IOCSIZE_MASK", IOCSIZE_MASK}, |
| 633 | #endif |
| 634 | #ifdef IOCSIZE_SHIFT |
| 635 | {"IOCSIZE_SHIFT", IOCSIZE_SHIFT}, |
| 636 | #endif |
| 637 | #ifdef NCC |
| 638 | {"NCC", NCC}, |
| 639 | #endif |
| 640 | #ifdef NCCS |
| 641 | {"NCCS", NCCS}, |
| 642 | #endif |
| 643 | #ifdef NSWTCH |
| 644 | {"NSWTCH", NSWTCH}, |
| 645 | #endif |
| 646 | #ifdef N_MOUSE |
| 647 | {"N_MOUSE", N_MOUSE}, |
| 648 | #endif |
| 649 | #ifdef N_PPP |
| 650 | {"N_PPP", N_PPP}, |
| 651 | #endif |
| 652 | #ifdef N_SLIP |
| 653 | {"N_SLIP", N_SLIP}, |
| 654 | #endif |
| 655 | #ifdef N_STRIP |
| 656 | {"N_STRIP", N_STRIP}, |
| 657 | #endif |
| 658 | #ifdef N_TTY |
| 659 | {"N_TTY", N_TTY}, |
| 660 | #endif |
| 661 | #ifdef TCFLSH |
| 662 | {"TCFLSH", TCFLSH}, |
| 663 | #endif |
| 664 | #ifdef TCGETA |
| 665 | {"TCGETA", TCGETA}, |
| 666 | #endif |
| 667 | #ifdef TCGETS |
| 668 | {"TCGETS", TCGETS}, |
| 669 | #endif |
| 670 | #ifdef TCSBRK |
| 671 | {"TCSBRK", TCSBRK}, |
| 672 | #endif |
| 673 | #ifdef TCSBRKP |
| 674 | {"TCSBRKP", TCSBRKP}, |
| 675 | #endif |
| 676 | #ifdef TCSETA |
| 677 | {"TCSETA", TCSETA}, |
| 678 | #endif |
| 679 | #ifdef TCSETAF |
| 680 | {"TCSETAF", TCSETAF}, |
| 681 | #endif |
| 682 | #ifdef TCSETAW |
| 683 | {"TCSETAW", TCSETAW}, |
| 684 | #endif |
| 685 | #ifdef TCSETS |
| 686 | {"TCSETS", TCSETS}, |
| 687 | #endif |
| 688 | #ifdef TCSETSF |
| 689 | {"TCSETSF", TCSETSF}, |
| 690 | #endif |
| 691 | #ifdef TCSETSW |
| 692 | {"TCSETSW", TCSETSW}, |
| 693 | #endif |
| 694 | #ifdef TCXONC |
| 695 | {"TCXONC", TCXONC}, |
| 696 | #endif |
| 697 | #ifdef TIOCCONS |
| 698 | {"TIOCCONS", TIOCCONS}, |
| 699 | #endif |
| 700 | #ifdef TIOCEXCL |
| 701 | {"TIOCEXCL", TIOCEXCL}, |
| 702 | #endif |
| 703 | #ifdef TIOCGETD |
| 704 | {"TIOCGETD", TIOCGETD}, |
| 705 | #endif |
| 706 | #ifdef TIOCGICOUNT |
| 707 | {"TIOCGICOUNT", TIOCGICOUNT}, |
| 708 | #endif |
| 709 | #ifdef TIOCGLCKTRMIOS |
| 710 | {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS}, |
| 711 | #endif |
| 712 | #ifdef TIOCGPGRP |
| 713 | {"TIOCGPGRP", TIOCGPGRP}, |
| 714 | #endif |
| 715 | #ifdef TIOCGSERIAL |
| 716 | {"TIOCGSERIAL", TIOCGSERIAL}, |
| 717 | #endif |
| 718 | #ifdef TIOCGSOFTCAR |
| 719 | {"TIOCGSOFTCAR", TIOCGSOFTCAR}, |
| 720 | #endif |
| 721 | #ifdef TIOCGWINSZ |
| 722 | {"TIOCGWINSZ", TIOCGWINSZ}, |
| 723 | #endif |
| 724 | #ifdef TIOCINQ |
| 725 | {"TIOCINQ", TIOCINQ}, |
| 726 | #endif |
| 727 | #ifdef TIOCLINUX |
| 728 | {"TIOCLINUX", TIOCLINUX}, |
| 729 | #endif |
| 730 | #ifdef TIOCMBIC |
| 731 | {"TIOCMBIC", TIOCMBIC}, |
| 732 | #endif |
| 733 | #ifdef TIOCMBIS |
| 734 | {"TIOCMBIS", TIOCMBIS}, |
| 735 | #endif |
| 736 | #ifdef TIOCMGET |
| 737 | {"TIOCMGET", TIOCMGET}, |
| 738 | #endif |
| 739 | #ifdef TIOCMIWAIT |
| 740 | {"TIOCMIWAIT", TIOCMIWAIT}, |
| 741 | #endif |
| 742 | #ifdef TIOCMSET |
| 743 | {"TIOCMSET", TIOCMSET}, |
| 744 | #endif |
| 745 | #ifdef TIOCM_CAR |
| 746 | {"TIOCM_CAR", TIOCM_CAR}, |
| 747 | #endif |
| 748 | #ifdef TIOCM_CD |
| 749 | {"TIOCM_CD", TIOCM_CD}, |
| 750 | #endif |
| 751 | #ifdef TIOCM_CTS |
| 752 | {"TIOCM_CTS", TIOCM_CTS}, |
| 753 | #endif |
| 754 | #ifdef TIOCM_DSR |
| 755 | {"TIOCM_DSR", TIOCM_DSR}, |
| 756 | #endif |
| 757 | #ifdef TIOCM_DTR |
| 758 | {"TIOCM_DTR", TIOCM_DTR}, |
| 759 | #endif |
| 760 | #ifdef TIOCM_LE |
| 761 | {"TIOCM_LE", TIOCM_LE}, |
| 762 | #endif |
| 763 | #ifdef TIOCM_RI |
| 764 | {"TIOCM_RI", TIOCM_RI}, |
| 765 | #endif |
| 766 | #ifdef TIOCM_RNG |
| 767 | {"TIOCM_RNG", TIOCM_RNG}, |
| 768 | #endif |
| 769 | #ifdef TIOCM_RTS |
| 770 | {"TIOCM_RTS", TIOCM_RTS}, |
| 771 | #endif |
| 772 | #ifdef TIOCM_SR |
| 773 | {"TIOCM_SR", TIOCM_SR}, |
| 774 | #endif |
| 775 | #ifdef TIOCM_ST |
| 776 | {"TIOCM_ST", TIOCM_ST}, |
| 777 | #endif |
| 778 | #ifdef TIOCNOTTY |
| 779 | {"TIOCNOTTY", TIOCNOTTY}, |
| 780 | #endif |
| 781 | #ifdef TIOCNXCL |
| 782 | {"TIOCNXCL", TIOCNXCL}, |
| 783 | #endif |
| 784 | #ifdef TIOCOUTQ |
| 785 | {"TIOCOUTQ", TIOCOUTQ}, |
| 786 | #endif |
| 787 | #ifdef TIOCPKT |
| 788 | {"TIOCPKT", TIOCPKT}, |
| 789 | #endif |
| 790 | #ifdef TIOCPKT_DATA |
| 791 | {"TIOCPKT_DATA", TIOCPKT_DATA}, |
| 792 | #endif |
| 793 | #ifdef TIOCPKT_DOSTOP |
| 794 | {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP}, |
| 795 | #endif |
| 796 | #ifdef TIOCPKT_FLUSHREAD |
| 797 | {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD}, |
| 798 | #endif |
| 799 | #ifdef TIOCPKT_FLUSHWRITE |
| 800 | {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE}, |
| 801 | #endif |
| 802 | #ifdef TIOCPKT_NOSTOP |
| 803 | {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP}, |
| 804 | #endif |
| 805 | #ifdef TIOCPKT_START |
| 806 | {"TIOCPKT_START", TIOCPKT_START}, |
| 807 | #endif |
| 808 | #ifdef TIOCPKT_STOP |
| 809 | {"TIOCPKT_STOP", TIOCPKT_STOP}, |
| 810 | #endif |
| 811 | #ifdef TIOCSCTTY |
| 812 | {"TIOCSCTTY", TIOCSCTTY}, |
| 813 | #endif |
| 814 | #ifdef TIOCSERCONFIG |
| 815 | {"TIOCSERCONFIG", TIOCSERCONFIG}, |
| 816 | #endif |
| 817 | #ifdef TIOCSERGETLSR |
| 818 | {"TIOCSERGETLSR", TIOCSERGETLSR}, |
| 819 | #endif |
| 820 | #ifdef TIOCSERGETMULTI |
| 821 | {"TIOCSERGETMULTI", TIOCSERGETMULTI}, |
| 822 | #endif |
| 823 | #ifdef TIOCSERGSTRUCT |
| 824 | {"TIOCSERGSTRUCT", TIOCSERGSTRUCT}, |
| 825 | #endif |
| 826 | #ifdef TIOCSERGWILD |
| 827 | {"TIOCSERGWILD", TIOCSERGWILD}, |
| 828 | #endif |
| 829 | #ifdef TIOCSERSETMULTI |
| 830 | {"TIOCSERSETMULTI", TIOCSERSETMULTI}, |
| 831 | #endif |
| 832 | #ifdef TIOCSERSWILD |
| 833 | {"TIOCSERSWILD", TIOCSERSWILD}, |
| 834 | #endif |
| 835 | #ifdef TIOCSER_TEMT |
| 836 | {"TIOCSER_TEMT", TIOCSER_TEMT}, |
| 837 | #endif |
| 838 | #ifdef TIOCSETD |
| 839 | {"TIOCSETD", TIOCSETD}, |
| 840 | #endif |
| 841 | #ifdef TIOCSLCKTRMIOS |
| 842 | {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS}, |
| 843 | #endif |
| 844 | #ifdef TIOCSPGRP |
| 845 | {"TIOCSPGRP", TIOCSPGRP}, |
| 846 | #endif |
| 847 | #ifdef TIOCSSERIAL |
| 848 | {"TIOCSSERIAL", TIOCSSERIAL}, |
| 849 | #endif |
| 850 | #ifdef TIOCSSOFTCAR |
| 851 | {"TIOCSSOFTCAR", TIOCSSOFTCAR}, |
| 852 | #endif |
| 853 | #ifdef TIOCSTI |
| 854 | {"TIOCSTI", TIOCSTI}, |
| 855 | #endif |
| 856 | #ifdef TIOCSWINSZ |
| 857 | {"TIOCSWINSZ", TIOCSWINSZ}, |
| 858 | #endif |
| 859 | #ifdef TIOCTTYGSTRUCT |
| 860 | {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT}, |
| 861 | #endif |
| 862 | |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 863 | /* sentinel */ |
| 864 | {NULL, 0} |
| 865 | }; |
| 866 | |
| 867 | |
Guido van Rossum | 3886bb6 | 1998-12-04 18:50:17 +0000 | [diff] [blame] | 868 | DL_EXPORT(void) |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 869 | PyInit_termios(void) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 870 | { |
| 871 | PyObject *m, *d; |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 872 | struct constant *constant = termios_constants; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 873 | |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 874 | m = Py_InitModule4("termios", termios_methods, termios__doc__, |
| 875 | (PyObject *)NULL, PYTHON_API_VERSION); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 876 | |
| 877 | d = PyModule_GetDict(m); |
Guido van Rossum | 0cb96de | 1997-10-01 04:29:29 +0000 | [diff] [blame] | 878 | TermiosError = PyErr_NewException("termios.error", NULL, NULL); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 879 | PyDict_SetItemString(d, "error", TermiosError); |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 880 | |
| 881 | while (constant->name != NULL) { |
| 882 | PyModule_AddIntConstant(m, constant->name, constant->value); |
| 883 | ++constant; |
| 884 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 885 | } |