1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9
10
11 PyDoc_STRVAR(termios_tcgetattr__doc__,
12 "tcgetattr($module, fd, /)\n"
13 "--\n"
14 "\n"
15 "Get the tty attributes for file descriptor fd.\n"
16 "\n"
17 "Returns a list [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]\n"
18 "where cc is a list of the tty special characters (each a string of\n"
19 "length 1, except the items with indices VMIN and VTIME, which are\n"
20 "integers when these fields are defined). The interpretation of the\n"
21 "flags and the speeds as well as the indexing in the cc array must be\n"
22 "done using the symbolic constants defined in this module.");
23
24 #define TERMIOS_TCGETATTR_METHODDEF \
25 {"tcgetattr", (PyCFunction)termios_tcgetattr, METH_O, termios_tcgetattr__doc__},
26
27 static PyObject *
28 termios_tcgetattr_impl(PyObject *module, int fd);
29
30 static PyObject *
31 termios_tcgetattr(PyObject *module, PyObject *arg)
32 {
33 PyObject *return_value = NULL;
34 int fd;
35
36 if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
37 goto exit;
38 }
39 return_value = termios_tcgetattr_impl(module, fd);
40
41 exit:
42 return return_value;
43 }
44
45 PyDoc_STRVAR(termios_tcsetattr__doc__,
46 "tcsetattr($module, fd, when, attributes, /)\n"
47 "--\n"
48 "\n"
49 "Set the tty attributes for file descriptor fd.\n"
50 "\n"
51 "The attributes to be set are taken from the attributes argument, which\n"
52 "is a list like the one returned by tcgetattr(). The when argument\n"
53 "determines when the attributes are changed: termios.TCSANOW to\n"
54 "change immediately, termios.TCSADRAIN to change after transmitting all\n"
55 "queued output, or termios.TCSAFLUSH to change after transmitting all\n"
56 "queued output and discarding all queued input.");
57
58 #define TERMIOS_TCSETATTR_METHODDEF \
59 {"tcsetattr", _PyCFunction_CAST(termios_tcsetattr), METH_FASTCALL, termios_tcsetattr__doc__},
60
61 static PyObject *
62 termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term);
63
64 static PyObject *
65 termios_tcsetattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
66 {
67 PyObject *return_value = NULL;
68 int fd;
69 int when;
70 PyObject *term;
71
72 if (!_PyArg_CheckPositional("tcsetattr", nargs, 3, 3)) {
73 goto exit;
74 }
75 if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
76 goto exit;
77 }
78 when = _PyLong_AsInt(args[1]);
79 if (when == -1 && PyErr_Occurred()) {
80 goto exit;
81 }
82 term = args[2];
83 return_value = termios_tcsetattr_impl(module, fd, when, term);
84
85 exit:
86 return return_value;
87 }
88
89 PyDoc_STRVAR(termios_tcsendbreak__doc__,
90 "tcsendbreak($module, fd, duration, /)\n"
91 "--\n"
92 "\n"
93 "Send a break on file descriptor fd.\n"
94 "\n"
95 "A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n"
96 "has a system dependent meaning.");
97
98 #define TERMIOS_TCSENDBREAK_METHODDEF \
99 {"tcsendbreak", _PyCFunction_CAST(termios_tcsendbreak), METH_FASTCALL, termios_tcsendbreak__doc__},
100
101 static PyObject *
102 termios_tcsendbreak_impl(PyObject *module, int fd, int duration);
103
104 static PyObject *
105 termios_tcsendbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
106 {
107 PyObject *return_value = NULL;
108 int fd;
109 int duration;
110
111 if (!_PyArg_CheckPositional("tcsendbreak", nargs, 2, 2)) {
112 goto exit;
113 }
114 if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
115 goto exit;
116 }
117 duration = _PyLong_AsInt(args[1]);
118 if (duration == -1 && PyErr_Occurred()) {
119 goto exit;
120 }
121 return_value = termios_tcsendbreak_impl(module, fd, duration);
122
123 exit:
124 return return_value;
125 }
126
127 PyDoc_STRVAR(termios_tcdrain__doc__,
128 "tcdrain($module, fd, /)\n"
129 "--\n"
130 "\n"
131 "Wait until all output written to file descriptor fd has been transmitted.");
132
133 #define TERMIOS_TCDRAIN_METHODDEF \
134 {"tcdrain", (PyCFunction)termios_tcdrain, METH_O, termios_tcdrain__doc__},
135
136 static PyObject *
137 termios_tcdrain_impl(PyObject *module, int fd);
138
139 static PyObject *
140 termios_tcdrain(PyObject *module, PyObject *arg)
141 {
142 PyObject *return_value = NULL;
143 int fd;
144
145 if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
146 goto exit;
147 }
148 return_value = termios_tcdrain_impl(module, fd);
149
150 exit:
151 return return_value;
152 }
153
154 PyDoc_STRVAR(termios_tcflush__doc__,
155 "tcflush($module, fd, queue, /)\n"
156 "--\n"
157 "\n"
158 "Discard queued data on file descriptor fd.\n"
159 "\n"
160 "The queue selector specifies which queue: termios.TCIFLUSH for the input\n"
161 "queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n"
162 "both queues.");
163
164 #define TERMIOS_TCFLUSH_METHODDEF \
165 {"tcflush", _PyCFunction_CAST(termios_tcflush), METH_FASTCALL, termios_tcflush__doc__},
166
167 static PyObject *
168 termios_tcflush_impl(PyObject *module, int fd, int queue);
169
170 static PyObject *
171 termios_tcflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
172 {
173 PyObject *return_value = NULL;
174 int fd;
175 int queue;
176
177 if (!_PyArg_CheckPositional("tcflush", nargs, 2, 2)) {
178 goto exit;
179 }
180 if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
181 goto exit;
182 }
183 queue = _PyLong_AsInt(args[1]);
184 if (queue == -1 && PyErr_Occurred()) {
185 goto exit;
186 }
187 return_value = termios_tcflush_impl(module, fd, queue);
188
189 exit:
190 return return_value;
191 }
192
193 PyDoc_STRVAR(termios_tcflow__doc__,
194 "tcflow($module, fd, action, /)\n"
195 "--\n"
196 "\n"
197 "Suspend or resume input or output on file descriptor fd.\n"
198 "\n"
199 "The action argument can be termios.TCOOFF to suspend output,\n"
200 "termios.TCOON to restart output, termios.TCIOFF to suspend input,\n"
201 "or termios.TCION to restart input.");
202
203 #define TERMIOS_TCFLOW_METHODDEF \
204 {"tcflow", _PyCFunction_CAST(termios_tcflow), METH_FASTCALL, termios_tcflow__doc__},
205
206 static PyObject *
207 termios_tcflow_impl(PyObject *module, int fd, int action);
208
209 static PyObject *
210 termios_tcflow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
211 {
212 PyObject *return_value = NULL;
213 int fd;
214 int action;
215
216 if (!_PyArg_CheckPositional("tcflow", nargs, 2, 2)) {
217 goto exit;
218 }
219 if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
220 goto exit;
221 }
222 action = _PyLong_AsInt(args[1]);
223 if (action == -1 && PyErr_Occurred()) {
224 goto exit;
225 }
226 return_value = termios_tcflow_impl(module, fd, action);
227
228 exit:
229 return return_value;
230 }
231
232 PyDoc_STRVAR(termios_tcgetwinsize__doc__,
233 "tcgetwinsize($module, fd, /)\n"
234 "--\n"
235 "\n"
236 "Get the tty winsize for file descriptor fd.\n"
237 "\n"
238 "Returns a tuple (ws_row, ws_col).");
239
240 #define TERMIOS_TCGETWINSIZE_METHODDEF \
241 {"tcgetwinsize", (PyCFunction)termios_tcgetwinsize, METH_O, termios_tcgetwinsize__doc__},
242
243 static PyObject *
244 termios_tcgetwinsize_impl(PyObject *module, int fd);
245
246 static PyObject *
247 termios_tcgetwinsize(PyObject *module, PyObject *arg)
248 {
249 PyObject *return_value = NULL;
250 int fd;
251
252 if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
253 goto exit;
254 }
255 return_value = termios_tcgetwinsize_impl(module, fd);
256
257 exit:
258 return return_value;
259 }
260
261 PyDoc_STRVAR(termios_tcsetwinsize__doc__,
262 "tcsetwinsize($module, fd, winsize, /)\n"
263 "--\n"
264 "\n"
265 "Set the tty winsize for file descriptor fd.\n"
266 "\n"
267 "The winsize to be set is taken from the winsize argument, which\n"
268 "is a two-item tuple (ws_row, ws_col) like the one returned by tcgetwinsize().");
269
270 #define TERMIOS_TCSETWINSIZE_METHODDEF \
271 {"tcsetwinsize", _PyCFunction_CAST(termios_tcsetwinsize), METH_FASTCALL, termios_tcsetwinsize__doc__},
272
273 static PyObject *
274 termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz);
275
276 static PyObject *
277 termios_tcsetwinsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
278 {
279 PyObject *return_value = NULL;
280 int fd;
281 PyObject *winsz;
282
283 if (!_PyArg_CheckPositional("tcsetwinsize", nargs, 2, 2)) {
284 goto exit;
285 }
286 if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
287 goto exit;
288 }
289 winsz = args[1];
290 return_value = termios_tcsetwinsize_impl(module, fd, winsz);
291
292 exit:
293 return return_value;
294 }
295 /*[clinic end generated code: output=d286a3906a051869 input=a9049054013a1b77]*/