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 | |
Martin v. Löwis | be4fea6 | 2003-10-31 13:01:24 +0000 | [diff] [blame] | 5 | /* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE |
| 6 | is defined, so we define it here. */ |
| 7 | #if defined(__sgi) |
| 8 | #define CTRL(c) ((c)&037) |
| 9 | #endif |
| 10 | |
jcea | f0a95f2 | 2018-01-28 14:00:48 +0100 | [diff] [blame] | 11 | #if defined(__sun) |
| 12 | /* We could do better. Check issue-32660 */ |
| 13 | #include <sys/filio.h> |
| 14 | #include <sys/sockio.h> |
| 15 | #endif |
| 16 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 17 | #include <termios.h> |
Fred Drake | 9b3bc49 | 2001-04-04 21:19:26 +0000 | [diff] [blame] | 18 | #include <sys/ioctl.h> |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 19 | |
Fred Drake | 87068f1 | 2001-05-11 16:14:17 +0000 | [diff] [blame] | 20 | /* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR, |
Min ho Kim | 39d87b5 | 2019-08-31 06:21:19 +1000 | [diff] [blame] | 21 | * MDTR, MRI, and MRTS (apparently used internally by some things |
Fred Drake | 87068f1 | 2001-05-11 16:14:17 +0000 | [diff] [blame] | 22 | * defined as macros; these are not used here directly). |
| 23 | */ |
| 24 | #ifdef HAVE_SYS_MODEM_H |
| 25 | #include <sys/modem.h> |
| 26 | #endif |
Neal Norwitz | 8225103 | 2003-05-23 14:35:24 +0000 | [diff] [blame] | 27 | /* HP-UX requires that this be included to pick up TIOCGPGRP and friends */ |
| 28 | #ifdef HAVE_SYS_BSDTTY_H |
| 29 | #include <sys/bsdtty.h> |
| 30 | #endif |
Fred Drake | 87068f1 | 2001-05-11 16:14:17 +0000 | [diff] [blame] | 31 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 32 | PyDoc_STRVAR(termios__doc__, |
| 33 | "This module provides an interface to the Posix calls for tty I/O control.\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 34 | For a complete description of these calls, see the Posix or Unix manual\n\ |
| 35 | pages. It is only available for those Unix versions that support Posix\n\ |
| 36 | termios style tty I/O control.\n\ |
| 37 | \n\ |
| 38 | All functions in this module take a file descriptor fd as their first\n\ |
| 39 | argument. This can be an integer file descriptor, such as returned by\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 40 | sys.stdin.fileno(), or a file object, such as sys.stdin itself."); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 41 | |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 42 | typedef struct { |
| 43 | PyObject *TermiosError; |
| 44 | } termiosmodulestate; |
Hai Shi | f707d94 | 2020-03-16 21:15:01 +0800 | [diff] [blame] | 45 | |
| 46 | static inline termiosmodulestate* |
| 47 | get_termios_state(PyObject *module) |
| 48 | { |
| 49 | void *state = PyModule_GetState(module); |
| 50 | assert(state != NULL); |
| 51 | return (termiosmodulestate *)state; |
| 52 | } |
| 53 | |
| 54 | #define modulestate_global get_termios_state(PyState_FindModule(&termiosmodule)) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 55 | |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 56 | static int fdconv(PyObject* obj, void* p) |
| 57 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 58 | int fd; |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 59 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 60 | fd = PyObject_AsFileDescriptor(obj); |
| 61 | if (fd >= 0) { |
| 62 | *(int*)p = fd; |
| 63 | return 1; |
| 64 | } |
| 65 | return 0; |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 66 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 67 | |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 68 | static struct PyModuleDef termiosmodule; |
| 69 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 70 | PyDoc_STRVAR(termios_tcgetattr__doc__, |
| 71 | "tcgetattr(fd) -> list_of_attrs\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 72 | \n\ |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 73 | Get the tty attributes for file descriptor fd, as follows:\n\ |
| 74 | [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\ |
| 75 | of the tty special characters (each a string of length 1, except the items\n\ |
| 76 | with indices VMIN and VTIME, which are integers when these fields are\n\ |
| 77 | defined). The interpretation of the flags and the speeds as well as the\n\ |
| 78 | indexing in the cc array must be done using the symbolic constants defined\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 79 | in this module."); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 80 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 81 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 82 | termios_tcgetattr(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 83 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 84 | int fd; |
| 85 | struct termios mode; |
| 86 | PyObject *cc; |
| 87 | speed_t ispeed, ospeed; |
| 88 | PyObject *v; |
| 89 | int i; |
| 90 | char ch; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 91 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 92 | if (!PyArg_ParseTuple(args, "O&:tcgetattr", |
| 93 | fdconv, (void*)&fd)) |
| 94 | return NULL; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 95 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 96 | if (tcgetattr(fd, &mode) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 97 | return PyErr_SetFromErrno(modulestate_global->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 98 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 99 | ispeed = cfgetispeed(&mode); |
| 100 | ospeed = cfgetospeed(&mode); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 101 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 102 | cc = PyList_New(NCCS); |
| 103 | if (cc == NULL) |
| 104 | return NULL; |
| 105 | for (i = 0; i < NCCS; i++) { |
| 106 | ch = (char)mode.c_cc[i]; |
| 107 | v = PyBytes_FromStringAndSize(&ch, 1); |
| 108 | if (v == NULL) |
| 109 | goto err; |
| 110 | PyList_SetItem(cc, i, v); |
| 111 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 112 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 113 | /* Convert the MIN and TIME slots to integer. On some systems, the |
| 114 | MIN and TIME slots are the same as the EOF and EOL slots. So we |
| 115 | only do this in noncanonical input mode. */ |
| 116 | if ((mode.c_lflag & ICANON) == 0) { |
| 117 | v = PyLong_FromLong((long)mode.c_cc[VMIN]); |
| 118 | if (v == NULL) |
| 119 | goto err; |
| 120 | PyList_SetItem(cc, VMIN, v); |
| 121 | v = PyLong_FromLong((long)mode.c_cc[VTIME]); |
| 122 | if (v == NULL) |
| 123 | goto err; |
| 124 | PyList_SetItem(cc, VTIME, v); |
| 125 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 126 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 127 | if (!(v = PyList_New(7))) |
| 128 | goto err; |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 129 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 130 | PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag)); |
| 131 | PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag)); |
| 132 | PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag)); |
| 133 | PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag)); |
| 134 | PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed)); |
| 135 | PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed)); |
Zackery Spytz | 53835e9 | 2018-10-28 22:55:20 -0600 | [diff] [blame] | 136 | if (PyErr_Occurred()) { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 137 | Py_DECREF(v); |
| 138 | goto err; |
| 139 | } |
Zackery Spytz | 53835e9 | 2018-10-28 22:55:20 -0600 | [diff] [blame] | 140 | PyList_SetItem(v, 6, cc); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 141 | return v; |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 142 | err: |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 143 | Py_DECREF(cc); |
| 144 | return NULL; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 147 | PyDoc_STRVAR(termios_tcsetattr__doc__, |
| 148 | "tcsetattr(fd, when, attributes) -> None\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 149 | \n\ |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 150 | Set the tty attributes for file descriptor fd.\n\ |
| 151 | The attributes to be set are taken from the attributes argument, which\n\ |
| 152 | is a list like the one returned by tcgetattr(). The when argument\n\ |
Fred Drake | 29fd031 | 2001-04-09 19:32:52 +0000 | [diff] [blame] | 153 | determines when the attributes are changed: termios.TCSANOW to\n\ |
| 154 | change immediately, termios.TCSADRAIN to change after transmitting all\n\ |
| 155 | queued output, or termios.TCSAFLUSH to change after transmitting all\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 156 | queued output and discarding all queued input. "); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 157 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 158 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 159 | termios_tcsetattr(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 160 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 161 | int fd, when; |
| 162 | struct termios mode; |
| 163 | speed_t ispeed, ospeed; |
| 164 | PyObject *term, *cc, *v; |
| 165 | int i; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 166 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 167 | if (!PyArg_ParseTuple(args, "O&iO:tcsetattr", |
| 168 | fdconv, &fd, &when, &term)) |
| 169 | return NULL; |
| 170 | if (!PyList_Check(term) || PyList_Size(term) != 7) { |
| 171 | PyErr_SetString(PyExc_TypeError, |
| 172 | "tcsetattr, arg 3: must be 7 element list"); |
| 173 | return NULL; |
| 174 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 175 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 176 | /* Get the old mode, in case there are any hidden fields... */ |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 177 | termiosmodulestate *state = modulestate_global; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 178 | if (tcgetattr(fd, &mode) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 179 | return PyErr_SetFromErrno(state->TermiosError); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 180 | mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0)); |
| 181 | mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1)); |
| 182 | mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2)); |
| 183 | mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3)); |
| 184 | ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4)); |
| 185 | ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5)); |
| 186 | cc = PyList_GetItem(term, 6); |
| 187 | if (PyErr_Occurred()) |
| 188 | return NULL; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 189 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 190 | if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) { |
| 191 | PyErr_Format(PyExc_TypeError, |
| 192 | "tcsetattr: attributes[6] must be %d element list", |
| 193 | NCCS); |
| 194 | return NULL; |
| 195 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 196 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 197 | for (i = 0; i < NCCS; i++) { |
| 198 | v = PyList_GetItem(cc, i); |
Barry Warsaw | 5709dcf | 1997-01-10 18:42:18 +0000 | [diff] [blame] | 199 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 200 | if (PyBytes_Check(v) && PyBytes_Size(v) == 1) |
| 201 | mode.c_cc[i] = (cc_t) * PyBytes_AsString(v); |
| 202 | else if (PyLong_Check(v)) |
| 203 | mode.c_cc[i] = (cc_t) PyLong_AsLong(v); |
| 204 | else { |
| 205 | PyErr_SetString(PyExc_TypeError, |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 206 | "tcsetattr: elements of attributes must be characters or integers"); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 207 | return NULL; |
| 208 | } |
| 209 | } |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 210 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 211 | if (cfsetispeed(&mode, (speed_t) ispeed) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 212 | return PyErr_SetFromErrno(state->TermiosError); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 213 | if (cfsetospeed(&mode, (speed_t) ospeed) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 214 | return PyErr_SetFromErrno(state->TermiosError); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 215 | if (tcsetattr(fd, when, &mode) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 216 | return PyErr_SetFromErrno(state->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 217 | |
Serhiy Storchaka | 228b12e | 2017-01-23 09:47:21 +0200 | [diff] [blame] | 218 | Py_RETURN_NONE; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 221 | PyDoc_STRVAR(termios_tcsendbreak__doc__, |
| 222 | "tcsendbreak(fd, duration) -> None\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 223 | \n\ |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 224 | Send a break on file descriptor fd.\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 225 | A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 226 | has a system dependent meaning."); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 227 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 228 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 229 | termios_tcsendbreak(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 230 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 231 | int fd, duration; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 232 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 233 | if (!PyArg_ParseTuple(args, "O&i:tcsendbreak", |
| 234 | fdconv, &fd, &duration)) |
| 235 | return NULL; |
| 236 | if (tcsendbreak(fd, duration) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 237 | return PyErr_SetFromErrno(modulestate_global->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 238 | |
Serhiy Storchaka | 228b12e | 2017-01-23 09:47:21 +0200 | [diff] [blame] | 239 | Py_RETURN_NONE; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 242 | PyDoc_STRVAR(termios_tcdrain__doc__, |
| 243 | "tcdrain(fd) -> None\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 244 | \n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 245 | Wait until all output written to file descriptor fd has been transmitted."); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 246 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 247 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 248 | termios_tcdrain(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 249 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 250 | int fd; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 251 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 252 | if (!PyArg_ParseTuple(args, "O&:tcdrain", |
| 253 | fdconv, &fd)) |
| 254 | return NULL; |
| 255 | if (tcdrain(fd) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 256 | return PyErr_SetFromErrno(modulestate_global->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 257 | |
Serhiy Storchaka | 228b12e | 2017-01-23 09:47:21 +0200 | [diff] [blame] | 258 | Py_RETURN_NONE; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 259 | } |
| 260 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 261 | PyDoc_STRVAR(termios_tcflush__doc__, |
| 262 | "tcflush(fd, queue) -> None\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 263 | \n\ |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 264 | Discard queued data on file descriptor fd.\n\ |
Fred Drake | 29fd031 | 2001-04-09 19:32:52 +0000 | [diff] [blame] | 265 | The queue selector specifies which queue: termios.TCIFLUSH for the input\n\ |
| 266 | queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 267 | both queues. "); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 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_tcflush(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 271 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 272 | int fd, queue; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 273 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 274 | if (!PyArg_ParseTuple(args, "O&i:tcflush", |
| 275 | fdconv, &fd, &queue)) |
| 276 | return NULL; |
| 277 | if (tcflush(fd, queue) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 278 | return PyErr_SetFromErrno(modulestate_global->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 279 | |
Serhiy Storchaka | 228b12e | 2017-01-23 09:47:21 +0200 | [diff] [blame] | 280 | Py_RETURN_NONE; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 283 | PyDoc_STRVAR(termios_tcflow__doc__, |
| 284 | "tcflow(fd, action) -> None\n\ |
Fred Drake | b638aaf | 2001-05-07 17:55:35 +0000 | [diff] [blame] | 285 | \n\ |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 286 | Suspend or resume input or output on file descriptor fd.\n\ |
Fred Drake | 29fd031 | 2001-04-09 19:32:52 +0000 | [diff] [blame] | 287 | The action argument can be termios.TCOOFF to suspend output,\n\ |
| 288 | termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\ |
Martin v. Löwis | 14f8b4c | 2002-06-13 20:33:02 +0000 | [diff] [blame] | 289 | or termios.TCION to restart input."); |
Guido van Rossum | 1aca4d8 | 1998-03-03 22:10:18 +0000 | [diff] [blame] | 290 | |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 291 | static PyObject * |
Peter Schneider-Kamp | 416d413 | 2000-07-10 12:15:54 +0000 | [diff] [blame] | 292 | termios_tcflow(PyObject *self, PyObject *args) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 293 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 294 | int fd, action; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 295 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 296 | if (!PyArg_ParseTuple(args, "O&i:tcflow", |
| 297 | fdconv, &fd, &action)) |
| 298 | return NULL; |
| 299 | if (tcflow(fd, action) == -1) |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 300 | return PyErr_SetFromErrno(modulestate_global->TermiosError); |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 301 | |
Serhiy Storchaka | 228b12e | 2017-01-23 09:47:21 +0200 | [diff] [blame] | 302 | Py_RETURN_NONE; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | static PyMethodDef termios_methods[] = |
| 306 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 307 | {"tcgetattr", termios_tcgetattr, |
| 308 | METH_VARARGS, termios_tcgetattr__doc__}, |
| 309 | {"tcsetattr", termios_tcsetattr, |
| 310 | METH_VARARGS, termios_tcsetattr__doc__}, |
| 311 | {"tcsendbreak", termios_tcsendbreak, |
| 312 | METH_VARARGS, termios_tcsendbreak__doc__}, |
| 313 | {"tcdrain", termios_tcdrain, |
| 314 | METH_VARARGS, termios_tcdrain__doc__}, |
| 315 | {"tcflush", termios_tcflush, |
| 316 | METH_VARARGS, termios_tcflush__doc__}, |
| 317 | {"tcflow", termios_tcflow, |
| 318 | METH_VARARGS, termios_tcflow__doc__}, |
| 319 | {NULL, NULL} |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 320 | }; |
| 321 | |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 322 | |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 323 | #if defined(VSWTCH) && !defined(VSWTC) |
| 324 | #define VSWTC VSWTCH |
| 325 | #endif |
| 326 | |
| 327 | #if defined(VSWTC) && !defined(VSWTCH) |
| 328 | #define VSWTCH VSWTC |
| 329 | #endif |
| 330 | |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 331 | static struct constant { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 332 | char *name; |
| 333 | long value; |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 334 | } termios_constants[] = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 335 | /* cfgetospeed(), cfsetospeed() constants */ |
| 336 | {"B0", B0}, |
| 337 | {"B50", B50}, |
| 338 | {"B75", B75}, |
| 339 | {"B110", B110}, |
| 340 | {"B134", B134}, |
| 341 | {"B150", B150}, |
| 342 | {"B200", B200}, |
| 343 | {"B300", B300}, |
| 344 | {"B600", B600}, |
| 345 | {"B1200", B1200}, |
| 346 | {"B1800", B1800}, |
| 347 | {"B2400", B2400}, |
| 348 | {"B4800", B4800}, |
| 349 | {"B9600", B9600}, |
| 350 | {"B19200", B19200}, |
| 351 | {"B38400", B38400}, |
Guido van Rossum | 2242f2f | 2001-04-11 20:58:20 +0000 | [diff] [blame] | 352 | #ifdef B57600 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 353 | {"B57600", B57600}, |
Guido van Rossum | 2242f2f | 2001-04-11 20:58:20 +0000 | [diff] [blame] | 354 | #endif |
| 355 | #ifdef B115200 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 356 | {"B115200", B115200}, |
Guido van Rossum | 2242f2f | 2001-04-11 20:58:20 +0000 | [diff] [blame] | 357 | #endif |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 358 | #ifdef B230400 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 359 | {"B230400", B230400}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 360 | #endif |
Antoine Pitrou | a78f74c | 2010-11-20 20:03:08 +0000 | [diff] [blame] | 361 | #ifdef B460800 |
| 362 | {"B460800", B460800}, |
| 363 | #endif |
| 364 | #ifdef B500000 |
| 365 | {"B500000", B500000}, |
| 366 | #endif |
| 367 | #ifdef B576000 |
| 368 | {"B576000", B576000}, |
| 369 | #endif |
| 370 | #ifdef B921600 |
| 371 | {"B921600", B921600}, |
| 372 | #endif |
| 373 | #ifdef B1000000 |
| 374 | {"B1000000", B1000000}, |
| 375 | #endif |
| 376 | #ifdef B1152000 |
| 377 | {"B1152000", B1152000}, |
| 378 | #endif |
| 379 | #ifdef B1500000 |
| 380 | {"B1500000", B1500000}, |
| 381 | #endif |
| 382 | #ifdef B2000000 |
| 383 | {"B2000000", B2000000}, |
| 384 | #endif |
| 385 | #ifdef B2500000 |
| 386 | {"B2500000", B2500000}, |
| 387 | #endif |
| 388 | #ifdef B3000000 |
| 389 | {"B3000000", B3000000}, |
| 390 | #endif |
| 391 | #ifdef B3500000 |
| 392 | {"B3500000", B3500000}, |
| 393 | #endif |
| 394 | #ifdef B4000000 |
| 395 | {"B4000000", B4000000}, |
| 396 | #endif |
| 397 | |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 398 | #ifdef CBAUDEX |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 399 | {"CBAUDEX", CBAUDEX}, |
Fred Drake | 9ef7fa8 | 2001-03-01 21:54:49 +0000 | [diff] [blame] | 400 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 401 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 402 | /* tcsetattr() constants */ |
| 403 | {"TCSANOW", TCSANOW}, |
| 404 | {"TCSADRAIN", TCSADRAIN}, |
| 405 | {"TCSAFLUSH", TCSAFLUSH}, |
Gregory P. Smith | cafc22f | 2009-11-01 19:24:18 +0000 | [diff] [blame] | 406 | #ifdef TCSASOFT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 407 | {"TCSASOFT", TCSASOFT}, |
Gregory P. Smith | cafc22f | 2009-11-01 19:24:18 +0000 | [diff] [blame] | 408 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 409 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 410 | /* tcflush() constants */ |
| 411 | {"TCIFLUSH", TCIFLUSH}, |
| 412 | {"TCOFLUSH", TCOFLUSH}, |
| 413 | {"TCIOFLUSH", TCIOFLUSH}, |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 414 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 415 | /* tcflow() constants */ |
| 416 | {"TCOOFF", TCOOFF}, |
| 417 | {"TCOON", TCOON}, |
| 418 | {"TCIOFF", TCIOFF}, |
| 419 | {"TCION", TCION}, |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 420 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 421 | /* struct termios.c_iflag constants */ |
| 422 | {"IGNBRK", IGNBRK}, |
| 423 | {"BRKINT", BRKINT}, |
| 424 | {"IGNPAR", IGNPAR}, |
| 425 | {"PARMRK", PARMRK}, |
| 426 | {"INPCK", INPCK}, |
| 427 | {"ISTRIP", ISTRIP}, |
| 428 | {"INLCR", INLCR}, |
| 429 | {"IGNCR", IGNCR}, |
| 430 | {"ICRNL", ICRNL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 431 | #ifdef IUCLC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 432 | {"IUCLC", IUCLC}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 433 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 434 | {"IXON", IXON}, |
| 435 | {"IXANY", IXANY}, |
| 436 | {"IXOFF", IXOFF}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 437 | #ifdef IMAXBEL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 438 | {"IMAXBEL", IMAXBEL}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 439 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 440 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 441 | /* struct termios.c_oflag constants */ |
| 442 | {"OPOST", OPOST}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 443 | #ifdef OLCUC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 444 | {"OLCUC", OLCUC}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 445 | #endif |
Andrew MacIntyre | 7bf6833 | 2002-03-03 02:59:16 +0000 | [diff] [blame] | 446 | #ifdef ONLCR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 447 | {"ONLCR", ONLCR}, |
Andrew MacIntyre | 7bf6833 | 2002-03-03 02:59:16 +0000 | [diff] [blame] | 448 | #endif |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 449 | #ifdef OCRNL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 450 | {"OCRNL", OCRNL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 451 | #endif |
| 452 | #ifdef ONOCR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 453 | {"ONOCR", ONOCR}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 454 | #endif |
| 455 | #ifdef ONLRET |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 456 | {"ONLRET", ONLRET}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 457 | #endif |
| 458 | #ifdef OFILL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 459 | {"OFILL", OFILL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 460 | #endif |
| 461 | #ifdef OFDEL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 462 | {"OFDEL", OFDEL}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 463 | #endif |
| 464 | #ifdef NLDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 465 | {"NLDLY", NLDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 466 | #endif |
| 467 | #ifdef CRDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 468 | {"CRDLY", CRDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 469 | #endif |
| 470 | #ifdef TABDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 471 | {"TABDLY", TABDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 472 | #endif |
| 473 | #ifdef BSDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 474 | {"BSDLY", BSDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 475 | #endif |
| 476 | #ifdef VTDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 477 | {"VTDLY", VTDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 478 | #endif |
| 479 | #ifdef FFDLY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 480 | {"FFDLY", FFDLY}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 481 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 482 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 483 | /* struct termios.c_oflag-related values (delay mask) */ |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 484 | #ifdef NL0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 485 | {"NL0", NL0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 486 | #endif |
| 487 | #ifdef NL1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 488 | {"NL1", NL1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 489 | #endif |
| 490 | #ifdef CR0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 491 | {"CR0", CR0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 492 | #endif |
| 493 | #ifdef CR1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 494 | {"CR1", CR1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 495 | #endif |
| 496 | #ifdef CR2 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 497 | {"CR2", CR2}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 498 | #endif |
| 499 | #ifdef CR3 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 500 | {"CR3", CR3}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 501 | #endif |
| 502 | #ifdef TAB0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 503 | {"TAB0", TAB0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 504 | #endif |
| 505 | #ifdef TAB1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 506 | {"TAB1", TAB1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 507 | #endif |
| 508 | #ifdef TAB2 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 509 | {"TAB2", TAB2}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 510 | #endif |
| 511 | #ifdef TAB3 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 512 | {"TAB3", TAB3}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 513 | #endif |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 514 | #ifdef XTABS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 515 | {"XTABS", XTABS}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 516 | #endif |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 517 | #ifdef BS0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 518 | {"BS0", BS0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 519 | #endif |
| 520 | #ifdef BS1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 521 | {"BS1", BS1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 522 | #endif |
| 523 | #ifdef VT0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 524 | {"VT0", VT0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 525 | #endif |
| 526 | #ifdef VT1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 527 | {"VT1", VT1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 528 | #endif |
| 529 | #ifdef FF0 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 530 | {"FF0", FF0}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 531 | #endif |
| 532 | #ifdef FF1 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 533 | {"FF1", FF1}, |
Fred Drake | d85556c | 2001-03-03 18:08:52 +0000 | [diff] [blame] | 534 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 535 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 536 | /* struct termios.c_cflag constants */ |
| 537 | {"CSIZE", CSIZE}, |
| 538 | {"CSTOPB", CSTOPB}, |
| 539 | {"CREAD", CREAD}, |
| 540 | {"PARENB", PARENB}, |
| 541 | {"PARODD", PARODD}, |
| 542 | {"HUPCL", HUPCL}, |
| 543 | {"CLOCAL", CLOCAL}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 544 | #ifdef CIBAUD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 545 | {"CIBAUD", CIBAUD}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 546 | #endif |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 547 | #ifdef CRTSCTS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 548 | {"CRTSCTS", (long)CRTSCTS}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 549 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 550 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 551 | /* struct termios.c_cflag-related values (character size) */ |
| 552 | {"CS5", CS5}, |
| 553 | {"CS6", CS6}, |
| 554 | {"CS7", CS7}, |
| 555 | {"CS8", CS8}, |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 556 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 557 | /* struct termios.c_lflag constants */ |
| 558 | {"ISIG", ISIG}, |
| 559 | {"ICANON", ICANON}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 560 | #ifdef XCASE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 561 | {"XCASE", XCASE}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 562 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 563 | {"ECHO", ECHO}, |
| 564 | {"ECHOE", ECHOE}, |
| 565 | {"ECHOK", ECHOK}, |
| 566 | {"ECHONL", ECHONL}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 567 | #ifdef ECHOCTL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 568 | {"ECHOCTL", ECHOCTL}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 569 | #endif |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 570 | #ifdef ECHOPRT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 571 | {"ECHOPRT", ECHOPRT}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 572 | #endif |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 573 | #ifdef ECHOKE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 574 | {"ECHOKE", ECHOKE}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 575 | #endif |
| 576 | #ifdef FLUSHO |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 577 | {"FLUSHO", FLUSHO}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 578 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 579 | {"NOFLSH", NOFLSH}, |
| 580 | {"TOSTOP", TOSTOP}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 581 | #ifdef PENDIN |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 582 | {"PENDIN", PENDIN}, |
Fred Drake | abb379e | 2001-03-01 03:28:08 +0000 | [diff] [blame] | 583 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 584 | {"IEXTEN", IEXTEN}, |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 585 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 586 | /* indexes into the control chars array returned by tcgetattr() */ |
| 587 | {"VINTR", VINTR}, |
| 588 | {"VQUIT", VQUIT}, |
| 589 | {"VERASE", VERASE}, |
| 590 | {"VKILL", VKILL}, |
| 591 | {"VEOF", VEOF}, |
| 592 | {"VTIME", VTIME}, |
| 593 | {"VMIN", VMIN}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 594 | #ifdef VSWTC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 595 | /* The #defines above ensure that if either is defined, both are, |
| 596 | * but both may be omitted by the system headers. ;-( */ |
| 597 | {"VSWTC", VSWTC}, |
| 598 | {"VSWTCH", VSWTCH}, |
Fred Drake | dedbebf | 2001-03-02 06:50:58 +0000 | [diff] [blame] | 599 | #endif |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 600 | {"VSTART", VSTART}, |
| 601 | {"VSTOP", VSTOP}, |
| 602 | {"VSUSP", VSUSP}, |
| 603 | {"VEOL", VEOL}, |
Fred Drake | d0b625d | 2001-05-22 15:44:15 +0000 | [diff] [blame] | 604 | #ifdef VREPRINT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 605 | {"VREPRINT", VREPRINT}, |
Fred Drake | 87068f1 | 2001-05-11 16:14:17 +0000 | [diff] [blame] | 606 | #endif |
Fred Drake | d0b625d | 2001-05-22 15:44:15 +0000 | [diff] [blame] | 607 | #ifdef VDISCARD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 608 | {"VDISCARD", VDISCARD}, |
Fred Drake | 87068f1 | 2001-05-11 16:14:17 +0000 | [diff] [blame] | 609 | #endif |
Thomas Wouters | 819bb2c | 2001-06-11 15:25:16 +0000 | [diff] [blame] | 610 | #ifdef VWERASE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 611 | {"VWERASE", VWERASE}, |
Thomas Wouters | 819bb2c | 2001-06-11 15:25:16 +0000 | [diff] [blame] | 612 | #endif |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 613 | #ifdef VLNEXT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 614 | {"VLNEXT", VLNEXT}, |
Thomas Wouters | 2b30524 | 2001-06-15 12:05:44 +0000 | [diff] [blame] | 615 | #endif |
Andrew MacIntyre | 7bf6833 | 2002-03-03 02:59:16 +0000 | [diff] [blame] | 616 | #ifdef VEOL2 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 617 | {"VEOL2", VEOL2}, |
Andrew MacIntyre | 7bf6833 | 2002-03-03 02:59:16 +0000 | [diff] [blame] | 618 | #endif |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 619 | |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 620 | |
| 621 | #ifdef B460800 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 622 | {"B460800", B460800}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 623 | #endif |
Anthony Shaw | 7dc72b8 | 2020-01-04 23:56:31 +1100 | [diff] [blame] | 624 | #ifdef B500000 |
| 625 | {"B500000", B500000}, |
| 626 | #endif |
| 627 | #ifdef B576000 |
| 628 | { "B576000", B576000}, |
| 629 | #endif |
| 630 | #ifdef B921600 |
| 631 | { "B921600", B921600}, |
| 632 | #endif |
| 633 | #ifdef B1000000 |
| 634 | { "B1000000", B1000000}, |
| 635 | #endif |
| 636 | #ifdef B1152000 |
| 637 | { "B1152000", B1152000}, |
| 638 | #endif |
| 639 | #ifdef B1500000 |
| 640 | { "B1500000", B1500000}, |
| 641 | #endif |
| 642 | #ifdef B2000000 |
| 643 | { "B2000000", B2000000}, |
| 644 | #endif |
| 645 | #ifdef B2500000 |
| 646 | { "B2500000", B2500000}, |
| 647 | #endif |
| 648 | #ifdef B3000000 |
| 649 | { "B3000000", B3000000}, |
| 650 | #endif |
| 651 | #ifdef B3500000 |
| 652 | { "B3500000", B3500000}, |
| 653 | #endif |
| 654 | #ifdef B4000000 |
| 655 | { "B4000000", B4000000}, |
| 656 | #endif |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 657 | #ifdef CBAUD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 658 | {"CBAUD", CBAUD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 659 | #endif |
| 660 | #ifdef CDEL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 661 | {"CDEL", CDEL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 662 | #endif |
| 663 | #ifdef CDSUSP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 664 | {"CDSUSP", CDSUSP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 665 | #endif |
| 666 | #ifdef CEOF |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 667 | {"CEOF", CEOF}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 668 | #endif |
| 669 | #ifdef CEOL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 670 | {"CEOL", CEOL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 671 | #endif |
| 672 | #ifdef CEOL2 |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 673 | {"CEOL2", CEOL2}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 674 | #endif |
| 675 | #ifdef CEOT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 676 | {"CEOT", CEOT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 677 | #endif |
| 678 | #ifdef CERASE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 679 | {"CERASE", CERASE}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 680 | #endif |
| 681 | #ifdef CESC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 682 | {"CESC", CESC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 683 | #endif |
| 684 | #ifdef CFLUSH |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 685 | {"CFLUSH", CFLUSH}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 686 | #endif |
| 687 | #ifdef CINTR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 688 | {"CINTR", CINTR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 689 | #endif |
| 690 | #ifdef CKILL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 691 | {"CKILL", CKILL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 692 | #endif |
| 693 | #ifdef CLNEXT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 694 | {"CLNEXT", CLNEXT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 695 | #endif |
| 696 | #ifdef CNUL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 697 | {"CNUL", CNUL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 698 | #endif |
| 699 | #ifdef COMMON |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 700 | {"COMMON", COMMON}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 701 | #endif |
| 702 | #ifdef CQUIT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 703 | {"CQUIT", CQUIT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 704 | #endif |
| 705 | #ifdef CRPRNT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 706 | {"CRPRNT", CRPRNT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 707 | #endif |
| 708 | #ifdef CSTART |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 709 | {"CSTART", CSTART}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 710 | #endif |
| 711 | #ifdef CSTOP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 712 | {"CSTOP", CSTOP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 713 | #endif |
| 714 | #ifdef CSUSP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 715 | {"CSUSP", CSUSP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 716 | #endif |
| 717 | #ifdef CSWTCH |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 718 | {"CSWTCH", CSWTCH}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 719 | #endif |
| 720 | #ifdef CWERASE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 721 | {"CWERASE", CWERASE}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 722 | #endif |
| 723 | #ifdef EXTA |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 724 | {"EXTA", EXTA}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 725 | #endif |
| 726 | #ifdef EXTB |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 727 | {"EXTB", EXTB}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 728 | #endif |
| 729 | #ifdef FIOASYNC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 730 | {"FIOASYNC", FIOASYNC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 731 | #endif |
| 732 | #ifdef FIOCLEX |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 733 | {"FIOCLEX", FIOCLEX}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 734 | #endif |
| 735 | #ifdef FIONBIO |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 736 | {"FIONBIO", FIONBIO}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 737 | #endif |
| 738 | #ifdef FIONCLEX |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 739 | {"FIONCLEX", FIONCLEX}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 740 | #endif |
| 741 | #ifdef FIONREAD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 742 | {"FIONREAD", FIONREAD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 743 | #endif |
| 744 | #ifdef IBSHIFT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 745 | {"IBSHIFT", IBSHIFT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 746 | #endif |
| 747 | #ifdef INIT_C_CC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 748 | {"INIT_C_CC", INIT_C_CC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 749 | #endif |
| 750 | #ifdef IOCSIZE_MASK |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 751 | {"IOCSIZE_MASK", IOCSIZE_MASK}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 752 | #endif |
| 753 | #ifdef IOCSIZE_SHIFT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 754 | {"IOCSIZE_SHIFT", IOCSIZE_SHIFT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 755 | #endif |
| 756 | #ifdef NCC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 757 | {"NCC", NCC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 758 | #endif |
| 759 | #ifdef NCCS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 760 | {"NCCS", NCCS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 761 | #endif |
| 762 | #ifdef NSWTCH |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 763 | {"NSWTCH", NSWTCH}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 764 | #endif |
| 765 | #ifdef N_MOUSE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 766 | {"N_MOUSE", N_MOUSE}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 767 | #endif |
| 768 | #ifdef N_PPP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 769 | {"N_PPP", N_PPP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 770 | #endif |
| 771 | #ifdef N_SLIP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 772 | {"N_SLIP", N_SLIP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 773 | #endif |
| 774 | #ifdef N_STRIP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 775 | {"N_STRIP", N_STRIP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 776 | #endif |
| 777 | #ifdef N_TTY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 778 | {"N_TTY", N_TTY}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 779 | #endif |
| 780 | #ifdef TCFLSH |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 781 | {"TCFLSH", TCFLSH}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 782 | #endif |
| 783 | #ifdef TCGETA |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 784 | {"TCGETA", TCGETA}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 785 | #endif |
| 786 | #ifdef TCGETS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 787 | {"TCGETS", TCGETS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 788 | #endif |
| 789 | #ifdef TCSBRK |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 790 | {"TCSBRK", TCSBRK}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 791 | #endif |
| 792 | #ifdef TCSBRKP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 793 | {"TCSBRKP", TCSBRKP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 794 | #endif |
| 795 | #ifdef TCSETA |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 796 | {"TCSETA", TCSETA}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 797 | #endif |
| 798 | #ifdef TCSETAF |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 799 | {"TCSETAF", TCSETAF}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 800 | #endif |
| 801 | #ifdef TCSETAW |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 802 | {"TCSETAW", TCSETAW}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 803 | #endif |
| 804 | #ifdef TCSETS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 805 | {"TCSETS", TCSETS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 806 | #endif |
| 807 | #ifdef TCSETSF |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 808 | {"TCSETSF", TCSETSF}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 809 | #endif |
| 810 | #ifdef TCSETSW |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 811 | {"TCSETSW", TCSETSW}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 812 | #endif |
| 813 | #ifdef TCXONC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 814 | {"TCXONC", TCXONC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 815 | #endif |
| 816 | #ifdef TIOCCONS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 817 | {"TIOCCONS", TIOCCONS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 818 | #endif |
| 819 | #ifdef TIOCEXCL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 820 | {"TIOCEXCL", TIOCEXCL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 821 | #endif |
| 822 | #ifdef TIOCGETD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 823 | {"TIOCGETD", TIOCGETD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 824 | #endif |
| 825 | #ifdef TIOCGICOUNT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 826 | {"TIOCGICOUNT", TIOCGICOUNT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 827 | #endif |
| 828 | #ifdef TIOCGLCKTRMIOS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 829 | {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 830 | #endif |
| 831 | #ifdef TIOCGPGRP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 832 | {"TIOCGPGRP", TIOCGPGRP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 833 | #endif |
| 834 | #ifdef TIOCGSERIAL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 835 | {"TIOCGSERIAL", TIOCGSERIAL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 836 | #endif |
| 837 | #ifdef TIOCGSOFTCAR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 838 | {"TIOCGSOFTCAR", TIOCGSOFTCAR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 839 | #endif |
| 840 | #ifdef TIOCGWINSZ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 841 | {"TIOCGWINSZ", TIOCGWINSZ}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 842 | #endif |
| 843 | #ifdef TIOCINQ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 844 | {"TIOCINQ", TIOCINQ}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 845 | #endif |
| 846 | #ifdef TIOCLINUX |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 847 | {"TIOCLINUX", TIOCLINUX}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 848 | #endif |
| 849 | #ifdef TIOCMBIC |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 850 | {"TIOCMBIC", TIOCMBIC}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 851 | #endif |
| 852 | #ifdef TIOCMBIS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 853 | {"TIOCMBIS", TIOCMBIS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 854 | #endif |
| 855 | #ifdef TIOCMGET |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 856 | {"TIOCMGET", TIOCMGET}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 857 | #endif |
| 858 | #ifdef TIOCMIWAIT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 859 | {"TIOCMIWAIT", TIOCMIWAIT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 860 | #endif |
| 861 | #ifdef TIOCMSET |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 862 | {"TIOCMSET", TIOCMSET}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 863 | #endif |
| 864 | #ifdef TIOCM_CAR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 865 | {"TIOCM_CAR", TIOCM_CAR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 866 | #endif |
| 867 | #ifdef TIOCM_CD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 868 | {"TIOCM_CD", TIOCM_CD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 869 | #endif |
| 870 | #ifdef TIOCM_CTS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 871 | {"TIOCM_CTS", TIOCM_CTS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 872 | #endif |
| 873 | #ifdef TIOCM_DSR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 874 | {"TIOCM_DSR", TIOCM_DSR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 875 | #endif |
| 876 | #ifdef TIOCM_DTR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 877 | {"TIOCM_DTR", TIOCM_DTR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 878 | #endif |
| 879 | #ifdef TIOCM_LE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 880 | {"TIOCM_LE", TIOCM_LE}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 881 | #endif |
| 882 | #ifdef TIOCM_RI |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 883 | {"TIOCM_RI", TIOCM_RI}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 884 | #endif |
| 885 | #ifdef TIOCM_RNG |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 886 | {"TIOCM_RNG", TIOCM_RNG}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 887 | #endif |
| 888 | #ifdef TIOCM_RTS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 889 | {"TIOCM_RTS", TIOCM_RTS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 890 | #endif |
| 891 | #ifdef TIOCM_SR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 892 | {"TIOCM_SR", TIOCM_SR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 893 | #endif |
| 894 | #ifdef TIOCM_ST |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 895 | {"TIOCM_ST", TIOCM_ST}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 896 | #endif |
| 897 | #ifdef TIOCNOTTY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 898 | {"TIOCNOTTY", TIOCNOTTY}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 899 | #endif |
| 900 | #ifdef TIOCNXCL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 901 | {"TIOCNXCL", TIOCNXCL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 902 | #endif |
| 903 | #ifdef TIOCOUTQ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 904 | {"TIOCOUTQ", TIOCOUTQ}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 905 | #endif |
| 906 | #ifdef TIOCPKT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 907 | {"TIOCPKT", TIOCPKT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 908 | #endif |
| 909 | #ifdef TIOCPKT_DATA |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 910 | {"TIOCPKT_DATA", TIOCPKT_DATA}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 911 | #endif |
| 912 | #ifdef TIOCPKT_DOSTOP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 913 | {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 914 | #endif |
| 915 | #ifdef TIOCPKT_FLUSHREAD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 916 | {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 917 | #endif |
| 918 | #ifdef TIOCPKT_FLUSHWRITE |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 919 | {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 920 | #endif |
| 921 | #ifdef TIOCPKT_NOSTOP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 922 | {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 923 | #endif |
| 924 | #ifdef TIOCPKT_START |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 925 | {"TIOCPKT_START", TIOCPKT_START}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 926 | #endif |
| 927 | #ifdef TIOCPKT_STOP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 928 | {"TIOCPKT_STOP", TIOCPKT_STOP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 929 | #endif |
| 930 | #ifdef TIOCSCTTY |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 931 | {"TIOCSCTTY", TIOCSCTTY}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 932 | #endif |
| 933 | #ifdef TIOCSERCONFIG |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 934 | {"TIOCSERCONFIG", TIOCSERCONFIG}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 935 | #endif |
| 936 | #ifdef TIOCSERGETLSR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 937 | {"TIOCSERGETLSR", TIOCSERGETLSR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 938 | #endif |
| 939 | #ifdef TIOCSERGETMULTI |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 940 | {"TIOCSERGETMULTI", TIOCSERGETMULTI}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 941 | #endif |
| 942 | #ifdef TIOCSERGSTRUCT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 943 | {"TIOCSERGSTRUCT", TIOCSERGSTRUCT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 944 | #endif |
| 945 | #ifdef TIOCSERGWILD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 946 | {"TIOCSERGWILD", TIOCSERGWILD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 947 | #endif |
| 948 | #ifdef TIOCSERSETMULTI |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 949 | {"TIOCSERSETMULTI", TIOCSERSETMULTI}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 950 | #endif |
| 951 | #ifdef TIOCSERSWILD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 952 | {"TIOCSERSWILD", TIOCSERSWILD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 953 | #endif |
| 954 | #ifdef TIOCSER_TEMT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 955 | {"TIOCSER_TEMT", TIOCSER_TEMT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 956 | #endif |
| 957 | #ifdef TIOCSETD |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 958 | {"TIOCSETD", TIOCSETD}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 959 | #endif |
| 960 | #ifdef TIOCSLCKTRMIOS |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 961 | {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 962 | #endif |
| 963 | #ifdef TIOCSPGRP |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 964 | {"TIOCSPGRP", TIOCSPGRP}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 965 | #endif |
| 966 | #ifdef TIOCSSERIAL |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 967 | {"TIOCSSERIAL", TIOCSSERIAL}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 968 | #endif |
| 969 | #ifdef TIOCSSOFTCAR |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 970 | {"TIOCSSOFTCAR", TIOCSSOFTCAR}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 971 | #endif |
| 972 | #ifdef TIOCSTI |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 973 | {"TIOCSTI", TIOCSTI}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 974 | #endif |
| 975 | #ifdef TIOCSWINSZ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 976 | {"TIOCSWINSZ", TIOCSWINSZ}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 977 | #endif |
| 978 | #ifdef TIOCTTYGSTRUCT |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 979 | {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT}, |
Fred Drake | 55a0034 | 2001-03-26 17:14:02 +0000 | [diff] [blame] | 980 | #endif |
| 981 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 982 | /* sentinel */ |
| 983 | {NULL, 0} |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 984 | }; |
| 985 | |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 986 | static int termiosmodule_traverse(PyObject *m, visitproc visit, void *arg) { |
Hai Shi | f707d94 | 2020-03-16 21:15:01 +0800 | [diff] [blame] | 987 | Py_VISIT(get_termios_state(m)->TermiosError); |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | static int termiosmodule_clear(PyObject *m) { |
Hai Shi | f707d94 | 2020-03-16 21:15:01 +0800 | [diff] [blame] | 992 | Py_CLEAR(get_termios_state(m)->TermiosError); |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 993 | return 0; |
| 994 | } |
| 995 | |
| 996 | static void termiosmodule_free(void *m) { |
| 997 | termiosmodule_clear((PyObject *)m); |
| 998 | } |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 999 | |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 1000 | static struct PyModuleDef termiosmodule = { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1001 | PyModuleDef_HEAD_INIT, |
| 1002 | "termios", |
| 1003 | termios__doc__, |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 1004 | sizeof(termiosmodulestate), |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1005 | termios_methods, |
| 1006 | NULL, |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 1007 | termiosmodule_traverse, |
| 1008 | termiosmodule_clear, |
| 1009 | termiosmodule_free, |
Martin v. Löwis | 1a21451 | 2008-06-11 05:26:20 +0000 | [diff] [blame] | 1010 | }; |
| 1011 | |
Mark Hammond | fe51c6d | 2002-08-02 02:27:13 +0000 | [diff] [blame] | 1012 | PyMODINIT_FUNC |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 1013 | PyInit_termios(void) |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 1014 | { |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1015 | PyObject *m; |
| 1016 | struct constant *constant = termios_constants; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 1017 | |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 1018 | if ((m = PyState_FindModule(&termiosmodule)) != NULL) { |
| 1019 | Py_INCREF(m); |
| 1020 | return m; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1021 | } |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 1022 | |
| 1023 | if ((m = PyModule_Create(&termiosmodule)) == NULL) { |
| 1024 | return NULL; |
| 1025 | } |
| 1026 | |
Hai Shi | f707d94 | 2020-03-16 21:15:01 +0800 | [diff] [blame] | 1027 | termiosmodulestate *state = get_termios_state(m); |
Dino Viehland | bd0c7a1 | 2019-09-10 11:33:30 +0100 | [diff] [blame] | 1028 | state->TermiosError = PyErr_NewException("termios.error", NULL, NULL); |
| 1029 | if (state->TermiosError == NULL) { |
| 1030 | return NULL; |
| 1031 | } |
| 1032 | Py_INCREF(state->TermiosError); |
| 1033 | PyModule_AddObject(m, "error", state->TermiosError); |
Fred Drake | df48d14 | 2001-02-27 21:22:39 +0000 | [diff] [blame] | 1034 | |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1035 | while (constant->name != NULL) { |
| 1036 | PyModule_AddIntConstant(m, constant->name, constant->value); |
| 1037 | ++constant; |
| 1038 | } |
| 1039 | return m; |
Guido van Rossum | 9adae8e | 1994-09-12 10:41:22 +0000 | [diff] [blame] | 1040 | } |