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