blob: 6ed4395ae4dd4c16e0a987a3c8943b3ba1f0d265 [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
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200197 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000198}
199
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000200PyDoc_STRVAR(termios_tcsendbreak__doc__,
201"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000202\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000203Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000204A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000205has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000206
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000207static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000208termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000209{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000210 int fd, duration;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000211
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000212 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
213 fdconv, &fd, &duration))
214 return NULL;
215 if (tcsendbreak(fd, duration) == -1)
216 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000217
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200218 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000219}
220
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000221PyDoc_STRVAR(termios_tcdrain__doc__,
222"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000223\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000224Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000225
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000226static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000227termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000228{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000229 int fd;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000230
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000231 if (!PyArg_ParseTuple(args, "O&:tcdrain",
232 fdconv, &fd))
233 return NULL;
234 if (tcdrain(fd) == -1)
235 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000236
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200237 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000238}
239
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000240PyDoc_STRVAR(termios_tcflush__doc__,
241"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000242\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000243Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000244The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
245queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000246both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000247
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000248static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000249termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000250{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000251 int fd, queue;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000252
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000253 if (!PyArg_ParseTuple(args, "O&i:tcflush",
254 fdconv, &fd, &queue))
255 return NULL;
256 if (tcflush(fd, queue) == -1)
257 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000258
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200259 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000260}
261
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000262PyDoc_STRVAR(termios_tcflow__doc__,
263"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000264\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000265Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000266The action argument can be termios.TCOOFF to suspend output,\n\
267termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000268or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000269
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000270static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000271termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000272{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000273 int fd, action;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000274
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000275 if (!PyArg_ParseTuple(args, "O&i:tcflow",
276 fdconv, &fd, &action))
277 return NULL;
278 if (tcflow(fd, action) == -1)
279 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000280
Serhiy Storchaka228b12e2017-01-23 09:47:21 +0200281 Py_RETURN_NONE;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000282}
283
284static PyMethodDef termios_methods[] =
285{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000286 {"tcgetattr", termios_tcgetattr,
287 METH_VARARGS, termios_tcgetattr__doc__},
288 {"tcsetattr", termios_tcsetattr,
289 METH_VARARGS, termios_tcsetattr__doc__},
290 {"tcsendbreak", termios_tcsendbreak,
291 METH_VARARGS, termios_tcsendbreak__doc__},
292 {"tcdrain", termios_tcdrain,
293 METH_VARARGS, termios_tcdrain__doc__},
294 {"tcflush", termios_tcflush,
295 METH_VARARGS, termios_tcflush__doc__},
296 {"tcflow", termios_tcflow,
297 METH_VARARGS, termios_tcflow__doc__},
298 {NULL, NULL}
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000299};
300
Fred Drakedf48d142001-02-27 21:22:39 +0000301
Fred Drake9ef7fa82001-03-01 21:54:49 +0000302#if defined(VSWTCH) && !defined(VSWTC)
303#define VSWTC VSWTCH
304#endif
305
306#if defined(VSWTC) && !defined(VSWTCH)
307#define VSWTCH VSWTC
308#endif
309
Fred Drakedf48d142001-02-27 21:22:39 +0000310static struct constant {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000311 char *name;
312 long value;
Fred Drakedf48d142001-02-27 21:22:39 +0000313} termios_constants[] = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000314 /* cfgetospeed(), cfsetospeed() constants */
315 {"B0", B0},
316 {"B50", B50},
317 {"B75", B75},
318 {"B110", B110},
319 {"B134", B134},
320 {"B150", B150},
321 {"B200", B200},
322 {"B300", B300},
323 {"B600", B600},
324 {"B1200", B1200},
325 {"B1800", B1800},
326 {"B2400", B2400},
327 {"B4800", B4800},
328 {"B9600", B9600},
329 {"B19200", B19200},
330 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000331#ifdef B57600
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000332 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000333#endif
334#ifdef B115200
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000335 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000336#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000337#ifdef B230400
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000338 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000339#endif
Antoine Pitroua78f74c2010-11-20 20:03:08 +0000340#ifdef B460800
341 {"B460800", B460800},
342#endif
343#ifdef B500000
344 {"B500000", B500000},
345#endif
346#ifdef B576000
347 {"B576000", B576000},
348#endif
349#ifdef B921600
350 {"B921600", B921600},
351#endif
352#ifdef B1000000
353 {"B1000000", B1000000},
354#endif
355#ifdef B1152000
356 {"B1152000", B1152000},
357#endif
358#ifdef B1500000
359 {"B1500000", B1500000},
360#endif
361#ifdef B2000000
362 {"B2000000", B2000000},
363#endif
364#ifdef B2500000
365 {"B2500000", B2500000},
366#endif
367#ifdef B3000000
368 {"B3000000", B3000000},
369#endif
370#ifdef B3500000
371 {"B3500000", B3500000},
372#endif
373#ifdef B4000000
374 {"B4000000", B4000000},
375#endif
376
Fred Drake9ef7fa82001-03-01 21:54:49 +0000377#ifdef CBAUDEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000378 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000379#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000380
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000381 /* tcsetattr() constants */
382 {"TCSANOW", TCSANOW},
383 {"TCSADRAIN", TCSADRAIN},
384 {"TCSAFLUSH", TCSAFLUSH},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000385#ifdef TCSASOFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000386 {"TCSASOFT", TCSASOFT},
Gregory P. Smithcafc22f2009-11-01 19:24:18 +0000387#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000388
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000389 /* tcflush() constants */
390 {"TCIFLUSH", TCIFLUSH},
391 {"TCOFLUSH", TCOFLUSH},
392 {"TCIOFLUSH", TCIOFLUSH},
Fred Drakedf48d142001-02-27 21:22:39 +0000393
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000394 /* tcflow() constants */
395 {"TCOOFF", TCOOFF},
396 {"TCOON", TCOON},
397 {"TCIOFF", TCIOFF},
398 {"TCION", TCION},
Fred Drakedf48d142001-02-27 21:22:39 +0000399
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000400 /* struct termios.c_iflag constants */
401 {"IGNBRK", IGNBRK},
402 {"BRKINT", BRKINT},
403 {"IGNPAR", IGNPAR},
404 {"PARMRK", PARMRK},
405 {"INPCK", INPCK},
406 {"ISTRIP", ISTRIP},
407 {"INLCR", INLCR},
408 {"IGNCR", IGNCR},
409 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000410#ifdef IUCLC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000411 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000412#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000413 {"IXON", IXON},
414 {"IXANY", IXANY},
415 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000416#ifdef IMAXBEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000417 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000418#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000419
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000420 /* struct termios.c_oflag constants */
421 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000422#ifdef OLCUC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000423 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000424#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000425#ifdef ONLCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000426 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000427#endif
Fred Draked85556c2001-03-03 18:08:52 +0000428#ifdef OCRNL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000429 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000430#endif
431#ifdef ONOCR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000432 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000433#endif
434#ifdef ONLRET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000435 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000436#endif
437#ifdef OFILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000438 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000439#endif
440#ifdef OFDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000441 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000442#endif
443#ifdef NLDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000444 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000445#endif
446#ifdef CRDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000447 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000448#endif
449#ifdef TABDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000450 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000451#endif
452#ifdef BSDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000453 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000454#endif
455#ifdef VTDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000456 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000457#endif
458#ifdef FFDLY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000459 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000460#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000461
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000462 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000463#ifdef NL0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000464 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000465#endif
466#ifdef NL1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000467 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000468#endif
469#ifdef CR0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000470 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000471#endif
472#ifdef CR1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000473 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000474#endif
475#ifdef CR2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000476 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000477#endif
478#ifdef CR3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000479 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000480#endif
481#ifdef TAB0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000482 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000483#endif
484#ifdef TAB1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000485 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000486#endif
487#ifdef TAB2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000488 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000489#endif
490#ifdef TAB3
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000491 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000492#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000493#ifdef XTABS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000494 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000495#endif
Fred Draked85556c2001-03-03 18:08:52 +0000496#ifdef BS0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000497 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000498#endif
499#ifdef BS1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000500 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000501#endif
502#ifdef VT0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000503 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000504#endif
505#ifdef VT1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000506 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000507#endif
508#ifdef FF0
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000509 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000510#endif
511#ifdef FF1
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000512 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000513#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000514
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000515 /* struct termios.c_cflag constants */
516 {"CSIZE", CSIZE},
517 {"CSTOPB", CSTOPB},
518 {"CREAD", CREAD},
519 {"PARENB", PARENB},
520 {"PARODD", PARODD},
521 {"HUPCL", HUPCL},
522 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000523#ifdef CIBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000524 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000525#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000526#ifdef CRTSCTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000527 {"CRTSCTS", (long)CRTSCTS},
Fred Drakededbebf2001-03-02 06:50:58 +0000528#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000529
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000530 /* struct termios.c_cflag-related values (character size) */
531 {"CS5", CS5},
532 {"CS6", CS6},
533 {"CS7", CS7},
534 {"CS8", CS8},
Fred Drakedf48d142001-02-27 21:22:39 +0000535
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000536 /* struct termios.c_lflag constants */
537 {"ISIG", ISIG},
538 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000539#ifdef XCASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000540 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000541#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000542 {"ECHO", ECHO},
543 {"ECHOE", ECHOE},
544 {"ECHOK", ECHOK},
545 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000546#ifdef ECHOCTL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000547 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000548#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000549#ifdef ECHOPRT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000550 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000551#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000552#ifdef ECHOKE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000553 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000554#endif
555#ifdef FLUSHO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000556 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000557#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000558 {"NOFLSH", NOFLSH},
559 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000560#ifdef PENDIN
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000561 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000562#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000563 {"IEXTEN", IEXTEN},
Fred Drakedf48d142001-02-27 21:22:39 +0000564
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000565 /* indexes into the control chars array returned by tcgetattr() */
566 {"VINTR", VINTR},
567 {"VQUIT", VQUIT},
568 {"VERASE", VERASE},
569 {"VKILL", VKILL},
570 {"VEOF", VEOF},
571 {"VTIME", VTIME},
572 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000573#ifdef VSWTC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000574 /* The #defines above ensure that if either is defined, both are,
575 * but both may be omitted by the system headers. ;-( */
576 {"VSWTC", VSWTC},
577 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000578#endif
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000579 {"VSTART", VSTART},
580 {"VSTOP", VSTOP},
581 {"VSUSP", VSUSP},
582 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000583#ifdef VREPRINT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000584 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000585#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000586#ifdef VDISCARD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000587 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000588#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000589#ifdef VWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000590 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000591#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000592#ifdef VLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000593 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000594#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000595#ifdef VEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000596 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000597#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000598
Fred Drake55a00342001-03-26 17:14:02 +0000599
600#ifdef B460800
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000601 {"B460800", B460800},
Fred Drake55a00342001-03-26 17:14:02 +0000602#endif
603#ifdef CBAUD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000604 {"CBAUD", CBAUD},
Fred Drake55a00342001-03-26 17:14:02 +0000605#endif
606#ifdef CDEL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000607 {"CDEL", CDEL},
Fred Drake55a00342001-03-26 17:14:02 +0000608#endif
609#ifdef CDSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000610 {"CDSUSP", CDSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000611#endif
612#ifdef CEOF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000613 {"CEOF", CEOF},
Fred Drake55a00342001-03-26 17:14:02 +0000614#endif
615#ifdef CEOL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000616 {"CEOL", CEOL},
Fred Drake55a00342001-03-26 17:14:02 +0000617#endif
618#ifdef CEOL2
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000619 {"CEOL2", CEOL2},
Fred Drake55a00342001-03-26 17:14:02 +0000620#endif
621#ifdef CEOT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000622 {"CEOT", CEOT},
Fred Drake55a00342001-03-26 17:14:02 +0000623#endif
624#ifdef CERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000625 {"CERASE", CERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000626#endif
627#ifdef CESC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000628 {"CESC", CESC},
Fred Drake55a00342001-03-26 17:14:02 +0000629#endif
630#ifdef CFLUSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000631 {"CFLUSH", CFLUSH},
Fred Drake55a00342001-03-26 17:14:02 +0000632#endif
633#ifdef CINTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000634 {"CINTR", CINTR},
Fred Drake55a00342001-03-26 17:14:02 +0000635#endif
636#ifdef CKILL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000637 {"CKILL", CKILL},
Fred Drake55a00342001-03-26 17:14:02 +0000638#endif
639#ifdef CLNEXT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000640 {"CLNEXT", CLNEXT},
Fred Drake55a00342001-03-26 17:14:02 +0000641#endif
642#ifdef CNUL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000643 {"CNUL", CNUL},
Fred Drake55a00342001-03-26 17:14:02 +0000644#endif
645#ifdef COMMON
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000646 {"COMMON", COMMON},
Fred Drake55a00342001-03-26 17:14:02 +0000647#endif
648#ifdef CQUIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000649 {"CQUIT", CQUIT},
Fred Drake55a00342001-03-26 17:14:02 +0000650#endif
651#ifdef CRPRNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000652 {"CRPRNT", CRPRNT},
Fred Drake55a00342001-03-26 17:14:02 +0000653#endif
654#ifdef CSTART
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000655 {"CSTART", CSTART},
Fred Drake55a00342001-03-26 17:14:02 +0000656#endif
657#ifdef CSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000658 {"CSTOP", CSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000659#endif
660#ifdef CSUSP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000661 {"CSUSP", CSUSP},
Fred Drake55a00342001-03-26 17:14:02 +0000662#endif
663#ifdef CSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000664 {"CSWTCH", CSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000665#endif
666#ifdef CWERASE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000667 {"CWERASE", CWERASE},
Fred Drake55a00342001-03-26 17:14:02 +0000668#endif
669#ifdef EXTA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000670 {"EXTA", EXTA},
Fred Drake55a00342001-03-26 17:14:02 +0000671#endif
672#ifdef EXTB
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000673 {"EXTB", EXTB},
Fred Drake55a00342001-03-26 17:14:02 +0000674#endif
675#ifdef FIOASYNC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000676 {"FIOASYNC", FIOASYNC},
Fred Drake55a00342001-03-26 17:14:02 +0000677#endif
678#ifdef FIOCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000679 {"FIOCLEX", FIOCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000680#endif
681#ifdef FIONBIO
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000682 {"FIONBIO", FIONBIO},
Fred Drake55a00342001-03-26 17:14:02 +0000683#endif
684#ifdef FIONCLEX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000685 {"FIONCLEX", FIONCLEX},
Fred Drake55a00342001-03-26 17:14:02 +0000686#endif
687#ifdef FIONREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000688 {"FIONREAD", FIONREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000689#endif
690#ifdef IBSHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000691 {"IBSHIFT", IBSHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000692#endif
693#ifdef INIT_C_CC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000694 {"INIT_C_CC", INIT_C_CC},
Fred Drake55a00342001-03-26 17:14:02 +0000695#endif
696#ifdef IOCSIZE_MASK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000697 {"IOCSIZE_MASK", IOCSIZE_MASK},
Fred Drake55a00342001-03-26 17:14:02 +0000698#endif
699#ifdef IOCSIZE_SHIFT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000700 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
Fred Drake55a00342001-03-26 17:14:02 +0000701#endif
702#ifdef NCC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000703 {"NCC", NCC},
Fred Drake55a00342001-03-26 17:14:02 +0000704#endif
705#ifdef NCCS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000706 {"NCCS", NCCS},
Fred Drake55a00342001-03-26 17:14:02 +0000707#endif
708#ifdef NSWTCH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000709 {"NSWTCH", NSWTCH},
Fred Drake55a00342001-03-26 17:14:02 +0000710#endif
711#ifdef N_MOUSE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000712 {"N_MOUSE", N_MOUSE},
Fred Drake55a00342001-03-26 17:14:02 +0000713#endif
714#ifdef N_PPP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000715 {"N_PPP", N_PPP},
Fred Drake55a00342001-03-26 17:14:02 +0000716#endif
717#ifdef N_SLIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000718 {"N_SLIP", N_SLIP},
Fred Drake55a00342001-03-26 17:14:02 +0000719#endif
720#ifdef N_STRIP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000721 {"N_STRIP", N_STRIP},
Fred Drake55a00342001-03-26 17:14:02 +0000722#endif
723#ifdef N_TTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000724 {"N_TTY", N_TTY},
Fred Drake55a00342001-03-26 17:14:02 +0000725#endif
726#ifdef TCFLSH
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000727 {"TCFLSH", TCFLSH},
Fred Drake55a00342001-03-26 17:14:02 +0000728#endif
729#ifdef TCGETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000730 {"TCGETA", TCGETA},
Fred Drake55a00342001-03-26 17:14:02 +0000731#endif
732#ifdef TCGETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000733 {"TCGETS", TCGETS},
Fred Drake55a00342001-03-26 17:14:02 +0000734#endif
735#ifdef TCSBRK
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000736 {"TCSBRK", TCSBRK},
Fred Drake55a00342001-03-26 17:14:02 +0000737#endif
738#ifdef TCSBRKP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000739 {"TCSBRKP", TCSBRKP},
Fred Drake55a00342001-03-26 17:14:02 +0000740#endif
741#ifdef TCSETA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000742 {"TCSETA", TCSETA},
Fred Drake55a00342001-03-26 17:14:02 +0000743#endif
744#ifdef TCSETAF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000745 {"TCSETAF", TCSETAF},
Fred Drake55a00342001-03-26 17:14:02 +0000746#endif
747#ifdef TCSETAW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000748 {"TCSETAW", TCSETAW},
Fred Drake55a00342001-03-26 17:14:02 +0000749#endif
750#ifdef TCSETS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000751 {"TCSETS", TCSETS},
Fred Drake55a00342001-03-26 17:14:02 +0000752#endif
753#ifdef TCSETSF
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000754 {"TCSETSF", TCSETSF},
Fred Drake55a00342001-03-26 17:14:02 +0000755#endif
756#ifdef TCSETSW
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000757 {"TCSETSW", TCSETSW},
Fred Drake55a00342001-03-26 17:14:02 +0000758#endif
759#ifdef TCXONC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000760 {"TCXONC", TCXONC},
Fred Drake55a00342001-03-26 17:14:02 +0000761#endif
762#ifdef TIOCCONS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000763 {"TIOCCONS", TIOCCONS},
Fred Drake55a00342001-03-26 17:14:02 +0000764#endif
765#ifdef TIOCEXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000766 {"TIOCEXCL", TIOCEXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000767#endif
768#ifdef TIOCGETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000769 {"TIOCGETD", TIOCGETD},
Fred Drake55a00342001-03-26 17:14:02 +0000770#endif
771#ifdef TIOCGICOUNT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000772 {"TIOCGICOUNT", TIOCGICOUNT},
Fred Drake55a00342001-03-26 17:14:02 +0000773#endif
774#ifdef TIOCGLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000775 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000776#endif
777#ifdef TIOCGPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000778 {"TIOCGPGRP", TIOCGPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000779#endif
780#ifdef TIOCGSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000781 {"TIOCGSERIAL", TIOCGSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000782#endif
783#ifdef TIOCGSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000784 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000785#endif
786#ifdef TIOCGWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000787 {"TIOCGWINSZ", TIOCGWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000788#endif
789#ifdef TIOCINQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000790 {"TIOCINQ", TIOCINQ},
Fred Drake55a00342001-03-26 17:14:02 +0000791#endif
792#ifdef TIOCLINUX
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000793 {"TIOCLINUX", TIOCLINUX},
Fred Drake55a00342001-03-26 17:14:02 +0000794#endif
795#ifdef TIOCMBIC
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000796 {"TIOCMBIC", TIOCMBIC},
Fred Drake55a00342001-03-26 17:14:02 +0000797#endif
798#ifdef TIOCMBIS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000799 {"TIOCMBIS", TIOCMBIS},
Fred Drake55a00342001-03-26 17:14:02 +0000800#endif
801#ifdef TIOCMGET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000802 {"TIOCMGET", TIOCMGET},
Fred Drake55a00342001-03-26 17:14:02 +0000803#endif
804#ifdef TIOCMIWAIT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000805 {"TIOCMIWAIT", TIOCMIWAIT},
Fred Drake55a00342001-03-26 17:14:02 +0000806#endif
807#ifdef TIOCMSET
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000808 {"TIOCMSET", TIOCMSET},
Fred Drake55a00342001-03-26 17:14:02 +0000809#endif
810#ifdef TIOCM_CAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000811 {"TIOCM_CAR", TIOCM_CAR},
Fred Drake55a00342001-03-26 17:14:02 +0000812#endif
813#ifdef TIOCM_CD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000814 {"TIOCM_CD", TIOCM_CD},
Fred Drake55a00342001-03-26 17:14:02 +0000815#endif
816#ifdef TIOCM_CTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000817 {"TIOCM_CTS", TIOCM_CTS},
Fred Drake55a00342001-03-26 17:14:02 +0000818#endif
819#ifdef TIOCM_DSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000820 {"TIOCM_DSR", TIOCM_DSR},
Fred Drake55a00342001-03-26 17:14:02 +0000821#endif
822#ifdef TIOCM_DTR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000823 {"TIOCM_DTR", TIOCM_DTR},
Fred Drake55a00342001-03-26 17:14:02 +0000824#endif
825#ifdef TIOCM_LE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000826 {"TIOCM_LE", TIOCM_LE},
Fred Drake55a00342001-03-26 17:14:02 +0000827#endif
828#ifdef TIOCM_RI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000829 {"TIOCM_RI", TIOCM_RI},
Fred Drake55a00342001-03-26 17:14:02 +0000830#endif
831#ifdef TIOCM_RNG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000832 {"TIOCM_RNG", TIOCM_RNG},
Fred Drake55a00342001-03-26 17:14:02 +0000833#endif
834#ifdef TIOCM_RTS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000835 {"TIOCM_RTS", TIOCM_RTS},
Fred Drake55a00342001-03-26 17:14:02 +0000836#endif
837#ifdef TIOCM_SR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000838 {"TIOCM_SR", TIOCM_SR},
Fred Drake55a00342001-03-26 17:14:02 +0000839#endif
840#ifdef TIOCM_ST
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000841 {"TIOCM_ST", TIOCM_ST},
Fred Drake55a00342001-03-26 17:14:02 +0000842#endif
843#ifdef TIOCNOTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000844 {"TIOCNOTTY", TIOCNOTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000845#endif
846#ifdef TIOCNXCL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000847 {"TIOCNXCL", TIOCNXCL},
Fred Drake55a00342001-03-26 17:14:02 +0000848#endif
849#ifdef TIOCOUTQ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000850 {"TIOCOUTQ", TIOCOUTQ},
Fred Drake55a00342001-03-26 17:14:02 +0000851#endif
852#ifdef TIOCPKT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000853 {"TIOCPKT", TIOCPKT},
Fred Drake55a00342001-03-26 17:14:02 +0000854#endif
855#ifdef TIOCPKT_DATA
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000856 {"TIOCPKT_DATA", TIOCPKT_DATA},
Fred Drake55a00342001-03-26 17:14:02 +0000857#endif
858#ifdef TIOCPKT_DOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000859 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000860#endif
861#ifdef TIOCPKT_FLUSHREAD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000862 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
Fred Drake55a00342001-03-26 17:14:02 +0000863#endif
864#ifdef TIOCPKT_FLUSHWRITE
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000865 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
Fred Drake55a00342001-03-26 17:14:02 +0000866#endif
867#ifdef TIOCPKT_NOSTOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000868 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
Fred Drake55a00342001-03-26 17:14:02 +0000869#endif
870#ifdef TIOCPKT_START
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000871 {"TIOCPKT_START", TIOCPKT_START},
Fred Drake55a00342001-03-26 17:14:02 +0000872#endif
873#ifdef TIOCPKT_STOP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000874 {"TIOCPKT_STOP", TIOCPKT_STOP},
Fred Drake55a00342001-03-26 17:14:02 +0000875#endif
876#ifdef TIOCSCTTY
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000877 {"TIOCSCTTY", TIOCSCTTY},
Fred Drake55a00342001-03-26 17:14:02 +0000878#endif
879#ifdef TIOCSERCONFIG
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000880 {"TIOCSERCONFIG", TIOCSERCONFIG},
Fred Drake55a00342001-03-26 17:14:02 +0000881#endif
882#ifdef TIOCSERGETLSR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000883 {"TIOCSERGETLSR", TIOCSERGETLSR},
Fred Drake55a00342001-03-26 17:14:02 +0000884#endif
885#ifdef TIOCSERGETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000886 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000887#endif
888#ifdef TIOCSERGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000889 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000890#endif
891#ifdef TIOCSERGWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000892 {"TIOCSERGWILD", TIOCSERGWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000893#endif
894#ifdef TIOCSERSETMULTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000895 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
Fred Drake55a00342001-03-26 17:14:02 +0000896#endif
897#ifdef TIOCSERSWILD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000898 {"TIOCSERSWILD", TIOCSERSWILD},
Fred Drake55a00342001-03-26 17:14:02 +0000899#endif
900#ifdef TIOCSER_TEMT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000901 {"TIOCSER_TEMT", TIOCSER_TEMT},
Fred Drake55a00342001-03-26 17:14:02 +0000902#endif
903#ifdef TIOCSETD
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000904 {"TIOCSETD", TIOCSETD},
Fred Drake55a00342001-03-26 17:14:02 +0000905#endif
906#ifdef TIOCSLCKTRMIOS
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000907 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
Fred Drake55a00342001-03-26 17:14:02 +0000908#endif
909#ifdef TIOCSPGRP
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000910 {"TIOCSPGRP", TIOCSPGRP},
Fred Drake55a00342001-03-26 17:14:02 +0000911#endif
912#ifdef TIOCSSERIAL
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000913 {"TIOCSSERIAL", TIOCSSERIAL},
Fred Drake55a00342001-03-26 17:14:02 +0000914#endif
915#ifdef TIOCSSOFTCAR
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000916 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
Fred Drake55a00342001-03-26 17:14:02 +0000917#endif
918#ifdef TIOCSTI
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000919 {"TIOCSTI", TIOCSTI},
Fred Drake55a00342001-03-26 17:14:02 +0000920#endif
921#ifdef TIOCSWINSZ
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000922 {"TIOCSWINSZ", TIOCSWINSZ},
Fred Drake55a00342001-03-26 17:14:02 +0000923#endif
924#ifdef TIOCTTYGSTRUCT
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000925 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
Fred Drake55a00342001-03-26 17:14:02 +0000926#endif
927
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000928 /* sentinel */
929 {NULL, 0}
Fred Drakedf48d142001-02-27 21:22:39 +0000930};
931
932
Martin v. Löwis1a214512008-06-11 05:26:20 +0000933static struct PyModuleDef termiosmodule = {
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000934 PyModuleDef_HEAD_INIT,
935 "termios",
936 termios__doc__,
937 -1,
938 termios_methods,
939 NULL,
940 NULL,
941 NULL,
942 NULL
Martin v. Löwis1a214512008-06-11 05:26:20 +0000943};
944
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000945PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000946PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000947{
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000948 PyObject *m;
949 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000950
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000951 m = PyModule_Create(&termiosmodule);
952 if (m == NULL)
953 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000954
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000955 if (TermiosError == NULL) {
956 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
957 }
958 Py_INCREF(TermiosError);
959 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000960
Antoine Pitrouf95a1b32010-05-09 15:52:27 +0000961 while (constant->name != NULL) {
962 PyModule_AddIntConstant(m, constant->name, constant->value);
963 ++constant;
964 }
965 return m;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000966}