blob: 7601b68afda3c9ff77980781b84e5b3f43ea03fd [file] [log] [blame]
Guido van Rossum9adae8e1994-09-12 10:41:22 +00001/* termiosmodule.c -- POSIX terminal I/O module implementation. */
2
Guido van Rossumca6954a1999-01-14 19:31:42 +00003#include "Python.h"
Guido van Rossum9adae8e1994-09-12 10:41:22 +00004
Martin v. Löwisbe4fea62003-10-31 13:01:24 +00005/* 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
jceaf0a95f22018-01-28 14:00:48 +010011#if defined(__sun)
12/* We could do better. Check issue-32660 */
13#include <sys/filio.h>
14#include <sys/sockio.h>
15#endif
16
Guido van Rossum9adae8e1994-09-12 10:41:22 +000017#include <termios.h>
Fred Drake9b3bc492001-04-04 21:19:26 +000018#include <sys/ioctl.h>
Guido van Rossum1aca4d81998-03-03 22:10:18 +000019
Fred Drake87068f12001-05-11 16:14:17 +000020/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
21 * MDTR, MRI, and MRTS (appearantly used internally by some things
22 * defined as macros; these are not used here directly).
23 */
24#ifdef HAVE_SYS_MODEM_H
25#include <sys/modem.h>
26#endif
Neal Norwitz82251032003-05-23 14:35:24 +000027/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
28#ifdef HAVE_SYS_BSDTTY_H
29#include <sys/bsdtty.h>
30#endif
Fred Drake87068f12001-05-11 16:14:17 +000031
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000032PyDoc_STRVAR(termios__doc__,
33"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000034For a complete description of these calls, see the Posix or Unix manual\n\
35pages. It is only available for those Unix versions that support Posix\n\
36termios style tty I/O control.\n\
37\n\
38All functions in this module take a file descriptor fd as their first\n\
39argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000040sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000041
42static PyObject *TermiosError;
43
Fred Drakeb638aaf2001-05-07 17:55:35 +000044static int fdconv(PyObject* obj, void* p)
45{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000046 int fd;
Fred Drakeb638aaf2001-05-07 17:55:35 +000047
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000048 fd = PyObject_AsFileDescriptor(obj);
49 if (fd >= 0) {
50 *(int*)p = fd;
51 return 1;
52 }
53 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000054}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000055
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000056PyDoc_STRVAR(termios_tcgetattr__doc__,
57"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000058\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000059Get the tty attributes for file descriptor fd, as follows:\n\
60[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
61of the tty special characters (each a string of length 1, except the items\n\
62with indices VMIN and VTIME, which are integers when these fields are\n\
63defined). The interpretation of the flags and the speeds as well as the\n\
64indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000065in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000066
Guido van Rossum9adae8e1994-09-12 10:41:22 +000067static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000068termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000069{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000070 int fd;
71 struct termios mode;
72 PyObject *cc;
73 speed_t ispeed, ospeed;
74 PyObject *v;
75 int i;
76 char ch;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000077
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000078 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
79 fdconv, (void*)&fd))
80 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000081
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000082 if (tcgetattr(fd, &mode) == -1)
83 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000084
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000085 ispeed = cfgetispeed(&mode);
86 ospeed = cfgetospeed(&mode);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000087
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000088 cc = PyList_New(NCCS);
89 if (cc == NULL)
90 return NULL;
91 for (i = 0; i < NCCS; i++) {
92 ch = (char)mode.c_cc[i];
93 v = PyBytes_FromStringAndSize(&ch, 1);
94 if (v == NULL)
95 goto err;
96 PyList_SetItem(cc, i, v);
97 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +000098
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000099 /* Convert the MIN and TIME slots to integer. On some systems, the
100 MIN and TIME slots are the same as the EOF and EOL slots. So we
101 only do this in noncanonical input mode. */
102 if ((mode.c_lflag & ICANON) == 0) {
103 v = PyLong_FromLong((long)mode.c_cc[VMIN]);
104 if (v == NULL)
105 goto err;
106 PyList_SetItem(cc, VMIN, v);
107 v = PyLong_FromLong((long)mode.c_cc[VTIME]);
108 if (v == NULL)
109 goto err;
110 PyList_SetItem(cc, VTIME, v);
111 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000112
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000113 if (!(v = PyList_New(7)))
114 goto err;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000115
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000116 PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag));
117 PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag));
118 PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag));
119 PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag));
120 PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed));
121 PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed));
Zackery Spytz53835e92018-10-28 22:55:20 -0600122 if (PyErr_Occurred()) {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000123 Py_DECREF(v);
124 goto err;
125 }
Zackery Spytz53835e92018-10-28 22:55:20 -0600126 PyList_SetItem(v, 6, cc);
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000127 return v;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000128 err:
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000129 Py_DECREF(cc);
130 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000131}
132
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000133PyDoc_STRVAR(termios_tcsetattr__doc__,
134"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000135\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000136Set the tty attributes for file descriptor fd.\n\
137The attributes to be set are taken from the attributes argument, which\n\
138is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000139determines when the attributes are changed: termios.TCSANOW to\n\
140change immediately, termios.TCSADRAIN to change after transmitting all\n\
141queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000142queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000143
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000144static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000145termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000146{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000147 int fd, when;
148 struct termios mode;
149 speed_t ispeed, ospeed;
150 PyObject *term, *cc, *v;
151 int i;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000152
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000153 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
154 fdconv, &fd, &when, &term))
155 return NULL;
156 if (!PyList_Check(term) || PyList_Size(term) != 7) {
157 PyErr_SetString(PyExc_TypeError,
158 "tcsetattr, arg 3: must be 7 element list");
159 return NULL;
160 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000161
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000162 /* Get the old mode, in case there are any hidden fields... */
163 if (tcgetattr(fd, &mode) == -1)
164 return PyErr_SetFromErrno(TermiosError);
165 mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0));
166 mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1));
167 mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2));
168 mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3));
169 ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4));
170 ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5));
171 cc = PyList_GetItem(term, 6);
172 if (PyErr_Occurred())
173 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000174
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000175 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
176 PyErr_Format(PyExc_TypeError,
177 "tcsetattr: attributes[6] must be %d element list",
178 NCCS);
179 return NULL;
180 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000181
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000182 for (i = 0; i < NCCS; i++) {
183 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000184
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000185 if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
186 mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
187 else if (PyLong_Check(v))
188 mode.c_cc[i] = (cc_t) PyLong_AsLong(v);
189 else {
190 PyErr_SetString(PyExc_TypeError,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000191 "tcsetattr: elements of attributes must be characters or integers");
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000192 return NULL;
193 }
194 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000195
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000196 if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
197 return PyErr_SetFromErrno(TermiosError);
198 if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
199 return PyErr_SetFromErrno(TermiosError);
200 if (tcsetattr(fd, when, &mode) == -1)
201 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000202
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200203 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000204}
205
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000206PyDoc_STRVAR(termios_tcsendbreak__doc__,
207"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000208\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000209Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000210A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000211has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000212
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000213static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000214termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000215{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000216 int fd, duration;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000217
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000218 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
219 fdconv, &fd, &duration))
220 return NULL;
221 if (tcsendbreak(fd, duration) == -1)
222 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000223
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200224 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000225}
226
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000227PyDoc_STRVAR(termios_tcdrain__doc__,
228"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000229\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000230Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000231
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000232static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000233termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000234{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000235 int fd;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000236
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000237 if (!PyArg_ParseTuple(args, "O&:tcdrain",
238 fdconv, &fd))
239 return NULL;
240 if (tcdrain(fd) == -1)
241 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000242
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200243 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000244}
245
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000246PyDoc_STRVAR(termios_tcflush__doc__,
247"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000248\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000249Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000250The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
251queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000252both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000253
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000254static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000255termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000256{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000257 int fd, queue;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000258
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000259 if (!PyArg_ParseTuple(args, "O&i:tcflush",
260 fdconv, &fd, &queue))
261 return NULL;
262 if (tcflush(fd, queue) == -1)
263 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000264
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200265 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000266}
267
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000268PyDoc_STRVAR(termios_tcflow__doc__,
269"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000270\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000271Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000272The action argument can be termios.TCOOFF to suspend output,\n\
273termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000274or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000275
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000276static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000277termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000278{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000279 int fd, action;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000280
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000281 if (!PyArg_ParseTuple(args, "O&i:tcflow",
282 fdconv, &fd, &action))
283 return NULL;
284 if (tcflow(fd, action) == -1)
285 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000286
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200287 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000288}
289
290static PyMethodDef termios_methods[] =
291{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000292 {"tcgetattr", termios_tcgetattr,
293 METH_VARARGS, termios_tcgetattr__doc__},
294 {"tcsetattr", termios_tcsetattr,
295 METH_VARARGS, termios_tcsetattr__doc__},
296 {"tcsendbreak", termios_tcsendbreak,
297 METH_VARARGS, termios_tcsendbreak__doc__},
298 {"tcdrain", termios_tcdrain,
299 METH_VARARGS, termios_tcdrain__doc__},
300 {"tcflush", termios_tcflush,
301 METH_VARARGS, termios_tcflush__doc__},
302 {"tcflow", termios_tcflow,
303 METH_VARARGS, termios_tcflow__doc__},
304 {NULL, NULL}
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000305};
306
Fred Drakedf48d142001-02-27 21:22:39 +0000307
Fred Drake9ef7fa82001-03-01 21:54:49 +0000308#if defined(VSWTCH) && !defined(VSWTC)
309#define VSWTC VSWTCH
310#endif
311
312#if defined(VSWTC) && !defined(VSWTCH)
313#define VSWTCH VSWTC
314#endif
315
Fred Drakedf48d142001-02-27 21:22:39 +0000316static struct constant {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000317 char *name;
318 long value;
Fred Drakedf48d142001-02-27 21:22:39 +0000319} termios_constants[] = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000320 /* cfgetospeed(), cfsetospeed() constants */
321 {"B0", B0},
322 {"B50", B50},
323 {"B75", B75},
324 {"B110", B110},
325 {"B134", B134},
326 {"B150", B150},
327 {"B200", B200},
328 {"B300", B300},
329 {"B600", B600},
330 {"B1200", B1200},
331 {"B1800", B1800},
332 {"B2400", B2400},
333 {"B4800", B4800},
334 {"B9600", B9600},
335 {"B19200", B19200},
336 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000337#ifdef B57600
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000338 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000339#endif
340#ifdef B115200
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000341 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000342#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000343#ifdef B230400
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000344 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000345#endif
Antoine Pitroua78f74c2010-11-20 20:03:08 +0000346#ifdef B460800
347 {"B460800", B460800},
348#endif
349#ifdef B500000
350 {"B500000", B500000},
351#endif
352#ifdef B576000
353 {"B576000", B576000},
354#endif
355#ifdef B921600
356 {"B921600", B921600},
357#endif
358#ifdef B1000000
359 {"B1000000", B1000000},
360#endif
361#ifdef B1152000
362 {"B1152000", B1152000},
363#endif
364#ifdef B1500000
365 {"B1500000", B1500000},
366#endif
367#ifdef B2000000
368 {"B2000000", B2000000},
369#endif
370#ifdef B2500000
371 {"B2500000", B2500000},
372#endif
373#ifdef B3000000
374 {"B3000000", B3000000},
375#endif
376#ifdef B3500000
377 {"B3500000", B3500000},
378#endif
379#ifdef B4000000
380 {"B4000000", B4000000},
381#endif
382
Fred Drake9ef7fa82001-03-01 21:54:49 +0000383#ifdef CBAUDEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000384 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000385#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000386
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000387 /* tcsetattr() constants */
388 {"TCSANOW", TCSANOW},
389 {"TCSADRAIN", TCSADRAIN},
390 {"TCSAFLUSH", TCSAFLUSH},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000391#ifdef TCSASOFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000392 {"TCSASOFT", TCSASOFT},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000393#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000394
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000395 /* tcflush() constants */
396 {"TCIFLUSH", TCIFLUSH},
397 {"TCOFLUSH", TCOFLUSH},
398 {"TCIOFLUSH", TCIOFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000399
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000400 /* tcflow() constants */
401 {"TCOOFF", TCOOFF},
402 {"TCOON", TCOON},
403 {"TCIOFF", TCIOFF},
404 {"TCION", TCION},
Fred Drakedf48d142001-02-27 21:22:39 +0000405
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000406 /* struct termios.c_iflag constants */
407 {"IGNBRK", IGNBRK},
408 {"BRKINT", BRKINT},
409 {"IGNPAR", IGNPAR},
410 {"PARMRK", PARMRK},
411 {"INPCK", INPCK},
412 {"ISTRIP", ISTRIP},
413 {"INLCR", INLCR},
414 {"IGNCR", IGNCR},
415 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000416#ifdef IUCLC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000417 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000418#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000419 {"IXON", IXON},
420 {"IXANY", IXANY},
421 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000422#ifdef IMAXBEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000423 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000424#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000425
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000426 /* struct termios.c_oflag constants */
427 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000428#ifdef OLCUC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000429 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000430#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000431#ifdef ONLCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000432 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000433#endif
Fred Draked85556c2001-03-03 18:08:52 +0000434#ifdef OCRNL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000435 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000436#endif
437#ifdef ONOCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000438 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000439#endif
440#ifdef ONLRET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000441 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000442#endif
443#ifdef OFILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000444 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000445#endif
446#ifdef OFDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000447 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000448#endif
449#ifdef NLDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000450 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000451#endif
452#ifdef CRDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000453 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000454#endif
455#ifdef TABDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000456 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000457#endif
458#ifdef BSDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000459 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000460#endif
461#ifdef VTDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000462 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000463#endif
464#ifdef FFDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000465 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000466#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000467
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000468 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000469#ifdef NL0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000470 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000471#endif
472#ifdef NL1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000473 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000474#endif
475#ifdef CR0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000476 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000477#endif
478#ifdef CR1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000479 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000480#endif
481#ifdef CR2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000482 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000483#endif
484#ifdef CR3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000485 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000486#endif
487#ifdef TAB0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000488 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000489#endif
490#ifdef TAB1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000491 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000492#endif
493#ifdef TAB2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000494 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000495#endif
496#ifdef TAB3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000497 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000498#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000499#ifdef XTABS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000500 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000501#endif
Fred Draked85556c2001-03-03 18:08:52 +0000502#ifdef BS0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000503 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000504#endif
505#ifdef BS1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000506 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000507#endif
508#ifdef VT0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000509 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000510#endif
511#ifdef VT1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000512 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000513#endif
514#ifdef FF0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000515 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000516#endif
517#ifdef FF1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000518 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000519#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000520
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000521 /* struct termios.c_cflag constants */
522 {"CSIZE", CSIZE},
523 {"CSTOPB", CSTOPB},
524 {"CREAD", CREAD},
525 {"PARENB", PARENB},
526 {"PARODD", PARODD},
527 {"HUPCL", HUPCL},
528 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000529#ifdef CIBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000530 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000531#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000532#ifdef CRTSCTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000533 {"CRTSCTS", (long)CRTSCTS},
Fred Drakededbebf2001-03-02 06:50:58 +0000534#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000535
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000536 /* struct termios.c_cflag-related values (character size) */
537 {"CS5", CS5},
538 {"CS6", CS6},
539 {"CS7", CS7},
540 {"CS8", CS8},
Fred Drakedf48d142001-02-27 21:22:39 +0000541
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000542 /* struct termios.c_lflag constants */
543 {"ISIG", ISIG},
544 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000545#ifdef XCASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000546 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000547#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000548 {"ECHO", ECHO},
549 {"ECHOE", ECHOE},
550 {"ECHOK", ECHOK},
551 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000552#ifdef ECHOCTL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000553 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000554#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000555#ifdef ECHOPRT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000556 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000557#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000558#ifdef ECHOKE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000559 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000560#endif
561#ifdef FLUSHO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000562 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000563#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000564 {"NOFLSH", NOFLSH},
565 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000566#ifdef PENDIN
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000567 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000568#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000569 {"IEXTEN", IEXTEN},
Fred Drakedf48d142001-02-27 21:22:39 +0000570
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000571 /* indexes into the control chars array returned by tcgetattr() */
572 {"VINTR", VINTR},
573 {"VQUIT", VQUIT},
574 {"VERASE", VERASE},
575 {"VKILL", VKILL},
576 {"VEOF", VEOF},
577 {"VTIME", VTIME},
578 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000579#ifdef VSWTC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000580 /* The #defines above ensure that if either is defined, both are,
581 * but both may be omitted by the system headers. ;-( */
582 {"VSWTC", VSWTC},
583 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000584#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000585 {"VSTART", VSTART},
586 {"VSTOP", VSTOP},
587 {"VSUSP", VSUSP},
588 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000589#ifdef VREPRINT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000590 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000591#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000592#ifdef VDISCARD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000593 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000594#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000595#ifdef VWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000596 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000597#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000598#ifdef VLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000599 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000600#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000601#ifdef VEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000602 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000603#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000604
Fred Drake55a00342001-03-26 17:14:02 +0000605
606#ifdef B460800
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000607 {"B460800", B460800},
Fred Drake55a00342001-03-26 17:14:02 +0000608#endif
609#ifdef CBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000610 {"CBAUD", CBAUD},
Fred Drake55a00342001-03-26 17:14:02 +0000611#endif
612#ifdef CDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000613 {"CDEL", CDEL},
Fred Drake55a00342001-03-26 17:14:02 +0000614#endif
615#ifdef CDSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000616 {"CDSUSP", CDSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000617#endif
618#ifdef CEOF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000619 {"CEOF", CEOF},
Fred Drake55a00342001-03-26 17:14:02 +0000620#endif
621#ifdef CEOL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000622 {"CEOL", CEOL},
Fred Drake55a00342001-03-26 17:14:02 +0000623#endif
624#ifdef CEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000625 {"CEOL2", CEOL2},
Fred Drake55a00342001-03-26 17:14:02 +0000626#endif
627#ifdef CEOT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000628 {"CEOT", CEOT},
Fred Drake55a00342001-03-26 17:14:02 +0000629#endif
630#ifdef CERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000631 {"CERASE", CERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000632#endif
633#ifdef CESC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000634 {"CESC", CESC},
Fred Drake55a00342001-03-26 17:14:02 +0000635#endif
636#ifdef CFLUSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000637 {"CFLUSH", CFLUSH},
Fred Drake55a00342001-03-26 17:14:02 +0000638#endif
639#ifdef CINTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000640 {"CINTR", CINTR},
Fred Drake55a00342001-03-26 17:14:02 +0000641#endif
642#ifdef CKILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000643 {"CKILL", CKILL},
Fred Drake55a00342001-03-26 17:14:02 +0000644#endif
645#ifdef CLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000646 {"CLNEXT", CLNEXT},
Fred Drake55a00342001-03-26 17:14:02 +0000647#endif
648#ifdef CNUL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000649 {"CNUL", CNUL},
Fred Drake55a00342001-03-26 17:14:02 +0000650#endif
651#ifdef COMMON
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000652 {"COMMON", COMMON},
Fred Drake55a00342001-03-26 17:14:02 +0000653#endif
654#ifdef CQUIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000655 {"CQUIT", CQUIT},
Fred Drake55a00342001-03-26 17:14:02 +0000656#endif
657#ifdef CRPRNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000658 {"CRPRNT", CRPRNT},
Fred Drake55a00342001-03-26 17:14:02 +0000659#endif
660#ifdef CSTART
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000661 {"CSTART", CSTART},
Fred Drake55a00342001-03-26 17:14:02 +0000662#endif
663#ifdef CSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000664 {"CSTOP", CSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000665#endif
666#ifdef CSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000667 {"CSUSP", CSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000668#endif
669#ifdef CSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000670 {"CSWTCH", CSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000671#endif
672#ifdef CWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000673 {"CWERASE", CWERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000674#endif
675#ifdef EXTA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000676 {"EXTA", EXTA},
Fred Drake55a00342001-03-26 17:14:02 +0000677#endif
678#ifdef EXTB
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000679 {"EXTB", EXTB},
Fred Drake55a00342001-03-26 17:14:02 +0000680#endif
681#ifdef FIOASYNC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000682 {"FIOASYNC", FIOASYNC},
Fred Drake55a00342001-03-26 17:14:02 +0000683#endif
684#ifdef FIOCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000685 {"FIOCLEX", FIOCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000686#endif
687#ifdef FIONBIO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000688 {"FIONBIO", FIONBIO},
Fred Drake55a00342001-03-26 17:14:02 +0000689#endif
690#ifdef FIONCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000691 {"FIONCLEX", FIONCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000692#endif
693#ifdef FIONREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000694 {"FIONREAD", FIONREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000695#endif
696#ifdef IBSHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000697 {"IBSHIFT", IBSHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000698#endif
699#ifdef INIT_C_CC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000700 {"INIT_C_CC", INIT_C_CC},
Fred Drake55a00342001-03-26 17:14:02 +0000701#endif
702#ifdef IOCSIZE_MASK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000703 {"IOCSIZE_MASK", IOCSIZE_MASK},
Fred Drake55a00342001-03-26 17:14:02 +0000704#endif
705#ifdef IOCSIZE_SHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000706 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000707#endif
708#ifdef NCC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000709 {"NCC", NCC},
Fred Drake55a00342001-03-26 17:14:02 +0000710#endif
711#ifdef NCCS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000712 {"NCCS", NCCS},
Fred Drake55a00342001-03-26 17:14:02 +0000713#endif
714#ifdef NSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000715 {"NSWTCH", NSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000716#endif
717#ifdef N_MOUSE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000718 {"N_MOUSE", N_MOUSE},
Fred Drake55a00342001-03-26 17:14:02 +0000719#endif
720#ifdef N_PPP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000721 {"N_PPP", N_PPP},
Fred Drake55a00342001-03-26 17:14:02 +0000722#endif
723#ifdef N_SLIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000724 {"N_SLIP", N_SLIP},
Fred Drake55a00342001-03-26 17:14:02 +0000725#endif
726#ifdef N_STRIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000727 {"N_STRIP", N_STRIP},
Fred Drake55a00342001-03-26 17:14:02 +0000728#endif
729#ifdef N_TTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000730 {"N_TTY", N_TTY},
Fred Drake55a00342001-03-26 17:14:02 +0000731#endif
732#ifdef TCFLSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000733 {"TCFLSH", TCFLSH},
Fred Drake55a00342001-03-26 17:14:02 +0000734#endif
735#ifdef TCGETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000736 {"TCGETA", TCGETA},
Fred Drake55a00342001-03-26 17:14:02 +0000737#endif
738#ifdef TCGETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000739 {"TCGETS", TCGETS},
Fred Drake55a00342001-03-26 17:14:02 +0000740#endif
741#ifdef TCSBRK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000742 {"TCSBRK", TCSBRK},
Fred Drake55a00342001-03-26 17:14:02 +0000743#endif
744#ifdef TCSBRKP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000745 {"TCSBRKP", TCSBRKP},
Fred Drake55a00342001-03-26 17:14:02 +0000746#endif
747#ifdef TCSETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000748 {"TCSETA", TCSETA},
Fred Drake55a00342001-03-26 17:14:02 +0000749#endif
750#ifdef TCSETAF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000751 {"TCSETAF", TCSETAF},
Fred Drake55a00342001-03-26 17:14:02 +0000752#endif
753#ifdef TCSETAW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000754 {"TCSETAW", TCSETAW},
Fred Drake55a00342001-03-26 17:14:02 +0000755#endif
756#ifdef TCSETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000757 {"TCSETS", TCSETS},
Fred Drake55a00342001-03-26 17:14:02 +0000758#endif
759#ifdef TCSETSF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000760 {"TCSETSF", TCSETSF},
Fred Drake55a00342001-03-26 17:14:02 +0000761#endif
762#ifdef TCSETSW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000763 {"TCSETSW", TCSETSW},
Fred Drake55a00342001-03-26 17:14:02 +0000764#endif
765#ifdef TCXONC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000766 {"TCXONC", TCXONC},
Fred Drake55a00342001-03-26 17:14:02 +0000767#endif
768#ifdef TIOCCONS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000769 {"TIOCCONS", TIOCCONS},
Fred Drake55a00342001-03-26 17:14:02 +0000770#endif
771#ifdef TIOCEXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000772 {"TIOCEXCL", TIOCEXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000773#endif
774#ifdef TIOCGETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000775 {"TIOCGETD", TIOCGETD},
Fred Drake55a00342001-03-26 17:14:02 +0000776#endif
777#ifdef TIOCGICOUNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000778 {"TIOCGICOUNT", TIOCGICOUNT},
Fred Drake55a00342001-03-26 17:14:02 +0000779#endif
780#ifdef TIOCGLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000781 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000782#endif
783#ifdef TIOCGPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000784 {"TIOCGPGRP", TIOCGPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000785#endif
786#ifdef TIOCGSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000787 {"TIOCGSERIAL", TIOCGSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000788#endif
789#ifdef TIOCGSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000790 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000791#endif
792#ifdef TIOCGWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000793 {"TIOCGWINSZ", TIOCGWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000794#endif
795#ifdef TIOCINQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000796 {"TIOCINQ", TIOCINQ},
Fred Drake55a00342001-03-26 17:14:02 +0000797#endif
798#ifdef TIOCLINUX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000799 {"TIOCLINUX", TIOCLINUX},
Fred Drake55a00342001-03-26 17:14:02 +0000800#endif
801#ifdef TIOCMBIC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000802 {"TIOCMBIC", TIOCMBIC},
Fred Drake55a00342001-03-26 17:14:02 +0000803#endif
804#ifdef TIOCMBIS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000805 {"TIOCMBIS", TIOCMBIS},
Fred Drake55a00342001-03-26 17:14:02 +0000806#endif
807#ifdef TIOCMGET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000808 {"TIOCMGET", TIOCMGET},
Fred Drake55a00342001-03-26 17:14:02 +0000809#endif
810#ifdef TIOCMIWAIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000811 {"TIOCMIWAIT", TIOCMIWAIT},
Fred Drake55a00342001-03-26 17:14:02 +0000812#endif
813#ifdef TIOCMSET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000814 {"TIOCMSET", TIOCMSET},
Fred Drake55a00342001-03-26 17:14:02 +0000815#endif
816#ifdef TIOCM_CAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000817 {"TIOCM_CAR", TIOCM_CAR},
Fred Drake55a00342001-03-26 17:14:02 +0000818#endif
819#ifdef TIOCM_CD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000820 {"TIOCM_CD", TIOCM_CD},
Fred Drake55a00342001-03-26 17:14:02 +0000821#endif
822#ifdef TIOCM_CTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000823 {"TIOCM_CTS", TIOCM_CTS},
Fred Drake55a00342001-03-26 17:14:02 +0000824#endif
825#ifdef TIOCM_DSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000826 {"TIOCM_DSR", TIOCM_DSR},
Fred Drake55a00342001-03-26 17:14:02 +0000827#endif
828#ifdef TIOCM_DTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000829 {"TIOCM_DTR", TIOCM_DTR},
Fred Drake55a00342001-03-26 17:14:02 +0000830#endif
831#ifdef TIOCM_LE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000832 {"TIOCM_LE", TIOCM_LE},
Fred Drake55a00342001-03-26 17:14:02 +0000833#endif
834#ifdef TIOCM_RI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000835 {"TIOCM_RI", TIOCM_RI},
Fred Drake55a00342001-03-26 17:14:02 +0000836#endif
837#ifdef TIOCM_RNG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000838 {"TIOCM_RNG", TIOCM_RNG},
Fred Drake55a00342001-03-26 17:14:02 +0000839#endif
840#ifdef TIOCM_RTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000841 {"TIOCM_RTS", TIOCM_RTS},
Fred Drake55a00342001-03-26 17:14:02 +0000842#endif
843#ifdef TIOCM_SR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000844 {"TIOCM_SR", TIOCM_SR},
Fred Drake55a00342001-03-26 17:14:02 +0000845#endif
846#ifdef TIOCM_ST
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000847 {"TIOCM_ST", TIOCM_ST},
Fred Drake55a00342001-03-26 17:14:02 +0000848#endif
849#ifdef TIOCNOTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000850 {"TIOCNOTTY", TIOCNOTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000851#endif
852#ifdef TIOCNXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000853 {"TIOCNXCL", TIOCNXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000854#endif
855#ifdef TIOCOUTQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000856 {"TIOCOUTQ", TIOCOUTQ},
Fred Drake55a00342001-03-26 17:14:02 +0000857#endif
858#ifdef TIOCPKT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000859 {"TIOCPKT", TIOCPKT},
Fred Drake55a00342001-03-26 17:14:02 +0000860#endif
861#ifdef TIOCPKT_DATA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000862 {"TIOCPKT_DATA", TIOCPKT_DATA},
Fred Drake55a00342001-03-26 17:14:02 +0000863#endif
864#ifdef TIOCPKT_DOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000865 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000866#endif
867#ifdef TIOCPKT_FLUSHREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000868 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000869#endif
870#ifdef TIOCPKT_FLUSHWRITE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000871 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
Fred Drake55a00342001-03-26 17:14:02 +0000872#endif
873#ifdef TIOCPKT_NOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000874 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000875#endif
876#ifdef TIOCPKT_START
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000877 {"TIOCPKT_START", TIOCPKT_START},
Fred Drake55a00342001-03-26 17:14:02 +0000878#endif
879#ifdef TIOCPKT_STOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000880 {"TIOCPKT_STOP", TIOCPKT_STOP},
Fred Drake55a00342001-03-26 17:14:02 +0000881#endif
882#ifdef TIOCSCTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000883 {"TIOCSCTTY", TIOCSCTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000884#endif
885#ifdef TIOCSERCONFIG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000886 {"TIOCSERCONFIG", TIOCSERCONFIG},
Fred Drake55a00342001-03-26 17:14:02 +0000887#endif
888#ifdef TIOCSERGETLSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000889 {"TIOCSERGETLSR", TIOCSERGETLSR},
Fred Drake55a00342001-03-26 17:14:02 +0000890#endif
891#ifdef TIOCSERGETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000892 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000893#endif
894#ifdef TIOCSERGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000895 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000896#endif
897#ifdef TIOCSERGWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000898 {"TIOCSERGWILD", TIOCSERGWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000899#endif
900#ifdef TIOCSERSETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000901 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000902#endif
903#ifdef TIOCSERSWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000904 {"TIOCSERSWILD", TIOCSERSWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000905#endif
906#ifdef TIOCSER_TEMT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000907 {"TIOCSER_TEMT", TIOCSER_TEMT},
Fred Drake55a00342001-03-26 17:14:02 +0000908#endif
909#ifdef TIOCSETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000910 {"TIOCSETD", TIOCSETD},
Fred Drake55a00342001-03-26 17:14:02 +0000911#endif
912#ifdef TIOCSLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000913 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000914#endif
915#ifdef TIOCSPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000916 {"TIOCSPGRP", TIOCSPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000917#endif
918#ifdef TIOCSSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000919 {"TIOCSSERIAL", TIOCSSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000920#endif
921#ifdef TIOCSSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000922 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000923#endif
924#ifdef TIOCSTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000925 {"TIOCSTI", TIOCSTI},
Fred Drake55a00342001-03-26 17:14:02 +0000926#endif
927#ifdef TIOCSWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000928 {"TIOCSWINSZ", TIOCSWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000929#endif
930#ifdef TIOCTTYGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000931 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000932#endif
933
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000934 /* sentinel */
935 {NULL, 0}
Fred Drakedf48d142001-02-27 21:22:39 +0000936};
937
938
Martin v. Löwis1a214512008-06-11 05:26:20 +0000939static struct PyModuleDef termiosmodule = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000940 PyModuleDef_HEAD_INIT,
941 "termios",
942 termios__doc__,
943 -1,
944 termios_methods,
945 NULL,
946 NULL,
947 NULL,
948 NULL
Martin v. Löwis1a214512008-06-11 05:26:20 +0000949};
950
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000951PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000952PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000953{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000954 PyObject *m;
955 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000956
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000957 m = PyModule_Create(&termiosmodule);
958 if (m == NULL)
959 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000960
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000961 if (TermiosError == NULL) {
962 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
963 }
964 Py_INCREF(TermiosError);
965 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000966
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000967 while (constant->name != NULL) {
968 PyModule_AddIntConstant(m, constant->name, constant->value);
969 ++constant;
970 }
971 return m;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000972}