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