blob: 7e4eb7ba8d0dc810753b01d6c40e3fdd5a40de9a [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
Neal Norwitz82251032003-05-23 14:35:24 +000022/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
23#ifdef HAVE_SYS_BSDTTY_H
24#include <sys/bsdtty.h>
25#endif
Fred Drake87068f12001-05-11 16:14:17 +000026
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000027PyDoc_STRVAR(termios__doc__,
28"This module provides an interface to the Posix calls for tty I/O control.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000029For a complete description of these calls, see the Posix or Unix manual\n\
30pages. It is only available for those Unix versions that support Posix\n\
31termios style tty I/O control.\n\
32\n\
33All functions in this module take a file descriptor fd as their first\n\
34argument. This can be an integer file descriptor, such as returned by\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000035sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
Guido van Rossum9adae8e1994-09-12 10:41:22 +000036
37static PyObject *TermiosError;
38
Fred Drakeb638aaf2001-05-07 17:55:35 +000039static int fdconv(PyObject* obj, void* p)
40{
41 int fd;
42
43 fd = PyObject_AsFileDescriptor(obj);
Fred Drakec99ff602001-05-09 20:14:09 +000044 if (fd >= 0) {
45 *(int*)p = fd;
46 return 1;
Fred Drakeb638aaf2001-05-07 17:55:35 +000047 }
Fred Drakec99ff602001-05-09 20:14:09 +000048 return 0;
Fred Drakeb638aaf2001-05-07 17:55:35 +000049}
Guido van Rossum9adae8e1994-09-12 10:41:22 +000050
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000051PyDoc_STRVAR(termios_tcgetattr__doc__,
52"tcgetattr(fd) -> list_of_attrs\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +000053\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +000054Get the tty attributes for file descriptor fd, as follows:\n\
55[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
56of the tty special characters (each a string of length 1, except the items\n\
57with indices VMIN and VTIME, which are integers when these fields are\n\
58defined). The interpretation of the flags and the speeds as well as the\n\
59indexing in the cc array must be done using the symbolic constants defined\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +000060in this module.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +000061
Guido van Rossum9adae8e1994-09-12 10:41:22 +000062static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +000063termios_tcgetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +000064{
65 int fd;
66 struct termios mode;
67 PyObject *cc;
68 speed_t ispeed, ospeed;
69 PyObject *v;
70 int i;
71 char ch;
72
Fred Drakeb638aaf2001-05-07 17:55:35 +000073 if (!PyArg_ParseTuple(args, "O&:tcgetattr",
74 fdconv, (void*)&fd))
Guido van Rossum9adae8e1994-09-12 10:41:22 +000075 return NULL;
76
77 if (tcgetattr(fd, &mode) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +000078 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +000079
80 ispeed = cfgetispeed(&mode);
81 ospeed = cfgetospeed(&mode);
82
83 cc = PyList_New(NCCS);
84 if (cc == NULL)
85 return NULL;
86 for (i = 0; i < NCCS; i++) {
87 ch = (char)mode.c_cc[i];
88 v = PyString_FromStringAndSize(&ch, 1);
89 if (v == NULL)
Barry Warsaw5709dcf1997-01-10 18:42:18 +000090 goto err;
Guido van Rossum9adae8e1994-09-12 10:41:22 +000091 PyList_SetItem(cc, i, v);
92 }
93
94 /* Convert the MIN and TIME slots to integer. On some systems, the
95 MIN and TIME slots are the same as the EOF and EOL slots. So we
96 only do this in noncanonical input mode. */
Guido van Rossum36dd0d21996-12-10 15:23:00 +000097 if ((mode.c_lflag & ICANON) == 0) {
Guido van Rossum9adae8e1994-09-12 10:41:22 +000098 v = PyInt_FromLong((long)mode.c_cc[VMIN]);
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, VMIN, v);
102 v = PyInt_FromLong((long)mode.c_cc[VTIME]);
103 if (v == NULL)
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000104 goto err;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000105 PyList_SetItem(cc, VTIME, v);
106 }
107
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000108 if (!(v = PyList_New(7)))
109 goto err;
110
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000111 PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag));
112 PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag));
113 PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag));
114 PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag));
115 PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed));
116 PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed));
117 PyList_SetItem(v, 6, cc);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000118 if (PyErr_Occurred()){
119 Py_DECREF(v);
120 goto err;
121 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000122 return v;
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000123 err:
124 Py_DECREF(cc);
125 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000126}
127
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000128PyDoc_STRVAR(termios_tcsetattr__doc__,
129"tcsetattr(fd, when, attributes) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000130\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000131Set the tty attributes for file descriptor fd.\n\
132The attributes to be set are taken from the attributes argument, which\n\
133is a list like the one returned by tcgetattr(). The when argument\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000134determines when the attributes are changed: termios.TCSANOW to\n\
135change immediately, termios.TCSADRAIN to change after transmitting all\n\
136queued output, or termios.TCSAFLUSH to change after transmitting all\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000137queued output and discarding all queued input. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000138
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000139static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000140termios_tcsetattr(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000141{
142 int fd, when;
143 struct termios mode;
144 speed_t ispeed, ospeed;
145 PyObject *term, *cc, *v;
146 int i;
147
Fred Drakeb638aaf2001-05-07 17:55:35 +0000148 if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
149 fdconv, &fd, &when, &term))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000150 return NULL;
151 if (!PyList_Check(term) || PyList_Size(term) != 7) {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000152 PyErr_SetString(PyExc_TypeError,
153 "tcsetattr, arg 3: must be 7 element list");
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000154 return NULL;
155 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000156
Guido van Rossume7c41931998-06-12 14:26:18 +0000157 /* Get the old mode, in case there are any hidden fields... */
158 if (tcgetattr(fd, &mode) == -1)
159 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000160 mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0));
161 mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1));
162 mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2));
163 mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3));
164 ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4));
165 ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5));
166 cc = PyList_GetItem(term, 6);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000167 if (PyErr_Occurred())
168 return NULL;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000169
170 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000171 PyErr_Format(PyExc_TypeError,
172 "tcsetattr: attributes[6] must be %d element list",
173 NCCS);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000174 return NULL;
175 }
176
177 for (i = 0; i < NCCS; i++) {
178 v = PyList_GetItem(cc, i);
Barry Warsaw5709dcf1997-01-10 18:42:18 +0000179
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000180 if (PyString_Check(v) && PyString_Size(v) == 1)
181 mode.c_cc[i] = (cc_t) * PyString_AsString(v);
182 else if (PyInt_Check(v))
183 mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
184 else {
Fred Drakeb638aaf2001-05-07 17:55:35 +0000185 PyErr_SetString(PyExc_TypeError,
186 "tcsetattr: elements of attributes must be characters or integers");
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000187 return NULL;
188 }
189 }
190
191 if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000192 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000193 if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000194 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000195 if (tcsetattr(fd, when, &mode) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000196 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000197
198 Py_INCREF(Py_None);
199 return Py_None;
200}
201
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000202PyDoc_STRVAR(termios_tcsendbreak__doc__,
203"tcsendbreak(fd, duration) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000204\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000205Send a break on file descriptor fd.\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000206A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000207has a system dependent meaning.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000208
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000209static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000210termios_tcsendbreak(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000211{
212 int fd, duration;
213
Fred Drakeb638aaf2001-05-07 17:55:35 +0000214 if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
215 fdconv, &fd, &duration))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000216 return NULL;
217 if (tcsendbreak(fd, duration) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000218 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000219
220 Py_INCREF(Py_None);
221 return Py_None;
222}
223
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000224PyDoc_STRVAR(termios_tcdrain__doc__,
225"tcdrain(fd) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000226\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000227Wait until all output written to file descriptor fd has been transmitted.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000228
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000229static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000230termios_tcdrain(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000231{
232 int fd;
233
Fred Drakeb638aaf2001-05-07 17:55:35 +0000234 if (!PyArg_ParseTuple(args, "O&:tcdrain",
235 fdconv, &fd))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000236 return NULL;
237 if (tcdrain(fd) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000238 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000239
240 Py_INCREF(Py_None);
241 return Py_None;
242}
243
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000244PyDoc_STRVAR(termios_tcflush__doc__,
245"tcflush(fd, queue) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000246\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000247Discard queued data on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000248The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
249queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000250both queues. ");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000251
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000252static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000253termios_tcflush(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000254{
255 int fd, queue;
256
Fred Drakeb638aaf2001-05-07 17:55:35 +0000257 if (!PyArg_ParseTuple(args, "O&i:tcflush",
258 fdconv, &fd, &queue))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000259 return NULL;
260 if (tcflush(fd, queue) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000261 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000262
263 Py_INCREF(Py_None);
264 return Py_None;
265}
266
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000267PyDoc_STRVAR(termios_tcflow__doc__,
268"tcflow(fd, action) -> None\n\
Fred Drakeb638aaf2001-05-07 17:55:35 +0000269\n\
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000270Suspend or resume input or output on file descriptor fd.\n\
Fred Drake29fd0312001-04-09 19:32:52 +0000271The action argument can be termios.TCOOFF to suspend output,\n\
272termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
Martin v. Löwis14f8b4c2002-06-13 20:33:02 +0000273or termios.TCION to restart input.");
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000274
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000275static PyObject *
Peter Schneider-Kamp416d4132000-07-10 12:15:54 +0000276termios_tcflow(PyObject *self, PyObject *args)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000277{
278 int fd, action;
279
Fred Drakeb638aaf2001-05-07 17:55:35 +0000280 if (!PyArg_ParseTuple(args, "O&i:tcflow",
281 fdconv, &fd, &action))
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000282 return NULL;
283 if (tcflow(fd, action) == -1)
Guido van Rossumb8ad0241997-07-17 22:55:06 +0000284 return PyErr_SetFromErrno(TermiosError);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000285
286 Py_INCREF(Py_None);
287 return Py_None;
288}
289
290static PyMethodDef termios_methods[] =
291{
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000292 {"tcgetattr", termios_tcgetattr,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000293 METH_VARARGS, termios_tcgetattr__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000294 {"tcsetattr", termios_tcsetattr,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000295 METH_VARARGS, termios_tcsetattr__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000296 {"tcsendbreak", termios_tcsendbreak,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000297 METH_VARARGS, termios_tcsendbreak__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000298 {"tcdrain", termios_tcdrain,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000299 METH_VARARGS, termios_tcdrain__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000300 {"tcflush", termios_tcflush,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000301 METH_VARARGS, termios_tcflush__doc__},
Andrew M. Kuchlinga1abb722000-08-03 02:34:44 +0000302 {"tcflow", termios_tcflow,
Fred Drakeb638aaf2001-05-07 17:55:35 +0000303 METH_VARARGS, termios_tcflow__doc__},
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000304 {NULL, NULL}
305};
306
Fred Drakedf48d142001-02-27 21:22:39 +0000307
Fred Drake9ef7fa82001-03-01 21:54:49 +0000308#if defined(VSWTCH) && !defined(VSWTC)
309#define VSWTC VSWTCH
310#endif
311
312#if defined(VSWTC) && !defined(VSWTCH)
313#define VSWTCH VSWTC
314#endif
315
Fred Drakedf48d142001-02-27 21:22:39 +0000316static struct constant {
317 char *name;
318 long value;
319} termios_constants[] = {
320 /* cfgetospeed(), cfsetospeed() constants */
321 {"B0", B0},
322 {"B50", B50},
323 {"B75", B75},
324 {"B110", B110},
325 {"B134", B134},
326 {"B150", B150},
327 {"B200", B200},
328 {"B300", B300},
329 {"B600", B600},
330 {"B1200", B1200},
331 {"B1800", B1800},
332 {"B2400", B2400},
333 {"B4800", B4800},
334 {"B9600", B9600},
335 {"B19200", B19200},
336 {"B38400", B38400},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000337#ifdef B57600
Fred Drakedf48d142001-02-27 21:22:39 +0000338 {"B57600", B57600},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000339#endif
340#ifdef B115200
Fred Drakedf48d142001-02-27 21:22:39 +0000341 {"B115200", B115200},
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000342#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000343#ifdef B230400
Fred Drakedf48d142001-02-27 21:22:39 +0000344 {"B230400", B230400},
Fred Drakeabb379e2001-03-01 03:28:08 +0000345#endif
Fred Drake9ef7fa82001-03-01 21:54:49 +0000346#ifdef CBAUDEX
Fred Drakedf48d142001-02-27 21:22:39 +0000347 {"CBAUDEX", CBAUDEX},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000348#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000349
350 /* tcsetattr() constants */
351 {"TCSANOW", TCSANOW},
352 {"TCSADRAIN", TCSADRAIN},
353 {"TCSAFLUSH", TCSAFLUSH},
354
355 /* tcflush() constants */
356 {"TCIFLUSH", TCIFLUSH},
357 {"TCOFLUSH", TCOFLUSH},
358 {"TCIOFLUSH", TCIOFLUSH},
359
360 /* tcflow() constants */
361 {"TCOOFF", TCOOFF},
362 {"TCOON", TCOON},
363 {"TCIOFF", TCIOFF},
364 {"TCION", TCION},
365
366 /* struct termios.c_iflag constants */
367 {"IGNBRK", IGNBRK},
368 {"BRKINT", BRKINT},
369 {"IGNPAR", IGNPAR},
370 {"PARMRK", PARMRK},
371 {"INPCK", INPCK},
372 {"ISTRIP", ISTRIP},
373 {"INLCR", INLCR},
374 {"IGNCR", IGNCR},
375 {"ICRNL", ICRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000376#ifdef IUCLC
Fred Drakedf48d142001-02-27 21:22:39 +0000377 {"IUCLC", IUCLC},
Fred Draked85556c2001-03-03 18:08:52 +0000378#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000379 {"IXON", IXON},
380 {"IXANY", IXANY},
381 {"IXOFF", IXOFF},
Thomas Wouters2b305242001-06-15 12:05:44 +0000382#ifdef IMAXBEL
Fred Drakedf48d142001-02-27 21:22:39 +0000383 {"IMAXBEL", IMAXBEL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000384#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000385
386 /* struct termios.c_oflag constants */
387 {"OPOST", OPOST},
Fred Draked85556c2001-03-03 18:08:52 +0000388#ifdef OLCUC
Fred Drakedf48d142001-02-27 21:22:39 +0000389 {"OLCUC", OLCUC},
Fred Draked85556c2001-03-03 18:08:52 +0000390#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000391#ifdef ONLCR
Fred Drakedf48d142001-02-27 21:22:39 +0000392 {"ONLCR", ONLCR},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000393#endif
Fred Draked85556c2001-03-03 18:08:52 +0000394#ifdef OCRNL
Fred Drakedf48d142001-02-27 21:22:39 +0000395 {"OCRNL", OCRNL},
Fred Draked85556c2001-03-03 18:08:52 +0000396#endif
397#ifdef ONOCR
Fred Drakedf48d142001-02-27 21:22:39 +0000398 {"ONOCR", ONOCR},
Fred Draked85556c2001-03-03 18:08:52 +0000399#endif
400#ifdef ONLRET
Fred Drakedf48d142001-02-27 21:22:39 +0000401 {"ONLRET", ONLRET},
Fred Draked85556c2001-03-03 18:08:52 +0000402#endif
403#ifdef OFILL
Fred Drakedf48d142001-02-27 21:22:39 +0000404 {"OFILL", OFILL},
Fred Draked85556c2001-03-03 18:08:52 +0000405#endif
406#ifdef OFDEL
Fred Drakedf48d142001-02-27 21:22:39 +0000407 {"OFDEL", OFDEL},
Fred Draked85556c2001-03-03 18:08:52 +0000408#endif
409#ifdef NLDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000410 {"NLDLY", NLDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000411#endif
412#ifdef CRDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000413 {"CRDLY", CRDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000414#endif
415#ifdef TABDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000416 {"TABDLY", TABDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000417#endif
418#ifdef BSDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000419 {"BSDLY", BSDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000420#endif
421#ifdef VTDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000422 {"VTDLY", VTDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000423#endif
424#ifdef FFDLY
Fred Drakedf48d142001-02-27 21:22:39 +0000425 {"FFDLY", FFDLY},
Fred Draked85556c2001-03-03 18:08:52 +0000426#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000427
428 /* struct termios.c_oflag-related values (delay mask) */
Fred Draked85556c2001-03-03 18:08:52 +0000429#ifdef NL0
Fred Drakedf48d142001-02-27 21:22:39 +0000430 {"NL0", NL0},
Fred Draked85556c2001-03-03 18:08:52 +0000431#endif
432#ifdef NL1
Fred Drakedf48d142001-02-27 21:22:39 +0000433 {"NL1", NL1},
Fred Draked85556c2001-03-03 18:08:52 +0000434#endif
435#ifdef CR0
Fred Drakedf48d142001-02-27 21:22:39 +0000436 {"CR0", CR0},
Fred Draked85556c2001-03-03 18:08:52 +0000437#endif
438#ifdef CR1
Fred Drakedf48d142001-02-27 21:22:39 +0000439 {"CR1", CR1},
Fred Draked85556c2001-03-03 18:08:52 +0000440#endif
441#ifdef CR2
Fred Drakedf48d142001-02-27 21:22:39 +0000442 {"CR2", CR2},
Fred Draked85556c2001-03-03 18:08:52 +0000443#endif
444#ifdef CR3
Fred Drakedf48d142001-02-27 21:22:39 +0000445 {"CR3", CR3},
Fred Draked85556c2001-03-03 18:08:52 +0000446#endif
447#ifdef TAB0
Fred Drakedf48d142001-02-27 21:22:39 +0000448 {"TAB0", TAB0},
Fred Draked85556c2001-03-03 18:08:52 +0000449#endif
450#ifdef TAB1
Fred Drakedf48d142001-02-27 21:22:39 +0000451 {"TAB1", TAB1},
Fred Draked85556c2001-03-03 18:08:52 +0000452#endif
453#ifdef TAB2
Fred Drakedf48d142001-02-27 21:22:39 +0000454 {"TAB2", TAB2},
Fred Draked85556c2001-03-03 18:08:52 +0000455#endif
456#ifdef TAB3
Fred Drakedf48d142001-02-27 21:22:39 +0000457 {"TAB3", TAB3},
Fred Draked85556c2001-03-03 18:08:52 +0000458#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000459#ifdef XTABS
Fred Drakedf48d142001-02-27 21:22:39 +0000460 {"XTABS", XTABS},
Fred Drakededbebf2001-03-02 06:50:58 +0000461#endif
Fred Draked85556c2001-03-03 18:08:52 +0000462#ifdef BS0
Fred Drakedf48d142001-02-27 21:22:39 +0000463 {"BS0", BS0},
Fred Draked85556c2001-03-03 18:08:52 +0000464#endif
465#ifdef BS1
Fred Drakedf48d142001-02-27 21:22:39 +0000466 {"BS1", BS1},
Fred Draked85556c2001-03-03 18:08:52 +0000467#endif
468#ifdef VT0
Fred Drakedf48d142001-02-27 21:22:39 +0000469 {"VT0", VT0},
Fred Draked85556c2001-03-03 18:08:52 +0000470#endif
471#ifdef VT1
Fred Drakedf48d142001-02-27 21:22:39 +0000472 {"VT1", VT1},
Fred Draked85556c2001-03-03 18:08:52 +0000473#endif
474#ifdef FF0
Fred Drakedf48d142001-02-27 21:22:39 +0000475 {"FF0", FF0},
Fred Draked85556c2001-03-03 18:08:52 +0000476#endif
477#ifdef FF1
Fred Drakedf48d142001-02-27 21:22:39 +0000478 {"FF1", FF1},
Fred Draked85556c2001-03-03 18:08:52 +0000479#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000480
481 /* struct termios.c_cflag constants */
482 {"CSIZE", CSIZE},
483 {"CSTOPB", CSTOPB},
484 {"CREAD", CREAD},
485 {"PARENB", PARENB},
486 {"PARODD", PARODD},
487 {"HUPCL", HUPCL},
488 {"CLOCAL", CLOCAL},
Fred Drakeabb379e2001-03-01 03:28:08 +0000489#ifdef CIBAUD
Fred Drakedf48d142001-02-27 21:22:39 +0000490 {"CIBAUD", CIBAUD},
Fred Drakeabb379e2001-03-01 03:28:08 +0000491#endif
Fred Drakededbebf2001-03-02 06:50:58 +0000492#ifdef CRTSCTS
493 {"CRTSCTS", (long)CRTSCTS},
494#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000495
496 /* struct termios.c_cflag-related values (character size) */
497 {"CS5", CS5},
498 {"CS6", CS6},
499 {"CS7", CS7},
500 {"CS8", CS8},
501
502 /* struct termios.c_lflag constants */
503 {"ISIG", ISIG},
504 {"ICANON", ICANON},
Fred Drakeabb379e2001-03-01 03:28:08 +0000505#ifdef XCASE
Fred Drakedf48d142001-02-27 21:22:39 +0000506 {"XCASE", XCASE},
Fred Drakeabb379e2001-03-01 03:28:08 +0000507#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000508 {"ECHO", ECHO},
509 {"ECHOE", ECHOE},
510 {"ECHOK", ECHOK},
511 {"ECHONL", ECHONL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000512#ifdef ECHOCTL
Fred Drakedf48d142001-02-27 21:22:39 +0000513 {"ECHOCTL", ECHOCTL},
Thomas Wouters2b305242001-06-15 12:05:44 +0000514#endif
Fred Drakeabb379e2001-03-01 03:28:08 +0000515#ifdef ECHOPRT
Fred Drakedf48d142001-02-27 21:22:39 +0000516 {"ECHOPRT", ECHOPRT},
Fred Drakeabb379e2001-03-01 03:28:08 +0000517#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000518#ifdef ECHOKE
Fred Drakedf48d142001-02-27 21:22:39 +0000519 {"ECHOKE", ECHOKE},
Thomas Wouters2b305242001-06-15 12:05:44 +0000520#endif
521#ifdef FLUSHO
Fred Drakedf48d142001-02-27 21:22:39 +0000522 {"FLUSHO", FLUSHO},
Thomas Wouters2b305242001-06-15 12:05:44 +0000523#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000524 {"NOFLSH", NOFLSH},
525 {"TOSTOP", TOSTOP},
Fred Drakeabb379e2001-03-01 03:28:08 +0000526#ifdef PENDIN
Fred Drakedf48d142001-02-27 21:22:39 +0000527 {"PENDIN", PENDIN},
Fred Drakeabb379e2001-03-01 03:28:08 +0000528#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000529 {"IEXTEN", IEXTEN},
530
531 /* indexes into the control chars array returned by tcgetattr() */
532 {"VINTR", VINTR},
533 {"VQUIT", VQUIT},
534 {"VERASE", VERASE},
535 {"VKILL", VKILL},
536 {"VEOF", VEOF},
537 {"VTIME", VTIME},
538 {"VMIN", VMIN},
Fred Drakededbebf2001-03-02 06:50:58 +0000539#ifdef VSWTC
540 /* The #defines above ensure that if either is defined, both are,
541 * but both may be omitted by the system headers. ;-( */
Fred Drakedf48d142001-02-27 21:22:39 +0000542 {"VSWTC", VSWTC},
Fred Drake9ef7fa82001-03-01 21:54:49 +0000543 {"VSWTCH", VSWTCH},
Fred Drakededbebf2001-03-02 06:50:58 +0000544#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000545 {"VSTART", VSTART},
546 {"VSTOP", VSTOP},
547 {"VSUSP", VSUSP},
548 {"VEOL", VEOL},
Fred Draked0b625d2001-05-22 15:44:15 +0000549#ifdef VREPRINT
Fred Drakedf48d142001-02-27 21:22:39 +0000550 {"VREPRINT", VREPRINT},
Fred Drake87068f12001-05-11 16:14:17 +0000551#endif
Fred Draked0b625d2001-05-22 15:44:15 +0000552#ifdef VDISCARD
Fred Drakedf48d142001-02-27 21:22:39 +0000553 {"VDISCARD", VDISCARD},
Fred Drake87068f12001-05-11 16:14:17 +0000554#endif
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000555#ifdef VWERASE
Fred Drakedf48d142001-02-27 21:22:39 +0000556 {"VWERASE", VWERASE},
Thomas Wouters819bb2c2001-06-11 15:25:16 +0000557#endif
Thomas Wouters2b305242001-06-15 12:05:44 +0000558#ifdef VLNEXT
Fred Drakedf48d142001-02-27 21:22:39 +0000559 {"VLNEXT", VLNEXT},
Thomas Wouters2b305242001-06-15 12:05:44 +0000560#endif
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000561#ifdef VEOL2
Fred Drakedf48d142001-02-27 21:22:39 +0000562 {"VEOL2", VEOL2},
Andrew MacIntyre7bf68332002-03-03 02:59:16 +0000563#endif
Fred Drakedf48d142001-02-27 21:22:39 +0000564
Fred Drake55a00342001-03-26 17:14:02 +0000565
566#ifdef B460800
567 {"B460800", B460800},
568#endif
569#ifdef CBAUD
570 {"CBAUD", CBAUD},
571#endif
572#ifdef CDEL
573 {"CDEL", CDEL},
574#endif
575#ifdef CDSUSP
576 {"CDSUSP", CDSUSP},
577#endif
578#ifdef CEOF
579 {"CEOF", CEOF},
580#endif
581#ifdef CEOL
582 {"CEOL", CEOL},
583#endif
584#ifdef CEOL2
585 {"CEOL2", CEOL2},
586#endif
587#ifdef CEOT
588 {"CEOT", CEOT},
589#endif
590#ifdef CERASE
591 {"CERASE", CERASE},
592#endif
593#ifdef CESC
594 {"CESC", CESC},
595#endif
596#ifdef CFLUSH
597 {"CFLUSH", CFLUSH},
598#endif
599#ifdef CINTR
600 {"CINTR", CINTR},
601#endif
602#ifdef CKILL
603 {"CKILL", CKILL},
604#endif
605#ifdef CLNEXT
606 {"CLNEXT", CLNEXT},
607#endif
608#ifdef CNUL
609 {"CNUL", CNUL},
610#endif
611#ifdef COMMON
612 {"COMMON", COMMON},
613#endif
614#ifdef CQUIT
615 {"CQUIT", CQUIT},
616#endif
617#ifdef CRPRNT
618 {"CRPRNT", CRPRNT},
619#endif
620#ifdef CSTART
621 {"CSTART", CSTART},
622#endif
623#ifdef CSTOP
624 {"CSTOP", CSTOP},
625#endif
626#ifdef CSUSP
627 {"CSUSP", CSUSP},
628#endif
629#ifdef CSWTCH
630 {"CSWTCH", CSWTCH},
631#endif
632#ifdef CWERASE
633 {"CWERASE", CWERASE},
634#endif
635#ifdef EXTA
636 {"EXTA", EXTA},
637#endif
638#ifdef EXTB
639 {"EXTB", EXTB},
640#endif
641#ifdef FIOASYNC
642 {"FIOASYNC", FIOASYNC},
643#endif
644#ifdef FIOCLEX
645 {"FIOCLEX", FIOCLEX},
646#endif
647#ifdef FIONBIO
648 {"FIONBIO", FIONBIO},
649#endif
650#ifdef FIONCLEX
651 {"FIONCLEX", FIONCLEX},
652#endif
653#ifdef FIONREAD
654 {"FIONREAD", FIONREAD},
655#endif
656#ifdef IBSHIFT
657 {"IBSHIFT", IBSHIFT},
658#endif
659#ifdef INIT_C_CC
660 {"INIT_C_CC", INIT_C_CC},
661#endif
662#ifdef IOCSIZE_MASK
663 {"IOCSIZE_MASK", IOCSIZE_MASK},
664#endif
665#ifdef IOCSIZE_SHIFT
666 {"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
667#endif
668#ifdef NCC
669 {"NCC", NCC},
670#endif
671#ifdef NCCS
672 {"NCCS", NCCS},
673#endif
674#ifdef NSWTCH
675 {"NSWTCH", NSWTCH},
676#endif
677#ifdef N_MOUSE
678 {"N_MOUSE", N_MOUSE},
679#endif
680#ifdef N_PPP
681 {"N_PPP", N_PPP},
682#endif
683#ifdef N_SLIP
684 {"N_SLIP", N_SLIP},
685#endif
686#ifdef N_STRIP
687 {"N_STRIP", N_STRIP},
688#endif
689#ifdef N_TTY
690 {"N_TTY", N_TTY},
691#endif
692#ifdef TCFLSH
693 {"TCFLSH", TCFLSH},
694#endif
695#ifdef TCGETA
696 {"TCGETA", TCGETA},
697#endif
698#ifdef TCGETS
699 {"TCGETS", TCGETS},
700#endif
701#ifdef TCSBRK
702 {"TCSBRK", TCSBRK},
703#endif
704#ifdef TCSBRKP
705 {"TCSBRKP", TCSBRKP},
706#endif
707#ifdef TCSETA
708 {"TCSETA", TCSETA},
709#endif
710#ifdef TCSETAF
711 {"TCSETAF", TCSETAF},
712#endif
713#ifdef TCSETAW
714 {"TCSETAW", TCSETAW},
715#endif
716#ifdef TCSETS
717 {"TCSETS", TCSETS},
718#endif
719#ifdef TCSETSF
720 {"TCSETSF", TCSETSF},
721#endif
722#ifdef TCSETSW
723 {"TCSETSW", TCSETSW},
724#endif
725#ifdef TCXONC
726 {"TCXONC", TCXONC},
727#endif
728#ifdef TIOCCONS
729 {"TIOCCONS", TIOCCONS},
730#endif
731#ifdef TIOCEXCL
732 {"TIOCEXCL", TIOCEXCL},
733#endif
734#ifdef TIOCGETD
735 {"TIOCGETD", TIOCGETD},
736#endif
737#ifdef TIOCGICOUNT
738 {"TIOCGICOUNT", TIOCGICOUNT},
739#endif
740#ifdef TIOCGLCKTRMIOS
741 {"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
742#endif
743#ifdef TIOCGPGRP
744 {"TIOCGPGRP", TIOCGPGRP},
745#endif
746#ifdef TIOCGSERIAL
747 {"TIOCGSERIAL", TIOCGSERIAL},
748#endif
749#ifdef TIOCGSOFTCAR
750 {"TIOCGSOFTCAR", TIOCGSOFTCAR},
751#endif
752#ifdef TIOCGWINSZ
753 {"TIOCGWINSZ", TIOCGWINSZ},
754#endif
755#ifdef TIOCINQ
756 {"TIOCINQ", TIOCINQ},
757#endif
758#ifdef TIOCLINUX
759 {"TIOCLINUX", TIOCLINUX},
760#endif
761#ifdef TIOCMBIC
762 {"TIOCMBIC", TIOCMBIC},
763#endif
764#ifdef TIOCMBIS
765 {"TIOCMBIS", TIOCMBIS},
766#endif
767#ifdef TIOCMGET
768 {"TIOCMGET", TIOCMGET},
769#endif
770#ifdef TIOCMIWAIT
771 {"TIOCMIWAIT", TIOCMIWAIT},
772#endif
773#ifdef TIOCMSET
774 {"TIOCMSET", TIOCMSET},
775#endif
776#ifdef TIOCM_CAR
777 {"TIOCM_CAR", TIOCM_CAR},
778#endif
779#ifdef TIOCM_CD
780 {"TIOCM_CD", TIOCM_CD},
781#endif
782#ifdef TIOCM_CTS
783 {"TIOCM_CTS", TIOCM_CTS},
784#endif
785#ifdef TIOCM_DSR
786 {"TIOCM_DSR", TIOCM_DSR},
787#endif
788#ifdef TIOCM_DTR
789 {"TIOCM_DTR", TIOCM_DTR},
790#endif
791#ifdef TIOCM_LE
792 {"TIOCM_LE", TIOCM_LE},
793#endif
794#ifdef TIOCM_RI
795 {"TIOCM_RI", TIOCM_RI},
796#endif
797#ifdef TIOCM_RNG
798 {"TIOCM_RNG", TIOCM_RNG},
799#endif
800#ifdef TIOCM_RTS
801 {"TIOCM_RTS", TIOCM_RTS},
802#endif
803#ifdef TIOCM_SR
804 {"TIOCM_SR", TIOCM_SR},
805#endif
806#ifdef TIOCM_ST
807 {"TIOCM_ST", TIOCM_ST},
808#endif
809#ifdef TIOCNOTTY
810 {"TIOCNOTTY", TIOCNOTTY},
811#endif
812#ifdef TIOCNXCL
813 {"TIOCNXCL", TIOCNXCL},
814#endif
815#ifdef TIOCOUTQ
816 {"TIOCOUTQ", TIOCOUTQ},
817#endif
818#ifdef TIOCPKT
819 {"TIOCPKT", TIOCPKT},
820#endif
821#ifdef TIOCPKT_DATA
822 {"TIOCPKT_DATA", TIOCPKT_DATA},
823#endif
824#ifdef TIOCPKT_DOSTOP
825 {"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
826#endif
827#ifdef TIOCPKT_FLUSHREAD
828 {"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
829#endif
830#ifdef TIOCPKT_FLUSHWRITE
831 {"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
832#endif
833#ifdef TIOCPKT_NOSTOP
834 {"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
835#endif
836#ifdef TIOCPKT_START
837 {"TIOCPKT_START", TIOCPKT_START},
838#endif
839#ifdef TIOCPKT_STOP
840 {"TIOCPKT_STOP", TIOCPKT_STOP},
841#endif
842#ifdef TIOCSCTTY
843 {"TIOCSCTTY", TIOCSCTTY},
844#endif
845#ifdef TIOCSERCONFIG
846 {"TIOCSERCONFIG", TIOCSERCONFIG},
847#endif
848#ifdef TIOCSERGETLSR
849 {"TIOCSERGETLSR", TIOCSERGETLSR},
850#endif
851#ifdef TIOCSERGETMULTI
852 {"TIOCSERGETMULTI", TIOCSERGETMULTI},
853#endif
854#ifdef TIOCSERGSTRUCT
855 {"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
856#endif
857#ifdef TIOCSERGWILD
858 {"TIOCSERGWILD", TIOCSERGWILD},
859#endif
860#ifdef TIOCSERSETMULTI
861 {"TIOCSERSETMULTI", TIOCSERSETMULTI},
862#endif
863#ifdef TIOCSERSWILD
864 {"TIOCSERSWILD", TIOCSERSWILD},
865#endif
866#ifdef TIOCSER_TEMT
867 {"TIOCSER_TEMT", TIOCSER_TEMT},
868#endif
869#ifdef TIOCSETD
870 {"TIOCSETD", TIOCSETD},
871#endif
872#ifdef TIOCSLCKTRMIOS
873 {"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
874#endif
875#ifdef TIOCSPGRP
876 {"TIOCSPGRP", TIOCSPGRP},
877#endif
878#ifdef TIOCSSERIAL
879 {"TIOCSSERIAL", TIOCSSERIAL},
880#endif
881#ifdef TIOCSSOFTCAR
882 {"TIOCSSOFTCAR", TIOCSSOFTCAR},
883#endif
884#ifdef TIOCSTI
885 {"TIOCSTI", TIOCSTI},
886#endif
887#ifdef TIOCSWINSZ
888 {"TIOCSWINSZ", TIOCSWINSZ},
889#endif
890#ifdef TIOCTTYGSTRUCT
891 {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
892#endif
893
Fred Drakedf48d142001-02-27 21:22:39 +0000894 /* sentinel */
895 {NULL, 0}
896};
897
898
Mark Hammondfe51c6d2002-08-02 02:27:13 +0000899PyMODINIT_FUNC
Thomas Woutersf3f33dc2000-07-21 06:00:07 +0000900PyInit_termios(void)
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000901{
Fred Drake78f6c862002-02-14 07:11:23 +0000902 PyObject *m;
Fred Drakedf48d142001-02-27 21:22:39 +0000903 struct constant *constant = termios_constants;
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000904
Guido van Rossum1aca4d81998-03-03 22:10:18 +0000905 m = Py_InitModule4("termios", termios_methods, termios__doc__,
906 (PyObject *)NULL, PYTHON_API_VERSION);
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000907
Fred Drake78f6c862002-02-14 07:11:23 +0000908 if (TermiosError == NULL) {
909 TermiosError = PyErr_NewException("termios.error", NULL, NULL);
910 }
911 Py_INCREF(TermiosError);
912 PyModule_AddObject(m, "error", TermiosError);
Fred Drakedf48d142001-02-27 21:22:39 +0000913
914 while (constant->name != NULL) {
915 PyModule_AddIntConstant(m, constant->name, constant->value);
916 ++constant;
917 }
Guido van Rossum9adae8e1994-09-12 10:41:22 +0000918}