[pywin32-checkins] pywin32/win32/src win32pipe.i,1.14,1.15
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2007-06-06 21:41:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25484/win32/src Modified Files: win32pipe.i Log Message: Some 64-bit and autoduck fixes Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32pipe.i 16 Jul 2006 11:02:23 -0000 1.14 --- win32pipe.i 6 Jun 2007 21:41:46 -0000 1.15 *************** *** 297,311 **** PyObject *MyCallNamedPipe(PyObject *self, PyObject *args) { ! PyObject *obPipeName; ! char *data; ! int dataSize; DWORD timeOut; ! int readBufSize; TCHAR *szPipeName; ! if (!PyArg_ParseTuple(args, "Os#il:CallNamedPipe", ! &obPipeName, // @pyparm <o PyUNICODE>|pipeName||The name of the pipe. ! &data, &dataSize, // @pyparm string|data||The data to write. ! &readBufSize, // @pyparm int|bufSize||The size of the result buffer to allocate for the read. ! &timeOut)) // @pyparm int|timeOut||Specifies the number of milliseconds to wait for the named pipe to be available. In addition to numeric values, the following special values can be specified. // @flagh Value|Meaning // @flag win32pipe.NMPWAIT_NOWAIT|Does not wait for the named pipe. If the named pipe is not available, the function returns an error. --- 297,311 ---- PyObject *MyCallNamedPipe(PyObject *self, PyObject *args) { ! PyObject *obPipeName, *obdata; ! void *data; ! DWORD dataSize; DWORD timeOut; ! DWORD readBufSize; TCHAR *szPipeName; ! if (!PyArg_ParseTuple(args, "OOil:CallNamedPipe", ! &obPipeName, // @pyparm <o PyUNICODE>|pipeName||The name of the pipe. ! &obdata, // @pyparm string|data||The data to write. ! &readBufSize, // @pyparm int|bufSize||The size of the result buffer to allocate for the read. ! &timeOut)) // @pyparm int|timeOut||Specifies the number of milliseconds to wait for the named pipe to be available. In addition to numeric values, the following special values can be specified. // @flagh Value|Meaning // @flag win32pipe.NMPWAIT_NOWAIT|Does not wait for the named pipe. If the named pipe is not available, the function returns an error. *************** *** 313,327 **** // @flag win32pipe.NMPWAIT_USE_DEFAULT_WAIT|Uses the default time-out specified in a call to the CreateNamedPipe function. return NULL; ! if (!PyWinObject_AsTCHAR(obPipeName, &szPipeName)) return NULL; - void *readBuf = malloc(readBufSize); ! DWORD numRead = 0; BOOL ok; ! Py_BEGIN_ALLOW_THREADS ! ok = CallNamedPipe(szPipeName, (void *)data, dataSize, readBuf, readBufSize, &numRead, timeOut); ! Py_END_ALLOW_THREADS if (!ok) { PyWinObject_FreeTCHAR(szPipeName); --- 313,330 ---- // @flag win32pipe.NMPWAIT_USE_DEFAULT_WAIT|Uses the default time-out specified in a call to the CreateNamedPipe function. return NULL; ! if (!PyWinObject_AsReadBuffer(obdata, &data, &dataSize, FALSE)) ! return NULL; if (!PyWinObject_AsTCHAR(obPipeName, &szPipeName)) return NULL; void *readBuf = malloc(readBufSize); ! if (!readBuf){ ! PyWinObject_FreeTCHAR(szPipeName); ! return PyErr_NoMemory(); ! } DWORD numRead = 0; BOOL ok; ! Py_BEGIN_ALLOW_THREADS ! ok = CallNamedPipe(szPipeName, data, dataSize, readBuf, readBufSize, &numRead, timeOut); ! Py_END_ALLOW_THREADS if (!ok) { PyWinObject_FreeTCHAR(szPipeName); *************** *** 359,366 **** // @pyswig (int, int)|FdCreatePipe|As CreatePipe but returns file descriptors PyObject *FdCreatePipe( ! SECURITY_ATTRIBUTES *INPUT, // @pyparm <o PySECURITY_ATTRIBUTES>|sa|| ! DWORD nSize, // @pyparm int|nSize|| ! int mode // @pyparm int|mode|| ! ) { HANDLE hReadPipe; // variable for read handle --- 362,368 ---- // @pyswig (int, int)|FdCreatePipe|As CreatePipe but returns file descriptors PyObject *FdCreatePipe( ! SECURITY_ATTRIBUTES *INPUT, // @pyparm <o PySECURITY_ATTRIBUTES>|sa||Specifies security and inheritance for the pipe ! DWORD nSize, // @pyparm int|nSize||Buffer size for pipe. Use 0 for default size. ! int mode) // @pyparm int|mode||O_TEXT or O_BINARY { HANDLE hReadPipe; // variable for read handle *************** *** 377,382 **** return PyWin_SetAPIError("CreatePipe"); ! int read_fd = _open_osfhandle ((long) hReadPipe, mode); ! int write_fd = _open_osfhandle ((long) hWritePipe, mode); PyObject *result = Py_BuildValue("ii", read_fd, write_fd); return result; --- 379,384 ---- return PyWin_SetAPIError("CreatePipe"); ! int read_fd = _open_osfhandle ((INT_PTR)hReadPipe, mode); ! int write_fd = _open_osfhandle ((INT_PTR)hWritePipe, mode); PyObject *result = Py_BuildValue("ii", read_fd, write_fd); return result; *************** *** 443,447 **** PyObject *rc = NULL; if (PeekNamedPipe(hNamedPipe, buf, size, &bytesRead, &totalAvail, &bytesLeft)) { ! rc = Py_BuildValue("s#ii", (char *)buf, bytesRead, totalAvail, bytesLeft); } else PyWin_SetAPIError("PeekNamedPipe"); --- 445,451 ---- PyObject *rc = NULL; if (PeekNamedPipe(hNamedPipe, buf, size, &bytesRead, &totalAvail, &bytesLeft)) { ! rc = Py_BuildValue("Nii", ! PyString_FromStringAndSize((char *)buf, bytesRead), ! totalAvail, bytesLeft); } else PyWin_SetAPIError("PeekNamedPipe"); |