2020-08-16 12:51:00 -03:00
|
|
|
/* termios.c -- POSIX terminal I/O module implementation. */
|
1994-09-12 07:41:22 -03:00
|
|
|
|
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
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
module termios
|
|
|
|
[clinic start generated code]*/
|
|
|
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=01105c85d0ca7252]*/
|
|
|
|
|
|
|
|
#include "clinic/termios.c.h"
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-09-10 07:33:30 -03:00
|
|
|
static struct PyModuleDef termiosmodule;
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcgetattr
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
/
|
|
|
|
|
|
|
|
Get the tty attributes for file descriptor fd.
|
|
|
|
|
|
|
|
Returns a list [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
|
|
|
|
where cc is a list of the tty special characters (each a string of
|
|
|
|
length 1, except the items with indices VMIN and VTIME, which are
|
|
|
|
integers when these fields are defined). The interpretation of the
|
|
|
|
flags and the speeds as well as the indexing in the cc array must be
|
|
|
|
done using the symbolic constants defined in this module.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcgetattr_impl(PyObject *module, int fd)
|
|
|
|
/*[clinic end generated code: output=2b3da39db870e629 input=54dad9779ebe74b1]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
|
|
|
struct termios mode;
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2023-05-08 11:03:52 -03:00
|
|
|
r = tcgetattr(fd, &mode);
|
2022-11-22 06:14:23 -04:00
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (r == -1) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2020-09-08 05:59:15 -03:00
|
|
|
speed_t ispeed = cfgetispeed(&mode);
|
|
|
|
speed_t ospeed = cfgetospeed(&mode);
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2020-09-08 05:59:15 -03:00
|
|
|
PyObject *cc = PyList_New(NCCS);
|
|
|
|
if (cc == NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2020-09-08 05:59:15 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *v;
|
|
|
|
int i;
|
2010-05-09 12:52:27 -03:00
|
|
|
for (i = 0; i < NCCS; i++) {
|
2020-09-08 05:59:15 -03:00
|
|
|
char ch = (char)mode.c_cc[i];
|
2010-05-09 12:52:27 -03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcsetattr
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
when: int
|
|
|
|
attributes as term: object
|
|
|
|
/
|
|
|
|
|
|
|
|
Set the tty attributes for file descriptor fd.
|
|
|
|
|
|
|
|
The attributes to be set are taken from the attributes argument, which
|
|
|
|
is a list like the one returned by tcgetattr(). The when argument
|
|
|
|
determines when the attributes are changed: termios.TCSANOW to
|
|
|
|
change immediately, termios.TCSADRAIN to change after transmitting all
|
|
|
|
queued output, or termios.TCSAFLUSH to change after transmitting all
|
|
|
|
queued output and discarding all queued input.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term)
|
|
|
|
/*[clinic end generated code: output=bcd2b0a7b98a4bf5 input=5dafabdd5a08f018]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
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... */
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
|
|
|
struct termios mode;
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcgetattr(fd, &mode);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (r == -1) {
|
2019-09-10 07:33:30 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
2020-09-08 05:59:15 -03:00
|
|
|
}
|
|
|
|
|
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));
|
2020-09-08 05:59:15 -03:00
|
|
|
speed_t ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4));
|
|
|
|
speed_t ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5));
|
|
|
|
PyObject *cc = PyList_GetItem(term, 6);
|
|
|
|
if (PyErr_Occurred()) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2020-09-08 05:59:15 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"tcsetattr: attributes[6] must be %d element list",
|
|
|
|
NCCS);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-09-08 05:59:15 -03:00
|
|
|
int i;
|
|
|
|
PyObject *v;
|
2010-05-09 12:52:27 -03:00
|
|
|
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);
|
2022-11-22 06:14:23 -04:00
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcsetattr(fd, when, &mode);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -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
|
|
|
}
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcsendbreak
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
duration: int
|
|
|
|
/
|
|
|
|
|
|
|
|
Send a break on file descriptor fd.
|
|
|
|
|
|
|
|
A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration
|
|
|
|
has a system dependent meaning.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcsendbreak_impl(PyObject *module, int fd, int duration)
|
|
|
|
/*[clinic end generated code: output=5945f589b5d3ac66 input=dc2f32417691f8ed]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcsendbreak(fd, duration);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return PyErr_SetFromErrno(state->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
|
|
|
}
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcdrain
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
/
|
|
|
|
|
|
|
|
Wait until all output written to file descriptor fd has been transmitted.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcdrain_impl(PyObject *module, int fd)
|
|
|
|
/*[clinic end generated code: output=5fd86944c6255955 input=c99241b140b32447]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcdrain(fd);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return PyErr_SetFromErrno(state->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
|
|
|
}
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcflush
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
queue: int
|
|
|
|
/
|
|
|
|
|
|
|
|
Discard queued data on file descriptor fd.
|
|
|
|
|
|
|
|
The queue selector specifies which queue: termios.TCIFLUSH for the input
|
|
|
|
queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for
|
|
|
|
both queues.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcflush_impl(PyObject *module, int fd, int queue)
|
|
|
|
/*[clinic end generated code: output=2424f80312ec2f21 input=0f7d08122ddc07b5]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcflush(fd, queue);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return PyErr_SetFromErrno(state->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
|
|
|
}
|
|
|
|
|
2020-10-18 11:54:06 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcflow
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
action: int
|
|
|
|
/
|
|
|
|
|
|
|
|
Suspend or resume input or output on file descriptor fd.
|
|
|
|
|
|
|
|
The action argument can be termios.TCOOFF to suspend output,
|
|
|
|
termios.TCOON to restart output, termios.TCIOFF to suspend input,
|
|
|
|
or termios.TCION to restart input.
|
|
|
|
[clinic start generated code]*/
|
1998-03-03 18:10:18 -04:00
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyObject *
|
2020-10-18 11:54:06 -03:00
|
|
|
termios_tcflow_impl(PyObject *module, int fd, int action)
|
|
|
|
/*[clinic end generated code: output=afd10928e6ea66eb input=c6aff0640b6efd9c]*/
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = tcflow(fd, action);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return PyErr_SetFromErrno(state->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
|
|
|
}
|
|
|
|
|
2021-08-26 23:56:26 -03:00
|
|
|
/*[clinic input]
|
|
|
|
termios.tcgetwinsize
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
/
|
|
|
|
|
|
|
|
Get the tty winsize for file descriptor fd.
|
|
|
|
|
|
|
|
Returns a tuple (ws_row, ws_col).
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
termios_tcgetwinsize_impl(PyObject *module, int fd)
|
|
|
|
/*[clinic end generated code: output=31825977d5325fb6 input=5706c379d7fd984d]*/
|
|
|
|
{
|
|
|
|
#if defined(TIOCGWINSZ)
|
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
|
|
|
struct winsize w;
|
2023-05-08 11:03:52 -03:00
|
|
|
int r;
|
2022-11-22 06:14:23 -04:00
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = ioctl(fd, TIOCGWINSZ, &w);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2021-08-26 23:56:26 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *v;
|
|
|
|
if (!(v = PyTuple_New(2))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyTuple_SetItem(v, 0, PyLong_FromLong((long)w.ws_row));
|
|
|
|
PyTuple_SetItem(v, 1, PyLong_FromLong((long)w.ws_col));
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
Py_DECREF(v);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
#elif defined(TIOCGSIZE)
|
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
|
|
|
struct ttysize s;
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = ioctl(fd, TIOCGSIZE, &s);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
if (r == -1) {
|
2021-08-26 23:56:26 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *v;
|
|
|
|
if (!(v = PyTuple_New(2))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyTuple_SetItem(v, 0, PyLong_FromLong((long)s.ts_lines));
|
|
|
|
PyTuple_SetItem(v, 1, PyLong_FromLong((long)s.ts_cols));
|
|
|
|
if (PyErr_Occurred()) {
|
|
|
|
Py_DECREF(v);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
#else
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"requires termios.TIOCGWINSZ and/or termios.TIOCGSIZE");
|
|
|
|
return NULL;
|
|
|
|
#endif /* defined(TIOCGWINSZ) */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*[clinic input]
|
|
|
|
termios.tcsetwinsize
|
|
|
|
|
|
|
|
fd: fildes
|
|
|
|
winsize as winsz: object
|
|
|
|
/
|
|
|
|
|
|
|
|
Set the tty winsize for file descriptor fd.
|
|
|
|
|
|
|
|
The winsize to be set is taken from the winsize argument, which
|
|
|
|
is a two-item tuple (ws_row, ws_col) like the one returned by tcgetwinsize().
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz)
|
|
|
|
/*[clinic end generated code: output=2ac3c9bb6eda83e1 input=4a06424465b24aee]*/
|
|
|
|
{
|
|
|
|
if (!PySequence_Check(winsz) || PySequence_Size(winsz) != 2) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"tcsetwinsize, arg 2: must be a two-item sequence");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *tmp_item;
|
|
|
|
long winsz_0, winsz_1;
|
|
|
|
tmp_item = PySequence_GetItem(winsz, 0);
|
|
|
|
winsz_0 = PyLong_AsLong(tmp_item);
|
|
|
|
if (winsz_0 == -1 && PyErr_Occurred()) {
|
|
|
|
Py_XDECREF(tmp_item);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_XDECREF(tmp_item);
|
|
|
|
tmp_item = PySequence_GetItem(winsz, 1);
|
2021-10-03 10:58:14 -03:00
|
|
|
winsz_1 = PyLong_AsLong(tmp_item);
|
2021-08-26 23:56:26 -03:00
|
|
|
if (winsz_1 == -1 && PyErr_Occurred()) {
|
|
|
|
Py_XDECREF(tmp_item);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_XDECREF(tmp_item);
|
|
|
|
|
|
|
|
termiosmodulestate *state = PyModule_GetState(module);
|
|
|
|
|
|
|
|
#if defined(TIOCGWINSZ) && defined(TIOCSWINSZ)
|
|
|
|
struct winsize w;
|
|
|
|
/* Get the old winsize because it might have
|
|
|
|
more fields such as xpixel, ypixel. */
|
|
|
|
if (ioctl(fd, TIOCGWINSZ, &w) == -1) {
|
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
w.ws_row = (unsigned short) winsz_0;
|
|
|
|
w.ws_col = (unsigned short) winsz_1;
|
|
|
|
if ((((long)w.ws_row) != winsz_0) || (((long)w.ws_col) != winsz_1)) {
|
|
|
|
PyErr_SetString(PyExc_OverflowError,
|
|
|
|
"winsize value(s) out of range.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = ioctl(fd, TIOCSWINSZ, &w);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2021-08-26 23:56:26 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
#elif defined(TIOCGSIZE) && defined(TIOCSSIZE)
|
|
|
|
struct ttysize s;
|
2022-11-22 06:14:23 -04:00
|
|
|
int r;
|
2021-08-26 23:56:26 -03:00
|
|
|
/* Get the old ttysize because it might have more fields. */
|
2022-11-22 06:14:23 -04:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = ioctl(fd, TIOCGSIZE, &s);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2021-08-26 23:56:26 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
s.ts_lines = (int) winsz_0;
|
|
|
|
s.ts_cols = (int) winsz_1;
|
|
|
|
if ((((long)s.ts_lines) != winsz_0) || (((long)s.ts_cols) != winsz_1)) {
|
|
|
|
PyErr_SetString(PyExc_OverflowError,
|
|
|
|
"winsize value(s) out of range.");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-11-22 06:14:23 -04:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
|
|
|
r = ioctl(fd, TIOCSSIZE, &s);
|
|
|
|
Py_END_ALLOW_THREADS
|
|
|
|
|
|
|
|
if (r == -1) {
|
2021-08-26 23:56:26 -03:00
|
|
|
return PyErr_SetFromErrno(state->TermiosError);
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
#else
|
|
|
|
PyErr_SetString(PyExc_NotImplementedError,
|
|
|
|
"requires termios.TIOCGWINSZ, termios.TIOCSWINSZ and/or termios.TIOCGSIZE, termios.TIOCSSIZE");
|
|
|
|
return NULL;
|
|
|
|
#endif /* defined(TIOCGWINSZ) && defined(TIOCSWINSZ) */
|
|
|
|
}
|
|
|
|
|
1994-09-12 07:41:22 -03:00
|
|
|
static PyMethodDef termios_methods[] =
|
|
|
|
{
|
2020-10-18 11:54:06 -03:00
|
|
|
TERMIOS_TCGETATTR_METHODDEF
|
|
|
|
TERMIOS_TCSETATTR_METHODDEF
|
|
|
|
TERMIOS_TCSENDBREAK_METHODDEF
|
|
|
|
TERMIOS_TCDRAIN_METHODDEF
|
|
|
|
TERMIOS_TCFLUSH_METHODDEF
|
|
|
|
TERMIOS_TCFLOW_METHODDEF
|
2021-08-26 23:56:26 -03:00
|
|
|
TERMIOS_TCGETWINSIZE_METHODDEF
|
|
|
|
TERMIOS_TCSETWINSIZE_METHODDEF
|
2010-05-09 12:52:27 -03:00
|
|
|
{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
|
2021-08-26 23:56:26 -03:00
|
|
|
#ifdef TIOCGSIZE
|
|
|
|
{"TIOCGSIZE", TIOCGSIZE},
|
|
|
|
#endif
|
2001-03-26 13:14:02 -04:00
|
|
|
#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
|
2021-08-26 23:56:26 -03:00
|
|
|
#ifdef TIOCSSIZE
|
|
|
|
{"TIOCSSIZE", TIOCSSIZE},
|
|
|
|
#endif
|
2001-03-26 13:14:02 -04:00
|
|
|
#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
|
|
|
|
2021-08-09 15:32:54 -03:00
|
|
|
static int
|
2020-09-08 05:59:15 -03:00
|
|
|
termios_exec(PyObject *mod)
|
1994-09-12 07:41:22 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
struct constant *constant = termios_constants;
|
2020-09-08 05:59:15 -03:00
|
|
|
termiosmodulestate *state = get_termios_state(mod);
|
2019-09-10 07:33:30 -03:00
|
|
|
state->TermiosError = PyErr_NewException("termios.error", NULL, NULL);
|
2023-07-25 08:34:49 -03:00
|
|
|
if (PyModule_AddObjectRef(mod, "error", state->TermiosError) < 0) {
|
2020-09-08 05:59:15 -03:00
|
|
|
return -1;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
while (constant->name != NULL) {
|
2020-09-08 05:59:15 -03:00
|
|
|
if (PyModule_AddIntConstant(
|
|
|
|
mod, constant->name, constant->value) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
++constant;
|
|
|
|
}
|
2020-09-08 05:59:15 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyModuleDef_Slot termios_slots[] = {
|
|
|
|
{Py_mod_exec, termios_exec},
|
2023-05-05 18:11:27 -03:00
|
|
|
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
|
2020-09-08 05:59:15 -03:00
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct PyModuleDef termiosmodule = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
|
|
|
.m_name = "termios",
|
|
|
|
.m_doc = termios__doc__,
|
|
|
|
.m_size = sizeof(termiosmodulestate),
|
|
|
|
.m_methods = termios_methods,
|
|
|
|
.m_slots = termios_slots,
|
|
|
|
.m_traverse = termiosmodule_traverse,
|
|
|
|
.m_clear = termiosmodule_clear,
|
|
|
|
.m_free = termiosmodule_free,
|
|
|
|
};
|
|
|
|
|
|
|
|
PyMODINIT_FUNC PyInit_termios(void)
|
|
|
|
{
|
|
|
|
return PyModuleDef_Init(&termiosmodule);
|
1994-09-12 07:41:22 -03:00
|
|
|
}
|