summaryrefslogtreecommitdiff
path: root/PC/msvcrtmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-09 14:46:46 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-09 14:46:46 +0000
commit7674841ef015b47767c7939c16a8ea1fe92ae340 (patch)
tree7d47cc565698109d01fd147dcbfa17c669f5aece /PC/msvcrtmodule.c
parent976291be7875a1f83dcb64b9c936175fb1cefc8c (diff)
downloadcpython-7674841ef015b47767c7939c16a8ea1fe92ae340.tar.gz
Untabify C files. Will watch buildbots.
Diffstat (limited to 'PC/msvcrtmodule.c')
-rwxr-xr-xPC/msvcrtmodule.c358
1 files changed, 179 insertions, 179 deletions
diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c
index 9764a02ab3..68b7d2432e 100755
--- a/PC/msvcrtmodule.c
+++ b/PC/msvcrtmodule.c
@@ -1,18 +1,18 @@
/*********************************************************
- msvcrtmodule.c
+ msvcrtmodule.c
- A Python interface to the Microsoft Visual C Runtime
- Library, providing access to those non-portable, but
- still useful routines.
+ A Python interface to the Microsoft Visual C Runtime
+ Library, providing access to those non-portable, but
+ still useful routines.
- Only ever compiled with an MS compiler, so no attempt
- has been made to avoid MS language extensions, etc...
+ Only ever compiled with an MS compiler, so no attempt
+ has been made to avoid MS language extensions, etc...
- This may only work on NT or 95...
+ This may only work on NT or 95...
- Author: Mark Hammond and Guido van Rossum.
- Maintenance: Guido van Rossum.
+ Author: Mark Hammond and Guido van Rossum.
+ Maintenance: Guido van Rossum.
***********************************************************/
@@ -33,14 +33,14 @@
static PyObject *
msvcrt_heapmin(PyObject *self, PyObject *args)
{
- if (!PyArg_ParseTuple(args, ":heapmin"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":heapmin"))
+ return NULL;
- if (_heapmin() != 0)
- return PyErr_SetFromErrno(PyExc_IOError);
+ if (_heapmin() != 0)
+ return PyErr_SetFromErrno(PyExc_IOError);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
PyDoc_STRVAR(heapmin_doc,
@@ -53,22 +53,22 @@ to the operating system. On failure, this raises IOError.");
static PyObject *
msvcrt_locking(PyObject *self, PyObject *args)
{
- int fd;
- int mode;
- long nbytes;
- int err;
-
- if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes))
- return NULL;
-
- Py_BEGIN_ALLOW_THREADS
- err = _locking(fd, mode, nbytes);
- Py_END_ALLOW_THREADS
- if (err != 0)
- return PyErr_SetFromErrno(PyExc_IOError);
-
- Py_INCREF(Py_None);
- return Py_None;
+ int fd;
+ int mode;
+ long nbytes;
+ int err;
+
+ if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes))
+ return NULL;
+
+ Py_BEGIN_ALLOW_THREADS
+ err = _locking(fd, mode, nbytes);
+ Py_END_ALLOW_THREADS
+ if (err != 0)
+ return PyErr_SetFromErrno(PyExc_IOError);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
PyDoc_STRVAR(locking_doc,
@@ -86,16 +86,16 @@ individually.");
static PyObject *
msvcrt_setmode(PyObject *self, PyObject *args)
{
- int fd;
- int flags;
- if (!PyArg_ParseTuple(args,"ii:setmode", &fd, &flags))
- return NULL;
+ int fd;
+ int flags;
+ if (!PyArg_ParseTuple(args,"ii:setmode", &fd, &flags))
+ return NULL;
- flags = _setmode(fd, flags);
- if (flags == -1)
- return PyErr_SetFromErrno(PyExc_IOError);
+ flags = _setmode(fd, flags);
+ if (flags == -1)
+ return PyErr_SetFromErrno(PyExc_IOError);
- return PyInt_FromLong(flags);
+ return PyInt_FromLong(flags);
}
PyDoc_STRVAR(setmode_doc,
@@ -109,18 +109,18 @@ os.O_BINARY.");
static PyObject *
msvcrt_open_osfhandle(PyObject *self, PyObject *args)
{
- long handle;
- int flags;
- int fd;
+ long handle;
+ int flags;
+ int fd;
- if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags))
- return NULL;
+ if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags))
+ return NULL;
- fd = _open_osfhandle(handle, flags);
- if (fd == -1)
- return PyErr_SetFromErrno(PyExc_IOError);
+ fd = _open_osfhandle(handle, flags);
+ if (fd == -1)
+ return PyErr_SetFromErrno(PyExc_IOError);
- return PyInt_FromLong(fd);
+ return PyInt_FromLong(fd);
}
PyDoc_STRVAR(open_osfhandle_doc,
@@ -135,20 +135,20 @@ to os.fdopen() to create a file object.");
static PyObject *
msvcrt_get_osfhandle(PyObject *self, PyObject *args)
{
- int fd;
- Py_intptr_t handle;
+ int fd;
+ Py_intptr_t handle;
- if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
- return NULL;
+ if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd))
+ return NULL;
- handle = _get_osfhandle(fd);
- if (handle == -1)
- return PyErr_SetFromErrno(PyExc_IOError);
+ handle = _get_osfhandle(fd);
+ if (handle == -1)
+ return PyErr_SetFromErrno(PyExc_IOError);
- /* technically 'handle' is not a pointer, but a integer as
- large as a pointer, Python's *VoidPtr interface is the
- most appropriate here */
- return PyLong_FromVoidPtr((void*)handle);
+ /* technically 'handle' is not a pointer, but a integer as
+ large as a pointer, Python's *VoidPtr interface is the
+ most appropriate here */
+ return PyLong_FromVoidPtr((void*)handle);
}
PyDoc_STRVAR(get_osfhandle_doc,
@@ -162,13 +162,13 @@ if fd is not recognized.");
static PyObject *
msvcrt_kbhit(PyObject *self, PyObject *args)
{
- int ok;
+ int ok;
- if (!PyArg_ParseTuple(args, ":kbhit"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":kbhit"))
+ return NULL;
- ok = _kbhit();
- return PyInt_FromLong(ok);
+ ok = _kbhit();
+ return PyInt_FromLong(ok);
}
PyDoc_STRVAR(kbhit_doc,
@@ -179,17 +179,17 @@ Return true if a keypress is waiting to be read.");
static PyObject *
msvcrt_getch(PyObject *self, PyObject *args)
{
- int ch;
- char s[1];
+ int ch;
+ char s[1];
- if (!PyArg_ParseTuple(args, ":getch"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":getch"))
+ return NULL;
- Py_BEGIN_ALLOW_THREADS
- ch = _getch();
- Py_END_ALLOW_THREADS
- s[0] = ch;
- return PyString_FromStringAndSize(s, 1);
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getch();
+ Py_END_ALLOW_THREADS
+ s[0] = ch;
+ return PyString_FromStringAndSize(s, 1);
}
PyDoc_STRVAR(getch_doc,
@@ -206,17 +206,17 @@ this function.");
static PyObject *
msvcrt_getwch(PyObject *self, PyObject *args)
{
- Py_UNICODE ch;
- Py_UNICODE u[1];
+ Py_UNICODE ch;
+ Py_UNICODE u[1];
- if (!PyArg_ParseTuple(args, ":getwch"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":getwch"))
+ return NULL;
- Py_BEGIN_ALLOW_THREADS
- ch = _getwch();
- Py_END_ALLOW_THREADS
- u[0] = ch;
- return PyUnicode_FromUnicode(u, 1);
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getwch();
+ Py_END_ALLOW_THREADS
+ u[0] = ch;
+ return PyUnicode_FromUnicode(u, 1);
}
PyDoc_STRVAR(getwch_doc,
@@ -228,17 +228,17 @@ Wide char variant of getch(), returning a Unicode value.");
static PyObject *
msvcrt_getche(PyObject *self, PyObject *args)
{
- int ch;
- char s[1];
+ int ch;
+ char s[1];
- if (!PyArg_ParseTuple(args, ":getche"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":getche"))
+ return NULL;
- Py_BEGIN_ALLOW_THREADS
- ch = _getche();
- Py_END_ALLOW_THREADS
- s[0] = ch;
- return PyString_FromStringAndSize(s, 1);
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getche();
+ Py_END_ALLOW_THREADS
+ s[0] = ch;
+ return PyString_FromStringAndSize(s, 1);
}
PyDoc_STRVAR(getche_doc,
@@ -251,17 +251,17 @@ a printable character.");
static PyObject *
msvcrt_getwche(PyObject *self, PyObject *args)
{
- Py_UNICODE ch;
- Py_UNICODE s[1];
+ Py_UNICODE ch;
+ Py_UNICODE s[1];
- if (!PyArg_ParseTuple(args, ":getwche"))
- return NULL;
+ if (!PyArg_ParseTuple(args, ":getwche"))
+ return NULL;
- Py_BEGIN_ALLOW_THREADS
- ch = _getwche();
- Py_END_ALLOW_THREADS
- s[0] = ch;
- return PyUnicode_FromUnicode(s, 1);
+ Py_BEGIN_ALLOW_THREADS
+ ch = _getwche();
+ Py_END_ALLOW_THREADS
+ s[0] = ch;
+ return PyUnicode_FromUnicode(s, 1);
}
PyDoc_STRVAR(getwche_doc,
@@ -273,14 +273,14 @@ Wide char variant of getche(), returning a Unicode value.");
static PyObject *
msvcrt_putch(PyObject *self, PyObject *args)
{
- char ch;
+ char ch;
- if (!PyArg_ParseTuple(args, "c:putch", &ch))
- return NULL;
+ if (!PyArg_ParseTuple(args, "c:putch", &ch))
+ return NULL;
- _putch(ch);
- Py_INCREF(Py_None);
- return Py_None;
+ _putch(ch);
+ Py_INCREF(Py_None);
+ return Py_None;
}
PyDoc_STRVAR(putch_doc,
@@ -292,19 +292,19 @@ Print the character char to the console without buffering.");
static PyObject *
msvcrt_putwch(PyObject *self, PyObject *args)
{
- Py_UNICODE *ch;
- int size;
+ Py_UNICODE *ch;
+ int size;
- if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size))
- return NULL;
+ if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size))
+ return NULL;
- if (size == 0) {
- PyErr_SetString(PyExc_ValueError,
- "Expected unicode string of length 1");
- return NULL;
- }
- _putwch(*ch);
- Py_RETURN_NONE;
+ if (size == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "Expected unicode string of length 1");
+ return NULL;
+ }
+ _putwch(*ch);
+ Py_RETURN_NONE;
}
@@ -317,15 +317,15 @@ Wide char variant of putch(), accepting a Unicode value.");
static PyObject *
msvcrt_ungetch(PyObject *self, PyObject *args)
{
- char ch;
+ char ch;
- if (!PyArg_ParseTuple(args, "c:ungetch", &ch))
- return NULL;
+ if (!PyArg_ParseTuple(args, "c:ungetch", &ch))
+ return NULL;
- if (_ungetch(ch) == EOF)
- return PyErr_SetFromErrno(PyExc_IOError);
- Py_INCREF(Py_None);
- return Py_None;
+ if (_ungetch(ch) == EOF)
+ return PyErr_SetFromErrno(PyExc_IOError);
+ Py_INCREF(Py_None);
+ return Py_None;
}
PyDoc_STRVAR(ungetch_doc,
@@ -338,15 +338,15 @@ it will be the next character read by getch() or getche().");
static PyObject *
msvcrt_ungetwch(PyObject *self, PyObject *args)
{
- Py_UNICODE ch;
+ Py_UNICODE ch;
- if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
- return NULL;
+ if (!PyArg_ParseTuple(args, "u:ungetwch", &ch))
+ return NULL;
- if (_ungetch(ch) == EOF)
- return PyErr_SetFromErrno(PyExc_IOError);
- Py_INCREF(Py_None);
- return Py_None;
+ if (_ungetch(ch) == EOF)
+ return PyErr_SetFromErrno(PyExc_IOError);
+ Py_INCREF(Py_None);
+ return Py_None;
}
PyDoc_STRVAR(ungetwch_doc,
@@ -358,70 +358,70 @@ Wide char variant of ungetch(), accepting a Unicode value.");
static void
insertint(PyObject *d, char *name, int value)
{
- PyObject *v = PyInt_FromLong((long) value);
- if (v == NULL) {
- /* Don't bother reporting this error */
- PyErr_Clear();
- }
- else {
- PyDict_SetItemString(d, name, v);
- Py_DECREF(v);
- }
+ PyObject *v = PyInt_FromLong((long) value);
+ if (v == NULL) {
+ /* Don't bother reporting this error */
+ PyErr_Clear();
+ }
+ else {
+ PyDict_SetItemString(d, name, v);
+ Py_DECREF(v);
+ }
}
/* List of functions exported by this module */
static struct PyMethodDef msvcrt_functions[] = {
- {"heapmin", msvcrt_heapmin, METH_VARARGS, heapmin_doc},
- {"locking", msvcrt_locking, METH_VARARGS, locking_doc},
- {"setmode", msvcrt_setmode, METH_VARARGS, setmode_doc},
- {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS, open_osfhandle_doc},
- {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS, get_osfhandle_doc},
- {"kbhit", msvcrt_kbhit, METH_VARARGS, kbhit_doc},
- {"getch", msvcrt_getch, METH_VARARGS, getch_doc},
- {"getche", msvcrt_getche, METH_VARARGS, getche_doc},
- {"putch", msvcrt_putch, METH_VARARGS, putch_doc},
- {"ungetch", msvcrt_ungetch, METH_VARARGS, ungetch_doc},
+ {"heapmin", msvcrt_heapmin, METH_VARARGS, heapmin_doc},
+ {"locking", msvcrt_locking, METH_VARARGS, locking_doc},
+ {"setmode", msvcrt_setmode, METH_VARARGS, setmode_doc},
+ {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS, open_osfhandle_doc},
+ {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS, get_osfhandle_doc},
+ {"kbhit", msvcrt_kbhit, METH_VARARGS, kbhit_doc},
+ {"getch", msvcrt_getch, METH_VARARGS, getch_doc},
+ {"getche", msvcrt_getche, METH_VARARGS, getche_doc},
+ {"putch", msvcrt_putch, METH_VARARGS, putch_doc},
+ {"ungetch", msvcrt_ungetch, METH_VARARGS, ungetch_doc},
#ifdef _WCONIO_DEFINED
- {"getwch", msvcrt_getwch, METH_VARARGS, getwch_doc},
- {"getwche", msvcrt_getwche, METH_VARARGS, getwche_doc},
- {"putwch", msvcrt_putwch, METH_VARARGS, putwch_doc},
- {"ungetwch", msvcrt_ungetwch, METH_VARARGS, ungetwch_doc},
+ {"getwch", msvcrt_getwch, METH_VARARGS, getwch_doc},
+ {"getwche", msvcrt_getwche, METH_VARARGS, getwche_doc},
+ {"putwch", msvcrt_putwch, METH_VARARGS, putwch_doc},
+ {"ungetwch", msvcrt_ungetwch, METH_VARARGS, ungetwch_doc},
#endif
- {NULL, NULL}
+ {NULL, NULL}
};
PyMODINIT_FUNC
initmsvcrt(void)
{
- int st;
- PyObject *d;
- PyObject *m = Py_InitModule("msvcrt", msvcrt_functions);
- if (m == NULL)
- return;
- d = PyModule_GetDict(m);
-
- /* constants for the locking() function's mode argument */
- insertint(d, "LK_LOCK", _LK_LOCK);
- insertint(d, "LK_NBLCK", _LK_NBLCK);
- insertint(d, "LK_NBRLCK", _LK_NBRLCK);
- insertint(d, "LK_RLCK", _LK_RLCK);
- insertint(d, "LK_UNLCK", _LK_UNLCK);
-
- /* constants for the crt versions */
+ int st;
+ PyObject *d;
+ PyObject *m = Py_InitModule("msvcrt", msvcrt_functions);
+ if (m == NULL)
+ return;
+ d = PyModule_GetDict(m);
+
+ /* constants for the locking() function's mode argument */
+ insertint(d, "LK_LOCK", _LK_LOCK);
+ insertint(d, "LK_NBLCK", _LK_NBLCK);
+ insertint(d, "LK_NBRLCK", _LK_NBRLCK);
+ insertint(d, "LK_RLCK", _LK_RLCK);
+ insertint(d, "LK_UNLCK", _LK_UNLCK);
+
+ /* constants for the crt versions */
#ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN
- st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN",
- _VC_ASSEMBLY_PUBLICKEYTOKEN);
- if (st < 0)return;
+ st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN",
+ _VC_ASSEMBLY_PUBLICKEYTOKEN);
+ if (st < 0)return;
#endif
#ifdef _CRT_ASSEMBLY_VERSION
- st = PyModule_AddStringConstant(m, "CRT_ASSEMBLY_VERSION",
- _CRT_ASSEMBLY_VERSION);
- if (st < 0)return;
+ st = PyModule_AddStringConstant(m, "CRT_ASSEMBLY_VERSION",
+ _CRT_ASSEMBLY_VERSION);
+ if (st < 0)return;
#endif
#ifdef __LIBRARIES_ASSEMBLY_NAME_PREFIX
- st = PyModule_AddStringConstant(m, "LIBRARIES_ASSEMBLY_NAME_PREFIX",
- __LIBRARIES_ASSEMBLY_NAME_PREFIX);
- if (st < 0)return;
+ st = PyModule_AddStringConstant(m, "LIBRARIES_ASSEMBLY_NAME_PREFIX",
+ __LIBRARIES_ASSEMBLY_NAME_PREFIX);
+ if (st < 0)return;
#endif
}