Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 18 | msvcrt_heapmin_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 19 | |
| 20 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 21 | msvcrt_heapmin(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 40 | {"locking", (PyCFunction)msvcrt_locking, METH_FASTCALL, msvcrt_locking__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 41 | |
| 42 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 43 | msvcrt_locking_impl(PyObject *module, int fd, int mode, long nbytes); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 44 | |
| 45 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 46 | msvcrt_locking(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 47 | { |
| 48 | PyObject *return_value = NULL; |
| 49 | int fd; |
| 50 | int mode; |
| 51 | long nbytes; |
| 52 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 53 | if (!_PyArg_ParseStack(args, nargs, "iil:locking", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 54 | &fd, &mode, &nbytes)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 55 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 56 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 57 | |
| 58 | if (!_PyArg_NoStackKeywords("locking", kwnames)) { |
| 59 | goto exit; |
| 60 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 61 | return_value = msvcrt_locking_impl(module, fd, mode, nbytes); |
| 62 | |
| 63 | exit: |
| 64 | return return_value; |
| 65 | } |
| 66 | |
| 67 | PyDoc_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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 79 | {"setmode", (PyCFunction)msvcrt_setmode, METH_FASTCALL, msvcrt_setmode__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 80 | |
| 81 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 82 | msvcrt_setmode_impl(PyObject *module, int fd, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 83 | |
| 84 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 85 | msvcrt_setmode(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 86 | { |
| 87 | PyObject *return_value = NULL; |
| 88 | int fd; |
| 89 | int flags; |
| 90 | long _return_value; |
| 91 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 92 | if (!_PyArg_ParseStack(args, nargs, "ii:setmode", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 93 | &fd, &flags)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 94 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 95 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 96 | |
| 97 | if (!_PyArg_NoStackKeywords("setmode", kwnames)) { |
| 98 | goto exit; |
| 99 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 100 | _return_value = msvcrt_setmode_impl(module, fd, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 101 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 102 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 103 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 104 | return_value = PyLong_FromLong(_return_value); |
| 105 | |
| 106 | exit: |
| 107 | return return_value; |
| 108 | } |
| 109 | |
| 110 | PyDoc_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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 121 | {"open_osfhandle", (PyCFunction)msvcrt_open_osfhandle, METH_FASTCALL, msvcrt_open_osfhandle__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 122 | |
| 123 | static long |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 124 | msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 125 | |
| 126 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 127 | msvcrt_open_osfhandle(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 128 | { |
| 129 | PyObject *return_value = NULL; |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 130 | intptr_t handle; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 131 | int flags; |
| 132 | long _return_value; |
| 133 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 134 | if (!_PyArg_ParseStack(args, nargs, ""_Py_PARSE_INTPTR"i:open_osfhandle", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 135 | &handle, &flags)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 136 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 137 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 138 | |
| 139 | if (!_PyArg_NoStackKeywords("open_osfhandle", kwnames)) { |
| 140 | goto exit; |
| 141 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 142 | _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 143 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 144 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 145 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 146 | return_value = PyLong_FromLong(_return_value); |
| 147 | |
| 148 | exit: |
| 149 | return return_value; |
| 150 | } |
| 151 | |
| 152 | PyDoc_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 Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 163 | static intptr_t |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 164 | msvcrt_get_osfhandle_impl(PyObject *module, int fd); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 165 | |
| 166 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 167 | msvcrt_get_osfhandle(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 168 | { |
| 169 | PyObject *return_value = NULL; |
| 170 | int fd; |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 171 | intptr_t _return_value; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 172 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 173 | if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 174 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 175 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 176 | _return_value = msvcrt_get_osfhandle_impl(module, fd); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 177 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 178 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 179 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 180 | return_value = PyLong_FromVoidPtr((void *)_return_value); |
| 181 | |
| 182 | exit: |
| 183 | return return_value; |
| 184 | } |
| 185 | |
| 186 | PyDoc_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 | |
| 195 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 196 | msvcrt_kbhit_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 197 | |
| 198 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 199 | msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 200 | { |
| 201 | PyObject *return_value = NULL; |
| 202 | long _return_value; |
| 203 | |
| 204 | _return_value = msvcrt_kbhit_impl(module); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 205 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 206 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 207 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 208 | return_value = PyLong_FromLong(_return_value); |
| 209 | |
| 210 | exit: |
| 211 | return return_value; |
| 212 | } |
| 213 | |
| 214 | PyDoc_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 | |
| 229 | static int |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 230 | msvcrt_getch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 231 | |
| 232 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 233 | msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 234 | { |
| 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 Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 244 | PyDoc_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 | |
| 253 | static wchar_t |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 254 | msvcrt_getwch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 255 | |
| 256 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 257 | msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 258 | { |
| 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 Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 268 | PyDoc_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 | |
| 277 | static int |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 278 | msvcrt_getche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 279 | |
| 280 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 281 | msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 282 | { |
| 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 Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 292 | PyDoc_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 | |
| 301 | static wchar_t |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 302 | msvcrt_getwche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 303 | |
| 304 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 305 | msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 306 | { |
| 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 Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 316 | PyDoc_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 | |
| 325 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 326 | msvcrt_putch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 327 | |
| 328 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 329 | msvcrt_putch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 330 | { |
| 331 | PyObject *return_value = NULL; |
| 332 | char char_value; |
| 333 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 334 | if (!PyArg_Parse(arg, "c:putch", &char_value)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 335 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 336 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 337 | return_value = msvcrt_putch_impl(module, char_value); |
| 338 | |
| 339 | exit: |
| 340 | return return_value; |
| 341 | } |
| 342 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 343 | PyDoc_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 | |
| 352 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 353 | msvcrt_putwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 354 | |
| 355 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 356 | msvcrt_putwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 357 | { |
| 358 | PyObject *return_value = NULL; |
| 359 | int unicode_char; |
| 360 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 361 | if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 362 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 363 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 364 | return_value = msvcrt_putwch_impl(module, unicode_char); |
| 365 | |
| 366 | exit: |
| 367 | return return_value; |
| 368 | } |
| 369 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 370 | PyDoc_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 | |
| 383 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 384 | msvcrt_ungetch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 385 | |
| 386 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 387 | msvcrt_ungetch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 388 | { |
| 389 | PyObject *return_value = NULL; |
| 390 | char char_value; |
| 391 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 392 | if (!PyArg_Parse(arg, "c:ungetch", &char_value)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 393 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 394 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 395 | return_value = msvcrt_ungetch_impl(module, char_value); |
| 396 | |
| 397 | exit: |
| 398 | return return_value; |
| 399 | } |
| 400 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 401 | PyDoc_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 | |
| 410 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 411 | msvcrt_ungetwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 412 | |
| 413 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 414 | msvcrt_ungetwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 415 | { |
| 416 | PyObject *return_value = NULL; |
| 417 | int unicode_char; |
| 418 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 419 | if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 420 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 421 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 422 | return_value = msvcrt_ungetwch_impl(module, unicode_char); |
| 423 | |
| 424 | exit: |
| 425 | return return_value; |
| 426 | } |
| 427 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 428 | #if defined(_DEBUG) |
| 429 | |
| 430 | PyDoc_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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 439 | {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_FASTCALL, msvcrt_CrtSetReportFile__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 440 | |
| 441 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 442 | msvcrt_CrtSetReportFile_impl(PyObject *module, int type, int file); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 443 | |
| 444 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 445 | msvcrt_CrtSetReportFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 446 | { |
| 447 | PyObject *return_value = NULL; |
| 448 | int type; |
| 449 | int file; |
| 450 | long _return_value; |
| 451 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 452 | if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportFile", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 453 | &type, &file)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 454 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 455 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 456 | |
| 457 | if (!_PyArg_NoStackKeywords("CrtSetReportFile", kwnames)) { |
| 458 | goto exit; |
| 459 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 460 | _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 461 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 462 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 463 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 464 | return_value = PyLong_FromLong(_return_value); |
| 465 | |
| 466 | exit: |
| 467 | return return_value; |
| 468 | } |
| 469 | |
| 470 | #endif /* defined(_DEBUG) */ |
| 471 | |
| 472 | #if defined(_DEBUG) |
| 473 | |
| 474 | PyDoc_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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 483 | {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_FASTCALL, msvcrt_CrtSetReportMode__doc__}, |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 484 | |
| 485 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 486 | msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 487 | |
| 488 | static PyObject * |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 489 | msvcrt_CrtSetReportMode(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 490 | { |
| 491 | PyObject *return_value = NULL; |
| 492 | int type; |
| 493 | int mode; |
| 494 | long _return_value; |
| 495 | |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 496 | if (!_PyArg_ParseStack(args, nargs, "ii:CrtSetReportMode", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 497 | &type, &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 498 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 499 | } |
Victor Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 500 | |
| 501 | if (!_PyArg_NoStackKeywords("CrtSetReportMode", kwnames)) { |
| 502 | goto exit; |
| 503 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 504 | _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 505 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 506 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 507 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 508 | return_value = PyLong_FromLong(_return_value); |
| 509 | |
| 510 | exit: |
| 511 | return return_value; |
| 512 | } |
| 513 | |
| 514 | #endif /* defined(_DEBUG) */ |
| 515 | |
| 516 | #if defined(_DEBUG) |
| 517 | |
| 518 | PyDoc_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 | |
| 529 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 530 | msvcrt_set_error_mode_impl(PyObject *module, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 531 | |
| 532 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 533 | msvcrt_set_error_mode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 534 | { |
| 535 | PyObject *return_value = NULL; |
| 536 | int mode; |
| 537 | long _return_value; |
| 538 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 539 | if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 540 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 541 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 542 | _return_value = msvcrt_set_error_mode_impl(module, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 543 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 544 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 545 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 546 | return_value = PyLong_FromLong(_return_value); |
| 547 | |
| 548 | exit: |
| 549 | return return_value; |
| 550 | } |
| 551 | |
| 552 | #endif /* defined(_DEBUG) */ |
| 553 | |
| 554 | PyDoc_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 | |
| 563 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 564 | msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 565 | |
| 566 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 567 | msvcrt_SetErrorMode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 568 | { |
| 569 | PyObject *return_value = NULL; |
| 570 | unsigned int mode; |
| 571 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 572 | if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 573 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 574 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 575 | return_value = msvcrt_SetErrorMode_impl(module, mode); |
| 576 | |
| 577 | exit: |
| 578 | return return_value; |
| 579 | } |
| 580 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 581 | #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 Stinner | 259f0e4 | 2017-01-17 01:35:17 +0100 | [diff] [blame] | 592 | /*[clinic end generated code: output=36f1e78ca8bd3944 input=a9049054013a1b77]*/ |