blob: 9d4d780dca277592b0adf6b9cdf49f90f8932a3a [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
5#define PyInit_termios inittermios
6
Martin v. Löwisbe4fea62003-10-31 13:01:24 +00007/* 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 Rossum9adae8e1994-09-12 10:41:22 +000013#include <termios.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +000014#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 Drakeb638aaf2001-05-07 17:55:35 +000017#include <termio.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +000018#endif
Fred Drake9b3bc492001-04-04 21:19:26 +000019#include <sys/ioctl.h>
Guido van Rossum1aca4d81998-03-03 22:10:18 +000020
Fred Drake87068f12001-05-11 16:14:17 +000021/* 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 Norwitz82251032003-05-23 14:35:24 +000028/* 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 Drake87068f12001-05-11 16:14:17 +000032
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000033PyDoc_STRVAR(termios__doc__,
34"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000035For a complete description of these calls, see the Posix or Unix manual\n\
36pages. It is only available for those Unix versions that support Posix\n\
37termios style tty I/O control.\n\
38\n\
39All functions in this module take a file descriptor fd as their first\n\
40argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000041sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000042
43static PyObject *TermiosError;
44
Fred Drakeb638aaf2001-05-07 17:55:35 +000045static int fdconv(PyObject* obj, void* p)
46{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000047 int fd;
Fred Drakeb638aaf2001-05-07 17:55:35 +000048
Antoine Pitrouc83ea132010-05-09 14:46:46 +000049 fd = PyObject_AsFileDescriptor(obj);
50 if (fd >= 0) {
51 *(int*)p = fd;
52 return 1;
53 }
54 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000055}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000056
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000057PyDoc_STRVAR(termios_tcgetattr__doc__,
58"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000059\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000060Get the tty attributes for file descriptor fd, as follows:\n\
61[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
62of the tty special characters (each a string of length 1, except the items\n\
63with indices VMIN and VTIME, which are integers when these fields are\n\
64defined). The interpretation of the flags and the speeds as well as the\n\
65indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000066in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000067
Guido van Rossum9adae8e1994-09-12 10:41:22 +000068static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000069termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000070{
Antoine Pitrouc83ea132010-05-09 14:46:46 +000071 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 Rossum9adae8e1994-09-12 10:41:22 +000078
Antoine Pitrouc83ea132010-05-09 14:46:46 +000079 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
80 fdconv, (void*)&fd))
81 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000082
Antoine Pitrouc83ea132010-05-09 14:46:46 +000083 if (tcgetattr(fd, &mode) == -1)
84 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000085
Antoine Pitrouc83ea132010-05-09 14:46:46 +000086 ispeed = cfgetispeed(&mode);
87 ospeed = cfgetospeed(&mode);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000088
Antoine Pitrouc83ea132010-05-09 14:46:46 +000089 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 Rossum9adae8e1994-09-12 10:41:22 +000099
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000100 /* 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 Rossum9adae8e1994-09-12 10:41:22 +0000113
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000114 if (!(v = PyList_New(7)))
115 goto err;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000116
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000117 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 Warsaw5709dcf1997-01-10 18:42:18 +0000129 err:
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000130 Py_DECREF(cc);
131 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000132}
133
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000134PyDoc_STRVAR(termios_tcsetattr__doc__,
135"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000136\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000137Set the tty attributes for file descriptor fd.\n\
138The attributes to be set are taken from the attributes argument, which\n\
139is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000140determines when the attributes are changed: termios.TCSANOW to\n\
141change immediately, termios.TCSADRAIN to change after transmitting all\n\
142queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000143queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000144
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000145static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000146termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000147{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000148 int fd, when;
149 struct termios mode;
150 speed_t ispeed, ospeed;
151 PyObject *term, *cc, *v;
152 int i;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000153
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000154 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 Rossum9adae8e1994-09-12 10:41:22 +0000162
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000163 /* 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 Rossum9adae8e1994-09-12 10:41:22 +0000175
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000176 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 Rossum9adae8e1994-09-12 10:41:22 +0000182
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000183 for (i = 0; i < NCCS; i++) {
184 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000185
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000186 if (PyString_Check(v) && PyString_Size(v) == 1)
187 mode.c_cc[i] = (cc_t) * PyString_AsString(v);
Serhiy Storchaka994f04d2016-12-27 15:09:36 +0200188 else if (PyInt_Check(v) || PyLong_Check(v)) {
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000189 mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
Serhiy Storchaka994f04d2016-12-27 15:09:36 +0200190 if (mode.c_cc[i] == (cc_t) -1 && PyErr_Occurred())
191 return NULL;
192 }
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000193 else {
194 PyErr_SetString(PyExc_TypeError,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000195 "tcsetattr: elements of attributes must be characters or integers");
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000196 return NULL;
197 }
198 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000199
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000200 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 Rossum9adae8e1994-09-12 10:41:22 +0000206
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000207 Py_INCREF(Py_None);
208 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000209}
210
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000211PyDoc_STRVAR(termios_tcsendbreak__doc__,
212"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000213\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000214Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000215A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000216has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000217
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000218static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000219termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000220{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000221 int fd, duration;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000222
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000223 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 Rossum9adae8e1994-09-12 10:41:22 +0000228
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000229 Py_INCREF(Py_None);
230 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000231}
232
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000233PyDoc_STRVAR(termios_tcdrain__doc__,
234"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000235\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000236Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000237
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000238static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000239termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000240{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000241 int fd;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000242
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000243 if (!PyArg_ParseTuple(args, "O&:tcdrain",
244 fdconv, &fd))
245 return NULL;
246 if (tcdrain(fd) == -1)
247 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000248
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000249 Py_INCREF(Py_None);
250 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000251}
252
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000253PyDoc_STRVAR(termios_tcflush__doc__,
254"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000255\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000256Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000257The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
258queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000259both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000260
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000261static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000262termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000263{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000264 int fd, queue;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000265
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000266 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 Rossum9adae8e1994-09-12 10:41:22 +0000271
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000272 Py_INCREF(Py_None);
273 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000274}
275
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000276PyDoc_STRVAR(termios_tcflow__doc__,
277"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000278\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000279Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000280The action argument can be termios.TCOOFF to suspend output,\n\
281termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000282or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000283
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000284static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000285termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000286{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000287 int fd, action;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000288
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000289 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 Rossum9adae8e1994-09-12 10:41:22 +0000294
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000295 Py_INCREF(Py_None);
296 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000297}
298
299static PyMethodDef termios_methods[] =
300{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000301 {"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 Rossum9adae8e1994-09-12 10:41:22 +0000314};
315
Fred Drakedf48d142001-02-27 21:22:39 +0000316
Fred Drake9ef7fa82001-03-01 21:54:49 +0000317#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 Drakedf48d142001-02-27 21:22:39 +0000325static struct constant {
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000326 char *name;
327 long value;
Fred Drakedf48d142001-02-27 21:22:39 +0000328} termios_constants[] = {
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000329 /* 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 Rossum2242f2f2001-04-11 20:58:20 +0000346#ifdef B57600
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000347 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000348#endif
349#ifdef B115200
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000350 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000351#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000352#ifdef B230400
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000353 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000354#endif
Fred Drake9ef7fa82001-03-01 21:54:49 +0000355#ifdef CBAUDEX
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000356 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000357#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000358
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000359 /* tcsetattr() constants */
360 {"TCSANOW", TCSANOW},
361 {"TCSADRAIN", TCSADRAIN},
362 {"TCSAFLUSH", TCSAFLUSH},
Gregory P. Smithb2b92ea2009-10-31 21:23:39 +0000363#ifdef TCSASOFT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000364 {"TCSASOFT", TCSASOFT},
Gregory P. Smithb2b92ea2009-10-31 21:23:39 +0000365#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000366
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000367 /* tcflush() constants */
368 {"TCIFLUSH", TCIFLUSH},
369 {"TCOFLUSH", TCOFLUSH},
370 {"TCIOFLUSH", TCIOFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000371
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000372 /* tcflow() constants */
373 {"TCOOFF", TCOOFF},
374 {"TCOON", TCOON},
375 {"TCIOFF", TCIOFF},
376 {"TCION", TCION},
Fred Drakedf48d142001-02-27 21:22:39 +0000377
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000378 /* 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 Draked85556c2001-03-03 18:08:52 +0000388#ifdef IUCLC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000389 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000390#endif
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000391 {"IXON", IXON},
392 {"IXANY", IXANY},
393 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000394#ifdef IMAXBEL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000395 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000396#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000397
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000398 /* struct termios.c_oflag constants */
399 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000400#ifdef OLCUC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000401 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000402#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000403#ifdef ONLCR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000404 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000405#endif
Fred Draked85556c2001-03-03 18:08:52 +0000406#ifdef OCRNL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000407 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000408#endif
409#ifdef ONOCR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000410 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000411#endif
412#ifdef ONLRET
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000413 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000414#endif
415#ifdef OFILL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000416 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000417#endif
418#ifdef OFDEL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000419 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000420#endif
421#ifdef NLDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000422 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000423#endif
424#ifdef CRDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000425 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000426#endif
427#ifdef TABDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000428 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000429#endif
430#ifdef BSDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000431 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000432#endif
433#ifdef VTDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000434 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000435#endif
436#ifdef FFDLY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000437 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000438#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000439
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000440 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000441#ifdef NL0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000442 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000443#endif
444#ifdef NL1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000445 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000446#endif
447#ifdef CR0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000448 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000449#endif
450#ifdef CR1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000451 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000452#endif
453#ifdef CR2
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000454 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000455#endif
456#ifdef CR3
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000457 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000458#endif
459#ifdef TAB0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000460 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000461#endif
462#ifdef TAB1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000463 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000464#endif
465#ifdef TAB2
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000466 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000467#endif
468#ifdef TAB3
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000469 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000470#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000471#ifdef XTABS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000472 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000473#endif
Fred Draked85556c2001-03-03 18:08:52 +0000474#ifdef BS0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000475 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000476#endif
477#ifdef BS1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000478 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000479#endif
480#ifdef VT0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000481 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000482#endif
483#ifdef VT1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000484 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000485#endif
486#ifdef FF0
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000487 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000488#endif
489#ifdef FF1
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000490 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000491#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000492
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000493 /* 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 Drakeabb379e2001-03-01 03:28:08 +0000501#ifdef CIBAUD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000502 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000503#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000504#ifdef CRTSCTS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000505 {"CRTSCTS", (long)CRTSCTS},
Fred Drakededbebf2001-03-02 06:50:58 +0000506#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000507
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000508 /* struct termios.c_cflag-related values (character size) */
509 {"CS5", CS5},
510 {"CS6", CS6},
511 {"CS7", CS7},
512 {"CS8", CS8},
Fred Drakedf48d142001-02-27 21:22:39 +0000513
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000514 /* struct termios.c_lflag constants */
515 {"ISIG", ISIG},
516 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000517#ifdef XCASE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000518 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000519#endif
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000520 {"ECHO", ECHO},
521 {"ECHOE", ECHOE},
522 {"ECHOK", ECHOK},
523 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000524#ifdef ECHOCTL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000525 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000526#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000527#ifdef ECHOPRT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000528 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000529#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000530#ifdef ECHOKE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000531 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000532#endif
533#ifdef FLUSHO
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000534 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000535#endif
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000536 {"NOFLSH", NOFLSH},
537 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000538#ifdef PENDIN
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000539 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000540#endif
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000541 {"IEXTEN", IEXTEN},
Fred Drakedf48d142001-02-27 21:22:39 +0000542
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000543 /* 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 Drakededbebf2001-03-02 06:50:58 +0000551#ifdef VSWTC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000552 /* 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 Drakededbebf2001-03-02 06:50:58 +0000556#endif
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000557 {"VSTART", VSTART},
558 {"VSTOP", VSTOP},
559 {"VSUSP", VSUSP},
560 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000561#ifdef VREPRINT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000562 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000563#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000564#ifdef VDISCARD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000565 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000566#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000567#ifdef VWERASE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000568 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000569#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000570#ifdef VLNEXT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000571 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000572#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000573#ifdef VEOL2
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000574 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000575#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000576
Fred Drake55a00342001-03-26 17:14:02 +0000577
578#ifdef B460800
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000579 {"B460800", B460800},
Fred Drake55a00342001-03-26 17:14:02 +0000580#endif
581#ifdef CBAUD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000582 {"CBAUD", CBAUD},
Fred Drake55a00342001-03-26 17:14:02 +0000583#endif
584#ifdef CDEL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000585 {"CDEL", CDEL},
Fred Drake55a00342001-03-26 17:14:02 +0000586#endif
587#ifdef CDSUSP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000588 {"CDSUSP", CDSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000589#endif
590#ifdef CEOF
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000591 {"CEOF", CEOF},
Fred Drake55a00342001-03-26 17:14:02 +0000592#endif
593#ifdef CEOL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000594 {"CEOL", CEOL},
Fred Drake55a00342001-03-26 17:14:02 +0000595#endif
596#ifdef CEOL2
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000597 {"CEOL2", CEOL2},
Fred Drake55a00342001-03-26 17:14:02 +0000598#endif
599#ifdef CEOT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000600 {"CEOT", CEOT},
Fred Drake55a00342001-03-26 17:14:02 +0000601#endif
602#ifdef CERASE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000603 {"CERASE", CERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000604#endif
605#ifdef CESC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000606 {"CESC", CESC},
Fred Drake55a00342001-03-26 17:14:02 +0000607#endif
608#ifdef CFLUSH
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000609 {"CFLUSH", CFLUSH},
Fred Drake55a00342001-03-26 17:14:02 +0000610#endif
611#ifdef CINTR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000612 {"CINTR", CINTR},
Fred Drake55a00342001-03-26 17:14:02 +0000613#endif
614#ifdef CKILL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000615 {"CKILL", CKILL},
Fred Drake55a00342001-03-26 17:14:02 +0000616#endif
617#ifdef CLNEXT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000618 {"CLNEXT", CLNEXT},
Fred Drake55a00342001-03-26 17:14:02 +0000619#endif
620#ifdef CNUL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000621 {"CNUL", CNUL},
Fred Drake55a00342001-03-26 17:14:02 +0000622#endif
623#ifdef COMMON
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000624 {"COMMON", COMMON},
Fred Drake55a00342001-03-26 17:14:02 +0000625#endif
626#ifdef CQUIT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000627 {"CQUIT", CQUIT},
Fred Drake55a00342001-03-26 17:14:02 +0000628#endif
629#ifdef CRPRNT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000630 {"CRPRNT", CRPRNT},
Fred Drake55a00342001-03-26 17:14:02 +0000631#endif
632#ifdef CSTART
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000633 {"CSTART", CSTART},
Fred Drake55a00342001-03-26 17:14:02 +0000634#endif
635#ifdef CSTOP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000636 {"CSTOP", CSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000637#endif
638#ifdef CSUSP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000639 {"CSUSP", CSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000640#endif
641#ifdef CSWTCH
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000642 {"CSWTCH", CSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000643#endif
644#ifdef CWERASE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000645 {"CWERASE", CWERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000646#endif
647#ifdef EXTA
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000648 {"EXTA", EXTA},
Fred Drake55a00342001-03-26 17:14:02 +0000649#endif
650#ifdef EXTB
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000651 {"EXTB", EXTB},
Fred Drake55a00342001-03-26 17:14:02 +0000652#endif
653#ifdef FIOASYNC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000654 {"FIOASYNC", FIOASYNC},
Fred Drake55a00342001-03-26 17:14:02 +0000655#endif
656#ifdef FIOCLEX
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000657 {"FIOCLEX", FIOCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000658#endif
659#ifdef FIONBIO
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000660 {"FIONBIO", FIONBIO},
Fred Drake55a00342001-03-26 17:14:02 +0000661#endif
662#ifdef FIONCLEX
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000663 {"FIONCLEX", FIONCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000664#endif
665#ifdef FIONREAD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000666 {"FIONREAD", FIONREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000667#endif
668#ifdef IBSHIFT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000669 {"IBSHIFT", IBSHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000670#endif
671#ifdef INIT_C_CC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000672 {"INIT_C_CC", INIT_C_CC},
Fred Drake55a00342001-03-26 17:14:02 +0000673#endif
674#ifdef IOCSIZE_MASK
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000675 {"IOCSIZE_MASK", IOCSIZE_MASK},
Fred Drake55a00342001-03-26 17:14:02 +0000676#endif
677#ifdef IOCSIZE_SHIFT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000678 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000679#endif
680#ifdef NCC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000681 {"NCC", NCC},
Fred Drake55a00342001-03-26 17:14:02 +0000682#endif
683#ifdef NCCS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000684 {"NCCS", NCCS},
Fred Drake55a00342001-03-26 17:14:02 +0000685#endif
686#ifdef NSWTCH
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000687 {"NSWTCH", NSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000688#endif
689#ifdef N_MOUSE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000690 {"N_MOUSE", N_MOUSE},
Fred Drake55a00342001-03-26 17:14:02 +0000691#endif
692#ifdef N_PPP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000693 {"N_PPP", N_PPP},
Fred Drake55a00342001-03-26 17:14:02 +0000694#endif
695#ifdef N_SLIP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000696 {"N_SLIP", N_SLIP},
Fred Drake55a00342001-03-26 17:14:02 +0000697#endif
698#ifdef N_STRIP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000699 {"N_STRIP", N_STRIP},
Fred Drake55a00342001-03-26 17:14:02 +0000700#endif
701#ifdef N_TTY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000702 {"N_TTY", N_TTY},
Fred Drake55a00342001-03-26 17:14:02 +0000703#endif
704#ifdef TCFLSH
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000705 {"TCFLSH", TCFLSH},
Fred Drake55a00342001-03-26 17:14:02 +0000706#endif
707#ifdef TCGETA
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000708 {"TCGETA", TCGETA},
Fred Drake55a00342001-03-26 17:14:02 +0000709#endif
710#ifdef TCGETS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000711 {"TCGETS", TCGETS},
Fred Drake55a00342001-03-26 17:14:02 +0000712#endif
713#ifdef TCSBRK
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000714 {"TCSBRK", TCSBRK},
Fred Drake55a00342001-03-26 17:14:02 +0000715#endif
716#ifdef TCSBRKP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000717 {"TCSBRKP", TCSBRKP},
Fred Drake55a00342001-03-26 17:14:02 +0000718#endif
719#ifdef TCSETA
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000720 {"TCSETA", TCSETA},
Fred Drake55a00342001-03-26 17:14:02 +0000721#endif
722#ifdef TCSETAF
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000723 {"TCSETAF", TCSETAF},
Fred Drake55a00342001-03-26 17:14:02 +0000724#endif
725#ifdef TCSETAW
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000726 {"TCSETAW", TCSETAW},
Fred Drake55a00342001-03-26 17:14:02 +0000727#endif
728#ifdef TCSETS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000729 {"TCSETS", TCSETS},
Fred Drake55a00342001-03-26 17:14:02 +0000730#endif
731#ifdef TCSETSF
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000732 {"TCSETSF", TCSETSF},
Fred Drake55a00342001-03-26 17:14:02 +0000733#endif
734#ifdef TCSETSW
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000735 {"TCSETSW", TCSETSW},
Fred Drake55a00342001-03-26 17:14:02 +0000736#endif
737#ifdef TCXONC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000738 {"TCXONC", TCXONC},
Fred Drake55a00342001-03-26 17:14:02 +0000739#endif
740#ifdef TIOCCONS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000741 {"TIOCCONS", TIOCCONS},
Fred Drake55a00342001-03-26 17:14:02 +0000742#endif
743#ifdef TIOCEXCL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000744 {"TIOCEXCL", TIOCEXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000745#endif
746#ifdef TIOCGETD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000747 {"TIOCGETD", TIOCGETD},
Fred Drake55a00342001-03-26 17:14:02 +0000748#endif
749#ifdef TIOCGICOUNT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000750 {"TIOCGICOUNT", TIOCGICOUNT},
Fred Drake55a00342001-03-26 17:14:02 +0000751#endif
752#ifdef TIOCGLCKTRMIOS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000753 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000754#endif
755#ifdef TIOCGPGRP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000756 {"TIOCGPGRP", TIOCGPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000757#endif
758#ifdef TIOCGSERIAL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000759 {"TIOCGSERIAL", TIOCGSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000760#endif
761#ifdef TIOCGSOFTCAR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000762 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000763#endif
764#ifdef TIOCGWINSZ
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000765 {"TIOCGWINSZ", TIOCGWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000766#endif
767#ifdef TIOCINQ
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000768 {"TIOCINQ", TIOCINQ},
Fred Drake55a00342001-03-26 17:14:02 +0000769#endif
770#ifdef TIOCLINUX
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000771 {"TIOCLINUX", TIOCLINUX},
Fred Drake55a00342001-03-26 17:14:02 +0000772#endif
773#ifdef TIOCMBIC
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000774 {"TIOCMBIC", TIOCMBIC},
Fred Drake55a00342001-03-26 17:14:02 +0000775#endif
776#ifdef TIOCMBIS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000777 {"TIOCMBIS", TIOCMBIS},
Fred Drake55a00342001-03-26 17:14:02 +0000778#endif
779#ifdef TIOCMGET
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000780 {"TIOCMGET", TIOCMGET},
Fred Drake55a00342001-03-26 17:14:02 +0000781#endif
782#ifdef TIOCMIWAIT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000783 {"TIOCMIWAIT", TIOCMIWAIT},
Fred Drake55a00342001-03-26 17:14:02 +0000784#endif
785#ifdef TIOCMSET
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000786 {"TIOCMSET", TIOCMSET},
Fred Drake55a00342001-03-26 17:14:02 +0000787#endif
788#ifdef TIOCM_CAR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000789 {"TIOCM_CAR", TIOCM_CAR},
Fred Drake55a00342001-03-26 17:14:02 +0000790#endif
791#ifdef TIOCM_CD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000792 {"TIOCM_CD", TIOCM_CD},
Fred Drake55a00342001-03-26 17:14:02 +0000793#endif
794#ifdef TIOCM_CTS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000795 {"TIOCM_CTS", TIOCM_CTS},
Fred Drake55a00342001-03-26 17:14:02 +0000796#endif
797#ifdef TIOCM_DSR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000798 {"TIOCM_DSR", TIOCM_DSR},
Fred Drake55a00342001-03-26 17:14:02 +0000799#endif
800#ifdef TIOCM_DTR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000801 {"TIOCM_DTR", TIOCM_DTR},
Fred Drake55a00342001-03-26 17:14:02 +0000802#endif
803#ifdef TIOCM_LE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000804 {"TIOCM_LE", TIOCM_LE},
Fred Drake55a00342001-03-26 17:14:02 +0000805#endif
806#ifdef TIOCM_RI
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000807 {"TIOCM_RI", TIOCM_RI},
Fred Drake55a00342001-03-26 17:14:02 +0000808#endif
809#ifdef TIOCM_RNG
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000810 {"TIOCM_RNG", TIOCM_RNG},
Fred Drake55a00342001-03-26 17:14:02 +0000811#endif
812#ifdef TIOCM_RTS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000813 {"TIOCM_RTS", TIOCM_RTS},
Fred Drake55a00342001-03-26 17:14:02 +0000814#endif
815#ifdef TIOCM_SR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000816 {"TIOCM_SR", TIOCM_SR},
Fred Drake55a00342001-03-26 17:14:02 +0000817#endif
818#ifdef TIOCM_ST
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000819 {"TIOCM_ST", TIOCM_ST},
Fred Drake55a00342001-03-26 17:14:02 +0000820#endif
821#ifdef TIOCNOTTY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000822 {"TIOCNOTTY", TIOCNOTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000823#endif
824#ifdef TIOCNXCL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000825 {"TIOCNXCL", TIOCNXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000826#endif
827#ifdef TIOCOUTQ
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000828 {"TIOCOUTQ", TIOCOUTQ},
Fred Drake55a00342001-03-26 17:14:02 +0000829#endif
830#ifdef TIOCPKT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000831 {"TIOCPKT", TIOCPKT},
Fred Drake55a00342001-03-26 17:14:02 +0000832#endif
833#ifdef TIOCPKT_DATA
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000834 {"TIOCPKT_DATA", TIOCPKT_DATA},
Fred Drake55a00342001-03-26 17:14:02 +0000835#endif
836#ifdef TIOCPKT_DOSTOP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000837 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000838#endif
839#ifdef TIOCPKT_FLUSHREAD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000840 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000841#endif
842#ifdef TIOCPKT_FLUSHWRITE
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000843 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
Fred Drake55a00342001-03-26 17:14:02 +0000844#endif
845#ifdef TIOCPKT_NOSTOP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000846 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000847#endif
848#ifdef TIOCPKT_START
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000849 {"TIOCPKT_START", TIOCPKT_START},
Fred Drake55a00342001-03-26 17:14:02 +0000850#endif
851#ifdef TIOCPKT_STOP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000852 {"TIOCPKT_STOP", TIOCPKT_STOP},
Fred Drake55a00342001-03-26 17:14:02 +0000853#endif
854#ifdef TIOCSCTTY
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000855 {"TIOCSCTTY", TIOCSCTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000856#endif
857#ifdef TIOCSERCONFIG
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000858 {"TIOCSERCONFIG", TIOCSERCONFIG},
Fred Drake55a00342001-03-26 17:14:02 +0000859#endif
860#ifdef TIOCSERGETLSR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000861 {"TIOCSERGETLSR", TIOCSERGETLSR},
Fred Drake55a00342001-03-26 17:14:02 +0000862#endif
863#ifdef TIOCSERGETMULTI
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000864 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000865#endif
866#ifdef TIOCSERGSTRUCT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000867 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000868#endif
869#ifdef TIOCSERGWILD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000870 {"TIOCSERGWILD", TIOCSERGWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000871#endif
872#ifdef TIOCSERSETMULTI
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000873 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000874#endif
875#ifdef TIOCSERSWILD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000876 {"TIOCSERSWILD", TIOCSERSWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000877#endif
878#ifdef TIOCSER_TEMT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000879 {"TIOCSER_TEMT", TIOCSER_TEMT},
Fred Drake55a00342001-03-26 17:14:02 +0000880#endif
881#ifdef TIOCSETD
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000882 {"TIOCSETD", TIOCSETD},
Fred Drake55a00342001-03-26 17:14:02 +0000883#endif
884#ifdef TIOCSLCKTRMIOS
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000885 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000886#endif
887#ifdef TIOCSPGRP
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000888 {"TIOCSPGRP", TIOCSPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000889#endif
890#ifdef TIOCSSERIAL
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000891 {"TIOCSSERIAL", TIOCSSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000892#endif
893#ifdef TIOCSSOFTCAR
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000894 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000895#endif
896#ifdef TIOCSTI
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000897 {"TIOCSTI", TIOCSTI},
Fred Drake55a00342001-03-26 17:14:02 +0000898#endif
899#ifdef TIOCSWINSZ
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000900 {"TIOCSWINSZ", TIOCSWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000901#endif
902#ifdef TIOCTTYGSTRUCT
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000903 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000904#endif
905
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000906 /* sentinel */
907 {NULL, 0}
Fred Drakedf48d142001-02-27 21:22:39 +0000908};
909
910
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000911PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000912PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000913{
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000914 PyObject *m;
915 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000916
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000917 m = Py_InitModule4("termios", termios_methods, termios__doc__,
918 (PyObject *)NULL, PYTHON_API_VERSION);
919 if (m == NULL)
920 return;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000921
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000922 if (TermiosError == NULL) {
923 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
924 }
925 Py_INCREF(TermiosError);
926 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000927
Antoine Pitrouc83ea132010-05-09 14:46:46 +0000928 while (constant->name != NULL) {
929 PyModule_AddIntConstant(m, constant->name, constant->value);
930 ++constant;
931 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000932}