blob: 97a0da2bccba0987cf5c79c668fbebbd41c8d4d2 [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
Guido van Rossum9adae8e1994-09-12 10:41:22 +000011#include <termios.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +000012#ifdef __osf__
13/* On OSF, sys/ioctl.h requires that struct termio already be defined,
14 * so this needs to be included first on that platform. */
Fred Drakeb638aaf2001-05-07 17:55:35 +000015#include <termio.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +000016#endif
Fred Drake9b3bc492001-04-04 21:19:26 +000017#include <sys/ioctl.h>
Guido van Rossum1aca4d81998-03-03 22:10:18 +000018
Fred Drake87068f12001-05-11 16:14:17 +000019/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
20 * MDTR, MRI, and MRTS (appearantly used internally by some things
21 * defined as macros; these are not used here directly).
22 */
23#ifdef HAVE_SYS_MODEM_H
24#include <sys/modem.h>
25#endif
Neal Norwitz82251032003-05-23 14:35:24 +000026/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
27#ifdef HAVE_SYS_BSDTTY_H
28#include <sys/bsdtty.h>
29#endif
Fred Drake87068f12001-05-11 16:14:17 +000030
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000031PyDoc_STRVAR(termios__doc__,
32"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000033For a complete description of these calls, see the Posix or Unix manual\n\
34pages. It is only available for those Unix versions that support Posix\n\
35termios style tty I/O control.\n\
36\n\
37All functions in this module take a file descriptor fd as their first\n\
38argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000039sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000040
41static PyObject *TermiosError;
42
Fred Drakeb638aaf2001-05-07 17:55:35 +000043static int fdconv(PyObject* obj, void* p)
44{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000045 int fd;
Fred Drakeb638aaf2001-05-07 17:55:35 +000046
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000047 fd = PyObject_AsFileDescriptor(obj);
48 if (fd >= 0) {
49 *(int*)p = fd;
50 return 1;
51 }
52 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000053}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000054
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000055PyDoc_STRVAR(termios_tcgetattr__doc__,
56"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000057\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000058Get the tty attributes for file descriptor fd, as follows:\n\
59[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
60of the tty special characters (each a string of length 1, except the items\n\
61with indices VMIN and VTIME, which are integers when these fields are\n\
62defined). The interpretation of the flags and the speeds as well as the\n\
63indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000064in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000065
Guido van Rossum9adae8e1994-09-12 10:41:22 +000066static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000067termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000068{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000069 int fd;
70 struct termios mode;
71 PyObject *cc;
72 speed_t ispeed, ospeed;
73 PyObject *v;
74 int i;
75 char ch;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000076
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000077 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
78 fdconv, (void*)&fd))
79 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000080
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000081 if (tcgetattr(fd, &mode) == -1)
82 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000083
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000084 ispeed = cfgetispeed(&mode);
85 ospeed = cfgetospeed(&mode);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000086
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000087 cc = PyList_New(NCCS);
88 if (cc == NULL)
89 return NULL;
90 for (i = 0; i < NCCS; i++) {
91 ch = (char)mode.c_cc[i];
92 v = PyBytes_FromStringAndSize(&ch, 1);
93 if (v == NULL)
94 goto err;
95 PyList_SetItem(cc, i, v);
96 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +000097
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +000098 /* Convert the MIN and TIME slots to integer. On some systems, the
99 MIN and TIME slots are the same as the EOF and EOL slots. So we
100 only do this in noncanonical input mode. */
101 if ((mode.c_lflag & ICANON) == 0) {
102 v = PyLong_FromLong((long)mode.c_cc[VMIN]);
103 if (v == NULL)
104 goto err;
105 PyList_SetItem(cc, VMIN, v);
106 v = PyLong_FromLong((long)mode.c_cc[VTIME]);
107 if (v == NULL)
108 goto err;
109 PyList_SetItem(cc, VTIME, v);
110 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000111
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000112 if (!(v = PyList_New(7)))
113 goto err;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000114
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000115 PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag));
116 PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag));
117 PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag));
118 PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag));
119 PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed));
120 PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed));
121 PyList_SetItem(v, 6, cc);
122 if (PyErr_Occurred()){
123 Py_DECREF(v);
124 goto err;
125 }
126 return v;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000127 err:
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000128 Py_DECREF(cc);
129 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000130}
131
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000132PyDoc_STRVAR(termios_tcsetattr__doc__,
133"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000134\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000135Set the tty attributes for file descriptor fd.\n\
136The attributes to be set are taken from the attributes argument, which\n\
137is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000138determines when the attributes are changed: termios.TCSANOW to\n\
139change immediately, termios.TCSADRAIN to change after transmitting all\n\
140queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000141queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000142
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000143static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000144termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000145{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000146 int fd, when;
147 struct termios mode;
148 speed_t ispeed, ospeed;
149 PyObject *term, *cc, *v;
150 int i;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000151
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000152 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
153 fdconv, &fd, &when, &term))
154 return NULL;
155 if (!PyList_Check(term) || PyList_Size(term) != 7) {
156 PyErr_SetString(PyExc_TypeError,
157 "tcsetattr, arg 3: must be 7 element list");
158 return NULL;
159 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000160
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000161 /* Get the old mode, in case there are any hidden fields... */
162 if (tcgetattr(fd, &mode) == -1)
163 return PyErr_SetFromErrno(TermiosError);
164 mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0));
165 mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1));
166 mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2));
167 mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3));
168 ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4));
169 ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5));
170 cc = PyList_GetItem(term, 6);
171 if (PyErr_Occurred())
172 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000173
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000174 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
175 PyErr_Format(PyExc_TypeError,
176 "tcsetattr: attributes[6] must be %d element list",
177 NCCS);
178 return NULL;
179 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000180
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000181 for (i = 0; i < NCCS; i++) {
182 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000183
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000184 if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
185 mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
186 else if (PyLong_Check(v))
187 mode.c_cc[i] = (cc_t) PyLong_AsLong(v);
188 else {
189 PyErr_SetString(PyExc_TypeError,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000190 "tcsetattr: elements of attributes must be characters or integers");
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000191 return NULL;
192 }
193 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000194
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000195 if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
196 return PyErr_SetFromErrno(TermiosError);
197 if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
198 return PyErr_SetFromErrno(TermiosError);
199 if (tcsetattr(fd, when, &mode) == -1)
200 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000201
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000202 Py_INCREF(Py_None);
203 return Py_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 Pitrou7f14f0d2010-05-09 16:14:21 +0000216 int fd, duration;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000217
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +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
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000224 Py_INCREF(Py_None);
225 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000226}
227
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000228PyDoc_STRVAR(termios_tcdrain__doc__,
229"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000230\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000231Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000232
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000233static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000234termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000235{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000236 int fd;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000237
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000238 if (!PyArg_ParseTuple(args, "O&:tcdrain",
239 fdconv, &fd))
240 return NULL;
241 if (tcdrain(fd) == -1)
242 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000243
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000244 Py_INCREF(Py_None);
245 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000246}
247
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000248PyDoc_STRVAR(termios_tcflush__doc__,
249"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000250\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000251Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000252The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
253queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000254both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000255
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000256static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000257termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000258{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000259 int fd, queue;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000260
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000261 if (!PyArg_ParseTuple(args, "O&i:tcflush",
262 fdconv, &fd, &queue))
263 return NULL;
264 if (tcflush(fd, queue) == -1)
265 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000266
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000267 Py_INCREF(Py_None);
268 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000269}
270
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000271PyDoc_STRVAR(termios_tcflow__doc__,
272"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000273\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000274Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000275The action argument can be termios.TCOOFF to suspend output,\n\
276termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000277or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000278
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000279static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000280termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000281{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000282 int fd, action;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000283
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000284 if (!PyArg_ParseTuple(args, "O&i:tcflow",
285 fdconv, &fd, &action))
286 return NULL;
287 if (tcflow(fd, action) == -1)
288 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000289
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000290 Py_INCREF(Py_None);
291 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000292}
293
294static PyMethodDef termios_methods[] =
295{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000296 {"tcgetattr", termios_tcgetattr,
297 METH_VARARGS, termios_tcgetattr__doc__},
298 {"tcsetattr", termios_tcsetattr,
299 METH_VARARGS, termios_tcsetattr__doc__},
300 {"tcsendbreak", termios_tcsendbreak,
301 METH_VARARGS, termios_tcsendbreak__doc__},
302 {"tcdrain", termios_tcdrain,
303 METH_VARARGS, termios_tcdrain__doc__},
304 {"tcflush", termios_tcflush,
305 METH_VARARGS, termios_tcflush__doc__},
306 {"tcflow", termios_tcflow,
307 METH_VARARGS, termios_tcflow__doc__},
308 {NULL, NULL}
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000309};
310
Fred Drakedf48d142001-02-27 21:22:39 +0000311
Fred Drake9ef7fa82001-03-01 21:54:49 +0000312#if defined(VSWTCH) && !defined(VSWTC)
313#define VSWTC VSWTCH
314#endif
315
316#if defined(VSWTC) && !defined(VSWTCH)
317#define VSWTCH VSWTC
318#endif
319
Fred Drakedf48d142001-02-27 21:22:39 +0000320static struct constant {
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000321 char *name;
322 long value;
Fred Drakedf48d142001-02-27 21:22:39 +0000323} termios_constants[] = {
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000324 /* cfgetospeed(), cfsetospeed() constants */
325 {"B0", B0},
326 {"B50", B50},
327 {"B75", B75},
328 {"B110", B110},
329 {"B134", B134},
330 {"B150", B150},
331 {"B200", B200},
332 {"B300", B300},
333 {"B600", B600},
334 {"B1200", B1200},
335 {"B1800", B1800},
336 {"B2400", B2400},
337 {"B4800", B4800},
338 {"B9600", B9600},
339 {"B19200", B19200},
340 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000341#ifdef B57600
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000342 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000343#endif
344#ifdef B115200
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000345 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000346#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000347#ifdef B230400
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000348 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000349#endif
Fred Drake9ef7fa82001-03-01 21:54:49 +0000350#ifdef CBAUDEX
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000351 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000352#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000353
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000354 /* tcsetattr() constants */
355 {"TCSANOW", TCSANOW},
356 {"TCSADRAIN", TCSADRAIN},
357 {"TCSAFLUSH", TCSAFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000358
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000359 /* tcflush() constants */
360 {"TCIFLUSH", TCIFLUSH},
361 {"TCOFLUSH", TCOFLUSH},
362 {"TCIOFLUSH", TCIOFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000363
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000364 /* tcflow() constants */
365 {"TCOOFF", TCOOFF},
366 {"TCOON", TCOON},
367 {"TCIOFF", TCIOFF},
368 {"TCION", TCION},
Fred Drakedf48d142001-02-27 21:22:39 +0000369
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000370 /* struct termios.c_iflag constants */
371 {"IGNBRK", IGNBRK},
372 {"BRKINT", BRKINT},
373 {"IGNPAR", IGNPAR},
374 {"PARMRK", PARMRK},
375 {"INPCK", INPCK},
376 {"ISTRIP", ISTRIP},
377 {"INLCR", INLCR},
378 {"IGNCR", IGNCR},
379 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000380#ifdef IUCLC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000381 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000382#endif
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000383 {"IXON", IXON},
384 {"IXANY", IXANY},
385 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000386#ifdef IMAXBEL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000387 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000388#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000389
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000390 /* struct termios.c_oflag constants */
391 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000392#ifdef OLCUC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000393 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000394#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000395#ifdef ONLCR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000396 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000397#endif
Fred Draked85556c2001-03-03 18:08:52 +0000398#ifdef OCRNL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000399 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000400#endif
401#ifdef ONOCR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000402 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000403#endif
404#ifdef ONLRET
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000405 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000406#endif
407#ifdef OFILL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000408 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000409#endif
410#ifdef OFDEL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000411 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000412#endif
413#ifdef NLDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000414 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000415#endif
416#ifdef CRDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000417 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000418#endif
419#ifdef TABDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000420 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000421#endif
422#ifdef BSDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000423 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000424#endif
425#ifdef VTDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000426 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000427#endif
428#ifdef FFDLY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000429 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000430#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000431
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000432 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000433#ifdef NL0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000434 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000435#endif
436#ifdef NL1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000437 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000438#endif
439#ifdef CR0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000440 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000441#endif
442#ifdef CR1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000443 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000444#endif
445#ifdef CR2
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000446 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000447#endif
448#ifdef CR3
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000449 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000450#endif
451#ifdef TAB0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000452 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000453#endif
454#ifdef TAB1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000455 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000456#endif
457#ifdef TAB2
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000458 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000459#endif
460#ifdef TAB3
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000461 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000462#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000463#ifdef XTABS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000464 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000465#endif
Fred Draked85556c2001-03-03 18:08:52 +0000466#ifdef BS0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000467 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000468#endif
469#ifdef BS1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000470 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000471#endif
472#ifdef VT0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000473 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000474#endif
475#ifdef VT1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000476 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000477#endif
478#ifdef FF0
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000479 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000480#endif
481#ifdef FF1
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000482 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000483#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000484
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000485 /* struct termios.c_cflag constants */
486 {"CSIZE", CSIZE},
487 {"CSTOPB", CSTOPB},
488 {"CREAD", CREAD},
489 {"PARENB", PARENB},
490 {"PARODD", PARODD},
491 {"HUPCL", HUPCL},
492 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000493#ifdef CIBAUD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000494 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000495#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000496#ifdef CRTSCTS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000497 {"CRTSCTS", (long)CRTSCTS},
Fred Drakededbebf2001-03-02 06:50:58 +0000498#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000499
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000500 /* struct termios.c_cflag-related values (character size) */
501 {"CS5", CS5},
502 {"CS6", CS6},
503 {"CS7", CS7},
504 {"CS8", CS8},
Fred Drakedf48d142001-02-27 21:22:39 +0000505
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000506 /* struct termios.c_lflag constants */
507 {"ISIG", ISIG},
508 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000509#ifdef XCASE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000510 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000511#endif
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000512 {"ECHO", ECHO},
513 {"ECHOE", ECHOE},
514 {"ECHOK", ECHOK},
515 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000516#ifdef ECHOCTL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000517 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000518#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000519#ifdef ECHOPRT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000520 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000521#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000522#ifdef ECHOKE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000523 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000524#endif
525#ifdef FLUSHO
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000526 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000527#endif
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000528 {"NOFLSH", NOFLSH},
529 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000530#ifdef PENDIN
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000531 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000532#endif
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000533 {"IEXTEN", IEXTEN},
Fred Drakedf48d142001-02-27 21:22:39 +0000534
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000535 /* indexes into the control chars array returned by tcgetattr() */
536 {"VINTR", VINTR},
537 {"VQUIT", VQUIT},
538 {"VERASE", VERASE},
539 {"VKILL", VKILL},
540 {"VEOF", VEOF},
541 {"VTIME", VTIME},
542 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000543#ifdef VSWTC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000544 /* The #defines above ensure that if either is defined, both are,
545 * but both may be omitted by the system headers. ;-( */
546 {"VSWTC", VSWTC},
547 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000548#endif
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000549 {"VSTART", VSTART},
550 {"VSTOP", VSTOP},
551 {"VSUSP", VSUSP},
552 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000553#ifdef VREPRINT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000554 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000555#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000556#ifdef VDISCARD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000557 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000558#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000559#ifdef VWERASE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000560 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000561#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000562#ifdef VLNEXT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000563 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000564#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000565#ifdef VEOL2
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000566 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000567#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000568
Fred Drake55a00342001-03-26 17:14:02 +0000569
570#ifdef B460800
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000571 {"B460800", B460800},
Fred Drake55a00342001-03-26 17:14:02 +0000572#endif
573#ifdef CBAUD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000574 {"CBAUD", CBAUD},
Fred Drake55a00342001-03-26 17:14:02 +0000575#endif
576#ifdef CDEL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000577 {"CDEL", CDEL},
Fred Drake55a00342001-03-26 17:14:02 +0000578#endif
579#ifdef CDSUSP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000580 {"CDSUSP", CDSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000581#endif
582#ifdef CEOF
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000583 {"CEOF", CEOF},
Fred Drake55a00342001-03-26 17:14:02 +0000584#endif
585#ifdef CEOL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000586 {"CEOL", CEOL},
Fred Drake55a00342001-03-26 17:14:02 +0000587#endif
588#ifdef CEOL2
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000589 {"CEOL2", CEOL2},
Fred Drake55a00342001-03-26 17:14:02 +0000590#endif
591#ifdef CEOT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000592 {"CEOT", CEOT},
Fred Drake55a00342001-03-26 17:14:02 +0000593#endif
594#ifdef CERASE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000595 {"CERASE", CERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000596#endif
597#ifdef CESC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000598 {"CESC", CESC},
Fred Drake55a00342001-03-26 17:14:02 +0000599#endif
600#ifdef CFLUSH
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000601 {"CFLUSH", CFLUSH},
Fred Drake55a00342001-03-26 17:14:02 +0000602#endif
603#ifdef CINTR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000604 {"CINTR", CINTR},
Fred Drake55a00342001-03-26 17:14:02 +0000605#endif
606#ifdef CKILL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000607 {"CKILL", CKILL},
Fred Drake55a00342001-03-26 17:14:02 +0000608#endif
609#ifdef CLNEXT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000610 {"CLNEXT", CLNEXT},
Fred Drake55a00342001-03-26 17:14:02 +0000611#endif
612#ifdef CNUL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000613 {"CNUL", CNUL},
Fred Drake55a00342001-03-26 17:14:02 +0000614#endif
615#ifdef COMMON
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000616 {"COMMON", COMMON},
Fred Drake55a00342001-03-26 17:14:02 +0000617#endif
618#ifdef CQUIT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000619 {"CQUIT", CQUIT},
Fred Drake55a00342001-03-26 17:14:02 +0000620#endif
621#ifdef CRPRNT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000622 {"CRPRNT", CRPRNT},
Fred Drake55a00342001-03-26 17:14:02 +0000623#endif
624#ifdef CSTART
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000625 {"CSTART", CSTART},
Fred Drake55a00342001-03-26 17:14:02 +0000626#endif
627#ifdef CSTOP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000628 {"CSTOP", CSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000629#endif
630#ifdef CSUSP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000631 {"CSUSP", CSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000632#endif
633#ifdef CSWTCH
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000634 {"CSWTCH", CSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000635#endif
636#ifdef CWERASE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000637 {"CWERASE", CWERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000638#endif
639#ifdef EXTA
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000640 {"EXTA", EXTA},
Fred Drake55a00342001-03-26 17:14:02 +0000641#endif
642#ifdef EXTB
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000643 {"EXTB", EXTB},
Fred Drake55a00342001-03-26 17:14:02 +0000644#endif
645#ifdef FIOASYNC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000646 {"FIOASYNC", FIOASYNC},
Fred Drake55a00342001-03-26 17:14:02 +0000647#endif
648#ifdef FIOCLEX
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000649 {"FIOCLEX", FIOCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000650#endif
651#ifdef FIONBIO
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000652 {"FIONBIO", FIONBIO},
Fred Drake55a00342001-03-26 17:14:02 +0000653#endif
654#ifdef FIONCLEX
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000655 {"FIONCLEX", FIONCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000656#endif
657#ifdef FIONREAD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000658 {"FIONREAD", FIONREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000659#endif
660#ifdef IBSHIFT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000661 {"IBSHIFT", IBSHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000662#endif
663#ifdef INIT_C_CC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000664 {"INIT_C_CC", INIT_C_CC},
Fred Drake55a00342001-03-26 17:14:02 +0000665#endif
666#ifdef IOCSIZE_MASK
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000667 {"IOCSIZE_MASK", IOCSIZE_MASK},
Fred Drake55a00342001-03-26 17:14:02 +0000668#endif
669#ifdef IOCSIZE_SHIFT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000670 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000671#endif
672#ifdef NCC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000673 {"NCC", NCC},
Fred Drake55a00342001-03-26 17:14:02 +0000674#endif
675#ifdef NCCS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000676 {"NCCS", NCCS},
Fred Drake55a00342001-03-26 17:14:02 +0000677#endif
678#ifdef NSWTCH
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000679 {"NSWTCH", NSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000680#endif
681#ifdef N_MOUSE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000682 {"N_MOUSE", N_MOUSE},
Fred Drake55a00342001-03-26 17:14:02 +0000683#endif
684#ifdef N_PPP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000685 {"N_PPP", N_PPP},
Fred Drake55a00342001-03-26 17:14:02 +0000686#endif
687#ifdef N_SLIP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000688 {"N_SLIP", N_SLIP},
Fred Drake55a00342001-03-26 17:14:02 +0000689#endif
690#ifdef N_STRIP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000691 {"N_STRIP", N_STRIP},
Fred Drake55a00342001-03-26 17:14:02 +0000692#endif
693#ifdef N_TTY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000694 {"N_TTY", N_TTY},
Fred Drake55a00342001-03-26 17:14:02 +0000695#endif
696#ifdef TCFLSH
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000697 {"TCFLSH", TCFLSH},
Fred Drake55a00342001-03-26 17:14:02 +0000698#endif
699#ifdef TCGETA
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000700 {"TCGETA", TCGETA},
Fred Drake55a00342001-03-26 17:14:02 +0000701#endif
702#ifdef TCGETS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000703 {"TCGETS", TCGETS},
Fred Drake55a00342001-03-26 17:14:02 +0000704#endif
705#ifdef TCSBRK
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000706 {"TCSBRK", TCSBRK},
Fred Drake55a00342001-03-26 17:14:02 +0000707#endif
708#ifdef TCSBRKP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000709 {"TCSBRKP", TCSBRKP},
Fred Drake55a00342001-03-26 17:14:02 +0000710#endif
711#ifdef TCSETA
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000712 {"TCSETA", TCSETA},
Fred Drake55a00342001-03-26 17:14:02 +0000713#endif
714#ifdef TCSETAF
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000715 {"TCSETAF", TCSETAF},
Fred Drake55a00342001-03-26 17:14:02 +0000716#endif
717#ifdef TCSETAW
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000718 {"TCSETAW", TCSETAW},
Fred Drake55a00342001-03-26 17:14:02 +0000719#endif
720#ifdef TCSETS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000721 {"TCSETS", TCSETS},
Fred Drake55a00342001-03-26 17:14:02 +0000722#endif
723#ifdef TCSETSF
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000724 {"TCSETSF", TCSETSF},
Fred Drake55a00342001-03-26 17:14:02 +0000725#endif
726#ifdef TCSETSW
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000727 {"TCSETSW", TCSETSW},
Fred Drake55a00342001-03-26 17:14:02 +0000728#endif
729#ifdef TCXONC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000730 {"TCXONC", TCXONC},
Fred Drake55a00342001-03-26 17:14:02 +0000731#endif
732#ifdef TIOCCONS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000733 {"TIOCCONS", TIOCCONS},
Fred Drake55a00342001-03-26 17:14:02 +0000734#endif
735#ifdef TIOCEXCL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000736 {"TIOCEXCL", TIOCEXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000737#endif
738#ifdef TIOCGETD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000739 {"TIOCGETD", TIOCGETD},
Fred Drake55a00342001-03-26 17:14:02 +0000740#endif
741#ifdef TIOCGICOUNT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000742 {"TIOCGICOUNT", TIOCGICOUNT},
Fred Drake55a00342001-03-26 17:14:02 +0000743#endif
744#ifdef TIOCGLCKTRMIOS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000745 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000746#endif
747#ifdef TIOCGPGRP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000748 {"TIOCGPGRP", TIOCGPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000749#endif
750#ifdef TIOCGSERIAL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000751 {"TIOCGSERIAL", TIOCGSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000752#endif
753#ifdef TIOCGSOFTCAR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000754 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000755#endif
756#ifdef TIOCGWINSZ
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000757 {"TIOCGWINSZ", TIOCGWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000758#endif
759#ifdef TIOCINQ
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000760 {"TIOCINQ", TIOCINQ},
Fred Drake55a00342001-03-26 17:14:02 +0000761#endif
762#ifdef TIOCLINUX
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000763 {"TIOCLINUX", TIOCLINUX},
Fred Drake55a00342001-03-26 17:14:02 +0000764#endif
765#ifdef TIOCMBIC
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000766 {"TIOCMBIC", TIOCMBIC},
Fred Drake55a00342001-03-26 17:14:02 +0000767#endif
768#ifdef TIOCMBIS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000769 {"TIOCMBIS", TIOCMBIS},
Fred Drake55a00342001-03-26 17:14:02 +0000770#endif
771#ifdef TIOCMGET
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000772 {"TIOCMGET", TIOCMGET},
Fred Drake55a00342001-03-26 17:14:02 +0000773#endif
774#ifdef TIOCMIWAIT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000775 {"TIOCMIWAIT", TIOCMIWAIT},
Fred Drake55a00342001-03-26 17:14:02 +0000776#endif
777#ifdef TIOCMSET
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000778 {"TIOCMSET", TIOCMSET},
Fred Drake55a00342001-03-26 17:14:02 +0000779#endif
780#ifdef TIOCM_CAR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000781 {"TIOCM_CAR", TIOCM_CAR},
Fred Drake55a00342001-03-26 17:14:02 +0000782#endif
783#ifdef TIOCM_CD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000784 {"TIOCM_CD", TIOCM_CD},
Fred Drake55a00342001-03-26 17:14:02 +0000785#endif
786#ifdef TIOCM_CTS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000787 {"TIOCM_CTS", TIOCM_CTS},
Fred Drake55a00342001-03-26 17:14:02 +0000788#endif
789#ifdef TIOCM_DSR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000790 {"TIOCM_DSR", TIOCM_DSR},
Fred Drake55a00342001-03-26 17:14:02 +0000791#endif
792#ifdef TIOCM_DTR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000793 {"TIOCM_DTR", TIOCM_DTR},
Fred Drake55a00342001-03-26 17:14:02 +0000794#endif
795#ifdef TIOCM_LE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000796 {"TIOCM_LE", TIOCM_LE},
Fred Drake55a00342001-03-26 17:14:02 +0000797#endif
798#ifdef TIOCM_RI
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000799 {"TIOCM_RI", TIOCM_RI},
Fred Drake55a00342001-03-26 17:14:02 +0000800#endif
801#ifdef TIOCM_RNG
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000802 {"TIOCM_RNG", TIOCM_RNG},
Fred Drake55a00342001-03-26 17:14:02 +0000803#endif
804#ifdef TIOCM_RTS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000805 {"TIOCM_RTS", TIOCM_RTS},
Fred Drake55a00342001-03-26 17:14:02 +0000806#endif
807#ifdef TIOCM_SR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000808 {"TIOCM_SR", TIOCM_SR},
Fred Drake55a00342001-03-26 17:14:02 +0000809#endif
810#ifdef TIOCM_ST
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000811 {"TIOCM_ST", TIOCM_ST},
Fred Drake55a00342001-03-26 17:14:02 +0000812#endif
813#ifdef TIOCNOTTY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000814 {"TIOCNOTTY", TIOCNOTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000815#endif
816#ifdef TIOCNXCL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000817 {"TIOCNXCL", TIOCNXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000818#endif
819#ifdef TIOCOUTQ
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000820 {"TIOCOUTQ", TIOCOUTQ},
Fred Drake55a00342001-03-26 17:14:02 +0000821#endif
822#ifdef TIOCPKT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000823 {"TIOCPKT", TIOCPKT},
Fred Drake55a00342001-03-26 17:14:02 +0000824#endif
825#ifdef TIOCPKT_DATA
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000826 {"TIOCPKT_DATA", TIOCPKT_DATA},
Fred Drake55a00342001-03-26 17:14:02 +0000827#endif
828#ifdef TIOCPKT_DOSTOP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000829 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000830#endif
831#ifdef TIOCPKT_FLUSHREAD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000832 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000833#endif
834#ifdef TIOCPKT_FLUSHWRITE
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000835 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
Fred Drake55a00342001-03-26 17:14:02 +0000836#endif
837#ifdef TIOCPKT_NOSTOP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000838 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000839#endif
840#ifdef TIOCPKT_START
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000841 {"TIOCPKT_START", TIOCPKT_START},
Fred Drake55a00342001-03-26 17:14:02 +0000842#endif
843#ifdef TIOCPKT_STOP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000844 {"TIOCPKT_STOP", TIOCPKT_STOP},
Fred Drake55a00342001-03-26 17:14:02 +0000845#endif
846#ifdef TIOCSCTTY
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000847 {"TIOCSCTTY", TIOCSCTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000848#endif
849#ifdef TIOCSERCONFIG
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000850 {"TIOCSERCONFIG", TIOCSERCONFIG},
Fred Drake55a00342001-03-26 17:14:02 +0000851#endif
852#ifdef TIOCSERGETLSR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000853 {"TIOCSERGETLSR", TIOCSERGETLSR},
Fred Drake55a00342001-03-26 17:14:02 +0000854#endif
855#ifdef TIOCSERGETMULTI
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000856 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000857#endif
858#ifdef TIOCSERGSTRUCT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000859 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000860#endif
861#ifdef TIOCSERGWILD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000862 {"TIOCSERGWILD", TIOCSERGWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000863#endif
864#ifdef TIOCSERSETMULTI
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000865 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000866#endif
867#ifdef TIOCSERSWILD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000868 {"TIOCSERSWILD", TIOCSERSWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000869#endif
870#ifdef TIOCSER_TEMT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000871 {"TIOCSER_TEMT", TIOCSER_TEMT},
Fred Drake55a00342001-03-26 17:14:02 +0000872#endif
873#ifdef TIOCSETD
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000874 {"TIOCSETD", TIOCSETD},
Fred Drake55a00342001-03-26 17:14:02 +0000875#endif
876#ifdef TIOCSLCKTRMIOS
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000877 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000878#endif
879#ifdef TIOCSPGRP
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000880 {"TIOCSPGRP", TIOCSPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000881#endif
882#ifdef TIOCSSERIAL
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000883 {"TIOCSSERIAL", TIOCSSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000884#endif
885#ifdef TIOCSSOFTCAR
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000886 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000887#endif
888#ifdef TIOCSTI
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000889 {"TIOCSTI", TIOCSTI},
Fred Drake55a00342001-03-26 17:14:02 +0000890#endif
891#ifdef TIOCSWINSZ
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000892 {"TIOCSWINSZ", TIOCSWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000893#endif
894#ifdef TIOCTTYGSTRUCT
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000895 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000896#endif
897
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000898 /* sentinel */
899 {NULL, 0}
Fred Drakedf48d142001-02-27 21:22:39 +0000900};
901
902
Martin v. Löwis1a214512008-06-11 05:26:20 +0000903static struct PyModuleDef termiosmodule = {
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000904 PyModuleDef_HEAD_INIT,
905 "termios",
906 termios__doc__,
907 -1,
908 termios_methods,
909 NULL,
910 NULL,
911 NULL,
912 NULL
Martin v. Löwis1a214512008-06-11 05:26:20 +0000913};
914
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000915PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000916PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000917{
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000918 PyObject *m;
919 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000920
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000921 m = PyModule_Create(&termiosmodule);
922 if (m == NULL)
923 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000924
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000925 if (TermiosError == NULL) {
926 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
927 }
928 Py_INCREF(TermiosError);
929 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000930
Antoine Pitrou7f14f0d2010-05-09 16:14:21 +0000931 while (constant->name != NULL) {
932 PyModule_AddIntConstant(m, constant->name, constant->value);
933 ++constant;
934 }
935 return m;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000936}