blob: ed78ece933a84c9cc8c8c6b8f6ef82ae2f03bab9 [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
Guido van Rossum9adae8e1994-09-12 10:41:22 +00007#include <termios.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +00008#ifdef __osf__
9/* On OSF, sys/ioctl.h requires that struct termio already be defined,
10 * so this needs to be included first on that platform. */
Fred Drakeb638aaf2001-05-07 17:55:35 +000011#include <termio.h>
Fred Drakeb2877dd2001-05-09 17:53:06 +000012#endif
Fred Drake9b3bc492001-04-04 21:19:26 +000013#include <sys/ioctl.h>
Guido van Rossum1aca4d81998-03-03 22:10:18 +000014
Fred Drake87068f12001-05-11 16:14:17 +000015/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
16 * MDTR, MRI, and MRTS (appearantly used internally by some things
17 * defined as macros; these are not used here directly).
18 */
19#ifdef HAVE_SYS_MODEM_H
20#include <sys/modem.h>
21#endif
22
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000023PyDoc_STRVAR(termios__doc__,
24"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000025For a complete description of these calls, see the Posix or Unix manual\n\
26pages. It is only available for those Unix versions that support Posix\n\
27termios style tty I/O control.\n\
28\n\
29All functions in this module take a file descriptor fd as their first\n\
30argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000031sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000032
33static PyObject *TermiosError;
34
Fred Drakeb638aaf2001-05-07 17:55:35 +000035static int fdconv(PyObject* obj, void* p)
36{
37 int fd;
38
39 fd = PyObject_AsFileDescriptor(obj);
Fred Drakec99ff602001-05-09 20:14:09 +000040 if (fd >= 0) {
41 *(int*)p = fd;
42 return 1;
Fred Drakeb638aaf2001-05-07 17:55:35 +000043 }
Fred Drakec99ff602001-05-09 20:14:09 +000044 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000045}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000046
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000047PyDoc_STRVAR(termios_tcgetattr__doc__,
48"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000049\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000050Get the tty attributes for file descriptor fd, as follows:\n\
51[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
52of the tty special characters (each a string of length 1, except the items\n\
53with indices VMIN and VTIME, which are integers when these fields are\n\
54defined). The interpretation of the flags and the speeds as well as the\n\
55indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000056in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000057
Guido van Rossum9adae8e1994-09-12 10:41:22 +000058static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000059termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000060{
61 int fd;
62 struct termios mode;
63 PyObject *cc;
64 speed_t ispeed, ospeed;
65 PyObject *v;
66 int i;
67 char ch;
68
Fred Drakeb638aaf2001-05-07 17:55:35 +000069 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
70 fdconv, (void*)&fd))
Guido van Rossum9adae8e1994-09-12 10:41:22 +000071 return NULL;
72
73 if (tcgetattr(fd, &mode) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +000074 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000075
76 ispeed = cfgetispeed(&mode);
77 ospeed = cfgetospeed(&mode);
78
79 cc = PyList_New(NCCS);
80 if (cc == NULL)
81 return NULL;
82 for (i = 0; i < NCCS; i++) {
83 ch = (char)mode.c_cc[i];
84 v = PyString_FromStringAndSize(&ch, 1);
85 if (v == NULL)
Barry Warsaw5709dcf1997-01-10 18:42:18 +000086 goto err;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000087 PyList_SetItem(cc, i, v);
88 }
89
90 /* Convert the MIN and TIME slots to integer. On some systems, the
91 MIN and TIME slots are the same as the EOF and EOL slots. So we
92 only do this in noncanonical input mode. */
Guido van Rossum36dd0d21996-12-10 15:23:00 +000093 if ((mode.c_lflag & ICANON) == 0) {
Guido van Rossum9adae8e1994-09-12 10:41:22 +000094 v = PyInt_FromLong((long)mode.c_cc[VMIN]);
95 if (v == NULL)
Barry Warsaw5709dcf1997-01-10 18:42:18 +000096 goto err;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000097 PyList_SetItem(cc, VMIN, v);
98 v = PyInt_FromLong((long)mode.c_cc[VTIME]);
99 if (v == NULL)
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000100 goto err;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000101 PyList_SetItem(cc, VTIME, v);
102 }
103
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000104 if (!(v = PyList_New(7)))
105 goto err;
106
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000107 PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag));
108 PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag));
109 PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag));
110 PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag));
111 PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed));
112 PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed));
113 PyList_SetItem(v, 6, cc);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000114 if (PyErr_Occurred()){
115 Py_DECREF(v);
116 goto err;
117 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000118 return v;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000119 err:
120 Py_DECREF(cc);
121 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000122}
123
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000124PyDoc_STRVAR(termios_tcsetattr__doc__,
125"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000126\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000127Set the tty attributes for file descriptor fd.\n\
128The attributes to be set are taken from the attributes argument, which\n\
129is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000130determines when the attributes are changed: termios.TCSANOW to\n\
131change immediately, termios.TCSADRAIN to change after transmitting all\n\
132queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000133queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000134
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000135static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000136termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000137{
138 int fd, when;
139 struct termios mode;
140 speed_t ispeed, ospeed;
141 PyObject *term, *cc, *v;
142 int i;
143
Fred Drakeb638aaf2001-05-07 17:55:35 +0000144 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
145 fdconv, &fd, &when, &term))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000146 return NULL;
147 if (!PyList_Check(term) || PyList_Size(term) != 7) {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000148 PyErr_SetString(PyExc_TypeError,
149 "tcsetattr, arg 3: must be 7 element list");
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000150 return NULL;
151 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000152
Guido van Rossume7c41931998-06-12 14:26:18 +0000153 /* Get the old mode, in case there are any hidden fields... */
154 if (tcgetattr(fd, &mode) == -1)
155 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000156 mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0));
157 mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1));
158 mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));
159 mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3));
160 ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4));
161 ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5));
162 cc = PyList_GetItem(term, 6);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000163 if (PyErr_Occurred())
164 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000165
166 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000167 PyErr_Format(PyExc_TypeError,
168 "tcsetattr: attributes[6] must be %d element list",
169 NCCS);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000170 return NULL;
171 }
172
173 for (i = 0; i < NCCS; i++) {
174 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000175
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000176 if (PyString_Check(v) && PyString_Size(v) == 1)
177 mode.c_cc[i] = (cc_t) * PyString_AsString(v);
178 else if (PyInt_Check(v))
179 mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
180 else {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000181 PyErr_SetString(PyExc_TypeError,
182 "tcsetattr: elements of attributes must be characters or integers");
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000183 return NULL;
184 }
185 }
186
187 if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000188 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000189 if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000190 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000191 if (tcsetattr(fd, when, &mode) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000192 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000193
194 Py_INCREF(Py_None);
195 return Py_None;
196}
197
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000198PyDoc_STRVAR(termios_tcsendbreak__doc__,
199"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000200\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000201Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000202A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000203has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000204
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000205static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000206termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000207{
208 int fd, duration;
209
Fred Drakeb638aaf2001-05-07 17:55:35 +0000210 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
211 fdconv, &fd, &duration))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000212 return NULL;
213 if (tcsendbreak(fd, duration) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000214 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000215
216 Py_INCREF(Py_None);
217 return Py_None;
218}
219
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000220PyDoc_STRVAR(termios_tcdrain__doc__,
221"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000222\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000223Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000224
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000225static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000226termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000227{
228 int fd;
229
Fred Drakeb638aaf2001-05-07 17:55:35 +0000230 if (!PyArg_ParseTuple(args, "O&:tcdrain",
231 fdconv, &fd))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000232 return NULL;
233 if (tcdrain(fd) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000234 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000235
236 Py_INCREF(Py_None);
237 return Py_None;
238}
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{
251 int fd, queue;
252
Fred Drakeb638aaf2001-05-07 17:55:35 +0000253 if (!PyArg_ParseTuple(args, "O&i:tcflush",
254 fdconv, &fd, &queue))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000255 return NULL;
256 if (tcflush(fd, queue) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000257 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000258
259 Py_INCREF(Py_None);
260 return Py_None;
261}
262
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000263PyDoc_STRVAR(termios_tcflow__doc__,
264"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000265\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000266Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000267The action argument can be termios.TCOOFF to suspend output,\n\
268termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000269or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000270
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000271static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000272termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000273{
274 int fd, action;
275
Fred Drakeb638aaf2001-05-07 17:55:35 +0000276 if (!PyArg_ParseTuple(args, "O&i:tcflow",
277 fdconv, &fd, &action))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000278 return NULL;
279 if (tcflow(fd, action) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000280 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000281
282 Py_INCREF(Py_None);
283 return Py_None;
284}
285
286static PyMethodDef termios_methods[] =
287{
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000288 {"tcgetattr", termios_tcgetattr,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000289 METH_VARARGS, termios_tcgetattr__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000290 {"tcsetattr", termios_tcsetattr,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000291 METH_VARARGS, termios_tcsetattr__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000292 {"tcsendbreak", termios_tcsendbreak,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000293 METH_VARARGS, termios_tcsendbreak__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000294 {"tcdrain", termios_tcdrain,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000295 METH_VARARGS, termios_tcdrain__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000296 {"tcflush", termios_tcflush,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000297 METH_VARARGS, termios_tcflush__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000298 {"tcflow", termios_tcflow,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000299 METH_VARARGS, termios_tcflow__doc__},
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000300 {NULL, NULL}
301};
302
Fred Drakedf48d142001-02-27 21:22:39 +0000303
Fred Drake9ef7fa82001-03-01 21:54:49 +0000304#if defined(VSWTCH) && !defined(VSWTC)
305#define VSWTC VSWTCH
306#endif
307
308#if defined(VSWTC) && !defined(VSWTCH)
309#define VSWTCH VSWTC
310#endif
311
Fred Drakedf48d142001-02-27 21:22:39 +0000312static struct constant {
313 char *name;
314 long value;
315} termios_constants[] = {
316 /* cfgetospeed(), cfsetospeed() constants */
317 {"B0", B0},
318 {"B50", B50},
319 {"B75", B75},
320 {"B110", B110},
321 {"B134", B134},
322 {"B150", B150},
323 {"B200", B200},
324 {"B300", B300},
325 {"B600", B600},
326 {"B1200", B1200},
327 {"B1800", B1800},
328 {"B2400", B2400},
329 {"B4800", B4800},
330 {"B9600", B9600},
331 {"B19200", B19200},
332 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000333#ifdef B57600
Fred Drakedf48d142001-02-27 21:22:39 +0000334 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000335#endif
336#ifdef B115200
Fred Drakedf48d142001-02-27 21:22:39 +0000337 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000338#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000339#ifdef B230400
Fred Drakedf48d142001-02-27 21:22:39 +0000340 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000341#endif
Fred Drake9ef7fa82001-03-01 21:54:49 +0000342#ifdef CBAUDEX
Fred Drakedf48d142001-02-27 21:22:39 +0000343 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000344#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000345
346 /* tcsetattr() constants */
347 {"TCSANOW", TCSANOW},
348 {"TCSADRAIN", TCSADRAIN},
349 {"TCSAFLUSH", TCSAFLUSH},
350
351 /* tcflush() constants */
352 {"TCIFLUSH", TCIFLUSH},
353 {"TCOFLUSH", TCOFLUSH},
354 {"TCIOFLUSH", TCIOFLUSH},
355
356 /* tcflow() constants */
357 {"TCOOFF", TCOOFF},
358 {"TCOON", TCOON},
359 {"TCIOFF", TCIOFF},
360 {"TCION", TCION},
361
362 /* struct termios.c_iflag constants */
363 {"IGNBRK", IGNBRK},
364 {"BRKINT", BRKINT},
365 {"IGNPAR", IGNPAR},
366 {"PARMRK", PARMRK},
367 {"INPCK", INPCK},
368 {"ISTRIP", ISTRIP},
369 {"INLCR", INLCR},
370 {"IGNCR", IGNCR},
371 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000372#ifdef IUCLC
Fred Drakedf48d142001-02-27 21:22:39 +0000373 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000374#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000375 {"IXON", IXON},
376 {"IXANY", IXANY},
377 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000378#ifdef IMAXBEL
Fred Drakedf48d142001-02-27 21:22:39 +0000379 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000380#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000381
382 /* struct termios.c_oflag constants */
383 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000384#ifdef OLCUC
Fred Drakedf48d142001-02-27 21:22:39 +0000385 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000386#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000387#ifdef ONLCR
Fred Drakedf48d142001-02-27 21:22:39 +0000388 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000389#endif
Fred Draked85556c2001-03-03 18:08:52 +0000390#ifdef OCRNL
Fred Drakedf48d142001-02-27 21:22:39 +0000391 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000392#endif
393#ifdef ONOCR
Fred Drakedf48d142001-02-27 21:22:39 +0000394 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000395#endif
396#ifdef ONLRET
Fred Drakedf48d142001-02-27 21:22:39 +0000397 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000398#endif
399#ifdef OFILL
Fred Drakedf48d142001-02-27 21:22:39 +0000400 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000401#endif
402#ifdef OFDEL
Fred Drakedf48d142001-02-27 21:22:39 +0000403 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000404#endif
405#ifdef NLDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000406 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000407#endif
408#ifdef CRDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000409 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000410#endif
411#ifdef TABDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000412 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000413#endif
414#ifdef BSDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000415 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000416#endif
417#ifdef VTDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000418 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000419#endif
420#ifdef FFDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000421 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000422#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000423
424 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000425#ifdef NL0
Fred Drakedf48d142001-02-27 21:22:39 +0000426 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000427#endif
428#ifdef NL1
Fred Drakedf48d142001-02-27 21:22:39 +0000429 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000430#endif
431#ifdef CR0
Fred Drakedf48d142001-02-27 21:22:39 +0000432 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000433#endif
434#ifdef CR1
Fred Drakedf48d142001-02-27 21:22:39 +0000435 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000436#endif
437#ifdef CR2
Fred Drakedf48d142001-02-27 21:22:39 +0000438 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000439#endif
440#ifdef CR3
Fred Drakedf48d142001-02-27 21:22:39 +0000441 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000442#endif
443#ifdef TAB0
Fred Drakedf48d142001-02-27 21:22:39 +0000444 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000445#endif
446#ifdef TAB1
Fred Drakedf48d142001-02-27 21:22:39 +0000447 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000448#endif
449#ifdef TAB2
Fred Drakedf48d142001-02-27 21:22:39 +0000450 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000451#endif
452#ifdef TAB3
Fred Drakedf48d142001-02-27 21:22:39 +0000453 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000454#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000455#ifdef XTABS
Fred Drakedf48d142001-02-27 21:22:39 +0000456 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000457#endif
Fred Draked85556c2001-03-03 18:08:52 +0000458#ifdef BS0
Fred Drakedf48d142001-02-27 21:22:39 +0000459 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000460#endif
461#ifdef BS1
Fred Drakedf48d142001-02-27 21:22:39 +0000462 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000463#endif
464#ifdef VT0
Fred Drakedf48d142001-02-27 21:22:39 +0000465 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000466#endif
467#ifdef VT1
Fred Drakedf48d142001-02-27 21:22:39 +0000468 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000469#endif
470#ifdef FF0
Fred Drakedf48d142001-02-27 21:22:39 +0000471 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000472#endif
473#ifdef FF1
Fred Drakedf48d142001-02-27 21:22:39 +0000474 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000475#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000476
477 /* struct termios.c_cflag constants */
478 {"CSIZE", CSIZE},
479 {"CSTOPB", CSTOPB},
480 {"CREAD", CREAD},
481 {"PARENB", PARENB},
482 {"PARODD", PARODD},
483 {"HUPCL", HUPCL},
484 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000485#ifdef CIBAUD
Fred Drakedf48d142001-02-27 21:22:39 +0000486 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000487#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000488#ifdef CRTSCTS
489 {"CRTSCTS", (long)CRTSCTS},
490#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000491
492 /* struct termios.c_cflag-related values (character size) */
493 {"CS5", CS5},
494 {"CS6", CS6},
495 {"CS7", CS7},
496 {"CS8", CS8},
497
498 /* struct termios.c_lflag constants */
499 {"ISIG", ISIG},
500 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000501#ifdef XCASE
Fred Drakedf48d142001-02-27 21:22:39 +0000502 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000503#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000504 {"ECHO", ECHO},
505 {"ECHOE", ECHOE},
506 {"ECHOK", ECHOK},
507 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000508#ifdef ECHOCTL
Fred Drakedf48d142001-02-27 21:22:39 +0000509 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000510#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000511#ifdef ECHOPRT
Fred Drakedf48d142001-02-27 21:22:39 +0000512 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000513#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000514#ifdef ECHOKE
Fred Drakedf48d142001-02-27 21:22:39 +0000515 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000516#endif
517#ifdef FLUSHO
Fred Drakedf48d142001-02-27 21:22:39 +0000518 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000519#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000520 {"NOFLSH", NOFLSH},
521 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000522#ifdef PENDIN
Fred Drakedf48d142001-02-27 21:22:39 +0000523 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000524#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000525 {"IEXTEN", IEXTEN},
526
527 /* indexes into the control chars array returned by tcgetattr() */
528 {"VINTR", VINTR},
529 {"VQUIT", VQUIT},
530 {"VERASE", VERASE},
531 {"VKILL", VKILL},
532 {"VEOF", VEOF},
533 {"VTIME", VTIME},
534 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000535#ifdef VSWTC
536 /* The #defines above ensure that if either is defined, both are,
537 * but both may be omitted by the system headers. ;-( */
Fred Drakedf48d142001-02-27 21:22:39 +0000538 {"VSWTC", VSWTC},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000539 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000540#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000541 {"VSTART", VSTART},
542 {"VSTOP", VSTOP},
543 {"VSUSP", VSUSP},
544 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000545#ifdef VREPRINT
Fred Drakedf48d142001-02-27 21:22:39 +0000546 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000547#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000548#ifdef VDISCARD
Fred Drakedf48d142001-02-27 21:22:39 +0000549 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000550#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000551#ifdef VWERASE
Fred Drakedf48d142001-02-27 21:22:39 +0000552 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000553#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000554#ifdef VLNEXT
Fred Drakedf48d142001-02-27 21:22:39 +0000555 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000556#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000557#ifdef VEOL2
Fred Drakedf48d142001-02-27 21:22:39 +0000558 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000559#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000560
Fred Drake55a00342001-03-26 17:14:02 +0000561
562#ifdef B460800
563 {"B460800", B460800},
564#endif
565#ifdef CBAUD
566 {"CBAUD", CBAUD},
567#endif
568#ifdef CDEL
569 {"CDEL", CDEL},
570#endif
571#ifdef CDSUSP
572 {"CDSUSP", CDSUSP},
573#endif
574#ifdef CEOF
575 {"CEOF", CEOF},
576#endif
577#ifdef CEOL
578 {"CEOL", CEOL},
579#endif
580#ifdef CEOL2
581 {"CEOL2", CEOL2},
582#endif
583#ifdef CEOT
584 {"CEOT", CEOT},
585#endif
586#ifdef CERASE
587 {"CERASE", CERASE},
588#endif
589#ifdef CESC
590 {"CESC", CESC},
591#endif
592#ifdef CFLUSH
593 {"CFLUSH", CFLUSH},
594#endif
595#ifdef CINTR
596 {"CINTR", CINTR},
597#endif
598#ifdef CKILL
599 {"CKILL", CKILL},
600#endif
601#ifdef CLNEXT
602 {"CLNEXT", CLNEXT},
603#endif
604#ifdef CNUL
605 {"CNUL", CNUL},
606#endif
607#ifdef COMMON
608 {"COMMON", COMMON},
609#endif
610#ifdef CQUIT
611 {"CQUIT", CQUIT},
612#endif
613#ifdef CRPRNT
614 {"CRPRNT", CRPRNT},
615#endif
616#ifdef CSTART
617 {"CSTART", CSTART},
618#endif
619#ifdef CSTOP
620 {"CSTOP", CSTOP},
621#endif
622#ifdef CSUSP
623 {"CSUSP", CSUSP},
624#endif
625#ifdef CSWTCH
626 {"CSWTCH", CSWTCH},
627#endif
628#ifdef CWERASE
629 {"CWERASE", CWERASE},
630#endif
631#ifdef EXTA
632 {"EXTA", EXTA},
633#endif
634#ifdef EXTB
635 {"EXTB", EXTB},
636#endif
637#ifdef FIOASYNC
638 {"FIOASYNC", FIOASYNC},
639#endif
640#ifdef FIOCLEX
641 {"FIOCLEX", FIOCLEX},
642#endif
643#ifdef FIONBIO
644 {"FIONBIO", FIONBIO},
645#endif
646#ifdef FIONCLEX
647 {"FIONCLEX", FIONCLEX},
648#endif
649#ifdef FIONREAD
650 {"FIONREAD", FIONREAD},
651#endif
652#ifdef IBSHIFT
653 {"IBSHIFT", IBSHIFT},
654#endif
655#ifdef INIT_C_CC
656 {"INIT_C_CC", INIT_C_CC},
657#endif
658#ifdef IOCSIZE_MASK
659 {"IOCSIZE_MASK", IOCSIZE_MASK},
660#endif
661#ifdef IOCSIZE_SHIFT
662 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
663#endif
664#ifdef NCC
665 {"NCC", NCC},
666#endif
667#ifdef NCCS
668 {"NCCS", NCCS},
669#endif
670#ifdef NSWTCH
671 {"NSWTCH", NSWTCH},
672#endif
673#ifdef N_MOUSE
674 {"N_MOUSE", N_MOUSE},
675#endif
676#ifdef N_PPP
677 {"N_PPP", N_PPP},
678#endif
679#ifdef N_SLIP
680 {"N_SLIP", N_SLIP},
681#endif
682#ifdef N_STRIP
683 {"N_STRIP", N_STRIP},
684#endif
685#ifdef N_TTY
686 {"N_TTY", N_TTY},
687#endif
688#ifdef TCFLSH
689 {"TCFLSH", TCFLSH},
690#endif
691#ifdef TCGETA
692 {"TCGETA", TCGETA},
693#endif
694#ifdef TCGETS
695 {"TCGETS", TCGETS},
696#endif
697#ifdef TCSBRK
698 {"TCSBRK", TCSBRK},
699#endif
700#ifdef TCSBRKP
701 {"TCSBRKP", TCSBRKP},
702#endif
703#ifdef TCSETA
704 {"TCSETA", TCSETA},
705#endif
706#ifdef TCSETAF
707 {"TCSETAF", TCSETAF},
708#endif
709#ifdef TCSETAW
710 {"TCSETAW", TCSETAW},
711#endif
712#ifdef TCSETS
713 {"TCSETS", TCSETS},
714#endif
715#ifdef TCSETSF
716 {"TCSETSF", TCSETSF},
717#endif
718#ifdef TCSETSW
719 {"TCSETSW", TCSETSW},
720#endif
721#ifdef TCXONC
722 {"TCXONC", TCXONC},
723#endif
724#ifdef TIOCCONS
725 {"TIOCCONS", TIOCCONS},
726#endif
727#ifdef TIOCEXCL
728 {"TIOCEXCL", TIOCEXCL},
729#endif
730#ifdef TIOCGETD
731 {"TIOCGETD", TIOCGETD},
732#endif
733#ifdef TIOCGICOUNT
734 {"TIOCGICOUNT", TIOCGICOUNT},
735#endif
736#ifdef TIOCGLCKTRMIOS
737 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
738#endif
739#ifdef TIOCGPGRP
740 {"TIOCGPGRP", TIOCGPGRP},
741#endif
742#ifdef TIOCGSERIAL
743 {"TIOCGSERIAL", TIOCGSERIAL},
744#endif
745#ifdef TIOCGSOFTCAR
746 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
747#endif
748#ifdef TIOCGWINSZ
749 {"TIOCGWINSZ", TIOCGWINSZ},
750#endif
751#ifdef TIOCINQ
752 {"TIOCINQ", TIOCINQ},
753#endif
754#ifdef TIOCLINUX
755 {"TIOCLINUX", TIOCLINUX},
756#endif
757#ifdef TIOCMBIC
758 {"TIOCMBIC", TIOCMBIC},
759#endif
760#ifdef TIOCMBIS
761 {"TIOCMBIS", TIOCMBIS},
762#endif
763#ifdef TIOCMGET
764 {"TIOCMGET", TIOCMGET},
765#endif
766#ifdef TIOCMIWAIT
767 {"TIOCMIWAIT", TIOCMIWAIT},
768#endif
769#ifdef TIOCMSET
770 {"TIOCMSET", TIOCMSET},
771#endif
772#ifdef TIOCM_CAR
773 {"TIOCM_CAR", TIOCM_CAR},
774#endif
775#ifdef TIOCM_CD
776 {"TIOCM_CD", TIOCM_CD},
777#endif
778#ifdef TIOCM_CTS
779 {"TIOCM_CTS", TIOCM_CTS},
780#endif
781#ifdef TIOCM_DSR
782 {"TIOCM_DSR", TIOCM_DSR},
783#endif
784#ifdef TIOCM_DTR
785 {"TIOCM_DTR", TIOCM_DTR},
786#endif
787#ifdef TIOCM_LE
788 {"TIOCM_LE", TIOCM_LE},
789#endif
790#ifdef TIOCM_RI
791 {"TIOCM_RI", TIOCM_RI},
792#endif
793#ifdef TIOCM_RNG
794 {"TIOCM_RNG", TIOCM_RNG},
795#endif
796#ifdef TIOCM_RTS
797 {"TIOCM_RTS", TIOCM_RTS},
798#endif
799#ifdef TIOCM_SR
800 {"TIOCM_SR", TIOCM_SR},
801#endif
802#ifdef TIOCM_ST
803 {"TIOCM_ST", TIOCM_ST},
804#endif
805#ifdef TIOCNOTTY
806 {"TIOCNOTTY", TIOCNOTTY},
807#endif
808#ifdef TIOCNXCL
809 {"TIOCNXCL", TIOCNXCL},
810#endif
811#ifdef TIOCOUTQ
812 {"TIOCOUTQ", TIOCOUTQ},
813#endif
814#ifdef TIOCPKT
815 {"TIOCPKT", TIOCPKT},
816#endif
817#ifdef TIOCPKT_DATA
818 {"TIOCPKT_DATA", TIOCPKT_DATA},
819#endif
820#ifdef TIOCPKT_DOSTOP
821 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
822#endif
823#ifdef TIOCPKT_FLUSHREAD
824 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
825#endif
826#ifdef TIOCPKT_FLUSHWRITE
827 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
828#endif
829#ifdef TIOCPKT_NOSTOP
830 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
831#endif
832#ifdef TIOCPKT_START
833 {"TIOCPKT_START", TIOCPKT_START},
834#endif
835#ifdef TIOCPKT_STOP
836 {"TIOCPKT_STOP", TIOCPKT_STOP},
837#endif
838#ifdef TIOCSCTTY
839 {"TIOCSCTTY", TIOCSCTTY},
840#endif
841#ifdef TIOCSERCONFIG
842 {"TIOCSERCONFIG", TIOCSERCONFIG},
843#endif
844#ifdef TIOCSERGETLSR
845 {"TIOCSERGETLSR", TIOCSERGETLSR},
846#endif
847#ifdef TIOCSERGETMULTI
848 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
849#endif
850#ifdef TIOCSERGSTRUCT
851 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
852#endif
853#ifdef TIOCSERGWILD
854 {"TIOCSERGWILD", TIOCSERGWILD},
855#endif
856#ifdef TIOCSERSETMULTI
857 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
858#endif
859#ifdef TIOCSERSWILD
860 {"TIOCSERSWILD", TIOCSERSWILD},
861#endif
862#ifdef TIOCSER_TEMT
863 {"TIOCSER_TEMT", TIOCSER_TEMT},
864#endif
865#ifdef TIOCSETD
866 {"TIOCSETD", TIOCSETD},
867#endif
868#ifdef TIOCSLCKTRMIOS
869 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
870#endif
871#ifdef TIOCSPGRP
872 {"TIOCSPGRP", TIOCSPGRP},
873#endif
874#ifdef TIOCSSERIAL
875 {"TIOCSSERIAL", TIOCSSERIAL},
876#endif
877#ifdef TIOCSSOFTCAR
878 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
879#endif
880#ifdef TIOCSTI
881 {"TIOCSTI", TIOCSTI},
882#endif
883#ifdef TIOCSWINSZ
884 {"TIOCSWINSZ", TIOCSWINSZ},
885#endif
886#ifdef TIOCTTYGSTRUCT
887 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
888#endif
889
Fred Drakedf48d142001-02-27 21:22:39 +0000890 /* sentinel */
891 {NULL, 0}
892};
893
894
Guido van Rossum3886bb61998-12-04 18:50:17 +0000895DL_EXPORT(void)
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000896PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000897{
Fred Drake78f6c862002-02-14 07:11:23 +0000898 PyObject *m;
Fred Drakedf48d142001-02-27 21:22:39 +0000899 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000900
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000901 m = Py_InitModule4("termios", termios_methods, termios__doc__,
902 (PyObject *)NULL, PYTHON_API_VERSION);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000903
Fred Drake78f6c862002-02-14 07:11:23 +0000904 if (TermiosError == NULL) {
905 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
906 }
907 Py_INCREF(TermiosError);
908 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000909
910 while (constant->name != NULL) {
911 PyModule_AddIntConstant(m, constant->name, constant->value);
912 ++constant;
913 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000914}