Mercurial > cpython-lru_cache-weakref
annotate Modules/termios.c @ 16798:258dcafe2d0b legacy-trunk
Gustavo Niemeyer <niemeyer@conectiva.com>:
Fixed recno support (keys are integers rather than strings).
Work around DB bug that cause stdin to be closed by rnopen() when the
DB file needed to exist but did not (no longer segfaults).
This closes SF tracker patch #403445.
Also wrapped some long lines and added whitespace around operators -- FLD.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 27 Feb 2001 18:56:46 +0000 |
| parents | 8bd82cf361aa |
| children | b2585d8fdb8b |
| rev | line source |
|---|---|
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* termiosmodule.c -- POSIX terminal I/O module implementation. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
9887
ae908ef91cf0
Should include "Python.h", not <Python.h> -- it's not a standard
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
3 #include "Python.h" |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 #define PyInit_termios inittermios |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 #include <termios.h> |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
9 static char termios__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
10 This module provides an interface to the Posix calls for tty I/O control.\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
11 For a complete description of these calls, see the Posix or Unix manual\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
12 pages. It is only available for those Unix versions that support Posix\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
13 termios style tty I/O control (and then only if configured at installation\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
14 time).\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
15 \n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
16 All functions in this module take a file descriptor fd as their first\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
17 argument. This must be an integer file descriptor, such as returned by\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
18 sys.stdin.fileno().\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
19 \n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
20 This module should be used in conjunction with the TERMIOS module,\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
21 which defines the relevant symbolic constants."; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
22 |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
23 |
|
8823
f2a4a2b60860
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8494
diff
changeset
|
24 #ifdef __BEOS__ |
|
f2a4a2b60860
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8494
diff
changeset
|
25 #include <unistd.h> |
|
f2a4a2b60860
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8494
diff
changeset
|
26 #endif |
|
f2a4a2b60860
Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
8494
diff
changeset
|
27 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #define BAD "bad termios argument" |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 static PyObject *TermiosError; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 /* termios = tcgetattr(fd) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 termios is |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 [iflag, oflag, cflag, lflag, ispeed, ospeed, [cc[0], ..., cc[NCCS]]] |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 Return the attributes of the terminal device. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
38 static char termios_tcgetattr__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
39 tcgetattr(fd) -> list_of_attrs\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
40 Get the tty attributes for file descriptor fd, as follows:\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
41 [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
42 of the tty special characters (each a string of length 1, except the items\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
43 with indices VMIN and VTIME, which are integers when these fields are\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
44 defined). The interpretation of the flags and the speeds as well as the\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
45 indexing in the cc array must be done using the symbolic constants defined\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
46 in the TERMIOS module."; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
47 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 static PyObject * |
| 13501 | 49 termios_tcgetattr(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 int fd; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 struct termios mode; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 PyObject *cc; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 speed_t ispeed, ospeed; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 PyObject *v; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 int i; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 char ch; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 if (!PyArg_Parse(args, "i", &fd)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 if (tcgetattr(fd, &mode) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
63 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 ispeed = cfgetispeed(&mode); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 ospeed = cfgetospeed(&mode); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 cc = PyList_New(NCCS); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 if (cc == NULL) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 for (i = 0; i < NCCS; i++) { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 ch = (char)mode.c_cc[i]; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 v = PyString_FromStringAndSize(&ch, 1); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 if (v == NULL) |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
75 goto err; |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 PyList_SetItem(cc, i, v); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 /* Convert the MIN and TIME slots to integer. On some systems, the |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 MIN and TIME slots are the same as the EOF and EOL slots. So we |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 only do this in noncanonical input mode. */ |
|
4653
3b7cd83b602d
Fix operator priority bug found thanks to gcc -Wall.
Guido van Rossum <guido@python.org>
parents:
1888
diff
changeset
|
82 if ((mode.c_lflag & ICANON) == 0) { |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 v = PyInt_FromLong((long)mode.c_cc[VMIN]); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 if (v == NULL) |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
85 goto err; |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 PyList_SetItem(cc, VMIN, v); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 v = PyInt_FromLong((long)mode.c_cc[VTIME]); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 if (v == NULL) |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
89 goto err; |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 PyList_SetItem(cc, VTIME, v); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
93 if (!(v = PyList_New(7))) |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
94 goto err; |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
95 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 PyList_SetItem(v, 6, cc); |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
103 if (PyErr_Occurred()){ |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
104 Py_DECREF(v); |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
105 goto err; |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
106 } |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 return v; |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
108 err: |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
109 Py_DECREF(cc); |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
110 return NULL; |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 /* tcsetattr(fd, when, termios) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 Set the attributes of the terminal device. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
116 static char termios_tcsetattr__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
117 tcsetattr(fd, when, attributes) -> None\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
118 Set the tty attributes for file descriptor fd.\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
119 The attributes to be set are taken from the attributes argument, which\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
120 is a list like the one returned by tcgetattr(). The when argument\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
121 determines when the attributes are changed: TERMIOS.TCSANOW to\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
122 change immediately, TERMIOS.TCSADRAIN to change after transmitting all\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
123 queued output, or TERMIOS.TCSAFLUSH to change after transmitting all\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
124 queued output and discarding all queued input. "; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
125 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 static PyObject * |
| 13501 | 127 termios_tcsetattr(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 int fd, when; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 struct termios mode; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 speed_t ispeed, ospeed; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 PyObject *term, *cc, *v; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 int i; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 if (!PyArg_Parse(args, "(iiO)", &fd, &when, &term)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 if (!PyList_Check(term) || PyList_Size(term) != 7) { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 PyErr_SetString(PyExc_TypeError, BAD); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 |
|
8494
fc29625df532
In tcsetattr(), first initialize the mode structure by calling
Guido van Rossum <guido@python.org>
parents:
7531
diff
changeset
|
142 /* Get the old mode, in case there are any hidden fields... */ |
|
fc29625df532
In tcsetattr(), first initialize the mode structure by calling
Guido van Rossum <guido@python.org>
parents:
7531
diff
changeset
|
143 if (tcgetattr(fd, &mode) == -1) |
|
fc29625df532
In tcsetattr(), first initialize the mode structure by calling
Guido van Rossum <guido@python.org>
parents:
7531
diff
changeset
|
144 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5)); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 cc = PyList_GetItem(term, 6); |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
152 if (PyErr_Occurred()) |
|
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
153 return NULL; |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 if (!PyList_Check(cc) || PyList_Size(cc) != NCCS) { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 PyErr_SetString(PyExc_TypeError, BAD); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 for (i = 0; i < NCCS; i++) { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 v = PyList_GetItem(cc, i); |
|
4928
9be65e6c35c8
The usual return-value and memory management checks. I'm not planning
Barry Warsaw <barry@python.org>
parents:
4653
diff
changeset
|
162 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 if (PyString_Check(v) && PyString_Size(v) == 1) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 mode.c_cc[i] = (cc_t) * PyString_AsString(v); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 else if (PyInt_Check(v)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 mode.c_cc[i] = (cc_t) PyInt_AsLong(v); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 else { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 PyErr_SetString(PyExc_TypeError, BAD); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 if (cfsetispeed(&mode, (speed_t) ispeed) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
174 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 if (cfsetospeed(&mode, (speed_t) ospeed) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
176 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 if (tcsetattr(fd, when, &mode) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
178 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 Py_INCREF(Py_None); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 return Py_None; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 /* tcsendbreak(fd, duration) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 Generate a break condition. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
187 static char termios_tcsendbreak__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
188 tcsendbreak(fd, duration) -> None\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
189 Send a break on file descriptor fd.\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
190 A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration \n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
191 has a system dependent meaning. "; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
192 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 static PyObject * |
| 13501 | 194 termios_tcsendbreak(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 int fd, duration; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 if (!PyArg_Parse(args, "(ii)", &fd, &duration)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 if (tcsendbreak(fd, duration) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
201 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 Py_INCREF(Py_None); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 return Py_None; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 /* tcdrain(fd) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 Wait until all queued output to the terminal has been |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 transmitted. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
211 static char termios_tcdrain__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
212 tcdrain(fd) -> None\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
213 Wait until all output written to file descriptor fd has been transmitted. "; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
214 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 static PyObject * |
| 13501 | 216 termios_tcdrain(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 int fd; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 if (!PyArg_Parse(args, "i", &fd)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 if (tcdrain(fd) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
223 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 Py_INCREF(Py_None); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 return Py_None; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 /* tcflush(fd, queue) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 Clear the input and/or output queues associated with |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 the terminal. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
233 static char termios_tcflush__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
234 tcflush(fd, queue) -> None\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
235 Discard queued data on file descriptor fd.\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
236 The queue selector specifies which queue: TERMIOS.TCIFLUSH for the input\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
237 queue, TERMIOS.TCOFLUSH for the output queue, or TERMIOS.TCIOFLUSH for\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
238 both queues. "; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
239 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 static PyObject * |
| 13501 | 241 termios_tcflush(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 int fd, queue; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 if (!PyArg_Parse(args, "(ii)", &fd, &queue)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 if (tcflush(fd, queue) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
248 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 Py_INCREF(Py_None); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 return Py_None; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 /* tcflow(fd, action) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 Perform operations relating to XON/XOFF flow control on |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 the terminal. */ |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
257 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
258 static char termios_tcflow__doc__[] = "\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
259 tcflow(fd, action) -> None\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
260 Suspend or resume input or output on file descriptor fd.\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
261 The action argument can be TERMIOS.TCOOFF to suspend output,\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
262 TERMIOS.TCOON to restart output, TERMIOS.TCIOFF to suspend input,\n\ |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
263 or TERMIOS.TCION to restart input. "; |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
264 |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 static PyObject * |
| 13501 | 266 termios_tcflow(PyObject *self, PyObject *args) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 int fd, action; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 if (!PyArg_Parse(args, "(ii)", &fd, &action)) |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
271 return NULL; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
272 if (tcflow(fd, action) == -1) |
|
5827
a79d0cef10a1
Add 'return' keyword before error calls.
Guido van Rossum <guido@python.org>
parents:
4928
diff
changeset
|
273 return PyErr_SetFromErrno(TermiosError); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
274 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
275 Py_INCREF(Py_None); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
276 return Py_None; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
277 } |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
278 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
279 static PyMethodDef termios_methods[] = |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
280 { |
|
13820
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
281 {"tcgetattr", termios_tcgetattr, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
282 METH_OLDARGS, termios_tcgetattr__doc__}, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
283 {"tcsetattr", termios_tcsetattr, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
284 METH_OLDARGS, termios_tcsetattr__doc__}, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
285 {"tcsendbreak", termios_tcsendbreak, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
286 METH_OLDARGS, termios_tcsendbreak__doc__}, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
287 {"tcdrain", termios_tcdrain, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
288 METH_OLDARGS, termios_tcdrain__doc__}, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
289 {"tcflush", termios_tcflush, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
290 METH_OLDARGS, termios_tcflush__doc__}, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
291 {"tcflow", termios_tcflow, |
|
8bd82cf361aa
Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents:
13651
diff
changeset
|
292 METH_OLDARGS, termios_tcflow__doc__}, |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
293 {NULL, NULL} |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
294 }; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
295 |
|
9588
38023a425e48
Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents:
8823
diff
changeset
|
296 DL_EXPORT(void) |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13501
diff
changeset
|
297 PyInit_termios(void) |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
298 { |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
299 PyObject *m, *d; |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
300 |
|
7531
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
301 m = Py_InitModule4("termios", termios_methods, termios__doc__, |
|
b4660ad7dc41
Doc strings added by Mitch Chapman.
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
302 (PyObject *)NULL, PYTHON_API_VERSION); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
304 d = PyModule_GetDict(m); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
5827
diff
changeset
|
305 TermiosError = PyErr_NewException("termios.error", NULL, NULL); |
|
1879
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
306 PyDict_SetItemString(d, "error", TermiosError); |
|
91bfb2771554
Steen Lumholt's termios interface.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
307 } |
