blob: db4f46ebcec2f37eb849be73fa85d7562560c7c6 [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"
32"Raises IOError 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 \
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 *
Victor Stinner259f0e42017-01-17 01:35:17 +010046msvcrt_locking(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Zachary Ware45520892015-05-13 01:22:32 -050047{
48 PyObject *return_value = NULL;
49 int fd;
50 int mode;
51 long nbytes;
52
Victor Stinner259f0e42017-01-17 01:35:17 +010053 if (!_PyArg_ParseStack(args, nargs, "iil:locking",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030054 &fd, &mode, &nbytes)) {
Zachary Ware45520892015-05-13 01:22:32 -050055 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030056 }
Victor Stinner259f0e42017-01-17 01:35:17 +010057
58 if (!_PyArg_NoStackKeywords("locking", kwnames)) {
59 goto exit;
60 }
Zachary Ware45520892015-05-13 01:22:32 -050061 return_value = msvcrt_locking_impl(module, fd, mode, nbytes);
62
63exit:
64 return return_value;
65}
66
67PyDoc_STRVAR(msvcrt_setmode__doc__,
68"setmode($module, fd, mode, /)\n"
69"--\n"
70"\n"
71"Set the line-end translation mode for the file descriptor fd.\n"
72"\n"
73"To set it to text mode, flags should be os.O_TEXT; for binary, it\n"
74"should be os.O_BINARY.\n"
75"\n"
76"Return value is the previous mode.");
77
78#define MSVCRT_SETMODE_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +010079 {"setmode", (PyCFunction)msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__},
Zachary Ware45520892015-05-13 01:22:32 -050080
81static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030082msvcrt_setmode_impl(PyObject *module, int fd, int flags);
Zachary Ware45520892015-05-13 01:22:32 -050083
84static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +010085msvcrt_setmode(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Zachary Ware45520892015-05-13 01:22:32 -050086{
87 PyObject *return_value = NULL;
88 int fd;
89 int flags;
90 long _return_value;
91
Victor Stinner259f0e42017-01-17 01:35:17 +010092 if (!_PyArg_ParseStack(args, nargs, "ii:setmode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030093 &fd, &flags)) {
Zachary Ware45520892015-05-13 01:22:32 -050094 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030095 }
Victor Stinner259f0e42017-01-17 01:35:17 +010096
97 if (!_PyArg_NoStackKeywords("setmode", kwnames)) {
98 goto exit;
99 }
Zachary Ware45520892015-05-13 01:22:32 -0500100 _return_value = msvcrt_setmode_impl(module, fd, flags);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300101 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500102 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300103 }
Zachary Ware45520892015-05-13 01:22:32 -0500104 return_value = PyLong_FromLong(_return_value);
105
106exit:
107 return return_value;
108}
109
110PyDoc_STRVAR(msvcrt_open_osfhandle__doc__,
111"open_osfhandle($module, handle, flags, /)\n"
112"--\n"
113"\n"
114"Create a C runtime file descriptor from the file handle handle.\n"
115"\n"
116"The flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n"
117"and os.O_TEXT. The returned file descriptor may be used as a parameter\n"
118"to os.fdopen() to create a file object.");
119
120#define MSVCRT_OPEN_OSFHANDLE_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +0100121 {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500122
123static long
Benjamin Petersoncc854492016-09-08 09:29:11 -0700124msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags);
Zachary Ware45520892015-05-13 01:22:32 -0500125
126static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +0100127msvcrt_open_osfhandle(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Zachary Ware45520892015-05-13 01:22:32 -0500128{
129 PyObject *return_value = NULL;
Benjamin Petersoncc854492016-09-08 09:29:11 -0700130 intptr_t handle;
Zachary Ware45520892015-05-13 01:22:32 -0500131 int flags;
132 long _return_value;
133
Victor Stinner259f0e42017-01-17 01:35:17 +0100134 if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_INTPTR"i:open_osfhandle",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300135 &handle, &flags)) {
Zachary Ware45520892015-05-13 01:22:32 -0500136 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300137 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100138
139 if (!_PyArg_NoStackKeywords("open_osfhandle", kwnames)) {
140 goto exit;
141 }
Zachary Ware45520892015-05-13 01:22:32 -0500142 _return_value = msvcrt_open_osfhandle_impl(module, handle, flags);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300143 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500144 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300145 }
Zachary Ware45520892015-05-13 01:22:32 -0500146 return_value = PyLong_FromLong(_return_value);
147
148exit:
149 return return_value;
150}
151
152PyDoc_STRVAR(msvcrt_get_osfhandle__doc__,
153"get_osfhandle($module, fd, /)\n"
154"--\n"
155"\n"
156"Return the file handle for the file descriptor fd.\n"
157"\n"
158"Raises IOError if fd is not recognized.");
159
160#define MSVCRT_GET_OSFHANDLE_METHODDEF \
161 {"get_osfhandle", (PyCFunction)msvcrt_get_osfhandle, METH_O, msvcrt_get_osfhandle__doc__},
162
Benjamin Petersoncc854492016-09-08 09:29:11 -0700163static intptr_t
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300164msvcrt_get_osfhandle_impl(PyObject *module, int fd);
Zachary Ware45520892015-05-13 01:22:32 -0500165
166static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300167msvcrt_get_osfhandle(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500168{
169 PyObject *return_value = NULL;
170 int fd;
Benjamin Petersoncc854492016-09-08 09:29:11 -0700171 intptr_t _return_value;
Zachary Ware45520892015-05-13 01:22:32 -0500172
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300173 if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) {
Zachary Ware45520892015-05-13 01:22:32 -0500174 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300175 }
Zachary Ware45520892015-05-13 01:22:32 -0500176 _return_value = msvcrt_get_osfhandle_impl(module, fd);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300177 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500178 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300179 }
Zachary Ware45520892015-05-13 01:22:32 -0500180 return_value = PyLong_FromVoidPtr((void *)_return_value);
181
182exit:
183 return return_value;
184}
185
186PyDoc_STRVAR(msvcrt_kbhit__doc__,
187"kbhit($module, /)\n"
188"--\n"
189"\n"
190"Return true if a keypress is waiting to be read.");
191
192#define MSVCRT_KBHIT_METHODDEF \
193 {"kbhit", (PyCFunction)msvcrt_kbhit, METH_NOARGS, msvcrt_kbhit__doc__},
194
195static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300196msvcrt_kbhit_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500197
198static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300199msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500200{
201 PyObject *return_value = NULL;
202 long _return_value;
203
204 _return_value = msvcrt_kbhit_impl(module);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300205 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500206 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300207 }
Zachary Ware45520892015-05-13 01:22:32 -0500208 return_value = PyLong_FromLong(_return_value);
209
210exit:
211 return return_value;
212}
213
214PyDoc_STRVAR(msvcrt_getch__doc__,
215"getch($module, /)\n"
216"--\n"
217"\n"
218"Read a keypress and return the resulting character as a byte string.\n"
219"\n"
220"Nothing is echoed to the console. This call will block if a keypress is\n"
221"not already available, but will not wait for Enter to be pressed. If the\n"
222"pressed key was a special function key, this will return \'\\000\' or\n"
223"\'\\xe0\'; the next call will return the keycode. The Control-C keypress\n"
224"cannot be read with this function.");
225
226#define MSVCRT_GETCH_METHODDEF \
227 {"getch", (PyCFunction)msvcrt_getch, METH_NOARGS, msvcrt_getch__doc__},
228
229static int
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300230msvcrt_getch_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500231
232static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300233msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500234{
235 PyObject *return_value = NULL;
236 char s[1];
237
238 s[0] = msvcrt_getch_impl(module);
239 return_value = PyBytes_FromStringAndSize(s, 1);
240
241 return return_value;
242}
243
Zachary Ware45520892015-05-13 01:22:32 -0500244PyDoc_STRVAR(msvcrt_getwch__doc__,
245"getwch($module, /)\n"
246"--\n"
247"\n"
248"Wide char variant of getch(), returning a Unicode value.");
249
250#define MSVCRT_GETWCH_METHODDEF \
251 {"getwch", (PyCFunction)msvcrt_getwch, METH_NOARGS, msvcrt_getwch__doc__},
252
253static wchar_t
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300254msvcrt_getwch_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500255
256static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300257msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500258{
259 PyObject *return_value = NULL;
260 wchar_t _return_value;
261
262 _return_value = msvcrt_getwch_impl(module);
263 return_value = PyUnicode_FromOrdinal(_return_value);
264
265 return return_value;
266}
267
Zachary Ware45520892015-05-13 01:22:32 -0500268PyDoc_STRVAR(msvcrt_getche__doc__,
269"getche($module, /)\n"
270"--\n"
271"\n"
272"Similar to getch(), but the keypress will be echoed if possible.");
273
274#define MSVCRT_GETCHE_METHODDEF \
275 {"getche", (PyCFunction)msvcrt_getche, METH_NOARGS, msvcrt_getche__doc__},
276
277static int
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300278msvcrt_getche_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500279
280static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300281msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500282{
283 PyObject *return_value = NULL;
284 char s[1];
285
286 s[0] = msvcrt_getche_impl(module);
287 return_value = PyBytes_FromStringAndSize(s, 1);
288
289 return return_value;
290}
291
Zachary Ware45520892015-05-13 01:22:32 -0500292PyDoc_STRVAR(msvcrt_getwche__doc__,
293"getwche($module, /)\n"
294"--\n"
295"\n"
296"Wide char variant of getche(), returning a Unicode value.");
297
298#define MSVCRT_GETWCHE_METHODDEF \
299 {"getwche", (PyCFunction)msvcrt_getwche, METH_NOARGS, msvcrt_getwche__doc__},
300
301static wchar_t
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300302msvcrt_getwche_impl(PyObject *module);
Zachary Ware45520892015-05-13 01:22:32 -0500303
304static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300305msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored))
Zachary Ware45520892015-05-13 01:22:32 -0500306{
307 PyObject *return_value = NULL;
308 wchar_t _return_value;
309
310 _return_value = msvcrt_getwche_impl(module);
311 return_value = PyUnicode_FromOrdinal(_return_value);
312
313 return return_value;
314}
315
Zachary Ware45520892015-05-13 01:22:32 -0500316PyDoc_STRVAR(msvcrt_putch__doc__,
317"putch($module, char, /)\n"
318"--\n"
319"\n"
320"Print the byte string char to the console without buffering.");
321
322#define MSVCRT_PUTCH_METHODDEF \
323 {"putch", (PyCFunction)msvcrt_putch, METH_O, msvcrt_putch__doc__},
324
325static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300326msvcrt_putch_impl(PyObject *module, char char_value);
Zachary Ware45520892015-05-13 01:22:32 -0500327
328static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300329msvcrt_putch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500330{
331 PyObject *return_value = NULL;
332 char char_value;
333
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300334 if (!PyArg_Parse(arg, "c:putch", &char_value)) {
Zachary Ware45520892015-05-13 01:22:32 -0500335 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300336 }
Zachary Ware45520892015-05-13 01:22:32 -0500337 return_value = msvcrt_putch_impl(module, char_value);
338
339exit:
340 return return_value;
341}
342
Zachary Ware45520892015-05-13 01:22:32 -0500343PyDoc_STRVAR(msvcrt_putwch__doc__,
344"putwch($module, unicode_char, /)\n"
345"--\n"
346"\n"
347"Wide char variant of putch(), accepting a Unicode value.");
348
349#define MSVCRT_PUTWCH_METHODDEF \
350 {"putwch", (PyCFunction)msvcrt_putwch, METH_O, msvcrt_putwch__doc__},
351
352static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300353msvcrt_putwch_impl(PyObject *module, int unicode_char);
Zachary Ware45520892015-05-13 01:22:32 -0500354
355static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300356msvcrt_putwch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500357{
358 PyObject *return_value = NULL;
359 int unicode_char;
360
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300361 if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) {
Zachary Ware45520892015-05-13 01:22:32 -0500362 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300363 }
Zachary Ware45520892015-05-13 01:22:32 -0500364 return_value = msvcrt_putwch_impl(module, unicode_char);
365
366exit:
367 return return_value;
368}
369
Zachary Ware45520892015-05-13 01:22:32 -0500370PyDoc_STRVAR(msvcrt_ungetch__doc__,
371"ungetch($module, char, /)\n"
372"--\n"
373"\n"
374"Opposite of getch.\n"
375"\n"
376"Cause the byte string char to be \"pushed back\" into the\n"
377"console buffer; it will be the next character read by\n"
378"getch() or getche().");
379
380#define MSVCRT_UNGETCH_METHODDEF \
381 {"ungetch", (PyCFunction)msvcrt_ungetch, METH_O, msvcrt_ungetch__doc__},
382
383static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300384msvcrt_ungetch_impl(PyObject *module, char char_value);
Zachary Ware45520892015-05-13 01:22:32 -0500385
386static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300387msvcrt_ungetch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500388{
389 PyObject *return_value = NULL;
390 char char_value;
391
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300392 if (!PyArg_Parse(arg, "c:ungetch", &char_value)) {
Zachary Ware45520892015-05-13 01:22:32 -0500393 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300394 }
Zachary Ware45520892015-05-13 01:22:32 -0500395 return_value = msvcrt_ungetch_impl(module, char_value);
396
397exit:
398 return return_value;
399}
400
Zachary Ware45520892015-05-13 01:22:32 -0500401PyDoc_STRVAR(msvcrt_ungetwch__doc__,
402"ungetwch($module, unicode_char, /)\n"
403"--\n"
404"\n"
405"Wide char variant of ungetch(), accepting a Unicode value.");
406
407#define MSVCRT_UNGETWCH_METHODDEF \
408 {"ungetwch", (PyCFunction)msvcrt_ungetwch, METH_O, msvcrt_ungetwch__doc__},
409
410static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300411msvcrt_ungetwch_impl(PyObject *module, int unicode_char);
Zachary Ware45520892015-05-13 01:22:32 -0500412
413static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300414msvcrt_ungetwch(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500415{
416 PyObject *return_value = NULL;
417 int unicode_char;
418
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300419 if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) {
Zachary Ware45520892015-05-13 01:22:32 -0500420 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300421 }
Zachary Ware45520892015-05-13 01:22:32 -0500422 return_value = msvcrt_ungetwch_impl(module, unicode_char);
423
424exit:
425 return return_value;
426}
427
Zachary Ware45520892015-05-13 01:22:32 -0500428#if defined(_DEBUG)
429
430PyDoc_STRVAR(msvcrt_CrtSetReportFile__doc__,
431"CrtSetReportFile($module, type, file, /)\n"
432"--\n"
433"\n"
434"Wrapper around _CrtSetReportFile.\n"
435"\n"
436"Only available on Debug builds.");
437
438#define MSVCRT_CRTSETREPORTFILE_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +0100439 {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500440
441static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300442msvcrt_CrtSetReportFile_impl(PyObject *module, int type, int file);
Zachary Ware45520892015-05-13 01:22:32 -0500443
444static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +0100445msvcrt_CrtSetReportFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Zachary Ware45520892015-05-13 01:22:32 -0500446{
447 PyObject *return_value = NULL;
448 int type;
449 int file;
450 long _return_value;
451
Victor Stinner259f0e42017-01-17 01:35:17 +0100452 if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportFile",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300453 &type, &file)) {
Zachary Ware45520892015-05-13 01:22:32 -0500454 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300455 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100456
457 if (!_PyArg_NoStackKeywords("CrtSetReportFile", kwnames)) {
458 goto exit;
459 }
Zachary Ware45520892015-05-13 01:22:32 -0500460 _return_value = msvcrt_CrtSetReportFile_impl(module, type, file);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300461 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500462 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300463 }
Zachary Ware45520892015-05-13 01:22:32 -0500464 return_value = PyLong_FromLong(_return_value);
465
466exit:
467 return return_value;
468}
469
470#endif /* defined(_DEBUG) */
471
472#if defined(_DEBUG)
473
474PyDoc_STRVAR(msvcrt_CrtSetReportMode__doc__,
475"CrtSetReportMode($module, type, mode, /)\n"
476"--\n"
477"\n"
478"Wrapper around _CrtSetReportMode.\n"
479"\n"
480"Only available on Debug builds.");
481
482#define MSVCRT_CRTSETREPORTMODE_METHODDEF \
Victor Stinner259f0e42017-01-17 01:35:17 +0100483 {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__},
Zachary Ware45520892015-05-13 01:22:32 -0500484
485static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300486msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500487
488static PyObject *
Victor Stinner259f0e42017-01-17 01:35:17 +0100489msvcrt_CrtSetReportMode(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Zachary Ware45520892015-05-13 01:22:32 -0500490{
491 PyObject *return_value = NULL;
492 int type;
493 int mode;
494 long _return_value;
495
Victor Stinner259f0e42017-01-17 01:35:17 +0100496 if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300497 &type, &mode)) {
Zachary Ware45520892015-05-13 01:22:32 -0500498 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300499 }
Victor Stinner259f0e42017-01-17 01:35:17 +0100500
501 if (!_PyArg_NoStackKeywords("CrtSetReportMode", kwnames)) {
502 goto exit;
503 }
Zachary Ware45520892015-05-13 01:22:32 -0500504 _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300505 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500506 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300507 }
Zachary Ware45520892015-05-13 01:22:32 -0500508 return_value = PyLong_FromLong(_return_value);
509
510exit:
511 return return_value;
512}
513
514#endif /* defined(_DEBUG) */
515
516#if defined(_DEBUG)
517
518PyDoc_STRVAR(msvcrt_set_error_mode__doc__,
519"set_error_mode($module, mode, /)\n"
520"--\n"
521"\n"
522"Wrapper around _set_error_mode.\n"
523"\n"
524"Only available on Debug builds.");
525
526#define MSVCRT_SET_ERROR_MODE_METHODDEF \
527 {"set_error_mode", (PyCFunction)msvcrt_set_error_mode, METH_O, msvcrt_set_error_mode__doc__},
528
529static long
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300530msvcrt_set_error_mode_impl(PyObject *module, int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500531
532static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300533msvcrt_set_error_mode(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500534{
535 PyObject *return_value = NULL;
536 int mode;
537 long _return_value;
538
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300539 if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) {
Zachary Ware45520892015-05-13 01:22:32 -0500540 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300541 }
Zachary Ware45520892015-05-13 01:22:32 -0500542 _return_value = msvcrt_set_error_mode_impl(module, mode);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300543 if ((_return_value == -1) && PyErr_Occurred()) {
Zachary Ware45520892015-05-13 01:22:32 -0500544 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300545 }
Zachary Ware45520892015-05-13 01:22:32 -0500546 return_value = PyLong_FromLong(_return_value);
547
548exit:
549 return return_value;
550}
551
552#endif /* defined(_DEBUG) */
553
554PyDoc_STRVAR(msvcrt_SetErrorMode__doc__,
555"SetErrorMode($module, mode, /)\n"
556"--\n"
557"\n"
558"Wrapper around SetErrorMode.");
559
560#define MSVCRT_SETERRORMODE_METHODDEF \
561 {"SetErrorMode", (PyCFunction)msvcrt_SetErrorMode, METH_O, msvcrt_SetErrorMode__doc__},
562
563static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300564msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode);
Zachary Ware45520892015-05-13 01:22:32 -0500565
566static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300567msvcrt_SetErrorMode(PyObject *module, PyObject *arg)
Zachary Ware45520892015-05-13 01:22:32 -0500568{
569 PyObject *return_value = NULL;
570 unsigned int mode;
571
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300572 if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) {
Zachary Ware45520892015-05-13 01:22:32 -0500573 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300574 }
Zachary Ware45520892015-05-13 01:22:32 -0500575 return_value = msvcrt_SetErrorMode_impl(module, mode);
576
577exit:
578 return return_value;
579}
580
Zachary Ware45520892015-05-13 01:22:32 -0500581#ifndef MSVCRT_CRTSETREPORTFILE_METHODDEF
582 #define MSVCRT_CRTSETREPORTFILE_METHODDEF
583#endif /* !defined(MSVCRT_CRTSETREPORTFILE_METHODDEF) */
584
585#ifndef MSVCRT_CRTSETREPORTMODE_METHODDEF
586 #define MSVCRT_CRTSETREPORTMODE_METHODDEF
587#endif /* !defined(MSVCRT_CRTSETREPORTMODE_METHODDEF) */
588
589#ifndef MSVCRT_SET_ERROR_MODE_METHODDEF
590 #define MSVCRT_SET_ERROR_MODE_METHODDEF
591#endif /* !defined(MSVCRT_SET_ERROR_MODE_METHODDEF) */
Victor Stinner259f0e42017-01-17 01:35:17 +0100592/*[clinic end generated code: output=36f1e78ca8bd3944 input=a9049054013a1b77]*/