• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(msvcrt_heapmin__doc__,
6 "heapmin($module, /)\n"
7 "--\n"
8 "\n"
9 "Minimize the malloc() heap.\n"
10 "\n"
11 "Force the malloc() heap to clean itself up and return unused blocks\n"
12 "to the operating system. On failure, this raises OSError.");
13 
14 #define MSVCRT_HEAPMIN_METHODDEF    \
15     {"heapmin", (PyCFunction)msvcrt_heapmin, METH_NOARGS, msvcrt_heapmin__doc__},
16 
17 static PyObject *
18 msvcrt_heapmin_impl(PyObject *module);
19 
20 static PyObject *
msvcrt_heapmin(PyObject * module,PyObject * Py_UNUSED (ignored))21 msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored))
22 {
23     return msvcrt_heapmin_impl(module);
24 }
25 
26 PyDoc_STRVAR(msvcrt_locking__doc__,
27 "locking($module, fd, mode, nbytes, /)\n"
28 "--\n"
29 "\n"
30 "Lock part of a file based on file descriptor fd from the C runtime.\n"
31 "\n"
32 "Raises OSError on failure. The locked region of the file extends from\n"
33 "the current file position for nbytes bytes, and may continue beyond\n"
34 "the end of the file. mode must be one of the LK_* constants listed\n"
35 "below. Multiple regions in a file may be locked at the same time, but\n"
36 "may not overlap. Adjacent regions are not merged; they must be unlocked\n"
37 "individually.");
38 
39 #define MSVCRT_LOCKING_METHODDEF    \
40     {"locking", (PyCFunction)msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__},
41 
42 static PyObject *
43 msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes);
44 
45 static PyObject *
msvcrt_locking(PyObject * module,PyObject * const * args,Py_ssize_t nargs)46 msvcrt_locking(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
47 {
48     PyObject *return_value = NULL;
49     int fd;
50     int mode;
51     long nbytes;
52 
53     if (!_PyArg_ParseStack(args, nargs, "iil:locking",
54         &fd, &mode, &nbytes)) {
55         goto exit;
56     }
57     return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
58 
59 exit:
60     return return_value;
61 }
62 
63 PyDoc_STRVAR(msvcrt_setmode__doc__,
64 "setmode($module, fd, mode, /)\n"
65 "--\n"
66 "\n"
67 "Set the line-end translation mode for the file descriptor fd.\n"
68 "\n"
69 "To set it to text mode, flags should be os.O_TEXT; for binary, it\n"
70 "should be os.O_BINARY.\n"
71 "\n"
72 "Return value is the previous mode.");
73 
74 #define MSVCRT_SETMODE_METHODDEF    \
75     {"setmode", (PyCFunction)msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__},
76 
77 static long
78 msvcrt_setmode_impl(PyObject *module, int fd, int flags);
79 
80 static PyObject *
msvcrt_setmode(PyObject * module,PyObject * const * args,Py_ssize_t nargs)81 msvcrt_setmode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
82 {
83     PyObject *return_value = NULL;
84     int fd;
85     int flags;
86     long _return_value;
87 
88     if (!_PyArg_ParseStack(args, nargs, "ii:setmode",
89         &fd, &flags)) {
90         goto exit;
91     }
92     _return_value = msvcrt_setmode_impl(module, fd, flags);
93     if ((_return_value == -1) && PyErr_Occurred()) {
94         goto exit;
95     }
96     return_value = PyLong_FromLong(_return_value);
97 
98 exit:
99     return return_value;
100 }
101 
102 PyDoc_STRVAR(msvcrt_open_osfhandle__doc__,
103 "open_osfhandle($module, handle, flags, /)\n"
104 "--\n"
105 "\n"
106 "Create a C runtime file descriptor from the file handle handle.\n"
107 "\n"
108 "The flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n"
109 "and os.O_TEXT. The returned file descriptor may be used as a parameter\n"
110 "to os.fdopen() to create a file object.");
111 
112 #define MSVCRT_OPEN_OSFHANDLE_METHODDEF    \
113     {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__},
114 
115 static long
116 msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags);
117 
118 static PyObject *
msvcrt_open_osfhandle(PyObject * module,PyObject * const * args,Py_ssize_t nargs)119 msvcrt_open_osfhandle(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
120 {
121     PyObject *return_value = NULL;
122     void *handle;
123     int flags;
124     long _return_value;
125 
126     if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle",
127         &handle, &flags)) {
128         goto exit;
129     }
130     _return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
131     if ((_return_value == -1) && PyErr_Occurred()) {
132         goto exit;
133     }
134     return_value = PyLong_FromLong(_return_value);
135 
136 exit:
137     return return_value;
138 }
139 
140 PyDoc_STRVAR(msvcrt_get_osfhandle__doc__,
141 "get_osfhandle($module, fd, /)\n"
142 "--\n"
143 "\n"
144 "Return the file handle for the file descriptor fd.\n"
145 "\n"
146 "Raises OSError if fd is not recognized.");
147 
148 #define MSVCRT_GET_OSFHANDLE_METHODDEF    \
149     {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__},
150 
151 static void *
152 msvcrt_get_osfhandle_impl(PyObject *module, int fd);
153 
154 static PyObject *
msvcrt_get_osfhandle(PyObject * module,PyObject * arg)155 msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
156 {
157     PyObject *return_value = NULL;
158     int fd;
159     void *_return_value;
160 
161     if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
162         goto exit;
163     }
164     _return_value = msvcrt_get_osfhandle_impl(module, fd);
165     if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
166         goto exit;
167     }
168     return_value = PyLong_FromVoidPtr(_return_value);
169 
170 exit:
171     return return_value;
172 }
173 
174 PyDoc_STRVAR(msvcrt_kbhit__doc__,
175 "kbhit($module, /)\n"
176 "--\n"
177 "\n"
178 "Return true if a keypress is waiting to be read.");
179 
180 #define MSVCRT_KBHIT_METHODDEF    \
181     {"kbhit", (PyCFunction)msvcrt_kbhit, METH_NOARGS, msvcrt_kbhit__doc__},
182 
183 static long
184 msvcrt_kbhit_impl(PyObject *module);
185 
186 static PyObject *
msvcrt_kbhit(PyObject * module,PyObject * Py_UNUSED (ignored))187 msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored))
188 {
189     PyObject *return_value = NULL;
190     long _return_value;
191 
192     _return_value = msvcrt_kbhit_impl(module);
193     if ((_return_value == -1) && PyErr_Occurred()) {
194         goto exit;
195     }
196     return_value = PyLong_FromLong(_return_value);
197 
198 exit:
199     return return_value;
200 }
201 
202 PyDoc_STRVAR(msvcrt_getch__doc__,
203 "getch($module, /)\n"
204 "--\n"
205 "\n"
206 "Read a keypress and return the resulting character as a byte string.\n"
207 "\n"
208 "Nothing is echoed to the console. This call will block if a keypress is\n"
209 "not already available, but will not wait for Enter to be pressed. If the\n"
210 "pressed key was a special function key, this will return \'\\000\' or\n"
211 "\'\\xe0\'; the next call will return the keycode. The Control-C keypress\n"
212 "cannot be read with this function.");
213 
214 #define MSVCRT_GETCH_METHODDEF    \
215     {"getch", (PyCFunction)msvcrt_getch, METH_NOARGS, msvcrt_getch__doc__},
216 
217 static int
218 msvcrt_getch_impl(PyObject *module);
219 
220 static PyObject *
msvcrt_getch(PyObject * module,PyObject * Py_UNUSED (ignored))221 msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored))
222 {
223     PyObject *return_value = NULL;
224     char s[1];
225 
226     s[0] = msvcrt_getch_impl(module);
227     return_value = PyBytes_FromStringAndSize(s, 1);
228 
229     return return_value;
230 }
231 
232 PyDoc_STRVAR(msvcrt_getwch__doc__,
233 "getwch($module, /)\n"
234 "--\n"
235 "\n"
236 "Wide char variant of getch(), returning a Unicode value.");
237 
238 #define MSVCRT_GETWCH_METHODDEF    \
239     {"getwch", (PyCFunction)msvcrt_getwch, METH_NOARGS, msvcrt_getwch__doc__},
240 
241 static wchar_t
242 msvcrt_getwch_impl(PyObject *module);
243 
244 static PyObject *
msvcrt_getwch(PyObject * module,PyObject * Py_UNUSED (ignored))245 msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored))
246 {
247     PyObject *return_value = NULL;
248     wchar_t _return_value;
249 
250     _return_value = msvcrt_getwch_impl(module);
251     return_value = PyUnicode_FromOrdinal(_return_value);
252 
253     return return_value;
254 }
255 
256 PyDoc_STRVAR(msvcrt_getche__doc__,
257 "getche($module, /)\n"
258 "--\n"
259 "\n"
260 "Similar to getch(), but the keypress will be echoed if possible.");
261 
262 #define MSVCRT_GETCHE_METHODDEF    \
263     {"getche", (PyCFunction)msvcrt_getche, METH_NOARGS, msvcrt_getche__doc__},
264 
265 static int
266 msvcrt_getche_impl(PyObject *module);
267 
268 static PyObject *
msvcrt_getche(PyObject * module,PyObject * Py_UNUSED (ignored))269 msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored))
270 {
271     PyObject *return_value = NULL;
272     char s[1];
273 
274     s[0] = msvcrt_getche_impl(module);
275     return_value = PyBytes_FromStringAndSize(s, 1);
276 
277     return return_value;
278 }
279 
280 PyDoc_STRVAR(msvcrt_getwche__doc__,
281 "getwche($module, /)\n"
282 "--\n"
283 "\n"
284 "Wide char variant of getche(), returning a Unicode value.");
285 
286 #define MSVCRT_GETWCHE_METHODDEF    \
287     {"getwche", (PyCFunction)msvcrt_getwche, METH_NOARGS, msvcrt_getwche__doc__},
288 
289 static wchar_t
290 msvcrt_getwche_impl(PyObject *module);
291 
292 static PyObject *
msvcrt_getwche(PyObject * module,PyObject * Py_UNUSED (ignored))293 msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored))
294 {
295     PyObject *return_value = NULL;
296     wchar_t _return_value;
297 
298     _return_value = msvcrt_getwche_impl(module);
299     return_value = PyUnicode_FromOrdinal(_return_value);
300 
301     return return_value;
302 }
303 
304 PyDoc_STRVAR(msvcrt_putch__doc__,
305 "putch($module, char, /)\n"
306 "--\n"
307 "\n"
308 "Print the byte string char to the console without buffering.");
309 
310 #define MSVCRT_PUTCH_METHODDEF    \
311     {"putch", (PyCFunction)msvcrt_putch, METH_O, msvcrt_putch__doc__},
312 
313 static PyObject *
314 msvcrt_putch_impl(PyObject *module, char char_value);
315 
316 static PyObject *
msvcrt_putch(PyObject * module,PyObject * arg)317 msvcrt_putch(PyObject *module, PyObject *arg)
318 {
319     PyObject *return_value = NULL;
320     char char_value;
321 
322     if (!PyArg_Parse(arg, "c:putch", &char_value)) {
323         goto exit;
324     }
325     return_value = msvcrt_putch_impl(module, char_value);
326 
327 exit:
328     return return_value;
329 }
330 
331 PyDoc_STRVAR(msvcrt_putwch__doc__,
332 "putwch($module, unicode_char, /)\n"
333 "--\n"
334 "\n"
335 "Wide char variant of putch(), accepting a Unicode value.");
336 
337 #define MSVCRT_PUTWCH_METHODDEF    \
338     {"putwch", (PyCFunction)msvcrt_putwch, METH_O, msvcrt_putwch__doc__},
339 
340 static PyObject *
341 msvcrt_putwch_impl(PyObject *module, int unicode_char);
342 
343 static PyObject *
msvcrt_putwch(PyObject * module,PyObject * arg)344 msvcrt_putwch(PyObject *module, PyObject *arg)
345 {
346     PyObject *return_value = NULL;
347     int unicode_char;
348 
349     if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
350         goto exit;
351     }
352     return_value = msvcrt_putwch_impl(module, unicode_char);
353 
354 exit:
355     return return_value;
356 }
357 
358 PyDoc_STRVAR(msvcrt_ungetch__doc__,
359 "ungetch($module, char, /)\n"
360 "--\n"
361 "\n"
362 "Opposite of getch.\n"
363 "\n"
364 "Cause the byte string char to be \"pushed back\" into the\n"
365 "console buffer; it will be the next character read by\n"
366 "getch() or getche().");
367 
368 #define MSVCRT_UNGETCH_METHODDEF    \
369     {"ungetch", (PyCFunction)msvcrt_ungetch, METH_O, msvcrt_ungetch__doc__},
370 
371 static PyObject *
372 msvcrt_ungetch_impl(PyObject *module, char char_value);
373 
374 static PyObject *
msvcrt_ungetch(PyObject * module,PyObject * arg)375 msvcrt_ungetch(PyObject *module, PyObject *arg)
376 {
377     PyObject *return_value = NULL;
378     char char_value;
379 
380     if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
381         goto exit;
382     }
383     return_value = msvcrt_ungetch_impl(module, char_value);
384 
385 exit:
386     return return_value;
387 }
388 
389 PyDoc_STRVAR(msvcrt_ungetwch__doc__,
390 "ungetwch($module, unicode_char, /)\n"
391 "--\n"
392 "\n"
393 "Wide char variant of ungetch(), accepting a Unicode value.");
394 
395 #define MSVCRT_UNGETWCH_METHODDEF    \
396     {"ungetwch", (PyCFunction)msvcrt_ungetwch, METH_O, msvcrt_ungetwch__doc__},
397 
398 static PyObject *
399 msvcrt_ungetwch_impl(PyObject *module, int unicode_char);
400 
401 static PyObject *
msvcrt_ungetwch(PyObject * module,PyObject * arg)402 msvcrt_ungetwch(PyObject *module, PyObject *arg)
403 {
404     PyObject *return_value = NULL;
405     int unicode_char;
406 
407     if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
408         goto exit;
409     }
410     return_value = msvcrt_ungetwch_impl(module, unicode_char);
411 
412 exit:
413     return return_value;
414 }
415 
416 #if defined(_DEBUG)
417 
418 PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__,
419 "CrtSetReportFile($module, type, file, /)\n"
420 "--\n"
421 "\n"
422 "Wrapper around _CrtSetReportFile.\n"
423 "\n"
424 "Only available on Debug builds.");
425 
426 #define MSVCRT_CRTSETREPORTFILE_METHODDEF    \
427     {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__},
428 
429 static void *
430 msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file);
431 
432 static PyObject *
msvcrt_CrtSetReportFile(PyObject * module,PyObject * const * args,Py_ssize_t nargs)433 msvcrt_CrtSetReportFile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
434 {
435     PyObject *return_value = NULL;
436     int type;
437     void *file;
438     void *_return_value;
439 
440     if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile",
441         &type, &file)) {
442         goto exit;
443     }
444     _return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
445     if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
446         goto exit;
447     }
448     return_value = PyLong_FromVoidPtr(_return_value);
449 
450 exit:
451     return return_value;
452 }
453 
454 #endif /* defined(_DEBUG) */
455 
456 #if defined(_DEBUG)
457 
458 PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__,
459 "CrtSetReportMode($module, type, mode, /)\n"
460 "--\n"
461 "\n"
462 "Wrapper around _CrtSetReportMode.\n"
463 "\n"
464 "Only available on Debug builds.");
465 
466 #define MSVCRT_CRTSETREPORTMODE_METHODDEF    \
467     {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__},
468 
469 static long
470 msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode);
471 
472 static PyObject *
msvcrt_CrtSetReportMode(PyObject * module,PyObject * const * args,Py_ssize_t nargs)473 msvcrt_CrtSetReportMode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
474 {
475     PyObject *return_value = NULL;
476     int type;
477     int mode;
478     long _return_value;
479 
480     if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode",
481         &type, &mode)) {
482         goto exit;
483     }
484     _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
485     if ((_return_value == -1) && PyErr_Occurred()) {
486         goto exit;
487     }
488     return_value = PyLong_FromLong(_return_value);
489 
490 exit:
491     return return_value;
492 }
493 
494 #endif /* defined(_DEBUG) */
495 
496 #if defined(_DEBUG)
497 
498 PyDoc_STRVAR(msvcrt_set_error_mode__doc__,
499 "set_error_mode($module, mode, /)\n"
500 "--\n"
501 "\n"
502 "Wrapper around _set_error_mode.\n"
503 "\n"
504 "Only available on Debug builds.");
505 
506 #define MSVCRT_SET_ERROR_MODE_METHODDEF    \
507     {"set_error_mode", (PyCFunction)msvcrt_set_error_mode, METH_O, msvcrt_set_error_mode__doc__},
508 
509 static long
510 msvcrt_set_error_mode_impl(PyObject *module, int mode);
511 
512 static PyObject *
msvcrt_set_error_mode(PyObject * module,PyObject * arg)513 msvcrt_set_error_mode(PyObject *module, PyObject *arg)
514 {
515     PyObject *return_value = NULL;
516     int mode;
517     long _return_value;
518 
519     if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
520         goto exit;
521     }
522     _return_value = msvcrt_set_error_mode_impl(module, mode);
523     if ((_return_value == -1) && PyErr_Occurred()) {
524         goto exit;
525     }
526     return_value = PyLong_FromLong(_return_value);
527 
528 exit:
529     return return_value;
530 }
531 
532 #endif /* defined(_DEBUG) */
533 
534 PyDoc_STRVAR(msvcrt_SetErrorMode__doc__,
535 "SetErrorMode($module, mode, /)\n"
536 "--\n"
537 "\n"
538 "Wrapper around SetErrorMode.");
539 
540 #define MSVCRT_SETERRORMODE_METHODDEF    \
541     {"SetErrorMode", (PyCFunction)msvcrt_SetErrorMode, METH_O, msvcrt_SetErrorMode__doc__},
542 
543 static PyObject *
544 msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode);
545 
546 static PyObject *
msvcrt_SetErrorMode(PyObject * module,PyObject * arg)547 msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
548 {
549     PyObject *return_value = NULL;
550     unsigned int mode;
551 
552     if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
553         goto exit;
554     }
555     return_value = msvcrt_SetErrorMode_impl(module, mode);
556 
557 exit:
558     return return_value;
559 }
560 
561 #ifndef MSVCRT_CRTSETREPORTFILE_METHODDEF
562     #define MSVCRT_CRTSETREPORTFILE_METHODDEF
563 #endif /* !defined(MSVCRT_CRTSETREPORTFILE_METHODDEF) */
564 
565 #ifndef MSVCRT_CRTSETREPORTMODE_METHODDEF
566     #define MSVCRT_CRTSETREPORTMODE_METHODDEF
567 #endif /* !defined(MSVCRT_CRTSETREPORTMODE_METHODDEF) */
568 
569 #ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
570     #define MSVCRT_SET_ERROR_MODE_METHODDEF
571 #endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
572 /*[clinic end generated code: output=3dd4cf62afb9771a input=a9049054013a1b77]*/
573