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 \ |
| 40 | {"locking", (PyCFunction)msvcrt_locking, METH_VARARGS, msvcrt_locking__doc__}, |
| 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 46 | msvcrt_locking(PyObject *module, PyObject *args) |
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 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 53 | if (!PyArg_ParseTuple(args, "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 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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_VARARGS, msvcrt_setmode__doc__}, |
| 76 | |
| 77 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 78 | msvcrt_setmode_impl(PyObject *module, int fd, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 79 | |
| 80 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 81 | msvcrt_setmode(PyObject *module, PyObject *args) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 82 | { |
| 83 | PyObject *return_value = NULL; |
| 84 | int fd; |
| 85 | int flags; |
| 86 | long _return_value; |
| 87 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 88 | if (!PyArg_ParseTuple(args, "ii:setmode", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 89 | &fd, &flags)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 90 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 91 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 92 | _return_value = msvcrt_setmode_impl(module, fd, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 93 | if ((_return_value == -1) && PyErr_Occurred()) { |
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 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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_VARARGS, msvcrt_open_osfhandle__doc__}, |
| 114 | |
| 115 | static long |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 116 | msvcrt_open_osfhandle_impl(PyObject *module, intptr_t handle, int flags); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 117 | |
| 118 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 119 | msvcrt_open_osfhandle(PyObject *module, PyObject *args) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 120 | { |
| 121 | PyObject *return_value = NULL; |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 122 | intptr_t handle; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 123 | int flags; |
| 124 | long _return_value; |
| 125 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 126 | if (!PyArg_ParseTuple(args, ""_Py_PARSE_INTPTR"i:open_osfhandle", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 127 | &handle, &flags)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 128 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 129 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 130 | _return_value = msvcrt_open_osfhandle_impl(module, handle, flags); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 131 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 132 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 133 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 IOError 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 | |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 151 | static intptr_t |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 152 | msvcrt_get_osfhandle_impl(PyObject *module, int fd); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 153 | |
| 154 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 155 | msvcrt_get_osfhandle(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 156 | { |
| 157 | PyObject *return_value = NULL; |
| 158 | int fd; |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 159 | intptr_t _return_value; |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 160 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 161 | if (!PyArg_Parse(arg, "i:get_osfhandle", &fd)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 162 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 163 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 164 | _return_value = msvcrt_get_osfhandle_impl(module, fd); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 165 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 166 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 167 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 168 | return_value = PyLong_FromVoidPtr((void *)_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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 184 | msvcrt_kbhit_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 185 | |
| 186 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 187 | msvcrt_kbhit(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 188 | { |
| 189 | PyObject *return_value = NULL; |
| 190 | long _return_value; |
| 191 | |
| 192 | _return_value = msvcrt_kbhit_impl(module); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 193 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 194 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 195 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 218 | msvcrt_getch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 219 | |
| 220 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 221 | msvcrt_getch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 242 | msvcrt_getwch_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 243 | |
| 244 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 245 | msvcrt_getwch(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 266 | msvcrt_getche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 267 | |
| 268 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 269 | msvcrt_getche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 290 | msvcrt_getwche_impl(PyObject *module); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 291 | |
| 292 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 293 | msvcrt_getwche(PyObject *module, PyObject *Py_UNUSED(ignored)) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 314 | msvcrt_putch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 315 | |
| 316 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 317 | msvcrt_putch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 318 | { |
| 319 | PyObject *return_value = NULL; |
| 320 | char char_value; |
| 321 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 322 | if (!PyArg_Parse(arg, "c:putch", &char_value)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 323 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 324 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 325 | return_value = msvcrt_putch_impl(module, char_value); |
| 326 | |
| 327 | exit: |
| 328 | return return_value; |
| 329 | } |
| 330 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 341 | msvcrt_putwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 342 | |
| 343 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 344 | msvcrt_putwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 345 | { |
| 346 | PyObject *return_value = NULL; |
| 347 | int unicode_char; |
| 348 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 349 | if (!PyArg_Parse(arg, "C:putwch", &unicode_char)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 350 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 351 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 352 | return_value = msvcrt_putwch_impl(module, unicode_char); |
| 353 | |
| 354 | exit: |
| 355 | return return_value; |
| 356 | } |
| 357 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 372 | msvcrt_ungetch_impl(PyObject *module, char char_value); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 373 | |
| 374 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 375 | msvcrt_ungetch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 376 | { |
| 377 | PyObject *return_value = NULL; |
| 378 | char char_value; |
| 379 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 380 | if (!PyArg_Parse(arg, "c:ungetch", &char_value)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 381 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 382 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 383 | return_value = msvcrt_ungetch_impl(module, char_value); |
| 384 | |
| 385 | exit: |
| 386 | return return_value; |
| 387 | } |
| 388 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 399 | msvcrt_ungetwch_impl(PyObject *module, int unicode_char); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 400 | |
| 401 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 402 | msvcrt_ungetwch(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 403 | { |
| 404 | PyObject *return_value = NULL; |
| 405 | int unicode_char; |
| 406 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 407 | if (!PyArg_Parse(arg, "C:ungetwch", &unicode_char)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 408 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 409 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 410 | return_value = msvcrt_ungetwch_impl(module, unicode_char); |
| 411 | |
| 412 | exit: |
| 413 | return return_value; |
| 414 | } |
| 415 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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_VARARGS, msvcrt_CrtSetReportFile__doc__}, |
| 428 | |
| 429 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 430 | msvcrt_CrtSetReportFile_impl(PyObject *module, int type, int file); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 431 | |
| 432 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 433 | msvcrt_CrtSetReportFile(PyObject *module, PyObject *args) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 434 | { |
| 435 | PyObject *return_value = NULL; |
| 436 | int type; |
| 437 | int file; |
| 438 | long _return_value; |
| 439 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 440 | if (!PyArg_ParseTuple(args, "ii:CrtSetReportFile", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 441 | &type, &file)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 442 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 443 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 444 | _return_value = msvcrt_CrtSetReportFile_impl(module, type, file); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 445 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 446 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 447 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 448 | return_value = PyLong_FromLong(_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_VARARGS, msvcrt_CrtSetReportMode__doc__}, |
| 468 | |
| 469 | static long |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 470 | msvcrt_CrtSetReportMode_impl(PyObject *module, int type, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 471 | |
| 472 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 473 | msvcrt_CrtSetReportMode(PyObject *module, PyObject *args) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 474 | { |
| 475 | PyObject *return_value = NULL; |
| 476 | int type; |
| 477 | int mode; |
| 478 | long _return_value; |
| 479 | |
Zachary Ware | 77772c0 | 2015-05-13 10:58:35 -0500 | [diff] [blame] | 480 | if (!PyArg_ParseTuple(args, "ii:CrtSetReportMode", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 481 | &type, &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 482 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 483 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 484 | _return_value = msvcrt_CrtSetReportMode_impl(module, type, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 485 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 486 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 487 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 510 | msvcrt_set_error_mode_impl(PyObject *module, int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 511 | |
| 512 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 513 | msvcrt_set_error_mode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 514 | { |
| 515 | PyObject *return_value = NULL; |
| 516 | int mode; |
| 517 | long _return_value; |
| 518 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 519 | if (!PyArg_Parse(arg, "i:set_error_mode", &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 520 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 521 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 522 | _return_value = msvcrt_set_error_mode_impl(module, mode); |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 523 | if ((_return_value == -1) && PyErr_Occurred()) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 524 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 525 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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 * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 544 | msvcrt_SetErrorMode_impl(PyObject *module, unsigned int mode); |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 545 | |
| 546 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 547 | msvcrt_SetErrorMode(PyObject *module, PyObject *arg) |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 548 | { |
| 549 | PyObject *return_value = NULL; |
| 550 | unsigned int mode; |
| 551 | |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 552 | if (!PyArg_Parse(arg, "I:SetErrorMode", &mode)) { |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 553 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 554 | } |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 555 | return_value = msvcrt_SetErrorMode_impl(module, mode); |
| 556 | |
| 557 | exit: |
| 558 | return return_value; |
| 559 | } |
| 560 | |
Zachary Ware | 4552089 | 2015-05-13 01:22:32 -0500 | [diff] [blame] | 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) */ |
Benjamin Peterson | cc85449 | 2016-09-08 09:29:11 -0700 | [diff] [blame] | 572 | /*[clinic end generated code: output=ae04e2b50eef8b63 input=a9049054013a1b77]*/ |