blob: 6d7648a101daa52501e4a3bdcb8914820c914163 [file] [log] [blame]
Zachary Ware45520892015-05-13 01:22:32 -05001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
17static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030018msvcrt_heapmin_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -050019
20static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030021msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -050022{
23 return msvcrt_heapmin_impl(module);
24}
25
26PyDoc_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"
Serhiy Storchaka55fe1ae2017-04-16 10:46:38 +030032"Raises OSError on failure. The locked region of the file extends from\n"
Zachary Ware45520892015-05-13 01:22:32 -050033"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 \
Victor Stinner259f0e42017-01-17 01:35:17 +010040 {"locking", (PyCFunction)msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__},
Zachary Ware45520892015-05-13 01:22:32 -050041
42static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030043msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes);
Zachary Ware45520892015-05-13 01:22:32 -050044
45static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030046msvcrt_locking(PyObject *module, PyObject **args, Py_ssize_t nargs)
Zachary Ware45520892015-05-13 01:22:32 -050047{
48 PyObject *return_value = NULL;
49 int fd;
50 int mode;
51 long nbytes;
52
Sylvain74453812017-06-10 06:51:48 +020053 if (!_PyArg_ParseStack(args, nargs, "iil:locking",
54 &fd, &mode, &nbytes)) {
Victor Stinner259f0e42017-01-17 01:35:17 +010055 goto exit;
56 }
Zachary Ware45520892015-05-13 01:22:32 -050057 return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
58
59exit:
60 return return_value;
61}
62
63PyDoc_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 \
Victor Stinner259f0e42017-01-17 01:35:17 +010075 {"setmode", (PyCFunction)msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__},
Zachary Ware45520892015-05-13 01:22:32 -050076
77static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030078msvcrt_setmode_impl(PyObject *module, int fd, int flags);
Zachary Ware45520892015-05-13 01:22:32 -050079
80static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030081msvcrt_setmode(PyObject *module, PyObject **args, Py_ssize_t nargs)
Zachary Ware45520892015-05-13 01:22:32 -050082{
83 PyObject *return_value = NULL;
84 int fd;
85 int flags;
86 long _return_value;
87
Sylvain74453812017-06-10 06:51:48 +020088 if (!_PyArg_ParseStack(args, nargs, "ii:setmode",
89 &fd, &flags)) {
Victor Stinner259f0e42017-01-17 01:35:17 +010090 goto exit;
91 }
Zachary Ware45520892015-05-13 01:22:32 -050092 _return_value = msvcrt_setmode_impl(module, fd, flags);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030093 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -050094 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030095 }
Zachary Ware45520892015-05-13 01:22:32 -050096 return_value = PyLong_FromLong(_return_value);
97
98exit:
99 return return_value;
100}
101
102PyDoc_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 \
Victor Stinner259f0e42017-01-17 01:35:17 +0100113 {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500114
115static long
Segev Finer679b5662017-07-27 01:17:57 +0300116msvcrt_open_osfhandle_impl(PyObject *module, void *handle, int flags);
Zachary Ware45520892015-05-13 01:22:32 -0500117
118static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300119msvcrt_open_osfhandle(PyObject *module, PyObject **args, Py_ssize_t nargs)
Zachary Ware45520892015-05-13 01:22:32 -0500120{
121 PyObject *return_value = NULL;
Segev Finer679b5662017-07-27 01:17:57 +0300122 void *handle;
Zachary Ware45520892015-05-13 01:22:32 -0500123 int flags;
124 long _return_value;
125
Segev Finera80e9852017-07-27 06:15:18 +0300126 if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_UINTPTR"i:open_osfhandle",
Sylvain74453812017-06-10 06:51:48 +0200127 &handle, &flags)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100128 goto exit;
129 }
Zachary Ware45520892015-05-13 01:22:32 -0500130 _return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300131 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500132 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300133 }
Zachary Ware45520892015-05-13 01:22:32 -0500134 return_value = PyLong_FromLong(_return_value);
135
136exit:
137 return return_value;
138}
139
140PyDoc_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"
Serhiy Storchaka55fe1ae2017-04-16 10:46:38 +0300146"Raises OSError if fd is not recognized.");
Zachary Ware45520892015-05-13 01:22:32 -0500147
148#define MSVCRT_GET_OSFHANDLE_METHODDEF \
149 {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__},
150
Segev Finer679b5662017-07-27 01:17:57 +0300151static void *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300152msvcrt_get_osfhandle_impl(PyObject *module, int fd);
Zachary Ware45520892015-05-13 01:22:32 -0500153
154static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300155msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500156{
157 PyObject *return_value = NULL;
158 int fd;
Segev Finer679b5662017-07-27 01:17:57 +0300159 void *_return_value;
Zachary Ware45520892015-05-13 01:22:32 -0500160
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300161 if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
Zachary Ware45520892015-05-13 01:22:32 -0500162 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300163 }
Zachary Ware45520892015-05-13 01:22:32 -0500164 _return_value = msvcrt_get_osfhandle_impl(module, fd);
Segev Finer679b5662017-07-27 01:17:57 +0300165 if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500166 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300167 }
Segev Finer679b5662017-07-27 01:17:57 +0300168 return_value = PyLong_FromVoidPtr(_return_value);
Zachary Ware45520892015-05-13 01:22:32 -0500169
170exit:
171 return return_value;
172}
173
174PyDoc_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
183static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300184msvcrt_kbhit_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500185
186static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300187msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500188{
189 PyObject *return_value = NULL;
190 long _return_value;
191
192 _return_value = msvcrt_kbhit_impl(module);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300193 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500194 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300195 }
Zachary Ware45520892015-05-13 01:22:32 -0500196 return_value = PyLong_FromLong(_return_value);
197
198exit:
199 return return_value;
200}
201
202PyDoc_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
217static int
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300218msvcrt_getch_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500219
220static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300221msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500222{
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
Zachary Ware45520892015-05-13 01:22:32 -0500232PyDoc_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
241static wchar_t
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300242msvcrt_getwch_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500243
244static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300245msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500246{
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
Zachary Ware45520892015-05-13 01:22:32 -0500256PyDoc_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
265static int
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300266msvcrt_getche_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500267
268static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300269msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500270{
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
Zachary Ware45520892015-05-13 01:22:32 -0500280PyDoc_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
289static wchar_t
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300290msvcrt_getwche_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500291
292static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300293msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500294{
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
Zachary Ware45520892015-05-13 01:22:32 -0500304PyDoc_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
313static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300314msvcrt_putch_impl(PyObject *module, char char_value);
Zachary Ware45520892015-05-13 01:22:32 -0500315
316static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300317msvcrt_putch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500318{
319 PyObject *return_value = NULL;
320 char char_value;
321
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300322 if (!PyArg_Parse(arg, "c:putch", &char_value)) {
Zachary Ware45520892015-05-13 01:22:32 -0500323 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300324 }
Zachary Ware45520892015-05-13 01:22:32 -0500325 return_value = msvcrt_putch_impl(module, char_value);
326
327exit:
328 return return_value;
329}
330
Zachary Ware45520892015-05-13 01:22:32 -0500331PyDoc_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
340static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300341msvcrt_putwch_impl(PyObject *module, int unicode_char);
Zachary Ware45520892015-05-13 01:22:32 -0500342
343static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300344msvcrt_putwch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500345{
346 PyObject *return_value = NULL;
347 int unicode_char;
348
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300349 if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
Zachary Ware45520892015-05-13 01:22:32 -0500350 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300351 }
Zachary Ware45520892015-05-13 01:22:32 -0500352 return_value = msvcrt_putwch_impl(module, unicode_char);
353
354exit:
355 return return_value;
356}
357
Zachary Ware45520892015-05-13 01:22:32 -0500358PyDoc_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
371static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300372msvcrt_ungetch_impl(PyObject *module, char char_value);
Zachary Ware45520892015-05-13 01:22:32 -0500373
374static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300375msvcrt_ungetch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500376{
377 PyObject *return_value = NULL;
378 char char_value;
379
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300380 if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
Zachary Ware45520892015-05-13 01:22:32 -0500381 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300382 }
Zachary Ware45520892015-05-13 01:22:32 -0500383 return_value = msvcrt_ungetch_impl(module, char_value);
384
385exit:
386 return return_value;
387}
388
Zachary Ware45520892015-05-13 01:22:32 -0500389PyDoc_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
398static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300399msvcrt_ungetwch_impl(PyObject *module, int unicode_char);
Zachary Ware45520892015-05-13 01:22:32 -0500400
401static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300402msvcrt_ungetwch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500403{
404 PyObject *return_value = NULL;
405 int unicode_char;
406
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300407 if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
Zachary Ware45520892015-05-13 01:22:32 -0500408 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300409 }
Zachary Ware45520892015-05-13 01:22:32 -0500410 return_value = msvcrt_ungetwch_impl(module, unicode_char);
411
412exit:
413 return return_value;
414}
415
Zachary Ware45520892015-05-13 01:22:32 -0500416#if defined(_DEBUG)
417
418PyDoc_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 \
Victor Stinner259f0e42017-01-17 01:35:17 +0100427 {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500428
Segev Finer679b5662017-07-27 01:17:57 +0300429static void *
430msvcrt_CrtSetReportFile_impl(PyObject *module, int type, void *file);
Zachary Ware45520892015-05-13 01:22:32 -0500431
432static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300433msvcrt_CrtSetReportFile(PyObject *module, PyObject **args, Py_ssize_t nargs)
Zachary Ware45520892015-05-13 01:22:32 -0500434{
435 PyObject *return_value = NULL;
436 int type;
Segev Finer679b5662017-07-27 01:17:57 +0300437 void *file;
438 void *_return_value;
Zachary Ware45520892015-05-13 01:22:32 -0500439
Segev Finera80e9852017-07-27 06:15:18 +0300440 if (!_PyArg_ParseStack(args, nargs, "i"_Py_PARSE_UINTPTR":CrtSetReportFile",
Sylvain74453812017-06-10 06:51:48 +0200441 &type, &file)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100442 goto exit;
443 }
Zachary Ware45520892015-05-13 01:22:32 -0500444 _return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
Segev Finer679b5662017-07-27 01:17:57 +0300445 if ((_return_value == NULL || _return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500446 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300447 }
Segev Finer679b5662017-07-27 01:17:57 +0300448 return_value = PyLong_FromVoidPtr(_return_value);
Zachary Ware45520892015-05-13 01:22:32 -0500449
450exit:
451 return return_value;
452}
453
454#endif /* defined(_DEBUG) */
455
456#if defined(_DEBUG)
457
458PyDoc_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 \
Victor Stinner259f0e42017-01-17 01:35:17 +0100467 {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500468
469static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300470msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500471
472static PyObject *
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300473msvcrt_CrtSetReportMode(PyObject *module, PyObject **args, Py_ssize_t nargs)
Zachary Ware45520892015-05-13 01:22:32 -0500474{
475 PyObject *return_value = NULL;
476 int type;
477 int mode;
478 long _return_value;
479
Sylvain74453812017-06-10 06:51:48 +0200480 if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode",
481 &type, &mode)) {
Victor Stinner259f0e42017-01-17 01:35:17 +0100482 goto exit;
483 }
Zachary Ware45520892015-05-13 01:22:32 -0500484 _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300485 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500486 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300487 }
Zachary Ware45520892015-05-13 01:22:32 -0500488 return_value = PyLong_FromLong(_return_value);
489
490exit:
491 return return_value;
492}
493
494#endif /* defined(_DEBUG) */
495
496#if defined(_DEBUG)
497
498PyDoc_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
509static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300510msvcrt_set_error_mode_impl(PyObject *module, int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500511
512static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300513msvcrt_set_error_mode(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500514{
515 PyObject *return_value = NULL;
516 int mode;
517 long _return_value;
518
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300519 if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
Zachary Ware45520892015-05-13 01:22:32 -0500520 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300521 }
Zachary Ware45520892015-05-13 01:22:32 -0500522 _return_value = msvcrt_set_error_mode_impl(module, mode);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300523 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500524 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300525 }
Zachary Ware45520892015-05-13 01:22:32 -0500526 return_value = PyLong_FromLong(_return_value);
527
528exit:
529 return return_value;
530}
531
532#endif /* defined(_DEBUG) */
533
534PyDoc_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
543static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300544msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500545
546static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300547msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500548{
549 PyObject *return_value = NULL;
550 unsigned int mode;
551
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300552 if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
Zachary Ware45520892015-05-13 01:22:32 -0500553 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300554 }
Zachary Ware45520892015-05-13 01:22:32 -0500555 return_value = msvcrt_SetErrorMode_impl(module, mode);
556
557exit:
558 return return_value;
559}
560
Zachary Ware45520892015-05-13 01:22:32 -0500561#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) */
Segev Finera80e9852017-07-27 06:15:18 +0300572/*[clinic end generated code: output=66787cb934b8a3c2 input=a9049054013a1b77]*/