blob: b78d33e6889a61654caaf1b65ca6a343cda8fe67 [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 Drake9b3bc492001-04-04 21:19:26 +000012#include <sys/ioctl.h>
Guido van Rossum1aca4d81998-03-03 22:10:18 +000013
Fred Drake87068f12001-05-11 16:14:17 +000014/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
15 * MDTR, MRI, and MRTS (appearantly used internally by some things
16 * defined as macros; these are not used here directly).
17 */
18#ifdef HAVE_SYS_MODEM_H
19#include <sys/modem.h>
20#endif
Neal Norwitz82251032003-05-23 14:35:24 +000021/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
22#ifdef HAVE_SYS_BSDTTY_H
23#include <sys/bsdtty.h>
24#endif
Fred Drake87068f12001-05-11 16:14:17 +000025
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000026PyDoc_STRVAR(termios__doc__,
27"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000028For a complete description of these calls, see the Posix or Unix manual\n\
29pages. It is only available for those Unix versions that support Posix\n\
30termios style tty I/O control.\n\
31\n\
32All functions in this module take a file descriptor fd as their first\n\
33argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000034sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000035
36static PyObject *TermiosError;
37
Fred Drakeb638aaf2001-05-07 17:55:35 +000038static int fdconv(PyObject* obj, void* p)
39{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000040 int fd;
Fred Drakeb638aaf2001-05-07 17:55:35 +000041
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000042 fd = PyObject_AsFileDescriptor(obj);
43 if (fd >= 0) {
44 *(int*)p = fd;
45 return 1;
46 }
47 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000048}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000049
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000050PyDoc_STRVAR(termios_tcgetattr__doc__,
51"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000052\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000053Get the tty attributes for file descriptor fd, as follows:\n\
54[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
55of the tty special characters (each a string of length 1, except the items\n\
56with indices VMIN and VTIME, which are integers when these fields are\n\
57defined). The interpretation of the flags and the speeds as well as the\n\
58indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000059in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000060
Guido van Rossum9adae8e1994-09-12 10:41:22 +000061static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000062termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000063{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000064 int fd;
65 struct termios mode;
66 PyObject *cc;
67 speed_t ispeed, ospeed;
68 PyObject *v;
69 int i;
70 char ch;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000071
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000072 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
73 fdconv, (void*)&fd))
74 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000075
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000076 if (tcgetattr(fd, &mode) == -1)
77 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000078
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000079 ispeed = cfgetispeed(&mode);
80 ospeed = cfgetospeed(&mode);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000081
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000082 cc = PyList_New(NCCS);
83 if (cc == NULL)
84 return NULL;
85 for (i = 0; i < NCCS; i++) {
86 ch = (char)mode.c_cc[i];
87 v = PyBytes_FromStringAndSize(&ch, 1);
88 if (v == NULL)
89 goto err;
90 PyList_SetItem(cc, i, v);
91 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +000092
Antoine Pitrouf95a1b32010-05-09 15:52:27 +000093 /* Convert the MIN and TIME slots to integer. On some systems, the
94 MIN and TIME slots are the same as the EOF and EOL slots. So we
95 only do this in noncanonical input mode. */
96 if ((mode.c_lflag & ICANON) == 0) {
97 v = PyLong_FromLong((long)mode.c_cc[VMIN]);
98 if (v == NULL)
99 goto err;
100 PyList_SetItem(cc, VMIN, v);
101 v = PyLong_FromLong((long)mode.c_cc[VTIME]);
102 if (v == NULL)
103 goto err;
104 PyList_SetItem(cc, VTIME, v);
105 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000106
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000107 if (!(v = PyList_New(7)))
108 goto err;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000109
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000110 PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag));
111 PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag));
112 PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag));
113 PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag));
114 PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed));
115 PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed));
116 PyList_SetItem(v, 6, cc);
117 if (PyErr_Occurred()){
118 Py_DECREF(v);
119 goto err;
120 }
121 return v;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000122 err:
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000123 Py_DECREF(cc);
124 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000125}
126
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000127PyDoc_STRVAR(termios_tcsetattr__doc__,
128"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000129\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000130Set the tty attributes for file descriptor fd.\n\
131The attributes to be set are taken from the attributes argument, which\n\
132is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000133determines when the attributes are changed: termios.TCSANOW to\n\
134change immediately, termios.TCSADRAIN to change after transmitting all\n\
135queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000136queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000137
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000138static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000139termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000140{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000141 int fd, when;
142 struct termios mode;
143 speed_t ispeed, ospeed;
144 PyObject *term, *cc, *v;
145 int i;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000146
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000147 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
148 fdconv, &fd, &when, &term))
149 return NULL;
150 if (!PyList_Check(term) || PyList_Size(term) != 7) {
151 PyErr_SetString(PyExc_TypeError,
152 "tcsetattr, arg 3: must be 7 element list");
153 return NULL;
154 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000155
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000156 /* Get the old mode, in case there are any hidden fields... */
157 if (tcgetattr(fd, &mode) == -1)
158 return PyErr_SetFromErrno(TermiosError);
159 mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0));
160 mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1));
161 mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2));
162 mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3));
163 ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4));
164 ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5));
165 cc = PyList_GetItem(term, 6);
166 if (PyErr_Occurred())
167 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000168
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000169 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
170 PyErr_Format(PyExc_TypeError,
171 "tcsetattr: attributes[6] must be %d element list",
172 NCCS);
173 return NULL;
174 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000175
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000176 for (i = 0; i < NCCS; i++) {
177 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000178
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000179 if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
180 mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
181 else if (PyLong_Check(v))
182 mode.c_cc[i] = (cc_t) PyLong_AsLong(v);
183 else {
184 PyErr_SetString(PyExc_TypeError,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000185 "tcsetattr: elements of attributes must be characters or integers");
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000186 return NULL;
187 }
188 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000189
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000190 if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
191 return PyErr_SetFromErrno(TermiosError);
192 if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
193 return PyErr_SetFromErrno(TermiosError);
194 if (tcsetattr(fd, when, &mode) == -1)
195 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000196
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000197 Py_INCREF(Py_None);
198 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000199}
200
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000201PyDoc_STRVAR(termios_tcsendbreak__doc__,
202"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000203\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000204Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000205A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000206has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000207
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000208static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000209termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000210{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000211 int fd, duration;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000212
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000213 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
214 fdconv, &fd, &duration))
215 return NULL;
216 if (tcsendbreak(fd, duration) == -1)
217 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000218
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000219 Py_INCREF(Py_None);
220 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000221}
222
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000223PyDoc_STRVAR(termios_tcdrain__doc__,
224"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000225\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000226Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000227
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000228static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000229termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000230{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000231 int fd;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000232
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000233 if (!PyArg_ParseTuple(args, "O&:tcdrain",
234 fdconv, &fd))
235 return NULL;
236 if (tcdrain(fd) == -1)
237 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000238
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000239 Py_INCREF(Py_None);
240 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000241}
242
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000243PyDoc_STRVAR(termios_tcflush__doc__,
244"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000245\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000246Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000247The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
248queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000249both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000250
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000251static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000252termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000253{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000254 int fd, queue;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000255
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000256 if (!PyArg_ParseTuple(args, "O&i:tcflush",
257 fdconv, &fd, &queue))
258 return NULL;
259 if (tcflush(fd, queue) == -1)
260 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000261
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000262 Py_INCREF(Py_None);
263 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000264}
265
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000266PyDoc_STRVAR(termios_tcflow__doc__,
267"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000268\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000269Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000270The action argument can be termios.TCOOFF to suspend output,\n\
271termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000272or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000273
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000274static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000275termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000276{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000277 int fd, action;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000278
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000279 if (!PyArg_ParseTuple(args, "O&i:tcflow",
280 fdconv, &fd, &action))
281 return NULL;
282 if (tcflow(fd, action) == -1)
283 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000284
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000285 Py_INCREF(Py_None);
286 return Py_None;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000287}
288
289static PyMethodDef termios_methods[] =
290{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000291 {"tcgetattr", termios_tcgetattr,
292 METH_VARARGS, termios_tcgetattr__doc__},
293 {"tcsetattr", termios_tcsetattr,
294 METH_VARARGS, termios_tcsetattr__doc__},
295 {"tcsendbreak", termios_tcsendbreak,
296 METH_VARARGS, termios_tcsendbreak__doc__},
297 {"tcdrain", termios_tcdrain,
298 METH_VARARGS, termios_tcdrain__doc__},
299 {"tcflush", termios_tcflush,
300 METH_VARARGS, termios_tcflush__doc__},
301 {"tcflow", termios_tcflow,
302 METH_VARARGS, termios_tcflow__doc__},
303 {NULL, NULL}
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000304};
305
Fred Drakedf48d142001-02-27 21:22:39 +0000306
Fred Drake9ef7fa82001-03-01 21:54:49 +0000307#if defined(VSWTCH) && !defined(VSWTC)
308#define VSWTC VSWTCH
309#endif
310
311#if defined(VSWTC) && !defined(VSWTCH)
312#define VSWTCH VSWTC
313#endif
314
Fred Drakedf48d142001-02-27 21:22:39 +0000315static struct constant {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000316 char *name;
317 long value;
Fred Drakedf48d142001-02-27 21:22:39 +0000318} termios_constants[] = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000319 /* cfgetospeed(), cfsetospeed() constants */
320 {"B0", B0},
321 {"B50", B50},
322 {"B75", B75},
323 {"B110", B110},
324 {"B134", B134},
325 {"B150", B150},
326 {"B200", B200},
327 {"B300", B300},
328 {"B600", B600},
329 {"B1200", B1200},
330 {"B1800", B1800},
331 {"B2400", B2400},
332 {"B4800", B4800},
333 {"B9600", B9600},
334 {"B19200", B19200},
335 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000336#ifdef B57600
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000337 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000338#endif
339#ifdef B115200
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000340 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000341#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000342#ifdef B230400
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000343 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000344#endif
Antoine Pitroua78f74c2010-11-20 20:03:08 +0000345#ifdef B460800
346 {"B460800", B460800},
347#endif
348#ifdef B500000
349 {"B500000", B500000},
350#endif
351#ifdef B576000
352 {"B576000", B576000},
353#endif
354#ifdef B921600
355 {"B921600", B921600},
356#endif
357#ifdef B1000000
358 {"B1000000", B1000000},
359#endif
360#ifdef B1152000
361 {"B1152000", B1152000},
362#endif
363#ifdef B1500000
364 {"B1500000", B1500000},
365#endif
366#ifdef B2000000
367 {"B2000000", B2000000},
368#endif
369#ifdef B2500000
370 {"B2500000", B2500000},
371#endif
372#ifdef B3000000
373 {"B3000000", B3000000},
374#endif
375#ifdef B3500000
376 {"B3500000", B3500000},
377#endif
378#ifdef B4000000
379 {"B4000000", B4000000},
380#endif
381
Fred Drake9ef7fa82001-03-01 21:54:49 +0000382#ifdef CBAUDEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000383 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000384#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000385
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000386 /* tcsetattr() constants */
387 {"TCSANOW", TCSANOW},
388 {"TCSADRAIN", TCSADRAIN},
389 {"TCSAFLUSH", TCSAFLUSH},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000390#ifdef TCSASOFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000391 {"TCSASOFT", TCSASOFT},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000392#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000393
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000394 /* tcflush() constants */
395 {"TCIFLUSH", TCIFLUSH},
396 {"TCOFLUSH", TCOFLUSH},
397 {"TCIOFLUSH", TCIOFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000398
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000399 /* tcflow() constants */
400 {"TCOOFF", TCOOFF},
401 {"TCOON", TCOON},
402 {"TCIOFF", TCIOFF},
403 {"TCION", TCION},
Fred Drakedf48d142001-02-27 21:22:39 +0000404
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000405 /* struct termios.c_iflag constants */
406 {"IGNBRK", IGNBRK},
407 {"BRKINT", BRKINT},
408 {"IGNPAR", IGNPAR},
409 {"PARMRK", PARMRK},
410 {"INPCK", INPCK},
411 {"ISTRIP", ISTRIP},
412 {"INLCR", INLCR},
413 {"IGNCR", IGNCR},
414 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000415#ifdef IUCLC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000416 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000417#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000418 {"IXON", IXON},
419 {"IXANY", IXANY},
420 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000421#ifdef IMAXBEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000422 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000423#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000424
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000425 /* struct termios.c_oflag constants */
426 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000427#ifdef OLCUC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000428 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000429#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000430#ifdef ONLCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000431 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000432#endif
Fred Draked85556c2001-03-03 18:08:52 +0000433#ifdef OCRNL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000434 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000435#endif
436#ifdef ONOCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000437 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000438#endif
439#ifdef ONLRET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000440 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000441#endif
442#ifdef OFILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000443 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000444#endif
445#ifdef OFDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000446 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000447#endif
448#ifdef NLDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000449 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000450#endif
451#ifdef CRDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000452 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000453#endif
454#ifdef TABDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000455 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000456#endif
457#ifdef BSDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000458 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000459#endif
460#ifdef VTDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000461 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000462#endif
463#ifdef FFDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000464 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000465#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000466
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000467 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000468#ifdef NL0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000469 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000470#endif
471#ifdef NL1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000472 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000473#endif
474#ifdef CR0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000475 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000476#endif
477#ifdef CR1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000478 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000479#endif
480#ifdef CR2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000481 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000482#endif
483#ifdef CR3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000484 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000485#endif
486#ifdef TAB0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000487 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000488#endif
489#ifdef TAB1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000490 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000491#endif
492#ifdef TAB2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000493 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000494#endif
495#ifdef TAB3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000496 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000497#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000498#ifdef XTABS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000499 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000500#endif
Fred Draked85556c2001-03-03 18:08:52 +0000501#ifdef BS0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000502 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000503#endif
504#ifdef BS1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000505 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000506#endif
507#ifdef VT0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000508 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000509#endif
510#ifdef VT1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000511 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000512#endif
513#ifdef FF0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000514 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000515#endif
516#ifdef FF1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000517 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000518#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000519
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000520 /* struct termios.c_cflag constants */
521 {"CSIZE", CSIZE},
522 {"CSTOPB", CSTOPB},
523 {"CREAD", CREAD},
524 {"PARENB", PARENB},
525 {"PARODD", PARODD},
526 {"HUPCL", HUPCL},
527 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000528#ifdef CIBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000529 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000530#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000531#ifdef CRTSCTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000532 {"CRTSCTS", (long)CRTSCTS},
Fred Drakededbebf2001-03-02 06:50:58 +0000533#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000534
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000535 /* struct termios.c_cflag-related values (character size) */
536 {"CS5", CS5},
537 {"CS6", CS6},
538 {"CS7", CS7},
539 {"CS8", CS8},
Fred Drakedf48d142001-02-27 21:22:39 +0000540
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000541 /* struct termios.c_lflag constants */
542 {"ISIG", ISIG},
543 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000544#ifdef XCASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000545 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000546#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000547 {"ECHO", ECHO},
548 {"ECHOE", ECHOE},
549 {"ECHOK", ECHOK},
550 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000551#ifdef ECHOCTL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000552 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000553#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000554#ifdef ECHOPRT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000555 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000556#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000557#ifdef ECHOKE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000558 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000559#endif
560#ifdef FLUSHO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000561 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000562#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000563 {"NOFLSH", NOFLSH},
564 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000565#ifdef PENDIN
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000566 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000567#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000568 {"IEXTEN", IEXTEN},
Fred Drakedf48d142001-02-27 21:22:39 +0000569
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000570 /* indexes into the control chars array returned by tcgetattr() */
571 {"VINTR", VINTR},
572 {"VQUIT", VQUIT},
573 {"VERASE", VERASE},
574 {"VKILL", VKILL},
575 {"VEOF", VEOF},
576 {"VTIME", VTIME},
577 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000578#ifdef VSWTC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000579 /* The #defines above ensure that if either is defined, both are,
580 * but both may be omitted by the system headers. ;-( */
581 {"VSWTC", VSWTC},
582 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000583#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000584 {"VSTART", VSTART},
585 {"VSTOP", VSTOP},
586 {"VSUSP", VSUSP},
587 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000588#ifdef VREPRINT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000589 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000590#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000591#ifdef VDISCARD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000592 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000593#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000594#ifdef VWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000595 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000596#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000597#ifdef VLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000598 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000599#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000600#ifdef VEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000601 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000602#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000603
Fred Drake55a00342001-03-26 17:14:02 +0000604
605#ifdef B460800
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000606 {"B460800", B460800},
Fred Drake55a00342001-03-26 17:14:02 +0000607#endif
608#ifdef CBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000609 {"CBAUD", CBAUD},
Fred Drake55a00342001-03-26 17:14:02 +0000610#endif
611#ifdef CDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000612 {"CDEL", CDEL},
Fred Drake55a00342001-03-26 17:14:02 +0000613#endif
614#ifdef CDSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000615 {"CDSUSP", CDSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000616#endif
617#ifdef CEOF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000618 {"CEOF", CEOF},
Fred Drake55a00342001-03-26 17:14:02 +0000619#endif
620#ifdef CEOL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000621 {"CEOL", CEOL},
Fred Drake55a00342001-03-26 17:14:02 +0000622#endif
623#ifdef CEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000624 {"CEOL2", CEOL2},
Fred Drake55a00342001-03-26 17:14:02 +0000625#endif
626#ifdef CEOT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000627 {"CEOT", CEOT},
Fred Drake55a00342001-03-26 17:14:02 +0000628#endif
629#ifdef CERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000630 {"CERASE", CERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000631#endif
632#ifdef CESC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000633 {"CESC", CESC},
Fred Drake55a00342001-03-26 17:14:02 +0000634#endif
635#ifdef CFLUSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000636 {"CFLUSH", CFLUSH},
Fred Drake55a00342001-03-26 17:14:02 +0000637#endif
638#ifdef CINTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000639 {"CINTR", CINTR},
Fred Drake55a00342001-03-26 17:14:02 +0000640#endif
641#ifdef CKILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000642 {"CKILL", CKILL},
Fred Drake55a00342001-03-26 17:14:02 +0000643#endif
644#ifdef CLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000645 {"CLNEXT", CLNEXT},
Fred Drake55a00342001-03-26 17:14:02 +0000646#endif
647#ifdef CNUL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000648 {"CNUL", CNUL},
Fred Drake55a00342001-03-26 17:14:02 +0000649#endif
650#ifdef COMMON
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000651 {"COMMON", COMMON},
Fred Drake55a00342001-03-26 17:14:02 +0000652#endif
653#ifdef CQUIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000654 {"CQUIT", CQUIT},
Fred Drake55a00342001-03-26 17:14:02 +0000655#endif
656#ifdef CRPRNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000657 {"CRPRNT", CRPRNT},
Fred Drake55a00342001-03-26 17:14:02 +0000658#endif
659#ifdef CSTART
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000660 {"CSTART", CSTART},
Fred Drake55a00342001-03-26 17:14:02 +0000661#endif
662#ifdef CSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000663 {"CSTOP", CSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000664#endif
665#ifdef CSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000666 {"CSUSP", CSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000667#endif
668#ifdef CSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000669 {"CSWTCH", CSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000670#endif
671#ifdef CWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000672 {"CWERASE", CWERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000673#endif
674#ifdef EXTA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000675 {"EXTA", EXTA},
Fred Drake55a00342001-03-26 17:14:02 +0000676#endif
677#ifdef EXTB
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000678 {"EXTB", EXTB},
Fred Drake55a00342001-03-26 17:14:02 +0000679#endif
680#ifdef FIOASYNC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000681 {"FIOASYNC", FIOASYNC},
Fred Drake55a00342001-03-26 17:14:02 +0000682#endif
683#ifdef FIOCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000684 {"FIOCLEX", FIOCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000685#endif
686#ifdef FIONBIO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000687 {"FIONBIO", FIONBIO},
Fred Drake55a00342001-03-26 17:14:02 +0000688#endif
689#ifdef FIONCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000690 {"FIONCLEX", FIONCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000691#endif
692#ifdef FIONREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000693 {"FIONREAD", FIONREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000694#endif
695#ifdef IBSHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000696 {"IBSHIFT", IBSHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000697#endif
698#ifdef INIT_C_CC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000699 {"INIT_C_CC", INIT_C_CC},
Fred Drake55a00342001-03-26 17:14:02 +0000700#endif
701#ifdef IOCSIZE_MASK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000702 {"IOCSIZE_MASK", IOCSIZE_MASK},
Fred Drake55a00342001-03-26 17:14:02 +0000703#endif
704#ifdef IOCSIZE_SHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000705 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000706#endif
707#ifdef NCC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000708 {"NCC", NCC},
Fred Drake55a00342001-03-26 17:14:02 +0000709#endif
710#ifdef NCCS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000711 {"NCCS", NCCS},
Fred Drake55a00342001-03-26 17:14:02 +0000712#endif
713#ifdef NSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000714 {"NSWTCH", NSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000715#endif
716#ifdef N_MOUSE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000717 {"N_MOUSE", N_MOUSE},
Fred Drake55a00342001-03-26 17:14:02 +0000718#endif
719#ifdef N_PPP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000720 {"N_PPP", N_PPP},
Fred Drake55a00342001-03-26 17:14:02 +0000721#endif
722#ifdef N_SLIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000723 {"N_SLIP", N_SLIP},
Fred Drake55a00342001-03-26 17:14:02 +0000724#endif
725#ifdef N_STRIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000726 {"N_STRIP", N_STRIP},
Fred Drake55a00342001-03-26 17:14:02 +0000727#endif
728#ifdef N_TTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000729 {"N_TTY", N_TTY},
Fred Drake55a00342001-03-26 17:14:02 +0000730#endif
731#ifdef TCFLSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000732 {"TCFLSH", TCFLSH},
Fred Drake55a00342001-03-26 17:14:02 +0000733#endif
734#ifdef TCGETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000735 {"TCGETA", TCGETA},
Fred Drake55a00342001-03-26 17:14:02 +0000736#endif
737#ifdef TCGETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000738 {"TCGETS", TCGETS},
Fred Drake55a00342001-03-26 17:14:02 +0000739#endif
740#ifdef TCSBRK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000741 {"TCSBRK", TCSBRK},
Fred Drake55a00342001-03-26 17:14:02 +0000742#endif
743#ifdef TCSBRKP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000744 {"TCSBRKP", TCSBRKP},
Fred Drake55a00342001-03-26 17:14:02 +0000745#endif
746#ifdef TCSETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000747 {"TCSETA", TCSETA},
Fred Drake55a00342001-03-26 17:14:02 +0000748#endif
749#ifdef TCSETAF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000750 {"TCSETAF", TCSETAF},
Fred Drake55a00342001-03-26 17:14:02 +0000751#endif
752#ifdef TCSETAW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000753 {"TCSETAW", TCSETAW},
Fred Drake55a00342001-03-26 17:14:02 +0000754#endif
755#ifdef TCSETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000756 {"TCSETS", TCSETS},
Fred Drake55a00342001-03-26 17:14:02 +0000757#endif
758#ifdef TCSETSF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000759 {"TCSETSF", TCSETSF},
Fred Drake55a00342001-03-26 17:14:02 +0000760#endif
761#ifdef TCSETSW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000762 {"TCSETSW", TCSETSW},
Fred Drake55a00342001-03-26 17:14:02 +0000763#endif
764#ifdef TCXONC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000765 {"TCXONC", TCXONC},
Fred Drake55a00342001-03-26 17:14:02 +0000766#endif
767#ifdef TIOCCONS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000768 {"TIOCCONS", TIOCCONS},
Fred Drake55a00342001-03-26 17:14:02 +0000769#endif
770#ifdef TIOCEXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000771 {"TIOCEXCL", TIOCEXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000772#endif
773#ifdef TIOCGETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000774 {"TIOCGETD", TIOCGETD},
Fred Drake55a00342001-03-26 17:14:02 +0000775#endif
776#ifdef TIOCGICOUNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000777 {"TIOCGICOUNT", TIOCGICOUNT},
Fred Drake55a00342001-03-26 17:14:02 +0000778#endif
779#ifdef TIOCGLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000780 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000781#endif
782#ifdef TIOCGPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000783 {"TIOCGPGRP", TIOCGPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000784#endif
785#ifdef TIOCGSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000786 {"TIOCGSERIAL", TIOCGSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000787#endif
788#ifdef TIOCGSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000789 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000790#endif
791#ifdef TIOCGWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000792 {"TIOCGWINSZ", TIOCGWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000793#endif
794#ifdef TIOCINQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000795 {"TIOCINQ", TIOCINQ},
Fred Drake55a00342001-03-26 17:14:02 +0000796#endif
797#ifdef TIOCLINUX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000798 {"TIOCLINUX", TIOCLINUX},
Fred Drake55a00342001-03-26 17:14:02 +0000799#endif
800#ifdef TIOCMBIC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000801 {"TIOCMBIC", TIOCMBIC},
Fred Drake55a00342001-03-26 17:14:02 +0000802#endif
803#ifdef TIOCMBIS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000804 {"TIOCMBIS", TIOCMBIS},
Fred Drake55a00342001-03-26 17:14:02 +0000805#endif
806#ifdef TIOCMGET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000807 {"TIOCMGET", TIOCMGET},
Fred Drake55a00342001-03-26 17:14:02 +0000808#endif
809#ifdef TIOCMIWAIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000810 {"TIOCMIWAIT", TIOCMIWAIT},
Fred Drake55a00342001-03-26 17:14:02 +0000811#endif
812#ifdef TIOCMSET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000813 {"TIOCMSET", TIOCMSET},
Fred Drake55a00342001-03-26 17:14:02 +0000814#endif
815#ifdef TIOCM_CAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000816 {"TIOCM_CAR", TIOCM_CAR},
Fred Drake55a00342001-03-26 17:14:02 +0000817#endif
818#ifdef TIOCM_CD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000819 {"TIOCM_CD", TIOCM_CD},
Fred Drake55a00342001-03-26 17:14:02 +0000820#endif
821#ifdef TIOCM_CTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000822 {"TIOCM_CTS", TIOCM_CTS},
Fred Drake55a00342001-03-26 17:14:02 +0000823#endif
824#ifdef TIOCM_DSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000825 {"TIOCM_DSR", TIOCM_DSR},
Fred Drake55a00342001-03-26 17:14:02 +0000826#endif
827#ifdef TIOCM_DTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000828 {"TIOCM_DTR", TIOCM_DTR},
Fred Drake55a00342001-03-26 17:14:02 +0000829#endif
830#ifdef TIOCM_LE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000831 {"TIOCM_LE", TIOCM_LE},
Fred Drake55a00342001-03-26 17:14:02 +0000832#endif
833#ifdef TIOCM_RI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000834 {"TIOCM_RI", TIOCM_RI},
Fred Drake55a00342001-03-26 17:14:02 +0000835#endif
836#ifdef TIOCM_RNG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000837 {"TIOCM_RNG", TIOCM_RNG},
Fred Drake55a00342001-03-26 17:14:02 +0000838#endif
839#ifdef TIOCM_RTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000840 {"TIOCM_RTS", TIOCM_RTS},
Fred Drake55a00342001-03-26 17:14:02 +0000841#endif
842#ifdef TIOCM_SR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000843 {"TIOCM_SR", TIOCM_SR},
Fred Drake55a00342001-03-26 17:14:02 +0000844#endif
845#ifdef TIOCM_ST
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000846 {"TIOCM_ST", TIOCM_ST},
Fred Drake55a00342001-03-26 17:14:02 +0000847#endif
848#ifdef TIOCNOTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000849 {"TIOCNOTTY", TIOCNOTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000850#endif
851#ifdef TIOCNXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000852 {"TIOCNXCL", TIOCNXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000853#endif
854#ifdef TIOCOUTQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000855 {"TIOCOUTQ", TIOCOUTQ},
Fred Drake55a00342001-03-26 17:14:02 +0000856#endif
857#ifdef TIOCPKT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000858 {"TIOCPKT", TIOCPKT},
Fred Drake55a00342001-03-26 17:14:02 +0000859#endif
860#ifdef TIOCPKT_DATA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000861 {"TIOCPKT_DATA", TIOCPKT_DATA},
Fred Drake55a00342001-03-26 17:14:02 +0000862#endif
863#ifdef TIOCPKT_DOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000864 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000865#endif
866#ifdef TIOCPKT_FLUSHREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000867 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000868#endif
869#ifdef TIOCPKT_FLUSHWRITE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000870 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
Fred Drake55a00342001-03-26 17:14:02 +0000871#endif
872#ifdef TIOCPKT_NOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000873 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000874#endif
875#ifdef TIOCPKT_START
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000876 {"TIOCPKT_START", TIOCPKT_START},
Fred Drake55a00342001-03-26 17:14:02 +0000877#endif
878#ifdef TIOCPKT_STOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000879 {"TIOCPKT_STOP", TIOCPKT_STOP},
Fred Drake55a00342001-03-26 17:14:02 +0000880#endif
881#ifdef TIOCSCTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000882 {"TIOCSCTTY", TIOCSCTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000883#endif
884#ifdef TIOCSERCONFIG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000885 {"TIOCSERCONFIG", TIOCSERCONFIG},
Fred Drake55a00342001-03-26 17:14:02 +0000886#endif
887#ifdef TIOCSERGETLSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000888 {"TIOCSERGETLSR", TIOCSERGETLSR},
Fred Drake55a00342001-03-26 17:14:02 +0000889#endif
890#ifdef TIOCSERGETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000891 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000892#endif
893#ifdef TIOCSERGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000894 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000895#endif
896#ifdef TIOCSERGWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000897 {"TIOCSERGWILD", TIOCSERGWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000898#endif
899#ifdef TIOCSERSETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000900 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000901#endif
902#ifdef TIOCSERSWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000903 {"TIOCSERSWILD", TIOCSERSWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000904#endif
905#ifdef TIOCSER_TEMT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000906 {"TIOCSER_TEMT", TIOCSER_TEMT},
Fred Drake55a00342001-03-26 17:14:02 +0000907#endif
908#ifdef TIOCSETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000909 {"TIOCSETD", TIOCSETD},
Fred Drake55a00342001-03-26 17:14:02 +0000910#endif
911#ifdef TIOCSLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000912 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000913#endif
914#ifdef TIOCSPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000915 {"TIOCSPGRP", TIOCSPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000916#endif
917#ifdef TIOCSSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000918 {"TIOCSSERIAL", TIOCSSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000919#endif
920#ifdef TIOCSSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000921 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000922#endif
923#ifdef TIOCSTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000924 {"TIOCSTI", TIOCSTI},
Fred Drake55a00342001-03-26 17:14:02 +0000925#endif
926#ifdef TIOCSWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000927 {"TIOCSWINSZ", TIOCSWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000928#endif
929#ifdef TIOCTTYGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000930 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000931#endif
932
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000933 /* sentinel */
934 {NULL, 0}
Fred Drakedf48d142001-02-27 21:22:39 +0000935};
936
937
Martin v. Löwis1a214512008-06-11 05:26:20 +0000938static struct PyModuleDef termiosmodule = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000939 PyModuleDef_HEAD_INIT,
940 "termios",
941 termios__doc__,
942 -1,
943 termios_methods,
944 NULL,
945 NULL,
946 NULL,
947 NULL
Martin v. Löwis1a214512008-06-11 05:26:20 +0000948};
949
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000950PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000951PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000952{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000953 PyObject *m;
954 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000955
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000956 m = PyModule_Create(&termiosmodule);
957 if (m == NULL)
958 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000959
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000960 if (TermiosError == NULL) {
961 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
962 }
963 Py_INCREF(TermiosError);
964 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000965
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000966 while (constant->name != NULL) {
967 PyModule_AddIntConstant(m, constant->name, constant->value);
968 ++constant;
969 }
970 return m;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000971}