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