[pywin32-checkins] pywin32/win32/src win32pipe.i, 1.18, 1.19 win32popen.cpp, 1.10, 1.11
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
|
From: Mark H. <mha...@us...> - 2009-01-26 00:15:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv2168/win32/src Modified Files: win32pipe.i win32popen.cpp Log Message: On py2k, win32pipe.popen* no longer support win95 hacks via w9xpopen, and on py3k these functions don't exist at all! From py3k branch. Index: win32popen.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32popen.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32popen.cpp 6 Jun 2007 05:44:46 -0000 1.10 --- win32popen.cpp 26 Jan 2009 00:14:53 -0000 1.11 *************** *** 4,7 **** --- 4,11 ---- #include "Python.h" + + // Not used in py3k + #if (PY_VERSION_HEX < 0x03000000) + #include "malloc.h" #include "io.h" *************** *** 11,17 **** #define DllExport _declspec(dllexport) - extern bool g_fUsingWin9x; - extern CHAR g_szModulePath[]; - // These tell _PyPopen() wether to return 1, 2, or 3 file objects. #define POPEN_1 1 --- 15,18 ---- *************** *** 178,207 **** if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) return FALSE; ! if (!g_fUsingWin9x) ! { ! x = i + strlen(s3) + strlen(cmdstring) + 1; ! s2 = (char *)_alloca(x); ! ZeroMemory(s2, x); ! sprintf(s2, "%s%s%s", s1, s3, cmdstring); ! } ! else ! { ! // ! // Oh gag, we're on Win9x. Use the workaround listed in ! // KB: Q150956 ! // ! x = i + strlen(s3) + strlen(cmdstring) + 1 + strlen(g_szModulePath) + ! strlen(szConsoleSpawn) + 1; ! s2 = (char *)_alloca(x); ! ZeroMemory(s2, x); ! sprintf( ! s2, ! "%s%s%s%s%s\"", ! g_szModulePath, ! szConsoleSpawn, ! s1, ! s3, ! cmdstring); ! } } // Could be an else here to try cmd.exe / command.com in the path --- 179,186 ---- if (!(x = GetEnvironmentVariable("COMSPEC", s1, i))) return FALSE; ! x = i + strlen(s3) + strlen(cmdstring) + 1; ! s2 = (char *)_alloca(x); ! ZeroMemory(s2, x); ! sprintf(s2, "%s%s%s", s1, s3, cmdstring); } // Could be an else here to try cmd.exe / command.com in the path *************** *** 645,646 **** --- 624,627 ---- return result; } + + #endif // PY_VERSION_HEX < 0x03000000 Index: win32pipe.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32pipe.i,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** win32pipe.i 7 Jun 2008 07:23:54 -0000 1.18 --- win32pipe.i 26 Jan 2009 00:14:53 -0000 1.19 *************** *** 20,126 **** static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeClientSessionId = NULL; static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerSessionId = NULL; - - - // Global used to determine if Win9x win32pipe hack is necessary. - bool g_fUsingWin9x; - CHAR g_szModulePath[_MAX_PATH + 2]; - HINSTANCE g_hInstance = NULL; - - ///////////////////////////////////////////////////////////////////////////// - // DLL Entry Point - - #ifndef BUILD_FREEZE - // Doesnt work for freeze - but in that case, g_hInstance - // remaims NULL, so GetModuleFileName(NULL) will be used - // and still give the answer we are after. - extern "C" - BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) - { - if (dwReason == DLL_PROCESS_ATTACH) - g_hInstance = hInstance; - return TRUE; - } - #endif // BUILD_FREEZE - - static BOOL LoadModulePath(void) - { - DWORD cbModuleFilename; - CHAR *psz = NULL; - - // Note: GetModuleFileName will write nSize + 1 characters - // to get the null terminator. - cbModuleFilename = GetModuleFileName( - g_hInstance, - g_szModulePath, - sizeof(g_szModulePath) - 1); - if (0 == cbModuleFilename) - { - // hr = HRESULT_FROM_WIN32(GetLastError()); - // ErrorTrace(hr); - return FALSE; - } - - if ((sizeof(g_szModulePath) - 1) == cbModuleFilename) - { - // Note: This should never happen - // hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - // ErrorTrace(hr); - return FALSE; - } - - // Start from the end of the string and insert a '\0' after the first '\\' you find. - psz = g_szModulePath + strlen(g_szModulePath) - 1; - while (psz > g_szModulePath && *psz != '\\') - { - psz--; - } - - if (*psz == '\\') - { - psz++; - *psz = '\0'; - } - else - { - // Something wierd happened. :( - return FALSE; - } - return TRUE; - } - - %} %init %{ // All errors raised by this module are of this type. - Py_INCREF(PyWinExc_ApiError); PyDict_SetItemString(d, "error", PyWinExc_ApiError); ! // Setup g_fUsingWin9x and module path correctly... ! { ! LoadModulePath(); ! ! OSVERSIONINFO osvi; ! ! memset(&osvi, 0, sizeof(osvi)); ! osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); ! ! if (!GetVersionEx(&osvi)) ! { ! PyWin_SetAPIError("GetVersionEx"); ! } ! ! if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) ! { ! g_fUsingWin9x = TRUE; ! } ! else ! { ! g_fUsingWin9x = FALSE; ! } ! } ! HMODULE hmod=GetModuleHandle("Kernel32.dll"); if (!hmod) ! hmod=LoadLibrary("Kernel32.dll"); if (hmod){ pfnGetNamedPipeClientProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientProcessId"); --- 20,32 ---- static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeClientSessionId = NULL; static GetNamedPipeClientProcessIdfunc pfnGetNamedPipeServerSessionId = NULL; %} %init %{ // All errors raised by this module are of this type. PyDict_SetItemString(d, "error", PyWinExc_ApiError); ! HMODULE hmod=GetModuleHandle(_T("Kernel32.dll")); if (!hmod) ! hmod=LoadLibrary(_T("Kernel32.dll")); if (hmod){ pfnGetNamedPipeClientProcessId = (GetNamedPipeClientProcessIdfunc)GetProcAddress(hmod, "GetNamedPipeClientProcessId"); *************** *** 131,134 **** --- 37,41 ---- %} + %ifdef SWIG_PY2K %{ extern PyObject *PyPopen(PyObject *self, PyObject *args); *************** *** 150,153 **** --- 57,62 ---- %native(popen4) PyPopen4; + %endif // SWIG_PY2K + %native(GetNamedPipeHandleState) MyGetNamedPipeHandleState; *************** *** 353,362 **** if ((cbReadData!=(DWORD)-1) || !PyErr_Occurred()){ if (pOverlapped){ // guaranteed to be NULL on CE - PyBufferProcs *pb = NULL; obRet = PyBuffer_New(cbReadData); if (obRet==NULL) return NULL; ! pb = obRet->ob_type->tp_as_buffer; ! (*pb->bf_getwritebuffer)(obRet, 0, &readData); } else { obRet=PyString_FromStringAndSize(NULL, cbReadData); --- 262,272 ---- if ((cbReadData!=(DWORD)-1) || !PyErr_Occurred()){ if (pOverlapped){ // guaranteed to be NULL on CE obRet = PyBuffer_New(cbReadData); if (obRet==NULL) return NULL; ! // This shouldn't fail for buffer just created, but new buffer interface is screwy ... ! DWORD newbufsize; // maybe also check new buffer size matched requested size ? ! if (!PyWinObject_AsReadBuffer(obRet, &readData, &newbufsize)) ! return NULL; } else { obRet=PyString_FromStringAndSize(NULL, cbReadData); |