1994-09-12 07:41:22 -03:00
|
|
|
/* termiosmodule.c -- POSIX terminal I/O module implementation. */
|
|
|
|
|
1999-01-14 15:31:42 -04:00
|
|
|
#include "Python.h"
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2003-10-31 09:01:24 -04:00
|
|
|
/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE
|
|
|
|
is defined, so we define it here. */
|
|
|
|
#if defined(__sgi)
|
|
|
|
#define CTRL(c) ((c)&037)
|
|
|
|
#endif
|
|
|
|
|
2018-01-28 09:00:48 -04:00
|
|
|
#if defined(__sun)
|
|
|
|
/* We could do better. Check issue-32660 */
|
|
|
|
#include <sys/filio.h>
|
|
|
|
#include <sys/sockio.h>
|
|
|
|
#endif
|
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
#include <termios.h>
|
2001-04-04 18:19:26 -03:00
|
|
|
#include <sys/ioctl.h>
|
2001-05-07 14:55:35 -03:00
|
|
|
|
2001-05-11 13:14:17 -03:00
|
|
|
/* HP-UX requires that this be included to pick up MDCD, MCTS, MDSR,
|
2019-08-30 17:21:19 -03:00
|
|
|
* MDTR, MRI, and MRTS (apparently used internally by some things
|
2001-05-11 13:14:17 -03:00
|
|
|
* defined as macros; these are not used here directly).
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_SYS_MODEM_H
|
|
|
|
#include <sys/modem.h>
|
|
|
|
#endif
|
2003-05-23 11:35:24 -03:00
|
|
|
/* HP-UX requires that this be included to pick up TIOCGPGRP and friends */
|
|
|
|
#ifdef HAVE_SYS_BSDTTY_H
|
|
|
|
#include <sys/bsdtty.h>
|
|
|
|
#endif
|
2001-05-11 13:14:17 -03:00
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios__doc__,
|
|
|
|
"This module provides an interface to the Posix calls for tty I/O control.\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
For a complete description of these calls, see the Posix or Unix manual\n\
|
|
|
|
pages. It is only available for those Unix versions that support Posix\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
termios style tty I/O control.\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
\n\
|
|
|
|
All functions in this module take a file descriptor fd as their first\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
argument. This can be an integer file descriptor, such as returned by\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
sys.stdin.fileno(), or a file object, such as sys.stdin itself.");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
2019-09-10 07:33:30 -03:00
|
|
|
typedef struct {
|
|
|
|
PyObject *TermiosError;
|
|
|
|
} termiosmodulestate;
|
2020-03-16 10:15:01 -03:00
|
|
|
|
|
|
|
static inline termiosmodulestate*
|
|
|
|
get_termios_state(PyObject *module)
|
|
|
|
{
|
|
|
|
void *state = PyModule_GetState(module);
|
|
|
|
assert(state != NULL);
|
|
|
|
return (termiosmodulestate *)state;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define modulestate_global get_termios_state(PyState_FindModule(&termiosmodule))
|
1998-08-04 19:53:56 -03:00
|
|
|
|
2001-05-07 14:55:35 -03:00
|
|
|
static int fdconv(PyObject* obj, void* p)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = PyObject_AsFileDescriptor(obj);
|
|
|
|
if (fd >= 0) {
|
|
|
|
*(int*)p = fd;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2001-05-07 14:55:35 -03:00
|
|
|
}
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2019-09-10 07:33:30 -03:00
|
|
|
static struct PyModuleDef termiosmodule;
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcgetattr__doc__,
|
|
|
|
"tcgetattr(fd) -> list_of_attrs\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
Get the tty attributes for file descriptor fd, as follows:\n\
|
|
|
|
[iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\
|
|
|
|
of the tty special characters (each a string of length 1, except the items\n\
|
|
|
|
with indices VMIN and VTIME, which are integers when these fields are\n\
|
|
|
|
defined). The interpretation of the flags and the speeds as well as the\n\
|
|
|
|
indexing in the cc array must be done using the symbolic constants defined\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
in this module.");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcgetattr(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd;
|
|
|
|
struct termios mode;
|
|
|
|
PyObject *cc;
|
|
|
|
speed_t ispeed, ospeed;
|
|
|
|
PyObject *v;
|
|
|
|
int i;
|
|
|
|
char ch;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O&:tcgetattr",
|
|
|
|
fdconv, (void*)&fd))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (tcgetattr(fd, &mode) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(modulestate_global->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
ispeed = cfgetispeed(&mode);
|
|
|
|
ospeed = cfgetospeed(&mode);
|
|
|
|
|
|
|
|
cc = PyList_New(NCCS);
|
|
|
|
if (cc == NULL)
|
|
|
|
return NULL;
|
|
|
|
for (i = 0; i < NCCS; i++) {
|
|
|
|
ch = (char)mode.c_cc[i];
|
|
|
|
v = PyBytes_FromStringAndSize(&ch, 1);
|
|
|
|
if (v == NULL)
|
|
|
|
goto err;
|
|
|
|
PyList_SetItem(cc, i, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the MIN and TIME slots to integer. On some systems, the
|
|
|
|
MIN and TIME slots are the same as the EOF and EOL slots. So we
|
|
|
|
only do this in noncanonical input mode. */
|
|
|
|
if ((mode.c_lflag & ICANON) == 0) {
|
|
|
|
v = PyLong_FromLong((long)mode.c_cc[VMIN]);
|
|
|
|
if (v == NULL)
|
|
|
|
goto err;
|
|
|
|
PyList_SetItem(cc, VMIN, v);
|
|
|
|
v = PyLong_FromLong((long)mode.c_cc[VTIME]);
|
|
|
|
if (v == NULL)
|
|
|
|
goto err;
|
|
|
|
PyList_SetItem(cc, VTIME, v);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(v = PyList_New(7)))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag));
|
|
|
|
PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag));
|
|
|
|
PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag));
|
|
|
|
PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag));
|
|
|
|
PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed));
|
|
|
|
PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed));
|
2018-10-29 01:55:20 -03:00
|
|
|
if (PyErr_Occurred()) {
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_DECREF(v);
|
|
|
|
goto err;
|
|
|
|
}
|
2018-10-29 01:55:20 -03:00
|
|
|
PyList_SetItem(v, 6, cc);
|
2010-05-09 12:52:27 -03:00
|
|
|
return v;
|
1997-01-10 14:42:18 -04:00
|
|
|
err:
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_DECREF(cc);
|
|
|
|
return NULL;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcsetattr__doc__,
|
|
|
|
"tcsetattr(fd, when, attributes) -> None\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
Set the tty attributes for file descriptor fd.\n\
|
|
|
|
The attributes to be set are taken from the attributes argument, which\n\
|
|
|
|
is a list like the one returned by tcgetattr(). The when argument\n\
|
2001-04-09 16:32:52 -03:00
|
|
|
determines when the attributes are changed: termios.TCSANOW to\n\
|
|
|
|
change immediately, termios.TCSADRAIN to change after transmitting all\n\
|
|
|
|
queued output, or termios.TCSAFLUSH to change after transmitting all\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
queued output and discarding all queued input. ");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcsetattr(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd, when;
|
|
|
|
struct termios mode;
|
|
|
|
speed_t ispeed, ospeed;
|
|
|
|
PyObject *term, *cc, *v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O&iO:tcsetattr",
|
|
|
|
fdconv, &fd, &when, &term))
|
|
|
|
return NULL;
|
|
|
|
if (!PyList_Check(term) || PyList_Size(term) != 7) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"tcsetattr, arg 3: must be 7 element list");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the old mode, in case there are any hidden fields... */
|
2019-09-10 07:33:30 -03:00
|
|
|
termiosmodulestate *state = modulestate_global;
|
2010-05-09 12:52:27 -03:00
|
|
|
if (tcgetattr(fd, &mode) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0));
|
|
|
|
mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1));
|
|
|
|
mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2));
|
|
|
|
mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3));
|
|
|
|
ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4));
|
|
|
|
ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5));
|
|
|
|
cc = PyList_GetItem(term, 6);
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"tcsetattr: attributes[6] must be %d element list",
|
|
|
|
NCCS);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NCCS; i++) {
|
|
|
|
v = PyList_GetItem(cc, i);
|
|
|
|
|
|
|
|
if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
|
|
|
|
mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
|
|
|
|
else if (PyLong_Check(v))
|
|
|
|
mode.c_cc[i] = (cc_t) PyLong_AsLong(v);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
2001-05-07 14:55:35 -03:00
|
|
|
"tcsetattr: elements of attributes must be characters or integers");
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cfsetispeed(&mode, (speed_t) ispeed) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (cfsetospeed(&mode, (speed_t) ospeed) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (tcsetattr(fd, when, &mode) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcsendbreak__doc__,
|
|
|
|
"tcsendbreak(fd, duration) -> None\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
Send a break on file descriptor fd.\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
has a system dependent meaning.");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcsendbreak(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd, duration;
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "O&i:tcsendbreak",
|
|
|
|
fdconv, &fd, &duration))
|
|
|
|
return NULL;
|
|
|
|
if (tcsendbreak(fd, duration) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(modulestate_global->TermiosError);
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcdrain__doc__,
|
|
|
|
"tcdrain(fd) -> None\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
Wait until all output written to file descriptor fd has been transmitted.");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcdrain(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd;
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "O&:tcdrain",
|
|
|
|
fdconv, &fd))
|
|
|
|
return NULL;
|
|
|
|
if (tcdrain(fd) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(modulestate_global->TermiosError);
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcflush__doc__,
|
|
|
|
"tcflush(fd, queue) -> None\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
Discard queued data on file descriptor fd.\n\
|
2001-04-09 16:32:52 -03:00
|
|
|
The queue selector specifies which queue: termios.TCIFLUSH for the input\n\
|
|
|
|
queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
both queues. ");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcflush(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd, queue;
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "O&i:tcflush",
|
|
|
|
fdconv, &fd, &queue))
|
|
|
|
return NULL;
|
|
|
|
if (tcflush(fd, queue) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(modulestate_global->TermiosError);
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(termios_tcflow__doc__,
|
|
|
|
"tcflow(fd, action) -> None\n\
|
2001-05-07 14:55:35 -03:00
|
|
|
\n\
|
1998-03-03 18:10:18 -04:00
|
|
|
Suspend or resume input or output on file descriptor fd.\n\
|
2001-04-09 16:32:52 -03:00
|
|
|
The action argument can be termios.TCOOFF to suspend output,\n\
|
|
|
|
termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\
|
2002-06-13 17:33:02 -03:00
|
|
|
or termios.TCION to restart input.");
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2000-07-10 09:15:54 -03:00
|
|
|
termios_tcflow(PyObject *self, PyObject *args)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
int fd, action;
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyArg_ParseTuple(args, "O&i:tcflow",
|
|
|
|
fdconv, &fd, &action))
|
|
|
|
return NULL;
|
|
|
|
if (tcflow(fd, action) == -1)
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(modulestate_global->TermiosError);
|
1994-09-12 07:41:22 -03:00
|
|
|
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef termios_methods[] =
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
{"tcgetattr", termios_tcgetattr,
|
|
|
|
METH_VARARGS, termios_tcgetattr__doc__},
|
|
|
|
{"tcsetattr", termios_tcsetattr,
|
|
|
|
METH_VARARGS, termios_tcsetattr__doc__},
|
|
|
|
{"tcsendbreak", termios_tcsendbreak,
|
|
|
|
METH_VARARGS, termios_tcsendbreak__doc__},
|
|
|
|
{"tcdrain", termios_tcdrain,
|
|
|
|
METH_VARARGS, termios_tcdrain__doc__},
|
|
|
|
{"tcflush", termios_tcflush,
|
|
|
|
METH_VARARGS, termios_tcflush__doc__},
|
|
|
|
{"tcflow", termios_tcflow,
|
|
|
|
METH_VARARGS, termios_tcflow__doc__},
|
|
|
|
{NULL, NULL}
|
1994-09-12 07:41:22 -03:00
|
|
|
};
|
|
|
|
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2001-03-01 17:54:49 -04:00
|
|
|
#if defined(VSWTCH) && !defined(VSWTC)
|
|
|
|
#define VSWTC VSWTCH
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(VSWTC) && !defined(VSWTCH)
|
|
|
|
#define VSWTCH VSWTC
|
|
|
|
#endif
|
|
|
|
|
2001-02-27 17:22:39 -04:00
|
|
|
static struct constant {
|
2010-05-09 12:52:27 -03:00
|
|
|
char *name;
|
|
|
|
long value;
|
2001-02-27 17:22:39 -04:00
|
|
|
} termios_constants[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
/* cfgetospeed(), cfsetospeed() constants */
|
|
|
|
{"B0", B0},
|
|
|
|
{"B50", B50},
|
|
|
|
{"B75", B75},
|
|
|
|
{"B110", B110},
|
|
|
|
{"B134", B134},
|
|
|
|
{"B150", B150},
|
|
|
|
{"B200", B200},
|
|
|
|
{"B300", B300},
|
|
|
|
{"B600", B600},
|
|
|
|
{"B1200", B1200},
|
|
|
|
{"B1800", B1800},
|
|
|
|
{"B2400", B2400},
|
|
|
|
{"B4800", B4800},
|
|
|
|
{"B9600", B9600},
|
|
|
|
{"B19200", B19200},
|
|
|
|
{"B38400", B38400},
|
2001-04-11 17:58:20 -03:00
|
|
|
#ifdef B57600
|
2010-05-09 12:52:27 -03:00
|
|
|
{"B57600", B57600},
|
2001-04-11 17:58:20 -03:00
|
|
|
#endif
|
|
|
|
#ifdef B115200
|
2010-05-09 12:52:27 -03:00
|
|
|
{"B115200", B115200},
|
2001-04-11 17:58:20 -03:00
|
|
|
#endif
|
2001-02-28 23:28:08 -04:00
|
|
|
#ifdef B230400
|
2010-05-09 12:52:27 -03:00
|
|
|
{"B230400", B230400},
|
2001-02-28 23:28:08 -04:00
|
|
|
#endif
|
2010-11-20 16:03:08 -04:00
|
|
|
#ifdef B460800
|
|
|
|
{"B460800", B460800},
|
|
|
|
#endif
|
|
|
|
#ifdef B500000
|
|
|
|
{"B500000", B500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B576000
|
|
|
|
{"B576000", B576000},
|
|
|
|
#endif
|
|
|
|
#ifdef B921600
|
|
|
|
{"B921600", B921600},
|
|
|
|
#endif
|
|
|
|
#ifdef B1000000
|
|
|
|
{"B1000000", B1000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B1152000
|
|
|
|
{"B1152000", B1152000},
|
|
|
|
#endif
|
|
|
|
#ifdef B1500000
|
|
|
|
{"B1500000", B1500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B2000000
|
|
|
|
{"B2000000", B2000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B2500000
|
|
|
|
{"B2500000", B2500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B3000000
|
|
|
|
{"B3000000", B3000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B3500000
|
|
|
|
{"B3500000", B3500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B4000000
|
|
|
|
{"B4000000", B4000000},
|
|
|
|
#endif
|
|
|
|
|
2001-03-01 17:54:49 -04:00
|
|
|
#ifdef CBAUDEX
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CBAUDEX", CBAUDEX},
|
2001-03-01 17:54:49 -04:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* tcsetattr() constants */
|
|
|
|
{"TCSANOW", TCSANOW},
|
|
|
|
{"TCSADRAIN", TCSADRAIN},
|
|
|
|
{"TCSAFLUSH", TCSAFLUSH},
|
2009-11-01 15:24:18 -04:00
|
|
|
#ifdef TCSASOFT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSASOFT", TCSASOFT},
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* tcflush() constants */
|
|
|
|
{"TCIFLUSH", TCIFLUSH},
|
|
|
|
{"TCOFLUSH", TCOFLUSH},
|
|
|
|
{"TCIOFLUSH", TCIOFLUSH},
|
|
|
|
|
|
|
|
/* tcflow() constants */
|
|
|
|
{"TCOOFF", TCOOFF},
|
|
|
|
{"TCOON", TCOON},
|
|
|
|
{"TCIOFF", TCIOFF},
|
|
|
|
{"TCION", TCION},
|
|
|
|
|
|
|
|
/* struct termios.c_iflag constants */
|
|
|
|
{"IGNBRK", IGNBRK},
|
|
|
|
{"BRKINT", BRKINT},
|
|
|
|
{"IGNPAR", IGNPAR},
|
|
|
|
{"PARMRK", PARMRK},
|
|
|
|
{"INPCK", INPCK},
|
|
|
|
{"ISTRIP", ISTRIP},
|
|
|
|
{"INLCR", INLCR},
|
|
|
|
{"IGNCR", IGNCR},
|
|
|
|
{"ICRNL", ICRNL},
|
2001-03-03 14:08:52 -04:00
|
|
|
#ifdef IUCLC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IUCLC", IUCLC},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IXON", IXON},
|
|
|
|
{"IXANY", IXANY},
|
|
|
|
{"IXOFF", IXOFF},
|
2001-06-15 09:05:44 -03:00
|
|
|
#ifdef IMAXBEL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IMAXBEL", IMAXBEL},
|
2001-06-15 09:05:44 -03:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* struct termios.c_oflag constants */
|
|
|
|
{"OPOST", OPOST},
|
2001-03-03 14:08:52 -04:00
|
|
|
#ifdef OLCUC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"OLCUC", OLCUC},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
2002-03-02 22:59:16 -04:00
|
|
|
#ifdef ONLCR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ONLCR", ONLCR},
|
2002-03-02 22:59:16 -04:00
|
|
|
#endif
|
2001-03-03 14:08:52 -04:00
|
|
|
#ifdef OCRNL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"OCRNL", OCRNL},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef ONOCR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ONOCR", ONOCR},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef ONLRET
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ONLRET", ONLRET},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef OFILL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"OFILL", OFILL},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef OFDEL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"OFDEL", OFDEL},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef NLDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NLDLY", NLDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CRDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CRDLY", CRDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TABDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TABDLY", TABDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef BSDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"BSDLY", BSDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef VTDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VTDLY", VTDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FFDLY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FFDLY", FFDLY},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* struct termios.c_oflag-related values (delay mask) */
|
2001-03-03 14:08:52 -04:00
|
|
|
#ifdef NL0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NL0", NL0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef NL1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NL1", NL1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CR0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CR0", CR0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CR1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CR1", CR1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CR2
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CR2", CR2},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CR3
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CR3", CR3},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TAB0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TAB0", TAB0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TAB1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TAB1", TAB1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TAB2
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TAB2", TAB2},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TAB3
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TAB3", TAB3},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
2001-03-02 02:50:58 -04:00
|
|
|
#ifdef XTABS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"XTABS", XTABS},
|
2001-03-02 02:50:58 -04:00
|
|
|
#endif
|
2001-03-03 14:08:52 -04:00
|
|
|
#ifdef BS0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"BS0", BS0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef BS1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"BS1", BS1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef VT0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VT0", VT0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef VT1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VT1", VT1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FF0
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FF0", FF0},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FF1
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FF1", FF1},
|
2001-03-03 14:08:52 -04:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* struct termios.c_cflag constants */
|
|
|
|
{"CSIZE", CSIZE},
|
|
|
|
{"CSTOPB", CSTOPB},
|
|
|
|
{"CREAD", CREAD},
|
|
|
|
{"PARENB", PARENB},
|
|
|
|
{"PARODD", PARODD},
|
|
|
|
{"HUPCL", HUPCL},
|
|
|
|
{"CLOCAL", CLOCAL},
|
2001-02-28 23:28:08 -04:00
|
|
|
#ifdef CIBAUD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CIBAUD", CIBAUD},
|
2001-02-28 23:28:08 -04:00
|
|
|
#endif
|
2001-03-02 02:50:58 -04:00
|
|
|
#ifdef CRTSCTS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CRTSCTS", (long)CRTSCTS},
|
2001-03-02 02:50:58 -04:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* struct termios.c_cflag-related values (character size) */
|
|
|
|
{"CS5", CS5},
|
|
|
|
{"CS6", CS6},
|
|
|
|
{"CS7", CS7},
|
|
|
|
{"CS8", CS8},
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* struct termios.c_lflag constants */
|
|
|
|
{"ISIG", ISIG},
|
|
|
|
{"ICANON", ICANON},
|
2001-02-28 23:28:08 -04:00
|
|
|
#ifdef XCASE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"XCASE", XCASE},
|
2001-02-28 23:28:08 -04:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ECHO", ECHO},
|
|
|
|
{"ECHOE", ECHOE},
|
|
|
|
{"ECHOK", ECHOK},
|
|
|
|
{"ECHONL", ECHONL},
|
2001-06-15 09:05:44 -03:00
|
|
|
#ifdef ECHOCTL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ECHOCTL", ECHOCTL},
|
2001-06-15 09:05:44 -03:00
|
|
|
#endif
|
2001-02-28 23:28:08 -04:00
|
|
|
#ifdef ECHOPRT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ECHOPRT", ECHOPRT},
|
2001-02-28 23:28:08 -04:00
|
|
|
#endif
|
2001-06-15 09:05:44 -03:00
|
|
|
#ifdef ECHOKE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"ECHOKE", ECHOKE},
|
2001-06-15 09:05:44 -03:00
|
|
|
#endif
|
|
|
|
#ifdef FLUSHO
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FLUSHO", FLUSHO},
|
2001-06-15 09:05:44 -03:00
|
|
|
#endif
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NOFLSH", NOFLSH},
|
|
|
|
{"TOSTOP", TOSTOP},
|
2001-02-28 23:28:08 -04:00
|
|
|
#ifdef PENDIN
|
2010-05-09 12:52:27 -03:00
|
|
|
{"PENDIN", PENDIN},
|
|
|
|
#endif
|
|
|
|
{"IEXTEN", IEXTEN},
|
|
|
|
|
|
|
|
/* indexes into the control chars array returned by tcgetattr() */
|
|
|
|
{"VINTR", VINTR},
|
|
|
|
{"VQUIT", VQUIT},
|
|
|
|
{"VERASE", VERASE},
|
|
|
|
{"VKILL", VKILL},
|
|
|
|
{"VEOF", VEOF},
|
|
|
|
{"VTIME", VTIME},
|
|
|
|
{"VMIN", VMIN},
|
2001-03-02 02:50:58 -04:00
|
|
|
#ifdef VSWTC
|
2010-05-09 12:52:27 -03:00
|
|
|
/* The #defines above ensure that if either is defined, both are,
|
|
|
|
* but both may be omitted by the system headers. ;-( */
|
|
|
|
{"VSWTC", VSWTC},
|
|
|
|
{"VSWTCH", VSWTCH},
|
|
|
|
#endif
|
|
|
|
{"VSTART", VSTART},
|
|
|
|
{"VSTOP", VSTOP},
|
|
|
|
{"VSUSP", VSUSP},
|
|
|
|
{"VEOL", VEOL},
|
2001-05-22 12:44:15 -03:00
|
|
|
#ifdef VREPRINT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VREPRINT", VREPRINT},
|
2001-05-11 13:14:17 -03:00
|
|
|
#endif
|
2001-05-22 12:44:15 -03:00
|
|
|
#ifdef VDISCARD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VDISCARD", VDISCARD},
|
2001-05-11 13:14:17 -03:00
|
|
|
#endif
|
2001-06-11 12:25:16 -03:00
|
|
|
#ifdef VWERASE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VWERASE", VWERASE},
|
2001-06-11 12:25:16 -03:00
|
|
|
#endif
|
2001-06-15 09:05:44 -03:00
|
|
|
#ifdef VLNEXT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VLNEXT", VLNEXT},
|
2001-06-15 09:05:44 -03:00
|
|
|
#endif
|
2002-03-02 22:59:16 -04:00
|
|
|
#ifdef VEOL2
|
2010-05-09 12:52:27 -03:00
|
|
|
{"VEOL2", VEOL2},
|
2002-03-02 22:59:16 -04:00
|
|
|
#endif
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2001-03-26 13:14:02 -04:00
|
|
|
|
|
|
|
#ifdef B460800
|
2010-05-09 12:52:27 -03:00
|
|
|
{"B460800", B460800},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
2020-01-04 08:56:31 -04:00
|
|
|
#ifdef B500000
|
|
|
|
{"B500000", B500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B576000
|
|
|
|
{ "B576000", B576000},
|
|
|
|
#endif
|
|
|
|
#ifdef B921600
|
|
|
|
{ "B921600", B921600},
|
|
|
|
#endif
|
|
|
|
#ifdef B1000000
|
|
|
|
{ "B1000000", B1000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B1152000
|
|
|
|
{ "B1152000", B1152000},
|
|
|
|
#endif
|
|
|
|
#ifdef B1500000
|
|
|
|
{ "B1500000", B1500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B2000000
|
|
|
|
{ "B2000000", B2000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B2500000
|
|
|
|
{ "B2500000", B2500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B3000000
|
|
|
|
{ "B3000000", B3000000},
|
|
|
|
#endif
|
|
|
|
#ifdef B3500000
|
|
|
|
{ "B3500000", B3500000},
|
|
|
|
#endif
|
|
|
|
#ifdef B4000000
|
|
|
|
{ "B4000000", B4000000},
|
|
|
|
#endif
|
2001-03-26 13:14:02 -04:00
|
|
|
#ifdef CBAUD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CBAUD", CBAUD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CDEL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CDEL", CDEL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CDSUSP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CDSUSP", CDSUSP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CEOF
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CEOF", CEOF},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CEOL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CEOL", CEOL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CEOL2
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CEOL2", CEOL2},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CEOT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CEOT", CEOT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CERASE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CERASE", CERASE},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CESC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CESC", CESC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CFLUSH
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CFLUSH", CFLUSH},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CINTR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CINTR", CINTR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CKILL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CKILL", CKILL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CLNEXT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CLNEXT", CLNEXT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CNUL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CNUL", CNUL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef COMMON
|
2010-05-09 12:52:27 -03:00
|
|
|
{"COMMON", COMMON},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CQUIT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CQUIT", CQUIT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CRPRNT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CRPRNT", CRPRNT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CSTART
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CSTART", CSTART},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CSTOP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CSTOP", CSTOP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CSUSP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CSUSP", CSUSP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CSWTCH
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CSWTCH", CSWTCH},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef CWERASE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"CWERASE", CWERASE},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef EXTA
|
2010-05-09 12:52:27 -03:00
|
|
|
{"EXTA", EXTA},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef EXTB
|
2010-05-09 12:52:27 -03:00
|
|
|
{"EXTB", EXTB},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FIOASYNC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FIOASYNC", FIOASYNC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FIOCLEX
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FIOCLEX", FIOCLEX},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FIONBIO
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FIONBIO", FIONBIO},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FIONCLEX
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FIONCLEX", FIONCLEX},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef FIONREAD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"FIONREAD", FIONREAD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef IBSHIFT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IBSHIFT", IBSHIFT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef INIT_C_CC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"INIT_C_CC", INIT_C_CC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef IOCSIZE_MASK
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IOCSIZE_MASK", IOCSIZE_MASK},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef IOCSIZE_SHIFT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"IOCSIZE_SHIFT", IOCSIZE_SHIFT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef NCC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NCC", NCC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef NCCS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NCCS", NCCS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef NSWTCH
|
2010-05-09 12:52:27 -03:00
|
|
|
{"NSWTCH", NSWTCH},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef N_MOUSE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"N_MOUSE", N_MOUSE},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef N_PPP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"N_PPP", N_PPP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef N_SLIP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"N_SLIP", N_SLIP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef N_STRIP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"N_STRIP", N_STRIP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef N_TTY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"N_TTY", N_TTY},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCFLSH
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCFLSH", TCFLSH},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCGETA
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCGETA", TCGETA},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCGETS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCGETS", TCGETS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSBRK
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSBRK", TCSBRK},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSBRKP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSBRKP", TCSBRKP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETA
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETA", TCSETA},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETAF
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETAF", TCSETAF},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETAW
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETAW", TCSETAW},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETS", TCSETS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETSF
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETSF", TCSETSF},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCSETSW
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCSETSW", TCSETSW},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TCXONC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TCXONC", TCXONC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCCONS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCCONS", TIOCCONS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCEXCL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCEXCL", TIOCEXCL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGETD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGETD", TIOCGETD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGICOUNT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGICOUNT", TIOCGICOUNT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGLCKTRMIOS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGLCKTRMIOS", TIOCGLCKTRMIOS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGPGRP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGPGRP", TIOCGPGRP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGSERIAL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGSERIAL", TIOCGSERIAL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGSOFTCAR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGSOFTCAR", TIOCGSOFTCAR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCGWINSZ
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCGWINSZ", TIOCGWINSZ},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCINQ
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCINQ", TIOCINQ},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCLINUX
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCLINUX", TIOCLINUX},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCMBIC
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCMBIC", TIOCMBIC},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCMBIS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCMBIS", TIOCMBIS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCMGET
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCMGET", TIOCMGET},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCMIWAIT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCMIWAIT", TIOCMIWAIT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCMSET
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCMSET", TIOCMSET},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_CAR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_CAR", TIOCM_CAR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_CD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_CD", TIOCM_CD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_CTS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_CTS", TIOCM_CTS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_DSR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_DSR", TIOCM_DSR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_DTR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_DTR", TIOCM_DTR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_LE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_LE", TIOCM_LE},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_RI
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_RI", TIOCM_RI},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_RNG
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_RNG", TIOCM_RNG},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_RTS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_RTS", TIOCM_RTS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_SR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_SR", TIOCM_SR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCM_ST
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCM_ST", TIOCM_ST},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCNOTTY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCNOTTY", TIOCNOTTY},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCNXCL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCNXCL", TIOCNXCL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCOUTQ
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCOUTQ", TIOCOUTQ},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT", TIOCPKT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_DATA
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_DATA", TIOCPKT_DATA},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_DOSTOP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_DOSTOP", TIOCPKT_DOSTOP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_FLUSHREAD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_FLUSHREAD", TIOCPKT_FLUSHREAD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_FLUSHWRITE
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_FLUSHWRITE", TIOCPKT_FLUSHWRITE},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_NOSTOP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_NOSTOP", TIOCPKT_NOSTOP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_START
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_START", TIOCPKT_START},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCPKT_STOP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCPKT_STOP", TIOCPKT_STOP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSCTTY
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSCTTY", TIOCSCTTY},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERCONFIG
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERCONFIG", TIOCSERCONFIG},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERGETLSR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERGETLSR", TIOCSERGETLSR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERGETMULTI
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERGETMULTI", TIOCSERGETMULTI},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERGSTRUCT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERGSTRUCT", TIOCSERGSTRUCT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERGWILD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERGWILD", TIOCSERGWILD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERSETMULTI
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERSETMULTI", TIOCSERSETMULTI},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSERSWILD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSERSWILD", TIOCSERSWILD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSER_TEMT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSER_TEMT", TIOCSER_TEMT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSETD
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSETD", TIOCSETD},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSLCKTRMIOS
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSLCKTRMIOS", TIOCSLCKTRMIOS},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSPGRP
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSPGRP", TIOCSPGRP},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSSERIAL
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSSERIAL", TIOCSSERIAL},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSSOFTCAR
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSSOFTCAR", TIOCSSOFTCAR},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSTI
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSTI", TIOCSTI},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCSWINSZ
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCSWINSZ", TIOCSWINSZ},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
#ifdef TIOCTTYGSTRUCT
|
2010-05-09 12:52:27 -03:00
|
|
|
{"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},
|
2001-03-26 13:14:02 -04:00
|
|
|
#endif
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
/* sentinel */
|
|
|
|
{NULL, 0}
|
2001-02-27 17:22:39 -04:00
|
|
|
};
|
|
|
|
|
2019-09-10 07:33:30 -03:00
|
|
|
static int termiosmodule_traverse(PyObject *m, visitproc visit, void *arg) {
|
2020-03-16 10:15:01 -03:00
|
|
|
Py_VISIT(get_termios_state(m)->TermiosError);
|
2019-09-10 07:33:30 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int termiosmodule_clear(PyObject *m) {
|
2020-03-16 10:15:01 -03:00
|
|
|
Py_CLEAR(get_termios_state(m)->TermiosError);
|
2019-09-10 07:33:30 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void termiosmodule_free(void *m) {
|
|
|
|
termiosmodule_clear((PyObject *)m);
|
|
|
|
}
|
2001-02-27 17:22:39 -04:00
|
|
|
|
2008-06-11 02:26:20 -03:00
|
|
|
static struct PyModuleDef termiosmodule = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
"termios",
|
|
|
|
termios__doc__,
|
2019-09-10 07:33:30 -03:00
|
|
|
sizeof(termiosmodulestate),
|
2010-05-09 12:52:27 -03:00
|
|
|
termios_methods,
|
|
|
|
NULL,
|
2019-09-10 07:33:30 -03:00
|
|
|
termiosmodule_traverse,
|
|
|
|
termiosmodule_clear,
|
|
|
|
termiosmodule_free,
|
2008-06-11 02:26:20 -03:00
|
|
|
};
|
|
|
|
|
2002-08-01 23:27:13 -03:00
|
|
|
PyMODINIT_FUNC
|
2000-07-21 03:00:07 -03:00
|
|
|
PyInit_termios(void)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *m;
|
|
|
|
struct constant *constant = termios_constants;
|
|
|
|
|
2019-09-10 07:33:30 -03:00
|
|
|
if ((m = PyState_FindModule(&termiosmodule)) != NULL) {
|
|
|
|
Py_INCREF(m);
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((m = PyModule_Create(&termiosmodule)) == NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2019-09-10 07:33:30 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2020-03-16 10:15:01 -03:00
|
|
|
termiosmodulestate *state = get_termios_state(m);
|
2019-09-10 07:33:30 -03:00
|
|
|
state->TermiosError = PyErr_NewException("termios.error", NULL, NULL);
|
|
|
|
if (state->TermiosError == NULL) {
|
|
|
|
return NULL;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2019-09-10 07:33:30 -03:00
|
|
|
Py_INCREF(state->TermiosError);
|
|
|
|
PyModule_AddObject(m, "error", state->TermiosError);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
while (constant->name != NULL) {
|
|
|
|
PyModule_AddIntConstant(m, constant->name, constant->value);
|
|
|
|
++constant;
|
|
|
|
}
|
|
|
|
return m;
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|