Changeset 388 for python/vendor/current/PC
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/PC
- Files:
-
- 1 added
- 82 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/PC/VC6/_bsddb.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\db-4.7.25\build_windows" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\db-4.7.25\build_windows" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\db-4.7.25\build_windows" /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\db-4.7.25\build_windows" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_ctypes.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\_ctypes\libffi_msvc" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_ctypes_test.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_elementtree.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D "BYTEORDER=1234" /D "XML_CONTEXT_BYTES=1024" /D "USE_PYEXPAT_CAPI" /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_msi.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_multiprocessing.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_socket.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_sqlite3.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\sqlite-source-3.3.4" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D MODULE_NAME=\"sqlite3\" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/_testcapi.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -
python/vendor/current/PC/VC6/_tkinter.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D " _DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c46 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c74 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\..\tcltk\include" /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/build_ssl.py
r2 r388 13 13 # it should configure and build SSL, then build the ssl Python extension 14 14 # without intervention. 15 16 # Modified by Christian Heimes 17 # Now this script supports pre-generated makefiles and assembly files. 18 # Developers don't need an installation of Perl anymore to build Python. A svn 19 # checkout from our svn repository is enough. 15 20 16 21 import os, sys, re, shutil … … 37 42 def find_working_perl(perls): 38 43 for perl in perls: 39 fh = os.popen( perl + ' -e "use Win32;"')44 fh = os.popen('"%s" -e "use Win32;"' % perl) 40 45 fh.read() 41 46 rc = fh.close() … … 121 126 os.system(do_script) 122 127 128 def cmp(f1, f2): 129 bufsize = 1024 * 8 130 with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2: 131 while True: 132 b1 = fp1.read(bufsize) 133 b2 = fp2.read(bufsize) 134 if b1 != b2: 135 return False 136 if not b1: 137 return True 138 139 def copy(src, dst): 140 if os.path.isfile(dst) and cmp(src, dst): 141 return 142 shutil.copy(src, dst) 143 123 144 def main(): 124 145 debug = "-d" in sys.argv … … 130 151 makefile="ms\\nt.mak" 131 152 m32 = makefile 153 dirsuffix = "32" 132 154 configure += " no-idea no-rc5 no-mdc2" 133 155 make_flags = "" … … 138 160 perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) 139 161 perl = find_working_perl(perls) 140 if perl is None: 162 if perl: 163 print "Found a working perl at '%s'" % (perl,) 164 else: 141 165 print "No Perl installation was found. Existing Makefiles are used." 142 else:143 print "Found a working perl at '%s'" % (perl,)144 166 sys.stdout.flush() 145 # Look for SSL 3 levels up from pcbuild- ie, same place zlib etc all live.167 # Look for SSL 3 levels up from PC/VC6 - ie, same place zlib etc all live. 146 168 ssl_dir = find_best_ssl_dir(("..\\..\\..",)) 147 169 if ssl_dir is None: … … 174 196 175 197 fix_makefile(makefile) 176 shutil.copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) 177 shutil.copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) 198 copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch) 199 copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch) 200 201 # If the assembler files don't exist in tmpXX, copy them there 202 if perl is None: 203 if not os.path.exists("tmp"+dirsuffix): 204 os.mkdir("tmp"+dirsuffix) 205 for f in os.listdir("asm"+dirsuffix): 206 if not f.endswith(".asm"): continue 207 if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue 208 shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix) 178 209 179 210 # Now run make. 180 shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")181 shutil.copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")211 copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h") 212 copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h") 182 213 183 214 #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile) -
python/vendor/current/PC/VC6/bz2.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0. 5" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 55 55 LINK32=link.exe 56 56 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 57 # ADD LINK32 ..\..\..\bzip2-1.0. 5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd"57 # ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" 58 58 # SUBTRACT LINK32 /pdb:none /nodefaultlib 59 59 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0. 5" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\..\bzip2-1.0.6" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 … … 83 83 LINK32=link.exe 84 84 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 85 # ADD LINK32 ..\..\..\bzip2-1.0. 5\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept85 # ADD LINK32 ..\..\..\bzip2-1.0.6\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt" /nodefaultlib:"libc" /out:"./bz2_d.pyd" /pdbtype:sept 86 86 # SUBTRACT LINK32 /pdb:none 87 87 -
python/vendor/current/PC/VC6/pyexpat.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D " _DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\Modules\expat" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "HAVE_EXPAT_H" /D "WIN32" /D "_WINDOWS" /D "XML_NS" /D "XML_DTD" /D BYTEORDER=1234 /D XML_CONTEXT_BYTES=1024 /D "XML_STATIC" /D "HAVE_MEMMOVE" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 -
python/vendor/current/PC/VC6/pythoncore.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D " NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_DL_EXPORT" /YX /FD /Zm200 /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "USE_DL_EXPORT" /YX /FD /Zm200 /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o /win32 "NUL" … … 55 55 LINK32=link.exe 56 56 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 57 # ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python2 6.dll"57 # ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python27.dll" 58 58 # SUBTRACT LINK32 /pdb:none 59 59 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D " _DEBUG" /D "USE_DL_EXPORT" /D "WIN32" /D "_WINDOWS" /YX /FD /Zm200 /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /I "..\..\modules\zlib" /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "USE_DL_EXPORT" /D "WIN32" /D "_WINDOWS" /YX /FD /Zm200 /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o /win32 "NUL" … … 83 83 LINK32=link.exe 84 84 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 85 # ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python2 6_d.dll" /pdbtype:sept85 # ADD LINK32 largeint.lib kernel32.lib user32.lib advapi32.lib shell32.lib /nologo /base:"0x1e000000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./python27_d.dll" /pdbtype:sept 86 86 # SUBTRACT LINK32 /pdb:none 87 87 … … 98 98 # Begin Source File 99 99 100 SOURCE=..\..\Modules\_bytesio.c101 # End Source File102 # Begin Source File103 104 100 SOURCE=..\..\Modules\cjkcodecs\_codecs_cn.c 105 101 # End Source File … … 138 134 # Begin Source File 139 135 140 SOURCE=..\..\Modules\_fileio.c141 # End Source File142 # Begin Source File143 144 136 SOURCE=..\..\Modules\_functoolsmodule.c 145 137 # End Source File … … 154 146 # Begin Source File 155 147 148 SOURCE=..\..\Modules\_io\_iomodule.c 149 # End Source File 150 # Begin Source File 151 156 152 SOURCE=..\..\Modules\_json.c 157 153 # End Source File … … 166 162 # Begin Source File 167 163 164 SOURCE=..\..\Modules\_math.c 165 # End Source File 166 # Begin Source File 167 168 168 SOURCE=..\..\Modules\_randommodule.c 169 169 # End Source File … … 238 238 # Begin Source File 239 239 240 SOURCE=..\..\Modules\_io\bufferedio.c 241 # End Source File 242 # Begin Source File 243 240 244 SOURCE=..\..\Objects\bufferobject.c 241 245 # End Source File … … 246 250 # Begin Source File 247 251 252 SOURCE=..\..\Modules\_io\bytesio.c 253 # End Source File 254 # Begin Source File 255 248 256 SOURCE=..\..\Objects\bytes_methods.c 249 257 # End Source File 250 258 # Begin Source File 251 259 260 SOURCE=..\..\Objects\capsule.c 261 # End Source File 262 # Begin Source File 263 252 264 SOURCE=..\..\Objects\cellobject.c 253 265 # End Source File … … 326 338 # Begin Source File 327 339 340 SOURCE=..\..\Python\dtoa.c 341 # End Source File 342 # Begin Source File 343 328 344 SOURCE=..\..\Python\dynload_win.c 329 345 # End Source File … … 343 359 344 360 SOURCE=..\..\Objects\exceptions.c 361 # End Source File 362 # Begin Source File 363 364 SOURCE=..\..\Modules\_io\fileio.c 345 365 # End Source File 346 366 # Begin Source File … … 411 431 # Begin Source File 412 432 413 SOURCE=..\..\Python\getmtime.c414 # End Source File415 # Begin Source File416 417 433 SOURCE=..\..\Python\getopt.c 418 434 # End Source File … … 444 460 445 461 SOURCE=..\..\Modules\zlib\gzio.c 462 # End Source File 463 # Begin Source File 464 465 SOURCE=..\..\Modules\_io\iobase.c 446 466 # End Source File 447 467 # Begin Source File … … 524 544 # Begin Source File 525 545 546 SOURCE=..\..\Objects\memoryobject.c 547 # End Source File 548 # Begin Source File 549 526 550 SOURCE=..\..\Parser\metagrammar.c 527 551 # End Source File … … 604 628 # Begin Source File 605 629 630 SOURCE=..\..\Python\pyctype.c 631 # End Source File 632 # Begin Source File 633 606 634 SOURCE=..\..\Python\pyfpe.c 607 635 # End Source File … … 636 664 # Begin Source File 637 665 666 SOURCE=..\..\Python\random.c 667 # End Source File 668 # Begin Source File 669 638 670 SOURCE=..\..\Objects\rangeobject.c 639 671 # End Source File … … 668 700 # Begin Source File 669 701 702 SOURCE=..\..\Modules\_io\stringio.c 703 # End Source File 704 # Begin Source File 705 670 706 SOURCE=..\..\Objects\stringobject.c 671 707 # End Source File … … 696 732 # Begin Source File 697 733 734 SOURCE=..\..\Modules\_io\textio.c 735 # End Source File 736 # Begin Source File 737 698 738 SOURCE=..\..\Python\thread.c 699 739 # End Source File … … 745 785 746 786 SOURCE=..\..\Modules\xxsubtype.c 747 # End Source File748 # Begin Source File749 750 SOURCE=..\..\Modules\yuvconvert.c751 787 # End Source File 752 788 # Begin Source File -
python/vendor/current/PC/VC6/readme.txt
r2 r388 2 2 ------------------------------------- 3 3 This directory is used to build Python for Win32 platforms, e.g. Windows 4 2000 and XP. It requires Microsoft Visual C++ 6.x or 5.x. 4 2000 and XP. It requires Microsoft Visual C++ 6.x or 5.x and Platform 5 SDK February 2003 Edition (Core SDK). 5 6 (For other Windows platforms and compilers, see ../readme.txt.) 6 7 … … 12 13 13 14 1) pythoncore (this builds the main Python DLL and library files, 14 python2 6.{dll, lib} in Release mode)15 python27.{dll, lib} in Release mode) 15 16 16 17 2) python (this builds the main Python executable, … … 23 24 24 25 When using the Debug setting, the output files have a _d added to 25 their name: python2 6_d.dll, python_d.exe, pyexpat_d.pyd, and so on.26 their name: python27_d.dll, python_d.exe, pyexpat_d.pyd, and so on. 26 27 27 28 SUBPROJECTS … … 40 41 _msi 41 42 _msi.c. You need to install Windows Installer SDK to build this module. 42 http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm43 43 _socket 44 44 socketmodule.c … … 121 121 directory: 122 122 123 svn export http://svn.python.org/projects/external/bzip2-1.0. 5123 svn export http://svn.python.org/projects/external/bzip2-1.0.6 124 124 125 125 And requires building bz2 first. 126 126 127 cd dist\bzip2-1.0. 5127 cd dist\bzip2-1.0.6 128 128 nmake -f makefile.msc 129 129 130 All of this managed to build bzip2-1.0. 5\libbz2.lib, which the Python130 All of this managed to build bzip2-1.0.6\libbz2.lib, which the Python 131 131 project links in. 132 132 … … 203 203 http://www.openssl.org 204 204 205 You (probably) don't want the "engine" code. For example, get 206 openssl-0.9.8g.tar.gz 207 not 208 openssl-engine-0.9.8g.tar.gz 205 You (probably) don't want the "engine" code. For example, don't get 206 openssl-engine-0.9.6g.tar.gz 209 207 210 208 Unpack into the "dist" directory, retaining the folder name from 211 209 the archive - for example, the latest stable OpenSSL will install as 212 dist/openssl- 0.9.8g210 dist/openssl-1.0.0a 213 211 214 212 You can (theoretically) use any version of OpenSSL you like - the 215 213 build process will automatically select the latest version. 216 214 217 You must also install ActivePerl from 218 http://www.activestate.com/Products/ActivePerl/ 219 as this is used by the OpenSSL build process. Complain to them <wink>. 215 You can install the NASM assembler from 216 http://www.nasm.us/ 217 for x86 builds. Put nasmw.exe anywhere in your PATH. 218 Note: recent releases of nasm only have nasm.exe. Just rename it to 219 nasmw.exe. 220 221 You can also install ActivePerl from 222 http://www.activestate.com/activeperl/ 223 if you like to use the official sources instead of the files from 224 python's subversion repository. The svn version contains pre-build 225 makefiles and assembly files. 220 226 221 227 The MSVC project simply invokes PC/VC6/build_ssl.py to perform -
python/vendor/current/PC/VC6/select.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." / I "..\..\..\select113" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 … … 55 55 LINK32=link.exe 56 56 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 57 # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws ock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./select.pyd"57 # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./select.pyd" 58 58 # SUBTRACT LINK32 /pdb:none 59 59 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." / I "..\..\..\select113" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 … … 83 83 LINK32=link.exe 84 84 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept 85 # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws ock32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./select_d.pyd" /pdbtype:sept85 # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /base:"0x1D110000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt" /out:"./select_d.pyd" /pdbtype:sept 86 86 # SUBTRACT LINK32 /pdb:none 87 87 -
python/vendor/current/PC/VC6/tcl852.patch
r2 r388 10 10 # else 11 11 typedef struct _stat64 Tcl_StatBuf; 12 --- tcl8.5.2\generic\tcl.h Fri Jun 13 03:35:39 200813 +++ tcl8.5.2\generic\tcl.h Sun Jan 4 16:52:30 200914 @@ -367,7 +367,7 @@15 typedef struct stati64 Tcl_StatBuf;16 # define TCL_LL_MODIFIER "L"17 # else /* __BORLANDC__ */18 -# if _MSC_VER < 1400 && !defined(_M_IX86)19 +# if _MSC_VER < 1400 /*&& !defined(_M_IX86)*/20 typedef struct _stati64 Tcl_StatBuf;21 # else22 typedef struct _stat64 Tcl_StatBuf; -
python/vendor/current/PC/VC6/unicodedata.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MMAP_EXPORTS" /YX /FD /GZ /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -
python/vendor/current/PC/VC6/w9xpopen.dsp
r2 r388 43 43 # PROP Ignore_Export_Lib 0 44 44 # PROP Target_Dir "" 45 # ADD BASE CPP /nologo /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c46 # ADD CPP /nologo /MD /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c45 # ADD BASE CPP /nologo /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 46 # ADD CPP /nologo /MD /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c 47 47 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 48 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 … … 70 70 # PROP Ignore_Export_Lib 0 71 71 # PROP Target_Dir "" 72 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c73 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c72 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 73 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c 74 74 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 75 75 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -
python/vendor/current/PC/VC6/winsound.dsp
r2 r388 44 44 # PROP Target_Dir "" 45 45 F90=df.exe 46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D " WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c46 # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c 47 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /c 48 48 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 49 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 … … 72 72 # PROP Target_Dir "" 73 73 F90=df.exe 74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D " WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c74 # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c 75 # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\Include" /I ".." /D "Py_BUILD_CORE_MODULE" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINSOUND_EXPORTS" /YX /FD /GZ /c 76 76 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 77 77 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -
python/vendor/current/PC/VS7.1/_bsddb.vcproj
r2 r388 22 22 Optimization="0" 23 23 AdditionalIncludeDirectories="..\..\Include;..\..\PC;"..\..\..\db-4.4.20\build_win32"" 24 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS"24 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS" 25 25 RuntimeLibrary="3" 26 26 UsePrecompiledHeader="2" … … 77 77 InlineFunctionExpansion="1" 78 78 AdditionalIncludeDirectories="..\..\Include;..\..\PC;"..\..\..\db-4.4.20\build_win32"" 79 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"79 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 80 80 StringPooling="TRUE" 81 81 RuntimeLibrary="2" … … 135 135 InlineFunctionExpansion="1" 136 136 AdditionalIncludeDirectories="..\..\Include;..\..\PC;"..\..\..\db-4.4.20\build_win32"" 137 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"137 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 138 138 StringPooling="TRUE" 139 139 BasicRuntimeChecks="0" … … 197 197 InlineFunctionExpansion="1" 198 198 AdditionalIncludeDirectories="..\..\Include;..\..\PC;"..\..\..\db-4.4.20\build_win32"" 199 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"199 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 200 200 StringPooling="TRUE" 201 201 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_ctypes.vcproj
r2 r388 22 22 Optimization="0" 23 23 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\_ctypes\libffi_msvc" 24 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"24 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS" 25 25 MinimalRebuild="FALSE" 26 26 BasicRuntimeChecks="3" … … 76 76 InlineFunctionExpansion="1" 77 77 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\_ctypes\libffi_msvc" 78 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"78 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 79 79 StringPooling="TRUE" 80 80 RuntimeLibrary="2" … … 133 133 InlineFunctionExpansion="1" 134 134 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\_ctypes\libffi_msvc" 135 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"135 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 136 136 StringPooling="TRUE" 137 137 BasicRuntimeChecks="0" … … 192 192 InlineFunctionExpansion="1" 193 193 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\_ctypes\libffi_msvc" 194 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"194 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 195 195 StringPooling="TRUE" 196 196 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_ctypes_test.vcproj
r2 r388 21 21 Optimization="0" 22 22 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 23 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"23 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS" 24 24 MinimalRebuild="FALSE" 25 25 BasicRuntimeChecks="3" … … 73 73 InlineFunctionExpansion="1" 74 74 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 75 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"75 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 76 76 StringPooling="TRUE" 77 77 RuntimeLibrary="2" … … 128 128 Optimization="0" 129 129 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 130 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"130 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS" 131 131 MinimalRebuild="FALSE" 132 132 BasicRuntimeChecks="0" … … 183 183 InlineFunctionExpansion="1" 184 184 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 185 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"185 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 186 186 StringPooling="TRUE" 187 187 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_elementtree.vcproj
r2 r388 23 23 Optimization="0" 24 24 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 25 PreprocessorDefinitions=" _DEBUG;HAVE_EXPAT_H;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE"25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;HAVE_EXPAT_H;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE" 26 26 RuntimeLibrary="3" 27 27 UsePrecompiledHeader="2" … … 76 76 InlineFunctionExpansion="1" 77 77 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 78 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE"78 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE" 79 79 StringPooling="TRUE" 80 80 RuntimeLibrary="2" … … 132 132 InlineFunctionExpansion="1" 133 133 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 134 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE"134 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE" 135 135 StringPooling="TRUE" 136 136 BasicRuntimeChecks="0" … … 192 192 InlineFunctionExpansion="1" 193 193 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 194 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE"194 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;USE_PYEXPAT_CAPI;XML_STATIC;HAVE_MEMMOVE" 195 195 StringPooling="TRUE" 196 196 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_msi.vcproj
r2 r388 24 24 Optimization="0" 25 25 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 26 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS;_USRDLL"26 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS;_USRDLL" 27 27 BasicRuntimeChecks="3" 28 28 RuntimeLibrary="3" … … 79 79 InlineFunctionExpansion="1" 80 80 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 81 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL"81 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL" 82 82 StringPooling="TRUE" 83 83 RuntimeLibrary="2" … … 134 134 InlineFunctionExpansion="1" 135 135 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 136 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL"136 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL" 137 137 StringPooling="TRUE" 138 138 BasicRuntimeChecks="0" … … 194 194 InlineFunctionExpansion="1" 195 195 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 196 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL"196 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL" 197 197 StringPooling="TRUE" 198 198 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_socket.vcproj
r2 r388 22 22 Optimization="0" 23 23 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 24 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS"24 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS" 25 25 RuntimeLibrary="3" 26 26 UsePrecompiledHeader="2" … … 76 76 InlineFunctionExpansion="1" 77 77 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 78 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"78 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 79 79 StringPooling="TRUE" 80 80 RuntimeLibrary="2" … … 133 133 InlineFunctionExpansion="1" 134 134 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 135 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"135 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 136 136 StringPooling="TRUE" 137 137 BasicRuntimeChecks="0" … … 194 194 InlineFunctionExpansion="1" 195 195 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 196 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"196 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 197 197 StringPooling="TRUE" 198 198 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_sqlite3.vcproj
r2 r388 23 23 Optimization="0" 24 24 AdditionalIncludeDirectories="..\..\Include;..\..\PC;..\..\..\sqlite-source-3.3.4" 25 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\""25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\"" 26 26 RuntimeLibrary="3" 27 27 UsePrecompiledHeader="2" … … 78 78 InlineFunctionExpansion="1" 79 79 AdditionalIncludeDirectories="..\..\Include;..\..\PC;..\..\..\sqlite-source-3.3.4" 80 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\""80 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\"" 81 81 StringPooling="TRUE" 82 82 RuntimeLibrary="2" … … 136 136 InlineFunctionExpansion="1" 137 137 AdditionalIncludeDirectories="..\..\Include;..\..\PC;..\..\..\sqlite-source-3.3.4" 138 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\""138 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\"" 139 139 StringPooling="TRUE" 140 140 BasicRuntimeChecks="0" … … 198 198 InlineFunctionExpansion="1" 199 199 AdditionalIncludeDirectories="..\..\Include;..\..\PC;..\..\..\sqlite-source-3.3.4" 200 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\""200 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;MODULE_NAME=\"sqlite3\"" 201 201 StringPooling="TRUE" 202 202 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_testcapi.vcproj
r2 r388 24 24 InlineFunctionExpansion="1" 25 25 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 26 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"26 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 27 27 StringPooling="TRUE" 28 28 RuntimeLibrary="2" … … 76 76 Optimization="0" 77 77 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 78 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"78 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 79 79 BasicRuntimeChecks="3" 80 80 RuntimeLibrary="3" … … 131 131 InlineFunctionExpansion="1" 132 132 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 133 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"133 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 134 134 StringPooling="TRUE" 135 135 BasicRuntimeChecks="0" … … 190 190 InlineFunctionExpansion="1" 191 191 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 192 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"192 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 193 193 StringPooling="TRUE" 194 194 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/_tkinter.vcproj
r2 r388 23 23 InlineFunctionExpansion="1" 24 24 AdditionalIncludeDirectories="..\..\..\tcltk\include,..\..\Include,..\..\PC" 25 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;WITH_APPINIT"25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;WITH_APPINIT" 26 26 StringPooling="TRUE" 27 27 RuntimeLibrary="2" … … 79 79 Optimization="0" 80 80 AdditionalIncludeDirectories="..\..\..\tcltk\include,..\..\Include,..\..\PC" 81 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS;WITH_APPINIT"81 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS;WITH_APPINIT" 82 82 RuntimeLibrary="3" 83 83 UsePrecompiledHeader="2" … … 135 135 InlineFunctionExpansion="1" 136 136 AdditionalIncludeDirectories="..\..\..\tcltk\include,..\..\Include,..\..\PC" 137 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;WITH_APPINIT"137 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;WITH_APPINIT" 138 138 StringPooling="TRUE" 139 139 BasicRuntimeChecks="0" … … 197 197 InlineFunctionExpansion="1" 198 198 AdditionalIncludeDirectories="..\..\..\tcltk\include,..\..\Include,..\..\PC" 199 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;WITH_APPINIT"199 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;WITH_APPINIT" 200 200 StringPooling="TRUE" 201 201 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/bz2.vcproj
r2 r388 23 23 Optimization="0" 24 24 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\..\bzip2-1.0.3" 25 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS"25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS" 26 26 RuntimeLibrary="3" 27 27 UsePrecompiledHeader="2" … … 81 81 InlineFunctionExpansion="1" 82 82 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\..\bzip2-1.0.3" 83 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"83 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 84 84 StringPooling="TRUE" 85 85 RuntimeLibrary="2" … … 142 142 InlineFunctionExpansion="1" 143 143 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\..\bzip2-1.0.3" 144 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"144 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 145 145 StringPooling="TRUE" 146 146 BasicRuntimeChecks="0" … … 207 207 InlineFunctionExpansion="1" 208 208 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\..\bzip2-1.0.3" 209 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"209 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 210 210 StringPooling="TRUE" 211 211 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/make_buildinfo.c
r2 r388 22 22 int make_buildinfo2() 23 23 { 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 24 struct _stat st; 25 HKEY hTortoise; 26 char command[500]; 27 DWORD type, size; 28 if (_stat(".svn", &st) < 0) 29 return 0; 30 /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ 31 if (_stat("no_subwcrev", &st) == 0) 32 return 0; 33 if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && 34 RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) 35 /* Tortoise not installed */ 36 return 0; 37 command[0] = '"'; /* quote the path to the executable */ 38 size = sizeof(command) - 1; 39 if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || 40 type != REG_SZ) 41 /* Registry corrupted */ 42 return 0; 43 strcat(command, "bin\\subwcrev.exe"); 44 if (_stat(command+1, &st) < 0) 45 /* subwcrev.exe not part of the release */ 46 return 0; 47 strcat(command, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c getbuildinfo2.c"); 48 puts(command); fflush(stdout); 49 if (system(command) < 0) 50 return 0; 51 return 1; 52 52 } 53 53 54 54 int main(int argc, char*argv[]) 55 55 { 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 56 char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; 57 int do_unlink, result; 58 if (argc != 2) { 59 fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); 60 return EXIT_FAILURE; 61 } 62 if (strcmp(argv[1], "Release") == 0) { 63 strcat(command, "-MD "); 64 } 65 else if (strcmp(argv[1], "Debug") == 0) { 66 strcat(command, "-D_DEBUG -MDd "); 67 } 68 else if (strcmp(argv[1], "ReleaseItanium") == 0) { 69 strcat(command, "-MD /USECL:MS_ITANIUM "); 70 } 71 else if (strcmp(argv[1], "ReleaseAMD64") == 0) { 72 strcat(command, "-MD "); 73 strcat(command, "-MD /USECL:MS_OPTERON "); 74 } 75 else { 76 fprintf(stderr, "unsupported configuration %s\n", argv[1]); 77 return EXIT_FAILURE; 78 } 79 79 80 81 82 83 84 85 86 87 88 89 90 91 80 if ((do_unlink = make_buildinfo2())) 81 strcat(command, "getbuildinfo2.c -DSUBWCREV "); 82 else 83 strcat(command, "..\\..\\Modules\\getbuildinfo.c"); 84 strcat(command, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); 85 puts(command); fflush(stdout); 86 result = system(command); 87 if (do_unlink) 88 unlink("getbuildinfo2.c"); 89 if (result < 0) 90 return EXIT_FAILURE; 91 return 0; 92 92 } -
python/vendor/current/PC/VS7.1/pyexpat.vcproj
r2 r388 22 22 Optimization="0" 23 23 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 24 PreprocessorDefinitions=" _DEBUG;HAVE_EXPAT_H;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE"24 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;HAVE_EXPAT_H;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE" 25 25 RuntimeLibrary="3" 26 26 UsePrecompiledHeader="2" … … 75 75 InlineFunctionExpansion="1" 76 76 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 77 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE"77 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE" 78 78 StringPooling="TRUE" 79 79 RuntimeLibrary="2" … … 131 131 InlineFunctionExpansion="1" 132 132 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 133 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE"133 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE" 134 134 StringPooling="TRUE" 135 135 BasicRuntimeChecks="0" … … 191 191 InlineFunctionExpansion="1" 192 192 AdditionalIncludeDirectories="..\..\Include,..\..\PC,..\..\Modules\expat" 193 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE"193 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;XML_NS;XML_DTD;BYTEORDER=1234;XML_CONTEXT_BYTES=1024;XML_STATIC;HAVE_MEMMOVE" 194 194 StringPooling="TRUE" 195 195 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/pythoncore.vcproj
r2 r388 26 26 InlineFunctionExpansion="1" 27 27 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 28 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT"28 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT" 29 29 StringPooling="TRUE" 30 30 RuntimeLibrary="2" … … 40 40 Name="VCLinkerTool" 41 41 AdditionalDependencies="getbuildinfo.o" 42 OutputFile="./python2 6.dll"42 OutputFile="./python27.dll" 43 43 LinkIncremental="1" 44 44 SuppressStartupBanner="TRUE" 45 45 IgnoreDefaultLibraryNames="libc" 46 46 GenerateDebugInformation="TRUE" 47 ProgramDatabaseFile=".\./python2 6.pdb"47 ProgramDatabaseFile=".\./python27.pdb" 48 48 SubSystem="2" 49 49 BaseAddress="0x1e000000" 50 ImportLibrary=".\./python2 6.lib"50 ImportLibrary=".\./python27.lib" 51 51 TargetMachine="1"/> 52 52 <Tool … … 88 88 Optimization="0" 89 89 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 90 PreprocessorDefinitions=" _DEBUG;USE_DL_EXPORT;WIN32;_WINDOWS"90 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;USE_DL_EXPORT;WIN32;_WINDOWS" 91 91 RuntimeLibrary="3" 92 92 UsePrecompiledHeader="2" … … 100 100 Name="VCLinkerTool" 101 101 AdditionalDependencies="getbuildinfo.o" 102 OutputFile="./python2 6_d.dll"102 OutputFile="./python27_d.dll" 103 103 LinkIncremental="1" 104 104 SuppressStartupBanner="TRUE" 105 105 IgnoreDefaultLibraryNames="libc" 106 106 GenerateDebugInformation="TRUE" 107 ProgramDatabaseFile=".\./python2 6_d.pdb"107 ProgramDatabaseFile=".\./python27_d.pdb" 108 108 SubSystem="2" 109 109 BaseAddress="0x1e000000" 110 ImportLibrary=".\./python2 6_d.lib"110 ImportLibrary=".\./python27_d.lib" 111 111 TargetMachine="1"/> 112 112 <Tool … … 149 149 InlineFunctionExpansion="1" 150 150 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 151 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT"151 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT" 152 152 StringPooling="TRUE" 153 153 BasicRuntimeChecks="0" … … 167 167 AdditionalOptions=" /MACHINE:IA64 /USELINK:MS_SDK" 168 168 AdditionalDependencies="getbuildinfo.o" 169 OutputFile="./python2 6.dll"169 OutputFile="./python27.dll" 170 170 LinkIncremental="1" 171 171 SuppressStartupBanner="FALSE" 172 172 IgnoreDefaultLibraryNames="libc" 173 173 GenerateDebugInformation="TRUE" 174 ProgramDatabaseFile=".\./python2 6.pdb"174 ProgramDatabaseFile=".\./python27.pdb" 175 175 SubSystem="2" 176 176 BaseAddress="0x1e000000" 177 ImportLibrary=".\./python2 6.lib"177 ImportLibrary=".\./python27.lib" 178 178 TargetMachine="0"/> 179 179 <Tool … … 216 216 InlineFunctionExpansion="1" 217 217 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 218 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT"218 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT" 219 219 StringPooling="TRUE" 220 220 BasicRuntimeChecks="0" … … 234 234 AdditionalOptions=" /MACHINE:AMD64 /USELINK:MS_SDK" 235 235 AdditionalDependencies="getbuildinfo.o" 236 OutputFile="./python2 6.dll"236 OutputFile="./python27.dll" 237 237 LinkIncremental="1" 238 238 SuppressStartupBanner="TRUE" 239 239 IgnoreDefaultLibraryNames="libc" 240 240 GenerateDebugInformation="TRUE" 241 ProgramDatabaseFile=".\./python2 6.pdb"241 ProgramDatabaseFile=".\./python27.pdb" 242 242 SubSystem="2" 243 243 BaseAddress="0x1e000000" 244 ImportLibrary=".\./python2 6.lib"244 ImportLibrary=".\./python27.lib" 245 245 TargetMachine="0"/> 246 246 <Tool … … 363 363 </File> 364 364 <File 365 RelativePath="..\..\Modules\_bytesio.c">366 </File>367 <File368 365 RelativePath="..\..\Modules\_codecsmodule.c"> 369 366 </File> … … 372 369 </File> 373 370 <File 374 RelativePath="..\..\Modules\_fileio.c">375 </File>376 <File377 371 RelativePath="..\..\Modules\_functoolsmodule.c"> 378 372 </File> … … 384 378 </File> 385 379 <File 380 RelativePath="..\..\Modules\_io\_iomodule.c"> 381 </File> 382 <File 386 383 RelativePath="..\..\Modules\_json.c"> 387 384 </File> … … 393 390 </File> 394 391 <File 392 RelativePath="..\..\Modules\_math.c"> 393 </File> 394 <File 395 395 RelativePath="..\..\Modules\_randommodule.c"> 396 396 </File> … … 444 444 </File> 445 445 <File 446 RelativePath="..\..\Modules\_io\bufferedio.c"> 447 </File> 448 <File 446 449 RelativePath="..\..\Objects\bufferobject.c"> 447 450 </File> … … 450 453 </File> 451 454 <File 455 RelativePath="..\..\Modules\_io\bytesio.c"> 456 </File> 457 <File 452 458 RelativePath="..\..\Objects\stringobject.c"> 453 459 </File> 454 460 <File 455 461 RelativePath="..\..\Objects\bytes_methods.c"> 462 </File> 463 <File 464 RelativePath="..\..\Objects\capsule.c"> 456 465 </File> 457 466 <File … … 510 519 </File> 511 520 <File 521 RelativePath="..\..\Python\dtoa.c"> 522 </File> 523 <File 512 524 RelativePath="..\..\Python\dynload_win.c"> 513 525 </File> … … 525 537 </File> 526 538 <File 539 RelativePath="..\..\Modules\_io\fileio.c"> 540 </File> 541 <File 527 542 RelativePath="..\..\Objects\fileobject.c"> 528 543 </File> … … 568 583 <File 569 584 RelativePath="..\..\Python\getcopyright.c"> 570 </File>571 <File572 RelativePath="..\..\Python\getmtime.c">573 585 </File> 574 586 <File … … 633 645 </File> 634 646 <File 647 RelativePath="..\..\Modules\_io\iobase.c"> 648 </File> 649 <File 635 650 RelativePath="..\..\Objects\iterobject.c"> 636 651 </File> … … 663 678 </File> 664 679 <File 680 RelativePath="..\..\Objects\memoryobject.c"> 681 </File> 682 <File 665 683 RelativePath="..\..\Parser\metagrammar.c"> 666 684 </File> … … 723 741 </File> 724 742 <File 743 RelativePath="..\..\Python\pyctype.c"> 744 </File> 745 <File 725 746 RelativePath="..\..\Python\pyfpe.c"> 726 747 </File> … … 747 768 </File> 748 769 <File 770 RelativePath="..\..\Python\random.c"> 771 </File> 772 <File 749 773 RelativePath="..\..\Objects\rangeobject.c"> 750 774 </File> … … 771 795 </File> 772 796 <File 797 RelativePath="..\..\Modules\_io\stringio.c"> 798 </File> 799 <File 773 800 RelativePath="..\..\Modules\stropmodule.c"> 774 801 </File> … … 789 816 </File> 790 817 <File 818 RelativePath="..\..\Modules\_io\textio.c"> 819 </File> 820 <File 791 821 RelativePath="..\..\Python\thread.c"> 792 822 </File> … … 820 850 <File 821 851 RelativePath="..\..\Modules\xxsubtype.c"> 822 </File>823 <File824 RelativePath="..\..\Modules\yuvconvert.c">825 852 </File> 826 853 <File -
python/vendor/current/PC/VS7.1/readme.txt
r2 r388 13 13 14 14 1) pythoncore (this builds the main Python DLL and library files, 15 python2 6.{dll, lib} in Release mode)15 python27.{dll, lib} in Release mode) 16 16 NOTE: in previous releases, this subproject was 17 17 named after the release number, e.g. python20. … … 27 27 28 28 When using the Debug setting, the output files have a _d added to 29 their name: python2 6_d.dll, python_d.exe, parser_d.pyd, and so on.29 their name: python27_d.dll, python_d.exe, parser_d.pyd, and so on. 30 30 31 31 SUBPROJECTS -
python/vendor/current/PC/VS7.1/select.vcproj
r2 r388 23 23 InlineFunctionExpansion="1" 24 24 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 25 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 26 26 StringPooling="TRUE" 27 27 RuntimeLibrary="2" … … 36 36 <Tool 37 37 Name="VCLinkerTool" 38 AdditionalDependencies="ws ock32.lib"38 AdditionalDependencies="ws2_32.lib" 39 39 OutputFile="./select.pyd" 40 40 LinkIncremental="1" … … 79 79 Optimization="0" 80 80 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 81 PreprocessorDefinitions=" _DEBUG;WIN32;_WINDOWS"81 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;_DEBUG;WIN32;_WINDOWS" 82 82 RuntimeLibrary="3" 83 83 UsePrecompiledHeader="2" … … 90 90 <Tool 91 91 Name="VCLinkerTool" 92 AdditionalDependencies="ws ock32.lib"92 AdditionalDependencies="ws2_32.lib" 93 93 OutputFile="./select_d.pyd" 94 94 LinkIncremental="1" … … 135 135 InlineFunctionExpansion="1" 136 136 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 137 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"137 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 138 138 StringPooling="TRUE" 139 139 BasicRuntimeChecks="0" … … 152 152 Name="VCLinkerTool" 153 153 AdditionalOptions=" /MACHINE:IA64 /USELINK:MS_SDK" 154 AdditionalDependencies="ws ock32.lib"154 AdditionalDependencies="ws2_32.lib" 155 155 OutputFile="./select.pyd" 156 156 LinkIncremental="1" … … 197 197 InlineFunctionExpansion="1" 198 198 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 199 PreprocessorDefinitions=" NDEBUG;WIN32;_WINDOWS"199 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;NDEBUG;WIN32;_WINDOWS" 200 200 StringPooling="TRUE" 201 201 BasicRuntimeChecks="0" … … 214 214 Name="VCLinkerTool" 215 215 AdditionalOptions=" /MACHINE:AMD64 /USELINK:MS_SDK" 216 AdditionalDependencies="ws ock32.lib"216 AdditionalDependencies="ws2_32.lib" 217 217 OutputFile="./select.pyd" 218 218 LinkIncremental="1" -
python/vendor/current/PC/VS7.1/unicodedata.vcproj
r2 r388 24 24 InlineFunctionExpansion="1" 25 25 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 26 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"26 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 27 27 StringPooling="TRUE" 28 28 RuntimeLibrary="2" … … 76 76 Optimization="0" 77 77 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 78 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"78 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 79 79 BasicRuntimeChecks="3" 80 80 RuntimeLibrary="3" … … 131 131 InlineFunctionExpansion="1" 132 132 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 133 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"133 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 134 134 StringPooling="TRUE" 135 135 BasicRuntimeChecks="0" … … 190 190 InlineFunctionExpansion="1" 191 191 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 192 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS"192 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" 193 193 StringPooling="TRUE" 194 194 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS7.1/w9xpopen.vcproj
r2 r388 22 22 Name="VCCLCompilerTool" 23 23 Optimization="0" 24 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS"24 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS" 25 25 BasicRuntimeChecks="3" 26 26 RuntimeLibrary="3" … … 72 72 Optimization="2" 73 73 InlineFunctionExpansion="1" 74 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS"74 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS" 75 75 StringPooling="TRUE" 76 76 RuntimeLibrary="2" -
python/vendor/current/PC/VS7.1/winsound.vcproj
r2 r388 23 23 Optimization="0" 24 24 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 25 PreprocessorDefinitions=" WIN32;_DEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS"25 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;_DEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS" 26 26 BasicRuntimeChecks="3" 27 27 RuntimeLibrary="3" … … 78 78 InlineFunctionExpansion="1" 79 79 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 80 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS"80 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS" 81 81 StringPooling="TRUE" 82 82 RuntimeLibrary="2" … … 133 133 InlineFunctionExpansion="1" 134 134 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 135 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS"135 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS" 136 136 StringPooling="TRUE" 137 137 BasicRuntimeChecks="0" … … 193 193 InlineFunctionExpansion="1" 194 194 AdditionalIncludeDirectories="..\..\Include,..\..\PC" 195 PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS"195 PreprocessorDefinitions="Py_BUILD_CORE_MODULE;WIN32;NDEBUG;_WINDOWS;_USRDLL;WINSOUND_EXPORTS" 196 196 StringPooling="TRUE" 197 197 BasicRuntimeChecks="0" -
python/vendor/current/PC/VS8.0/_multiprocessing.vcproj
r2 r388 4 4 Version="8.00" 5 5 Name="_multiprocessing" 6 ProjectGUID="{9 e48b300-37d1-11dd-8c41-005056c00008}"6 ProjectGUID="{9E48B300-37D1-11DD-8C41-005056C00008}" 7 7 RootNamespace="_multiprocessing" 8 8 Keyword="Win32Proj" -
python/vendor/current/PC/VS8.0/_sqlite3.vcproj
r2 r388 43 43 <Tool 44 44 Name="VCCLCompilerTool" 45 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"45 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 46 46 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 47 47 /> … … 105 105 <Tool 106 106 Name="VCCLCompilerTool" 107 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"107 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 108 108 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 109 109 /> … … 167 167 <Tool 168 168 Name="VCCLCompilerTool" 169 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"169 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 170 170 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 171 171 /> … … 230 230 <Tool 231 231 Name="VCCLCompilerTool" 232 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"232 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 233 233 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 234 234 /> … … 292 292 <Tool 293 293 Name="VCCLCompilerTool" 294 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"294 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 295 295 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 296 296 /> … … 355 355 <Tool 356 356 Name="VCCLCompilerTool" 357 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"357 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 358 358 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 359 359 /> … … 418 418 <Tool 419 419 Name="VCCLCompilerTool" 420 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"420 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 421 421 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 422 422 /> … … 481 481 <Tool 482 482 Name="VCCLCompilerTool" 483 AdditionalIncludeDirectories="..\..\..\sqlite-3. 5.9"483 AdditionalIncludeDirectories="..\..\..\sqlite-3.6.21" 484 484 PreprocessorDefinitions="MODULE_NAME=\"sqlite3\"" 485 485 /> -
python/vendor/current/PC/VS8.0/bdist_wininst.vcproj
r2 r388 56 56 PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" 57 57 StringPooling="true" 58 RuntimeLibrary=" 2"58 RuntimeLibrary="0" 59 59 EnableFunctionLevelLinking="true" 60 60 WarningLevel="3" … … 146 146 PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" 147 147 StringPooling="true" 148 RuntimeLibrary=" 2"148 RuntimeLibrary="0" 149 149 EnableFunctionLevelLinking="true" 150 150 WarningLevel="3" -
python/vendor/current/PC/VS8.0/build_ssl.bat
r2 r388 3 3 if %1 EQU Debug ( 4 4 set HOST_PYTHON=python_d.exe 5 if not exist python2 6_d.dll exit 15 if not exist python27_d.dll exit 1 6 6 ) ELSE ( 7 7 set HOST_PYTHON=python.exe 8 if not exist python2 6.dll exit 18 if not exist python27.dll exit 1 9 9 ) 10 10 ) -
python/vendor/current/PC/VS8.0/build_ssl.py
r2 r388 9 9 # any other external packages there. 10 10 # * Install ActivePerl and ensure it is somewhere on your path. 11 # * Run this script from the PC Builddirectory.11 # * Run this script from the PC/VS8.0 directory. 12 12 # 13 13 # it should configure and build SSL, then build the _ssl and _hashlib … … 47 47 def find_working_perl(perls): 48 48 for perl in perls: 49 fh = os.popen( perl + ' -e "use Win32;"')49 fh = os.popen('"%s" -e "use Win32;"' % perl) 50 50 fh.read() 51 51 rc = fh.close() … … 179 179 perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) 180 180 perl = find_working_perl(perls) 181 if perl is None: 181 if perl: 182 print("Found a working perl at '%s'" % (perl,)) 183 else: 182 184 print("No Perl installation was found. Existing Makefiles are used.") 183 184 print("Found a working perl at '%s'" % (perl,))185 185 sys.stdout.flush() 186 # Look for SSL 2 levels up from pcbuild- ie, same place zlib etc all live.186 # Look for SSL 3 levels up from PC/VS8.0 - ie, same place zlib etc all live. 187 187 ssl_dir = find_best_ssl_dir(("..\\..\\..",)) 188 188 if ssl_dir is None: -
python/vendor/current/PC/VS8.0/bz2.vcproj
r2 r388 44 44 Name="VCCLCompilerTool" 45 45 AdditionalIncludeDirectories="$(bz2Dir)" 46 /> 47 <Tool 48 Name="VCManagedResourceCompilerTool" 49 /> 50 <Tool 51 Name="VCResourceCompilerTool" 52 /> 53 <Tool 54 Name="VCPreLinkEventTool" 55 Description="Build libbz2" 56 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Debug\libbz2.lib exit 0
if not exist $(PlatformName)-Debug mkdir $(PlatformName)-Debug
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Debug
nmake /nologo /f makefile.msc clean
" 57 /> 58 <Tool 59 Name="VCLinkerTool" 60 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Debug\libbz2.lib" 46 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 47 /> 48 <Tool 49 Name="VCManagedResourceCompilerTool" 50 /> 51 <Tool 52 Name="VCResourceCompilerTool" 53 /> 54 <Tool 55 Name="VCPreLinkEventTool" 56 /> 57 <Tool 58 Name="VCLinkerTool" 59 BaseAddress="0x1D170000" 61 60 /> 62 61 <Tool … … 107 106 Name="VCCLCompilerTool" 108 107 AdditionalIncludeDirectories="$(bz2Dir)" 109 /> 110 <Tool 111 Name="VCManagedResourceCompilerTool" 112 /> 113 <Tool 114 Name="VCResourceCompilerTool" 115 /> 116 <Tool 117 Name="VCPreLinkEventTool" 118 Description="Build libbz2" 119 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Debug\libbz2.lib exit 0
if not exist $(PlatformName)-Debug mkdir $(PlatformName)-Debug
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Debug
nmake /nologo /f makefile.msc clean
" 120 /> 121 <Tool 122 Name="VCLinkerTool" 123 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Debug\libbz2.lib" 108 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 109 /> 110 <Tool 111 Name="VCManagedResourceCompilerTool" 112 /> 113 <Tool 114 Name="VCResourceCompilerTool" 115 /> 116 <Tool 117 Name="VCPreLinkEventTool" 118 /> 119 <Tool 120 Name="VCLinkerTool" 121 BaseAddress="0x1D170000" 124 122 /> 125 123 <Tool … … 170 168 Name="VCCLCompilerTool" 171 169 AdditionalIncludeDirectories="$(bz2Dir)" 172 /> 173 <Tool 174 Name="VCManagedResourceCompilerTool" 175 /> 176 <Tool 177 Name="VCResourceCompilerTool" 178 /> 179 <Tool 180 Name="VCPreLinkEventTool" 181 Description="Build libbz2" 182 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 183 /> 184 <Tool 185 Name="VCLinkerTool" 186 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 170 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 171 /> 172 <Tool 173 Name="VCManagedResourceCompilerTool" 174 /> 175 <Tool 176 Name="VCResourceCompilerTool" 177 /> 178 <Tool 179 Name="VCPreLinkEventTool" 180 /> 181 <Tool 182 Name="VCLinkerTool" 183 BaseAddress="0x1D170000" 187 184 /> 188 185 <Tool … … 234 231 Name="VCCLCompilerTool" 235 232 AdditionalIncludeDirectories="$(bz2Dir)" 236 /> 237 <Tool 238 Name="VCManagedResourceCompilerTool" 239 /> 240 <Tool 241 Name="VCResourceCompilerTool" 242 /> 243 <Tool 244 Name="VCPreLinkEventTool" 245 Description="Build libbz2" 246 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 247 /> 248 <Tool 249 Name="VCLinkerTool" 250 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 233 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 234 /> 235 <Tool 236 Name="VCManagedResourceCompilerTool" 237 /> 238 <Tool 239 Name="VCResourceCompilerTool" 240 /> 241 <Tool 242 Name="VCPreLinkEventTool" 243 /> 244 <Tool 245 Name="VCLinkerTool" 246 BaseAddress="0x1D170000" 251 247 /> 252 248 <Tool … … 297 293 Name="VCCLCompilerTool" 298 294 AdditionalIncludeDirectories="$(bz2Dir)" 299 /> 300 <Tool 301 Name="VCManagedResourceCompilerTool" 302 /> 303 <Tool 304 Name="VCResourceCompilerTool" 305 /> 306 <Tool 307 Name="VCPreLinkEventTool" 308 Description="Build libbz2" 309 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 310 /> 311 <Tool 312 Name="VCLinkerTool" 313 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 295 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 296 /> 297 <Tool 298 Name="VCManagedResourceCompilerTool" 299 /> 300 <Tool 301 Name="VCResourceCompilerTool" 302 /> 303 <Tool 304 Name="VCPreLinkEventTool" 305 /> 306 <Tool 307 Name="VCLinkerTool" 308 BaseAddress="0x1D170000" 314 309 /> 315 310 <Tool … … 361 356 Name="VCCLCompilerTool" 362 357 AdditionalIncludeDirectories="$(bz2Dir)" 363 /> 364 <Tool 365 Name="VCManagedResourceCompilerTool" 366 /> 367 <Tool 368 Name="VCResourceCompilerTool" 369 /> 370 <Tool 371 Name="VCPreLinkEventTool" 372 Description="Build libbz2" 373 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 374 /> 375 <Tool 376 Name="VCLinkerTool" 377 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 358 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 359 /> 360 <Tool 361 Name="VCManagedResourceCompilerTool" 362 /> 363 <Tool 364 Name="VCResourceCompilerTool" 365 /> 366 <Tool 367 Name="VCPreLinkEventTool" 368 /> 369 <Tool 370 Name="VCLinkerTool" 371 BaseAddress="0x1D170000" 378 372 TargetMachine="17" 379 373 /> … … 425 419 Name="VCCLCompilerTool" 426 420 AdditionalIncludeDirectories="$(bz2Dir)" 427 /> 428 <Tool 429 Name="VCManagedResourceCompilerTool" 430 /> 431 <Tool 432 Name="VCResourceCompilerTool" 433 /> 434 <Tool 435 Name="VCPreLinkEventTool" 436 Description="Build libbz2" 437 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 438 /> 439 <Tool 440 Name="VCLinkerTool" 441 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 421 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 422 /> 423 <Tool 424 Name="VCManagedResourceCompilerTool" 425 /> 426 <Tool 427 Name="VCResourceCompilerTool" 428 /> 429 <Tool 430 Name="VCPreLinkEventTool" 431 /> 432 <Tool 433 Name="VCLinkerTool" 434 BaseAddress="0x1D170000" 442 435 /> 443 436 <Tool … … 489 482 Name="VCCLCompilerTool" 490 483 AdditionalIncludeDirectories="$(bz2Dir)" 491 /> 492 <Tool 493 Name="VCManagedResourceCompilerTool" 494 /> 495 <Tool 496 Name="VCResourceCompilerTool" 497 /> 498 <Tool 499 Name="VCPreLinkEventTool" 500 Description="Build libbz2" 501 CommandLine="cd $(bz2Dir)
if exist $(PlatformName)-Release\libbz2.lib exit 0
if not exist $(PlatformName)-Release mkdir $(PlatformName)-Release
nmake /nologo /f makefile.msc lib
copy libbz2.lib $(PlatformName)-Release
nmake /nologo /f makefile.msc clean
" 502 /> 503 <Tool 504 Name="VCLinkerTool" 505 AdditionalDependencies="$(bz2Dir)\$(PlatformName)-Release\libbz2.lib" 484 PreprocessorDefinitions="WIN32;_FILE_OFFSET_BITS=64" 485 /> 486 <Tool 487 Name="VCManagedResourceCompilerTool" 488 /> 489 <Tool 490 Name="VCResourceCompilerTool" 491 /> 492 <Tool 493 Name="VCPreLinkEventTool" 494 /> 495 <Tool 496 Name="VCLinkerTool" 497 BaseAddress="0x1D170000" 506 498 TargetMachine="17" 507 499 /> … … 540 532 </File> 541 533 </Filter> 534 <Filter 535 Name="bzip2 1.0.6 Header Files" 536 > 537 <File 538 RelativePath="$(bz2Dir)\bzlib.h" 539 > 540 </File> 541 <File 542 RelativePath="$(bz2Dir)\bzlib_private.h" 543 > 544 </File> 545 </Filter> 546 <Filter 547 Name="bzip2 1.0.6 Source Files" 548 > 549 <File 550 RelativePath="$(bz2Dir)\blocksort.c" 551 > 552 </File> 553 <File 554 RelativePath="$(bz2Dir)\bzlib.c" 555 > 556 </File> 557 <File 558 RelativePath="$(bz2Dir)\compress.c" 559 > 560 </File> 561 <File 562 RelativePath="$(bz2Dir)\crctable.c" 563 > 564 </File> 565 <File 566 RelativePath="$(bz2Dir)\decompress.c" 567 > 568 </File> 569 <File 570 RelativePath="$(bz2Dir)\huffman.c" 571 > 572 </File> 573 <File 574 RelativePath="$(bz2Dir)\randtable.c" 575 > 576 </File> 577 </Filter> 542 578 </Files> 543 579 <Globals> -
python/vendor/current/PC/VS8.0/make_buildinfo.c
r2 r388 24 24 int make_buildinfo2() 25 25 { 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 26 struct _stat st; 27 HKEY hTortoise; 28 char command[CMD_SIZE+1]; 29 DWORD type, size; 30 if (_stat(".svn", &st) < 0) 31 return 0; 32 /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ 33 if (_stat("no_subwcrev", &st) == 0) 34 return 0; 35 if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && 36 RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) 37 /* Tortoise not installed */ 38 return 0; 39 command[0] = '"'; /* quote the path to the executable */ 40 size = sizeof(command) - 1; 41 if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || 42 type != REG_SZ) 43 /* Registry corrupted */ 44 return 0; 45 strcat_s(command, CMD_SIZE, "bin\\subwcrev.exe"); 46 if (_stat(command+1, &st) < 0) 47 /* subwcrev.exe not part of the release */ 48 return 0; 49 strcat_s(command, CMD_SIZE, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c getbuildinfo2.c"); 50 puts(command); fflush(stdout); 51 if (system(command) < 0) 52 return 0; 53 return 1; 54 54 } 55 55 56 56 int main(int argc, char*argv[]) 57 57 { 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 58 char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; 59 int do_unlink, result; 60 if (argc != 2) { 61 fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); 62 return EXIT_FAILURE; 63 } 64 if (strcmp(argv[1], "Release") == 0) { 65 strcat_s(command, CMD_SIZE, "-MD "); 66 } 67 else if (strcmp(argv[1], "Debug") == 0) { 68 strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd "); 69 } 70 else if (strcmp(argv[1], "ReleaseItanium") == 0) { 71 strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM "); 72 } 73 else if (strcmp(argv[1], "ReleaseAMD64") == 0) { 74 strcat_s(command, CMD_SIZE, "-MD "); 75 strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON "); 76 } 77 else { 78 fprintf(stderr, "unsupported configuration %s\n", argv[1]); 79 return EXIT_FAILURE; 80 } 81 81 82 83 84 85 86 87 88 89 90 91 92 93 82 if ((do_unlink = make_buildinfo2())) 83 strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV "); 84 else 85 strcat_s(command, CMD_SIZE, "..\\..\\Modules\\getbuildinfo.c"); 86 strcat_s(command, CMD_SIZE, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); 87 puts(command); fflush(stdout); 88 result = system(command); 89 if (do_unlink) 90 _unlink("getbuildinfo2.c"); 91 if (result < 0) 92 return EXIT_FAILURE; 93 return 0; 94 94 } -
python/vendor/current/PC/VS8.0/pyd.vsprops
r2 r388 16 16 ProgramDatabaseFile="$(OutDir)\$(ProjectName).pdb" 17 17 ImportLibrary="$(OutDir)\$(TargetName).lib" 18 GenerateManifest="false" 19 /> 20 <Tool 21 Name="VCManifestTool" 22 EmbedManifest="false" 18 23 /> 19 24 <Tool -
python/vendor/current/PC/VS8.0/pyd_d.vsprops
r2 r388 20 20 ProgramDatabaseFile="$(OutDir)\$(ProjectName)_d.pdb" 21 21 ImportLibrary="$(OutDir)\$(TargetName).lib" 22 GenerateManifest="false" 23 /> 24 <Tool 25 Name="VCManifestTool" 26 EmbedManifest="false" 22 27 /> 23 28 <Tool -
python/vendor/current/PC/VS8.0/pyproject.vsprops
r2 r388 39 39 <UserMacro 40 40 Name="PyDllName" 41 Value="python2 6"41 Value="python27" 42 42 /> 43 43 <UserMacro … … 48 48 Name="externalsDir" 49 49 Value="..\..\.." 50 /> 51 <UserMacro 52 Name="bsddb47Dir" 53 Value="$(externalsDir)\db-4.7.25.0\build_windows" 54 /> 55 <UserMacro 56 Name="bsddb47DepLibs" 57 Value="ws2_32.lib" 50 58 /> 51 59 <UserMacro … … 66 74 /> 67 75 <UserMacro 68 Name="bsddb47Dir"69 Value="$(externalsDir)\db-4.7.25.0\build_windows"70 />71 <UserMacro72 Name="bsddb47DepLibs"73 Value="ws2_32.lib"74 />75 <UserMacro76 76 Name="sqlite3Dir" 77 Value="$(externalsDir)\sqlite-3. 5.9"77 Value="$(externalsDir)\sqlite-3.6.21" 78 78 /> 79 79 <UserMacro 80 80 Name="bz2Dir" 81 Value="$(externalsDir)\bzip2-1.0. 5"81 Value="$(externalsDir)\bzip2-1.0.6" 82 82 /> 83 83 <UserMacro 84 84 Name="opensslDir" 85 Value="$(externalsDir)\openssl-0.9.8 g"85 Value="$(externalsDir)\openssl-0.9.8y" 86 86 /> 87 87 <UserMacro -
python/vendor/current/PC/VS8.0/pythoncore.vcproj
r2 r388 716 716 </File> 717 717 <File 718 RelativePath="..\..\Include\dtoa.h" 719 > 720 </File> 721 <File 718 722 RelativePath="..\..\Include\enumobject.h" 719 723 > … … 849 853 <File 850 854 RelativePath="..\..\Include\pyarena.h" 855 > 856 </File> 857 <File 858 RelativePath="..\..\Include\pycapsule.h" 859 > 860 </File> 861 <File 862 RelativePath="..\..\Include\pyctype.h" 851 863 > 852 864 </File> … … 996 1008 </File> 997 1009 <File 998 RelativePath="..\..\Modules\_fileio.c"999 >1000 </File>1001 <File1002 RelativePath="..\..\Modules\_bytesio.c"1003 >1004 </File>1005 <File1006 1010 RelativePath="..\..\Modules\_functoolsmodule.c" 1007 1011 > … … 1028 1032 </File> 1029 1033 <File 1034 RelativePath="..\..\Modules\_math.c" 1035 > 1036 </File> 1037 <File 1038 RelativePath="..\..\Modules\_math.h" 1039 > 1040 </File> 1041 <File 1030 1042 RelativePath="..\..\Modules\_randommodule.c" 1031 1043 > … … 1169 1181 <File 1170 1182 RelativePath="..\..\Modules\xxsubtype.c" 1171 >1172 </File>1173 <File1174 RelativePath="..\..\Modules\yuv.h"1175 >1176 </File>1177 <File1178 RelativePath="..\..\Modules\yuvconvert.c"1179 1183 > 1180 1184 </File> … … 1352 1356 <File 1353 1357 RelativePath="..\..\Modules\cjkcodecs\multibytecodec.h" 1358 > 1359 </File> 1360 </Filter> 1361 <Filter 1362 Name="_io" 1363 > 1364 <File 1365 RelativePath="..\..\Modules\_io\_iomodule.c" 1366 > 1367 </File> 1368 <File 1369 RelativePath="..\..\Modules\_io\_iomodule.h" 1370 > 1371 </File> 1372 <File 1373 RelativePath="..\..\Modules\_io\bufferedio.c" 1374 > 1375 </File> 1376 <File 1377 RelativePath="..\..\Modules\_io\bytesio.c" 1378 > 1379 </File> 1380 <File 1381 RelativePath="..\..\Modules\_io\fileio.c" 1382 > 1383 </File> 1384 <File 1385 RelativePath="..\..\Modules\_io\iobase.c" 1386 > 1387 </File> 1388 <File 1389 RelativePath="..\..\Modules\_io\stringio.c" 1390 > 1391 </File> 1392 <File 1393 RelativePath="..\..\Modules\_io\textio.c" 1354 1394 > 1355 1395 </File> … … 1380 1420 </File> 1381 1421 <File 1422 RelativePath="..\..\Objects\capsule.c" 1423 > 1424 </File> 1425 <File 1426 RelativePath="..\..\Objects\cellobject.c" 1427 > 1428 </File> 1429 <File 1430 RelativePath="..\..\Objects\classobject.c" 1431 > 1432 </File> 1433 <File 1434 RelativePath="..\..\Objects\cobject.c" 1435 > 1436 </File> 1437 <File 1438 RelativePath="..\..\Objects\codeobject.c" 1439 > 1440 </File> 1441 <File 1442 RelativePath="..\..\Objects\complexobject.c" 1443 > 1444 </File> 1445 <File 1446 RelativePath="..\..\Objects\stringlib\count.h" 1447 > 1448 </File> 1449 <File 1450 RelativePath="..\..\Objects\descrobject.c" 1451 > 1452 </File> 1453 <File 1454 RelativePath="..\..\Objects\dictobject.c" 1455 > 1456 </File> 1457 <File 1458 RelativePath="..\..\Objects\enumobject.c" 1459 > 1460 </File> 1461 <File 1462 RelativePath="..\..\Objects\exceptions.c" 1463 > 1464 </File> 1465 <File 1466 RelativePath="..\..\Objects\stringlib\fastsearch.h" 1467 > 1468 </File> 1469 <File 1470 RelativePath="..\..\Objects\fileobject.c" 1471 > 1472 </File> 1473 <File 1474 RelativePath="..\..\Objects\stringlib\find.h" 1475 > 1476 </File> 1477 <File 1478 RelativePath="..\..\Objects\floatobject.c" 1479 > 1480 </File> 1481 <File 1482 RelativePath="..\..\Objects\frameobject.c" 1483 > 1484 </File> 1485 <File 1486 RelativePath="..\..\Objects\funcobject.c" 1487 > 1488 </File> 1489 <File 1490 RelativePath="..\..\Objects\genobject.c" 1491 > 1492 </File> 1493 <File 1494 RelativePath="..\..\Objects\intobject.c" 1495 > 1496 </File> 1497 <File 1498 RelativePath="..\..\Objects\iterobject.c" 1499 > 1500 </File> 1501 <File 1502 RelativePath="..\..\Objects\listobject.c" 1503 > 1504 </File> 1505 <File 1506 RelativePath="..\..\Objects\longobject.c" 1507 > 1508 </File> 1509 <File 1510 RelativePath="..\..\Objects\memoryobject.c" 1511 > 1512 </File> 1513 <File 1514 RelativePath="..\..\Objects\methodobject.c" 1515 > 1516 </File> 1517 <File 1518 RelativePath="..\..\Objects\moduleobject.c" 1519 > 1520 </File> 1521 <File 1522 RelativePath="..\..\Objects\object.c" 1523 > 1524 </File> 1525 <File 1526 RelativePath="..\..\Objects\obmalloc.c" 1527 > 1528 </File> 1529 <File 1530 RelativePath="..\..\Objects\stringlib\partition.h" 1531 > 1532 </File> 1533 <File 1534 RelativePath="..\..\Objects\rangeobject.c" 1535 > 1536 </File> 1537 <File 1538 RelativePath="..\..\Objects\setobject.c" 1539 > 1540 </File> 1541 <File 1542 RelativePath="..\..\Objects\sliceobject.c" 1543 > 1544 </File> 1545 <File 1546 RelativePath="..\..\Objects\stringlib\split.h" 1547 > 1548 </File> 1549 <File 1382 1550 RelativePath="..\..\Objects\stringobject.c" 1383 >1384 </File>1385 <File1386 RelativePath="..\..\Objects\cellobject.c"1387 >1388 </File>1389 <File1390 RelativePath="..\..\Objects\classobject.c"1391 >1392 </File>1393 <File1394 RelativePath="..\..\Objects\cobject.c"1395 >1396 </File>1397 <File1398 RelativePath="..\..\Objects\codeobject.c"1399 >1400 </File>1401 <File1402 RelativePath="..\..\Objects\complexobject.c"1403 >1404 </File>1405 <File1406 RelativePath="..\..\Objects\stringlib\count.h"1407 >1408 </File>1409 <File1410 RelativePath="..\..\Objects\descrobject.c"1411 >1412 </File>1413 <File1414 RelativePath="..\..\Objects\dictobject.c"1415 >1416 </File>1417 <File1418 RelativePath="..\..\Objects\enumobject.c"1419 >1420 </File>1421 <File1422 RelativePath="..\..\Objects\exceptions.c"1423 >1424 </File>1425 <File1426 RelativePath="..\..\Objects\stringlib\fastsearch.h"1427 >1428 </File>1429 <File1430 RelativePath="..\..\Objects\fileobject.c"1431 >1432 </File>1433 <File1434 RelativePath="..\..\Objects\stringlib\find.h"1435 >1436 </File>1437 <File1438 RelativePath="..\..\Objects\floatobject.c"1439 >1440 </File>1441 <File1442 RelativePath="..\..\Objects\frameobject.c"1443 >1444 </File>1445 <File1446 RelativePath="..\..\Objects\funcobject.c"1447 >1448 </File>1449 <File1450 RelativePath="..\..\Objects\genobject.c"1451 >1452 </File>1453 <File1454 RelativePath="..\..\Objects\intobject.c"1455 >1456 </File>1457 <File1458 RelativePath="..\..\Objects\iterobject.c"1459 >1460 </File>1461 <File1462 RelativePath="..\..\Objects\listobject.c"1463 >1464 </File>1465 <File1466 RelativePath="..\..\Objects\longobject.c"1467 >1468 </File>1469 <File1470 RelativePath="..\..\Objects\methodobject.c"1471 >1472 </File>1473 <File1474 RelativePath="..\..\Objects\moduleobject.c"1475 >1476 </File>1477 <File1478 RelativePath="..\..\Objects\object.c"1479 >1480 </File>1481 <File1482 RelativePath="..\..\Objects\obmalloc.c"1483 >1484 </File>1485 <File1486 RelativePath="..\..\Objects\stringlib\partition.h"1487 >1488 </File>1489 <File1490 RelativePath="..\..\Objects\rangeobject.c"1491 >1492 </File>1493 <File1494 RelativePath="..\..\Objects\setobject.c"1495 >1496 </File>1497 <File1498 RelativePath="..\..\Objects\sliceobject.c"1499 1551 > 1500 1552 </File> … … 1660 1712 </File> 1661 1713 <File 1714 RelativePath="..\..\Python\dtoa.c" 1715 > 1716 </File> 1717 <File 1662 1718 RelativePath="..\..\Python\dynload_win.c" 1663 1719 > … … 1696 1752 </File> 1697 1753 <File 1698 RelativePath="..\..\Python\getmtime.c"1699 >1700 </File>1701 <File1702 1754 RelativePath="..\..\Python\getopt.c" 1703 1755 > … … 1752 1804 </File> 1753 1805 <File 1806 RelativePath="..\..\Python\pyctype.c" 1807 > 1808 </File> 1809 <File 1754 1810 RelativePath="..\..\Python\pyfpe.c" 1755 1811 > … … 1777 1833 <File 1778 1834 RelativePath="..\..\Python\pythonrun.c" 1835 > 1836 </File> 1837 <File 1838 RelativePath="..\..\Python\random.c" 1779 1839 > 1780 1840 </File> -
python/vendor/current/PC/VS8.0/select.vcproj
r2 r388 55 55 <Tool 56 56 Name="VCLinkerTool" 57 AdditionalDependencies="ws ock32.lib"57 AdditionalDependencies="ws2_32.lib" 58 58 IgnoreDefaultLibraryNames="libc" 59 59 BaseAddress="0x1D110000" … … 117 117 <Tool 118 118 Name="VCLinkerTool" 119 AdditionalDependencies="ws ock32.lib"119 AdditionalDependencies="ws2_32.lib" 120 120 IgnoreDefaultLibraryNames="libc" 121 121 BaseAddress="0x1D110000" … … 179 179 <Tool 180 180 Name="VCLinkerTool" 181 AdditionalDependencies="ws ock32.lib"181 AdditionalDependencies="ws2_32.lib" 182 182 IgnoreDefaultLibraryNames="libc" 183 183 BaseAddress="0x1D110000" … … 242 242 <Tool 243 243 Name="VCLinkerTool" 244 AdditionalDependencies="ws ock32.lib"244 AdditionalDependencies="ws2_32.lib" 245 245 IgnoreDefaultLibraryNames="libc" 246 246 BaseAddress="0x1D110000" … … 304 304 <Tool 305 305 Name="VCLinkerTool" 306 AdditionalDependencies="ws ock32.lib"306 AdditionalDependencies="ws2_32.lib" 307 307 IgnoreDefaultLibraryNames="libc" 308 308 BaseAddress="0x1D110000" … … 367 367 <Tool 368 368 Name="VCLinkerTool" 369 AdditionalDependencies="ws ock32.lib"369 AdditionalDependencies="ws2_32.lib" 370 370 IgnoreDefaultLibraryNames="libc" 371 371 BaseAddress="0x1D110000" … … 430 430 <Tool 431 431 Name="VCLinkerTool" 432 AdditionalDependencies="ws ock32.lib"432 AdditionalDependencies="ws2_32.lib" 433 433 IgnoreDefaultLibraryNames="libc" 434 434 BaseAddress="0x1D110000" … … 493 493 <Tool 494 494 Name="VCLinkerTool" 495 AdditionalDependencies="ws ock32.lib"495 AdditionalDependencies="ws2_32.lib" 496 496 IgnoreDefaultLibraryNames="libc" 497 497 BaseAddress="0x1D110000" -
python/vendor/current/PC/VS8.0/sqlite3.vcproj
r2 r388 23 23 Name="Debug|Win32" 24 24 ConfigurationType="2" 25 InheritedPropertySheets=".\pyd_d.vsprops" 26 CharacterSet="0" 27 > 28 <Tool 29 Name="VCPreBuildEventTool" 30 /> 31 <Tool 32 Name="VCCustomBuildTool" 33 /> 34 <Tool 35 Name="VCXMLDataGeneratorTool" 36 /> 37 <Tool 38 Name="VCWebServiceProxyGeneratorTool" 39 /> 40 <Tool 41 Name="VCMIDLTool" 42 /> 43 <Tool 44 Name="VCCLCompilerTool" 45 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 46 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 25 InheritedPropertySheets=".\sqlite3.vsprops;.\debug.vsprops" 26 CharacterSet="0" 27 > 28 <Tool 29 Name="VCPreBuildEventTool" 30 /> 31 <Tool 32 Name="VCCustomBuildTool" 33 /> 34 <Tool 35 Name="VCXMLDataGeneratorTool" 36 /> 37 <Tool 38 Name="VCWebServiceProxyGeneratorTool" 39 /> 40 <Tool 41 Name="VCMIDLTool" 42 /> 43 <Tool 44 Name="VCCLCompilerTool" 45 AdditionalIncludeDirectories="" 47 46 /> 48 47 <Tool … … 84 83 Name="Debug|x64" 85 84 ConfigurationType="2" 86 InheritedPropertySheets=".\ pyd_d.vsprops;.\x64.vsprops"85 InheritedPropertySheets=".\sqlite3.vsprops;.\debug.vsprops;.\x64.vsprops" 87 86 CharacterSet="0" 88 87 > … … 105 104 <Tool 106 105 Name="VCCLCompilerTool" 107 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 108 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 106 AdditionalIncludeDirectories="" 109 107 /> 110 108 <Tool … … 146 144 Name="Release|Win32" 147 145 ConfigurationType="2" 148 InheritedPropertySheets=".\ pyd.vsprops"146 InheritedPropertySheets=".\sqlite3.vsprops" 149 147 CharacterSet="0" 150 148 WholeProgramOptimization="1" … … 167 165 <Tool 168 166 Name="VCCLCompilerTool" 169 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 170 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 167 AdditionalIncludeDirectories="" 171 168 /> 172 169 <Tool … … 208 205 Name="Release|x64" 209 206 ConfigurationType="2" 210 InheritedPropertySheets=".\ pyd.vsprops;.\x64.vsprops"207 InheritedPropertySheets=".\sqlite3.vsprops;.\x64.vsprops" 211 208 CharacterSet="0" 212 209 WholeProgramOptimization="1" … … 230 227 <Tool 231 228 Name="VCCLCompilerTool" 232 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 233 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 229 AdditionalIncludeDirectories="" 234 230 /> 235 231 <Tool … … 271 267 Name="PGInstrument|Win32" 272 268 ConfigurationType="2" 273 InheritedPropertySheets=".\ pyd.vsprops;.\pginstrument.vsprops"269 InheritedPropertySheets=".\sqlite3.vsprops;.\pginstrument.vsprops" 274 270 CharacterSet="0" 275 271 WholeProgramOptimization="1" … … 292 288 <Tool 293 289 Name="VCCLCompilerTool" 294 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 295 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 290 AdditionalIncludeDirectories=""..\..\..\sqlite-3.6.21"" 296 291 /> 297 292 <Tool … … 333 328 Name="PGInstrument|x64" 334 329 ConfigurationType="2" 335 InheritedPropertySheets=".\ pyd.vsprops;.\x64.vsprops;.\pginstrument.vsprops"330 InheritedPropertySheets=".\sqlite3.vsprops;.\x64.vsprops;.\pginstrument.vsprops" 336 331 CharacterSet="0" 337 332 WholeProgramOptimization="1" … … 355 350 <Tool 356 351 Name="VCCLCompilerTool" 357 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 358 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 352 AdditionalIncludeDirectories="" 359 353 /> 360 354 <Tool … … 395 389 Name="PGUpdate|Win32" 396 390 ConfigurationType="2" 397 InheritedPropertySheets=".\ pyd.vsprops;.\pgupdate.vsprops"391 InheritedPropertySheets=".\sqlite3.vsprops;.\pgupdate.vsprops" 398 392 CharacterSet="0" 399 393 WholeProgramOptimization="1" … … 416 410 <Tool 417 411 Name="VCCLCompilerTool" 418 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 419 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 412 AdditionalIncludeDirectories="" 420 413 /> 421 414 <Tool … … 457 450 Name="PGUpdate|x64" 458 451 ConfigurationType="2" 459 InheritedPropertySheets=".\ pyd.vsprops;.\x64.vsprops;.\pgupdate.vsprops"452 InheritedPropertySheets=".\sqlite3.vsprops;.\x64.vsprops;.\pgupdate.vsprops" 460 453 CharacterSet="0" 461 454 WholeProgramOptimization="1" … … 479 472 <Tool 480 473 Name="VCCLCompilerTool" 481 AdditionalIncludeDirectories="..\..\..\sqlite-3.5.9" 482 PreprocessorDefinitions="SQLITE_API=__declspec(dllexport)" 474 AdditionalIncludeDirectories="" 483 475 /> 484 476 <Tool … … 524 516 > 525 517 <File 526 RelativePath="..\..\..\sqlite-3. 5.9\sqlite3.h"518 RelativePath="..\..\..\sqlite-3.6.21\sqlite3.h" 527 519 > 528 520 </File> 529 521 <File 530 RelativePath="..\..\..\sqlite-3. 5.9\sqlite3ext.h"522 RelativePath="..\..\..\sqlite-3.6.21\sqlite3ext.h" 531 523 > 532 524 </File> … … 536 528 > 537 529 <File 538 RelativePath="..\..\..\sqlite-3. 5.9\sqlite3.c"530 RelativePath="..\..\..\sqlite-3.6.21\sqlite3.c" 539 531 > 540 532 </File> -
python/vendor/current/PC/_msi.c
r2 r388 21 21 char *cresult; 22 22 PyObject *oresult; 23 23 24 24 /* May return ok, local only, and no address. 25 25 For local only, the documentation says we still get a uuid. … … 27 27 use the result. */ 28 28 if (UuidCreate(&result) == RPC_S_UUID_NO_ADDRESS) { 29 30 29 PyErr_SetString(PyExc_NotImplementedError, "processing 'no address' result"); 30 return NULL; 31 31 } 32 32 33 33 if (UuidToString(&result, &cresult) == RPC_S_OUT_OF_MEMORY) { 34 35 34 PyErr_SetString(PyExc_MemoryError, "out of memory in uuidgen"); 35 return NULL; 36 36 } 37 37 … … 58 58 int result = _open(pszFile, oflag, pmode); 59 59 if (result == -1) 60 60 *err = errno; 61 61 return result; 62 62 } … … 66 66 UINT result = (UINT)_read(hf, memory, cb); 67 67 if (result != cb) 68 68 *err = errno; 69 69 return result; 70 70 } … … 74 74 UINT result = (UINT)_write(hf, memory, cb); 75 75 if (result != cb) 76 76 *err = errno; 77 77 return result; 78 78 } … … 82 82 int result = _close(hf); 83 83 if (result != 0) 84 84 *err = errno; 85 85 return result; 86 86 } … … 90 90 long result = (long)_lseek(hf, dist, seektype); 91 91 if (result == -1) 92 92 *err = errno; 93 93 return result; 94 94 } … … 98 98 int result = remove(pszFile); 99 99 if (result != 0) 100 100 *err = errno; 101 101 return result; 102 102 } … … 111 111 char *name = _tempnam("", "tmp"); 112 112 if ((name != NULL) && ((int)strlen(name) < cbTempName)) { 113 114 115 113 strcpy(pszTempName, name); 114 free(name); 115 return TRUE; 116 116 } 117 117 … … 123 123 { 124 124 if (pv) { 125 126 127 128 125 PyObject *result = PyObject_CallMethod(pv, "status", "iii", typeStatus, cb1, cb2); 126 if (result == NULL) 127 return -1; 128 Py_DECREF(result); 129 129 } 130 130 return 0; … … 134 134 { 135 135 if (pv) { 136 137 138 139 140 PyErr_Format(PyExc_TypeError, 141 142 143 144 145 146 147 136 PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab); 137 if (result == NULL) 138 return -1; 139 if (!PyString_Check(result)) { 140 PyErr_Format(PyExc_TypeError, 141 "Incorrect return type %s from getnextcabinet", 142 result->ob_type->tp_name); 143 Py_DECREF(result); 144 return FALSE; 145 } 146 strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab)); 147 return TRUE; 148 148 } 149 149 return FALSE; … … 158 158 /* Need Win32 handle to get time stamps */ 159 159 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL, 160 160 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 161 161 if (handle == INVALID_HANDLE_VALUE) 162 162 return -1; 163 163 164 164 if (GetFileInformationByHandle(handle, &bhfi) == FALSE) 165 165 { 166 167 166 CloseHandle(handle); 167 return -1; 168 168 } 169 169 … … 171 171 FileTimeToDosDateTime(&filetime, pdate, ptime); 172 172 173 *pattribs = (int)(bhfi.dwFileAttributes & 174 173 *pattribs = (int)(bhfi.dwFileAttributes & 174 (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH)); 175 175 176 176 CloseHandle(handle); … … 190 190 191 191 if (!PyArg_ParseTuple(args, "sO:FCICreate", &cabname, &files)) 192 192 return NULL; 193 193 194 194 if (!PyList_Check(files)) { 195 196 195 PyErr_SetString(PyExc_TypeError, "FCICreate expects a list"); 196 return NULL; 197 197 } 198 198 … … 210 210 211 211 for (i = 0, p = cabname; *p; p = CharNext(p)) 212 213 212 if (*p == '\\' || *p == '/') 213 i = p - cabname + 1; 214 214 215 215 if (i >= sizeof(ccab.szCabPath) || 216 217 218 216 strlen(cabname+i) >= sizeof(ccab.szCab)) { 217 PyErr_SetString(PyExc_ValueError, "path name too long"); 218 return 0; 219 219 } 220 220 221 221 if (i > 0) { 222 223 224 222 memcpy(ccab.szCabPath, cabname, i); 223 ccab.szCabPath[i] = '\0'; 224 strcpy(ccab.szCab, cabname+i); 225 225 } else { 226 227 226 strcpy(ccab.szCabPath, ".\\"); 227 strcpy(ccab.szCab, cabname); 228 228 } 229 229 230 230 hfci = FCICreate(&erf, cb_fileplaced, cb_alloc, cb_free, 231 232 231 cb_open, cb_read, cb_write, cb_close, cb_seek, cb_delete, 232 cb_gettempfile, &ccab, NULL); 233 233 234 234 if (hfci == NULL) { 235 236 235 PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); 236 return NULL; 237 237 } 238 238 239 239 for (i=0; i < PyList_GET_SIZE(files); i++) { 240 241 242 243 244 if (!FCIAddFile(hfci, filename, cabname, FALSE, 245 246 247 240 PyObject *item = PyList_GET_ITEM(files, i); 241 char *filename, *cabname; 242 if (!PyArg_ParseTuple(item, "ss", &filename, &cabname)) 243 goto err; 244 if (!FCIAddFile(hfci, filename, cabname, FALSE, 245 cb_getnextcabinet, cb_status, cb_getopeninfo, 246 tcompTYPE_MSZIP)) 247 goto err; 248 248 } 249 249 250 250 if (!FCIFlushCabinet(hfci, FALSE, cb_getnextcabinet, cb_status)) 251 251 goto err; 252 252 253 253 if (!FCIDestroy(hfci)) 254 254 goto err; 255 255 256 256 Py_INCREF(Py_None); … … 267 267 }msiobj; 268 268 269 static void 269 static void 270 270 msiobj_dealloc(msiobj* msidb) 271 271 { … … 293 293 294 294 if (err == 0) { 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 295 switch(status) { 296 case ERROR_ACCESS_DENIED: 297 PyErr_SetString(MSIError, "access denied"); 298 return NULL; 299 case ERROR_FUNCTION_FAILED: 300 PyErr_SetString(MSIError, "function failed"); 301 return NULL; 302 case ERROR_INVALID_DATA: 303 PyErr_SetString(MSIError, "invalid data"); 304 return NULL; 305 case ERROR_INVALID_HANDLE: 306 PyErr_SetString(MSIError, "invalid handle"); 307 return NULL; 308 case ERROR_INVALID_STATE: 309 PyErr_SetString(MSIError, "invalid state"); 310 return NULL; 311 case ERROR_INVALID_PARAMETER: 312 PyErr_SetString(MSIError, "invalid parameter"); 313 return NULL; 314 default: 315 PyErr_Format(MSIError, "unknown error %x", status); 316 return NULL; 317 } 318 318 } 319 319 320 320 code = MsiRecordGetInteger(err, 1); /* XXX code */ 321 321 if (MsiFormatRecord(0, err, res, &size) == ERROR_MORE_DATA) { 322 323 324 322 res = malloc(size+1); 323 MsiFormatRecord(0, err, res, &size); 324 res[size]='\0'; 325 325 } 326 326 MsiCloseHandle(err); 327 327 PyErr_SetString(MSIError, res); 328 328 if (res != buf) 329 329 free(res); 330 330 return NULL; 331 331 } … … 344 344 unsigned int field; 345 345 int status; 346 346 347 347 if (!PyArg_ParseTuple(args, "I:GetInteger", &field)) 348 348 return NULL; … … 364 364 DWORD size = sizeof(buf); 365 365 PyObject* string; 366 366 367 367 if (!PyArg_ParseTuple(args, "I:GetString", &field)) 368 368 return NULL; … … 387 387 int status = MsiRecordClearData(record->h); 388 388 if (status != ERROR_SUCCESS) 389 389 return msierror(status); 390 390 391 391 Py_INCREF(Py_None); … … 401 401 402 402 if (!PyArg_ParseTuple(args, "is:SetString", &field, &data)) 403 403 return NULL; 404 404 405 405 if ((status = MsiRecordSetString(record->h, field, data)) != ERROR_SUCCESS) 406 406 return msierror(status); 407 407 408 408 Py_INCREF(Py_None); … … 418 418 419 419 if (!PyArg_ParseTuple(args, "is:SetStream", &field, &data)) 420 420 return NULL; 421 421 422 422 if ((status = MsiRecordSetStream(record->h, field, data)) != ERROR_SUCCESS) 423 423 return msierror(status); 424 424 425 425 Py_INCREF(Py_None); … … 435 435 436 436 if (!PyArg_ParseTuple(args, "ii:SetInteger", &field, &data)) 437 437 return NULL; 438 438 439 439 if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS) 440 440 return msierror(status); 441 441 442 442 Py_INCREF(Py_None); … … 447 447 448 448 static PyMethodDef record_methods[] = { 449 { "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS, 450 449 { "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS, 450 PyDoc_STR("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount")}, 451 451 { "GetInteger", (PyCFunction)record_getinteger, METH_VARARGS, 452 452 PyDoc_STR("GetInteger(field) -> int\nWraps MsiRecordGetInteger")}, 453 453 { "GetString", (PyCFunction)record_getstring, METH_VARARGS, 454 454 PyDoc_STR("GetString(field) -> string\nWraps MsiRecordGetString")}, 455 { "SetString", (PyCFunction)record_setstring, METH_VARARGS, 456 457 { "SetStream", (PyCFunction)record_setstream, METH_VARARGS, 458 459 { "SetInteger", (PyCFunction)record_setinteger, METH_VARARGS, 460 461 { "ClearData", (PyCFunction)record_cleardata, METH_NOARGS, 462 455 { "SetString", (PyCFunction)record_setstring, METH_VARARGS, 456 PyDoc_STR("SetString(field,str) -> None\nWraps MsiRecordSetString")}, 457 { "SetStream", (PyCFunction)record_setstream, METH_VARARGS, 458 PyDoc_STR("SetStream(field,filename) -> None\nWraps MsiRecordSetInteger")}, 459 { "SetInteger", (PyCFunction)record_setinteger, METH_VARARGS, 460 PyDoc_STR("SetInteger(field,int) -> None\nWraps MsiRecordSetInteger")}, 461 { "ClearData", (PyCFunction)record_cleardata, METH_NOARGS, 462 PyDoc_STR("ClearData() -> int\nWraps MsiRecordGClearData")}, 463 463 { NULL, NULL } 464 464 }; 465 465 466 466 static PyTypeObject record_Type = { 467 468 "_msi.Record",/*tp_name*/469 sizeof(msiobj),/*tp_basicsize*/470 0,/*tp_itemsize*/471 472 473 0,/*tp_print*/474 0,/*tp_getattr*/475 0,/*tp_setattr*/476 0,/*tp_compare*/477 0,/*tp_repr*/478 0,/*tp_as_number*/479 0,/*tp_as_sequence*/480 0,/*tp_as_mapping*/481 0,/*tp_hash*/467 PyVarObject_HEAD_INIT(NULL, 0) 468 "_msi.Record", /*tp_name*/ 469 sizeof(msiobj), /*tp_basicsize*/ 470 0, /*tp_itemsize*/ 471 /* methods */ 472 (destructor)msiobj_dealloc, /*tp_dealloc*/ 473 0, /*tp_print*/ 474 0, /*tp_getattr*/ 475 0, /*tp_setattr*/ 476 0, /*tp_compare*/ 477 0, /*tp_repr*/ 478 0, /*tp_as_number*/ 479 0, /*tp_as_sequence*/ 480 0, /*tp_as_mapping*/ 481 0, /*tp_hash*/ 482 482 0, /*tp_call*/ 483 483 0, /*tp_str*/ … … 514 514 515 515 if (!result) { 516 517 516 MsiCloseHandle(h); 517 return NULL; 518 518 } 519 519 … … 538 538 539 539 if (!PyArg_ParseTuple(args, "i:GetProperty", &field)) 540 541 542 status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, 543 540 return NULL; 541 542 status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, 543 &fval, sval, &ssize); 544 544 if (status == ERROR_MORE_DATA) { 545 546 status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, 547 545 sval = malloc(ssize); 546 status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, 547 &fval, sval, &ssize); 548 548 } 549 549 550 550 switch(type) { 551 552 553 554 555 556 557 558 559 560 551 case VT_I2: case VT_I4: 552 return PyInt_FromLong(ival); 553 case VT_FILETIME: 554 PyErr_SetString(PyExc_NotImplementedError, "FILETIME result"); 555 return NULL; 556 case VT_LPSTR: 557 result = PyString_FromStringAndSize(sval, ssize); 558 if (sval != sbuf) 559 free(sval); 560 return result; 561 561 } 562 562 PyErr_Format(PyExc_NotImplementedError, "result of type %d", type); … … 572 572 status = MsiSummaryInfoGetPropertyCount(si->h, &result); 573 573 if (status != ERROR_SUCCESS) 574 574 return msierror(status); 575 575 576 576 return PyInt_FromLong(result); … … 585 585 586 586 if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data)) 587 587 return NULL; 588 588 589 589 if (PyString_Check(data)) { 590 591 590 status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR, 591 0, NULL, PyString_AsString(data)); 592 592 } else if (PyInt_Check(data)) { 593 594 593 status = MsiSummaryInfoSetProperty(si->h, field, VT_I4, 594 PyInt_AsLong(data), NULL, NULL); 595 595 } else { 596 597 598 } 599 596 PyErr_SetString(PyExc_TypeError, "unsupported type"); 597 return NULL; 598 } 599 600 600 if (status != ERROR_SUCCESS) 601 601 return msierror(status); 602 602 603 603 Py_INCREF(Py_None); … … 613 613 status = MsiSummaryInfoPersist(si->h); 614 614 if (status != ERROR_SUCCESS) 615 615 return msierror(status); 616 616 Py_INCREF(Py_None); 617 617 return Py_None; … … 619 619 620 620 static PyMethodDef summary_methods[] = { 621 { "GetProperty", (PyCFunction)summary_getproperty, METH_VARARGS, 622 623 { "GetPropertyCount", (PyCFunction)summary_getpropertycount, METH_NOARGS, 624 625 { "SetProperty", (PyCFunction)summary_setproperty, METH_VARARGS, 626 627 { "Persist", (PyCFunction)summary_persist, METH_NOARGS, 628 621 { "GetProperty", (PyCFunction)summary_getproperty, METH_VARARGS, 622 PyDoc_STR("GetProperty(propid) -> value\nWraps MsiSummaryInfoGetProperty")}, 623 { "GetPropertyCount", (PyCFunction)summary_getpropertycount, METH_NOARGS, 624 PyDoc_STR("GetProperty() -> int\nWraps MsiSummaryInfoGetPropertyCount")}, 625 { "SetProperty", (PyCFunction)summary_setproperty, METH_VARARGS, 626 PyDoc_STR("SetProperty(value) -> None\nWraps MsiSummaryInfoProperty")}, 627 { "Persist", (PyCFunction)summary_persist, METH_NOARGS, 628 PyDoc_STR("Persist() -> None\nWraps MsiSummaryInfoPersist")}, 629 629 { NULL, NULL } 630 630 }; 631 631 632 632 static PyTypeObject summary_Type = { 633 634 "_msi.SummaryInformation",/*tp_name*/635 sizeof(msiobj),/*tp_basicsize*/636 0,/*tp_itemsize*/637 638 639 0,/*tp_print*/640 0,/*tp_getattr*/641 0,/*tp_setattr*/642 0,/*tp_compare*/643 0,/*tp_repr*/644 0,/*tp_as_number*/645 0,/*tp_as_sequence*/646 0,/*tp_as_mapping*/647 0,/*tp_hash*/633 PyVarObject_HEAD_INIT(NULL, 0) 634 "_msi.SummaryInformation", /*tp_name*/ 635 sizeof(msiobj), /*tp_basicsize*/ 636 0, /*tp_itemsize*/ 637 /* methods */ 638 (destructor)msiobj_dealloc, /*tp_dealloc*/ 639 0, /*tp_print*/ 640 0, /*tp_getattr*/ 641 0, /*tp_setattr*/ 642 0, /*tp_compare*/ 643 0, /*tp_repr*/ 644 0, /*tp_as_number*/ 645 0, /*tp_as_sequence*/ 646 0, /*tp_as_mapping*/ 647 0, /*tp_hash*/ 648 648 0, /*tp_call*/ 649 649 0, /*tp_str*/ … … 684 684 685 685 if (!PyArg_ParseTuple(args, "O:Execute", &oparams)) 686 686 return NULL; 687 687 688 688 if (oparams != Py_None) { … … 696 696 status = MsiViewExecute(view->h, params); 697 697 if (status != ERROR_SUCCESS) 698 698 return msierror(status); 699 699 700 700 Py_INCREF(Py_None); … … 709 709 710 710 if ((status = MsiViewFetch(view->h, &result)) != ERROR_SUCCESS) 711 711 return msierror(status); 712 712 713 713 return record_new(result); … … 722 722 723 723 if (!PyArg_ParseTuple(args, "i:GetColumnInfo", &kind)) 724 724 return NULL; 725 725 726 726 if ((status = MsiViewGetColumnInfo(view->h, kind, &result)) != ERROR_SUCCESS) 727 727 return msierror(status); 728 728 729 729 return record_new(result); … … 738 738 739 739 if (!PyArg_ParseTuple(args, "iO:Modify", &kind, &data)) 740 740 return NULL; 741 741 742 742 if (data->ob_type != &record_Type) { 743 744 743 PyErr_SetString(PyExc_TypeError, "Modify expects a record object"); 744 return NULL; 745 745 } 746 746 747 747 if ((status = MsiViewModify(view->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS) 748 748 return msierror(status); 749 749 750 750 Py_INCREF(Py_None); … … 758 758 759 759 if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS) 760 760 return msierror(status); 761 761 762 762 Py_INCREF(Py_None); … … 765 765 766 766 static PyMethodDef view_methods[] = { 767 { "Execute", (PyCFunction)view_execute, METH_VARARGS, 768 767 { "Execute", (PyCFunction)view_execute, METH_VARARGS, 768 PyDoc_STR("Execute(params=None) -> None\nWraps MsiViewExecute")}, 769 769 { "GetColumnInfo", (PyCFunction)view_getcolumninfo, METH_VARARGS, 770 770 PyDoc_STR("GetColumnInfo() -> result\nWraps MsiGetColumnInfo")}, 771 771 { "Fetch", (PyCFunction)view_fetch, METH_NOARGS, 772 772 PyDoc_STR("Fetch() -> result\nWraps MsiViewFetch")}, 773 773 { "Modify", (PyCFunction)view_modify, METH_VARARGS, 774 774 PyDoc_STR("Modify(mode,record) -> None\nWraps MsiViewModify")}, 775 775 { "Close", (PyCFunction)view_close, METH_NOARGS, 776 776 PyDoc_STR("Close() -> result\nWraps MsiViewClose")}, 777 777 { NULL, NULL } 778 778 }; 779 779 780 780 static PyTypeObject msiview_Type = { 781 782 "_msi.View",/*tp_name*/783 sizeof(msiobj),/*tp_basicsize*/784 0,/*tp_itemsize*/785 786 787 0,/*tp_print*/788 0,/*tp_getattr*/789 0,/*tp_setattr*/790 0,/*tp_compare*/791 0,/*tp_repr*/792 0,/*tp_as_number*/793 0,/*tp_as_sequence*/794 0,/*tp_as_mapping*/795 0,/*tp_hash*/781 PyVarObject_HEAD_INIT(NULL, 0) 782 "_msi.View", /*tp_name*/ 783 sizeof(msiobj), /*tp_basicsize*/ 784 0, /*tp_itemsize*/ 785 /* methods */ 786 (destructor)msiobj_dealloc, /*tp_dealloc*/ 787 0, /*tp_print*/ 788 0, /*tp_getattr*/ 789 0, /*tp_setattr*/ 790 0, /*tp_compare*/ 791 0, /*tp_repr*/ 792 0, /*tp_as_number*/ 793 0, /*tp_as_sequence*/ 794 0, /*tp_as_mapping*/ 795 0, /*tp_hash*/ 796 796 0, /*tp_call*/ 797 797 0, /*tp_str*/ … … 833 833 834 834 if (!PyArg_ParseTuple(args, "s:OpenView", &sql)) 835 835 return NULL; 836 836 837 837 if ((status = MsiDatabaseOpenView(msidb->h, sql, &hView)) != ERROR_SUCCESS) 838 838 return msierror(status); 839 839 840 840 result = PyObject_NEW(struct msiobj, &msiview_Type); 841 841 if (!result) { 842 843 842 MsiCloseHandle(hView); 843 return NULL; 844 844 } 845 845 … … 854 854 855 855 if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS) 856 856 return msierror(status); 857 857 858 858 Py_INCREF(Py_None); … … 869 869 870 870 if (!PyArg_ParseTuple(args, "i:GetSummaryInformation", &count)) 871 871 return NULL; 872 872 873 873 status = MsiGetSummaryInformation(db->h, NULL, count, &result); 874 874 if (status != ERROR_SUCCESS) 875 875 return msierror(status); 876 876 877 877 oresult = PyObject_NEW(struct msiobj, &summary_Type); 878 878 if (!result) { 879 880 879 MsiCloseHandle(result); 880 return NULL; 881 881 } 882 882 … … 886 886 887 887 static PyMethodDef db_methods[] = { 888 { "OpenView", (PyCFunction)msidb_openview, METH_VARARGS, 889 888 { "OpenView", (PyCFunction)msidb_openview, METH_VARARGS, 889 PyDoc_STR("OpenView(sql) -> viewobj\nWraps MsiDatabaseOpenView")}, 890 890 { "Commit", (PyCFunction)msidb_commit, METH_NOARGS, 891 892 { "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS, 893 891 PyDoc_STR("Commit() -> None\nWraps MsiDatabaseCommit")}, 892 { "GetSummaryInformation", (PyCFunction)msidb_getsummaryinformation, METH_VARARGS, 893 PyDoc_STR("GetSummaryInformation(updateCount) -> viewobj\nWraps MsiGetSummaryInformation")}, 894 894 { NULL, NULL } 895 895 }; 896 896 897 897 static PyTypeObject msidb_Type = { 898 899 "_msi.Database",/*tp_name*/900 sizeof(msiobj),/*tp_basicsize*/901 0,/*tp_itemsize*/902 903 904 0,/*tp_print*/905 0,/*tp_getattr*/906 0,/*tp_setattr*/907 0,/*tp_compare*/908 0,/*tp_repr*/909 0,/*tp_as_number*/910 0,/*tp_as_sequence*/911 0,/*tp_as_mapping*/912 0,/*tp_hash*/898 PyVarObject_HEAD_INIT(NULL, 0) 899 "_msi.Database", /*tp_name*/ 900 sizeof(msiobj), /*tp_basicsize*/ 901 0, /*tp_itemsize*/ 902 /* methods */ 903 (destructor)msiobj_dealloc, /*tp_dealloc*/ 904 0, /*tp_print*/ 905 0, /*tp_getattr*/ 906 0, /*tp_setattr*/ 907 0, /*tp_compare*/ 908 0, /*tp_repr*/ 909 0, /*tp_as_number*/ 910 0, /*tp_as_sequence*/ 911 0, /*tp_as_mapping*/ 912 0, /*tp_hash*/ 913 913 0, /*tp_call*/ 914 914 0, /*tp_str*/ … … 946 946 MSIHANDLE h; 947 947 msiobj *result; 948 948 949 949 if (!PyArg_ParseTuple(args, "si:MSIOpenDatabase", &path, &persist)) 950 951 952 950 return NULL; 951 952 status = MsiOpenDatabase(path, (LPCSTR)persist, &h); 953 953 if (status != ERROR_SUCCESS) 954 954 return msierror(status); 955 955 956 956 result = PyObject_NEW(struct msiobj, &msidb_Type); 957 957 if (!result) { 958 959 958 MsiCloseHandle(h); 959 return NULL; 960 960 } 961 961 result->h = h; … … 970 970 971 971 if (!PyArg_ParseTuple(args, "i:CreateRecord", &count)) 972 973 972 return NULL; 973 974 974 h = MsiCreateRecord(count); 975 975 if (h == 0) 976 976 return msierror(0); 977 977 978 978 return record_new(h); … … 982 982 static PyMethodDef msi_methods[] = { 983 983 {"UuidCreate", (PyCFunction)uuidcreate, METH_NOARGS, 984 985 {"FCICreate", (PyCFunction)fcicreate,METH_VARARGS,986 987 988 989 990 991 {NULL, NULL}/* sentinel */984 PyDoc_STR("UuidCreate() -> string")}, 985 {"FCICreate", (PyCFunction)fcicreate, METH_VARARGS, 986 PyDoc_STR("fcicreate(cabname,files) -> None")}, 987 {"OpenDatabase", (PyCFunction)msiopendb, METH_VARARGS, 988 PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiOpenDatabase")}, 989 {"CreateRecord", (PyCFunction)createrecord, METH_VARARGS, 990 PyDoc_STR("OpenDatabase(name, flags) -> dbobj\nWraps MsiCreateRecord")}, 991 {NULL, NULL} /* sentinel */ 992 992 }; 993 993 … … 1001 1001 m = Py_InitModule3("_msi", msi_methods, msi_doc); 1002 1002 if (m == NULL) 1003 1003 return; 1004 1004 1005 1005 PyModule_AddIntConstant(m, "MSIDBOPEN_CREATEDIRECT", (int)MSIDBOPEN_CREATEDIRECT); … … 1047 1047 MSIError = PyErr_NewException ("_msi.MSIError", NULL, NULL); 1048 1048 if (!MSIError) 1049 1049 return; 1050 1050 PyModule_AddObject(m, "MSIError", MSIError); 1051 1051 } -
python/vendor/current/PC/_subprocess.c
r2 r388 50 50 51 51 typedef struct { 52 53 52 PyObject_HEAD 53 HANDLE handle; 54 54 } sp_handle_object; 55 55 … … 59 59 sp_handle_new(HANDLE handle) 60 60 { 61 62 63 64 65 66 67 68 69 61 sp_handle_object* self; 62 63 self = PyObject_NEW(sp_handle_object, &sp_handle_type); 64 if (self == NULL) 65 return NULL; 66 67 self->handle = handle; 68 69 return (PyObject*) self; 70 70 } 71 71 72 72 #if defined(MS_WIN32) && !defined(MS_WIN64) 73 #define HANDLE_TO_PYNUM(handle) 74 #define PY_HANDLE_PARAM 73 #define HANDLE_TO_PYNUM(handle) PyInt_FromLong((long) handle) 74 #define PY_HANDLE_PARAM "l" 75 75 #else 76 #define HANDLE_TO_PYNUM(handle) 77 #define PY_HANDLE_PARAM 76 #define HANDLE_TO_PYNUM(handle) PyLong_FromLongLong((long long) handle) 77 #define PY_HANDLE_PARAM "L" 78 78 #endif 79 79 … … 81 81 sp_handle_detach(sp_handle_object* self, PyObject* args) 82 82 { 83 84 85 86 87 88 89 90 91 92 93 83 HANDLE handle; 84 85 if (! PyArg_ParseTuple(args, ":Detach")) 86 return NULL; 87 88 handle = self->handle; 89 90 self->handle = INVALID_HANDLE_VALUE; 91 92 /* note: return the current handle, as an integer */ 93 return HANDLE_TO_PYNUM(handle); 94 94 } 95 95 … … 97 97 sp_handle_close(sp_handle_object* self, PyObject* args) 98 98 { 99 100 101 102 103 104 105 106 107 99 if (! PyArg_ParseTuple(args, ":Close")) 100 return NULL; 101 102 if (self->handle != INVALID_HANDLE_VALUE) { 103 CloseHandle(self->handle); 104 self->handle = INVALID_HANDLE_VALUE; 105 } 106 Py_INCREF(Py_None); 107 return Py_None; 108 108 } 109 109 … … 111 111 sp_handle_dealloc(sp_handle_object* self) 112 112 { 113 114 115 113 if (self->handle != INVALID_HANDLE_VALUE) 114 CloseHandle(self->handle); 115 PyObject_FREE(self); 116 116 } 117 117 118 118 static PyMethodDef sp_handle_methods[] = { 119 120 121 119 {"Detach", (PyCFunction) sp_handle_detach, METH_VARARGS}, 120 {"Close", (PyCFunction) sp_handle_close, METH_VARARGS}, 121 {NULL, NULL} 122 122 }; 123 123 … … 125 125 sp_handle_getattr(sp_handle_object* self, char* name) 126 126 { 127 127 return Py_FindMethod(sp_handle_methods, (PyObject*) self, name); 128 128 } 129 129 … … 131 131 sp_handle_as_int(sp_handle_object* self) 132 132 { 133 133 return HANDLE_TO_PYNUM(self->handle); 134 134 } 135 135 … … 137 137 138 138 statichere PyTypeObject sp_handle_type = { 139 140 0,/*ob_size*/141 142 143 144 145 0,/*tp_setattr*/146 0,/*tp_compare*/147 0,/*tp_repr*/148 &sp_handle_as_number,/*tp_as_number */149 0,/*tp_as_sequence */150 0,/*tp_as_mapping */151 0/*tp_hash*/139 PyObject_HEAD_INIT(NULL) 140 0, /*ob_size*/ 141 "_subprocess_handle", sizeof(sp_handle_object), 0, 142 (destructor) sp_handle_dealloc, /*tp_dealloc*/ 143 0, /*tp_print*/ 144 (getattrfunc) sp_handle_getattr,/*tp_getattr*/ 145 0, /*tp_setattr*/ 146 0, /*tp_compare*/ 147 0, /*tp_repr*/ 148 &sp_handle_as_number, /*tp_as_number */ 149 0, /*tp_as_sequence */ 150 0, /*tp_as_mapping */ 151 0 /*tp_hash*/ 152 152 }; 153 153 … … 155 155 /* windows API functions */ 156 156 157 PyDoc_STRVAR(GetStdHandle_doc, 158 "GetStdHandle(handle) -> integer\n\ 159 \n\ 160 Return a handle to the specified standard device\n\ 161 (STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, STD_ERROR_HANDLE).\n\ 162 The integer associated with the handle object is returned."); 163 157 164 static PyObject * 158 165 sp_GetStdHandle(PyObject* self, PyObject* args) 159 166 { 160 HANDLE handle; 161 int std_handle; 162 163 if (! PyArg_ParseTuple(args, "i:GetStdHandle", &std_handle)) 164 return NULL; 165 166 Py_BEGIN_ALLOW_THREADS 167 handle = GetStdHandle((DWORD) std_handle); 168 Py_END_ALLOW_THREADS 169 170 if (handle == INVALID_HANDLE_VALUE) 171 return PyErr_SetFromWindowsErr(GetLastError()); 172 173 if (! handle) { 174 Py_INCREF(Py_None); 175 return Py_None; 176 } 177 178 /* note: returns integer, not handle object */ 179 return HANDLE_TO_PYNUM(handle); 180 } 167 HANDLE handle; 168 int std_handle; 169 170 if (! PyArg_ParseTuple(args, "i:GetStdHandle", &std_handle)) 171 return NULL; 172 173 Py_BEGIN_ALLOW_THREADS 174 handle = GetStdHandle((DWORD) std_handle); 175 Py_END_ALLOW_THREADS 176 177 if (handle == INVALID_HANDLE_VALUE) 178 return PyErr_SetFromWindowsErr(GetLastError()); 179 180 if (! handle) { 181 Py_INCREF(Py_None); 182 return Py_None; 183 } 184 185 /* note: returns integer, not handle object */ 186 return HANDLE_TO_PYNUM(handle); 187 } 188 189 PyDoc_STRVAR(GetCurrentProcess_doc, 190 "GetCurrentProcess() -> handle\n\ 191 \n\ 192 Return a handle object for the current process."); 181 193 182 194 static PyObject * 183 195 sp_GetCurrentProcess(PyObject* self, PyObject* args) 184 196 { 185 if (! PyArg_ParseTuple(args, ":GetCurrentProcess")) 186 return NULL; 187 188 return sp_handle_new(GetCurrentProcess()); 189 } 197 if (! PyArg_ParseTuple(args, ":GetCurrentProcess")) 198 return NULL; 199 200 return sp_handle_new(GetCurrentProcess()); 201 } 202 203 PyDoc_STRVAR(DuplicateHandle_doc, 204 "DuplicateHandle(source_proc_handle, source_handle,\n\ 205 target_proc_handle, target_handle, access,\n\ 206 inherit[, options]) -> handle\n\ 207 \n\ 208 Return a duplicate handle object.\n\ 209 \n\ 210 The duplicate handle refers to the same object as the original\n\ 211 handle. Therefore, any changes to the object are reflected\n\ 212 through both handles."); 190 213 191 214 static PyObject * 192 215 sp_DuplicateHandle(PyObject* self, PyObject* args) 193 216 { 194 HANDLE target_handle; 195 BOOL result; 196 197 HANDLE source_process_handle; 198 HANDLE source_handle; 199 HANDLE target_process_handle; 200 int desired_access; 201 int inherit_handle; 202 int options = 0; 203 204 if (! PyArg_ParseTuple(args, 205 PY_HANDLE_PARAM PY_HANDLE_PARAM PY_HANDLE_PARAM 206 "ii|i:DuplicateHandle", 207 &source_process_handle, 208 &source_handle, 209 &target_process_handle, 210 &desired_access, 211 &inherit_handle, 212 &options)) 213 return NULL; 214 215 Py_BEGIN_ALLOW_THREADS 216 result = DuplicateHandle( 217 source_process_handle, 218 source_handle, 219 target_process_handle, 220 &target_handle, 221 desired_access, 222 inherit_handle, 223 options 224 ); 225 Py_END_ALLOW_THREADS 226 227 if (! result) 228 return PyErr_SetFromWindowsErr(GetLastError()); 229 230 return sp_handle_new(target_handle); 231 } 217 HANDLE target_handle; 218 BOOL result; 219 220 HANDLE source_process_handle; 221 HANDLE source_handle; 222 HANDLE target_process_handle; 223 int desired_access; 224 int inherit_handle; 225 int options = 0; 226 227 if (! PyArg_ParseTuple(args, 228 PY_HANDLE_PARAM PY_HANDLE_PARAM PY_HANDLE_PARAM 229 "ii|i:DuplicateHandle", 230 &source_process_handle, 231 &source_handle, 232 &target_process_handle, 233 &desired_access, 234 &inherit_handle, 235 &options)) 236 return NULL; 237 238 Py_BEGIN_ALLOW_THREADS 239 result = DuplicateHandle( 240 source_process_handle, 241 source_handle, 242 target_process_handle, 243 &target_handle, 244 desired_access, 245 inherit_handle, 246 options 247 ); 248 Py_END_ALLOW_THREADS 249 250 if (! result) 251 return PyErr_SetFromWindowsErr(GetLastError()); 252 253 return sp_handle_new(target_handle); 254 } 255 256 PyDoc_STRVAR(CreatePipe_doc, 257 "CreatePipe(pipe_attrs, size) -> (read_handle, write_handle)\n\ 258 \n\ 259 Create an anonymous pipe, and return handles to the read and\n\ 260 write ends of the pipe.\n\ 261 \n\ 262 pipe_attrs is ignored internally and can be None."); 232 263 233 264 static PyObject * 234 265 sp_CreatePipe(PyObject* self, PyObject* args) 235 266 { 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 267 HANDLE read_pipe; 268 HANDLE write_pipe; 269 BOOL result; 270 271 PyObject* pipe_attributes; /* ignored */ 272 int size; 273 274 if (! PyArg_ParseTuple(args, "Oi:CreatePipe", &pipe_attributes, &size)) 275 return NULL; 276 277 Py_BEGIN_ALLOW_THREADS 278 result = CreatePipe(&read_pipe, &write_pipe, NULL, size); 279 Py_END_ALLOW_THREADS 280 281 if (! result) 282 return PyErr_SetFromWindowsErr(GetLastError()); 283 284 return Py_BuildValue( 285 "NN", sp_handle_new(read_pipe), sp_handle_new(write_pipe)); 255 286 } 256 287 … … 260 291 getint(PyObject* obj, char* name) 261 292 { 262 263 264 265 266 267 268 269 270 271 272 293 PyObject* value; 294 int ret; 295 296 value = PyObject_GetAttrString(obj, name); 297 if (! value) { 298 PyErr_Clear(); /* FIXME: propagate error? */ 299 return 0; 300 } 301 ret = (int) PyInt_AsLong(value); 302 Py_DECREF(value); 303 return ret; 273 304 } 274 305 … … 276 307 gethandle(PyObject* obj, char* name) 277 308 { 278 279 280 281 282 283 284 285 286 287 288 289 290 291 309 sp_handle_object* value; 310 HANDLE ret; 311 312 value = (sp_handle_object*) PyObject_GetAttrString(obj, name); 313 if (! value) { 314 PyErr_Clear(); /* FIXME: propagate error? */ 315 return NULL; 316 } 317 if (value->ob_type != &sp_handle_type) 318 ret = NULL; 319 else 320 ret = value->handle; 321 Py_DECREF(value); 322 return ret; 292 323 } 293 324 … … 295 326 getenvironment(PyObject* environment) 296 327 { 297 298 299 300 301 302 303 /* convert environment dictionary to windows enviroment string */304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 328 int i, envsize; 329 PyObject* out = NULL; 330 PyObject* keys; 331 PyObject* values; 332 char* p; 333 334 /* convert environment dictionary to windows environment string */ 335 if (! PyMapping_Check(environment)) { 336 PyErr_SetString( 337 PyExc_TypeError, "environment must be dictionary or None"); 338 return NULL; 339 } 340 341 envsize = PyMapping_Length(environment); 342 343 keys = PyMapping_Keys(environment); 344 values = PyMapping_Values(environment); 345 if (!keys || !values) 346 goto error; 347 348 out = PyString_FromStringAndSize(NULL, 2048); 349 if (! out) 350 goto error; 351 352 p = PyString_AS_STRING(out); 353 354 for (i = 0; i < envsize; i++) { 355 int ksize, vsize, totalsize; 356 PyObject* key = PyList_GET_ITEM(keys, i); 357 PyObject* value = PyList_GET_ITEM(values, i); 358 359 if (! PyString_Check(key) || ! PyString_Check(value)) { 360 PyErr_SetString(PyExc_TypeError, 361 "environment can only contain strings"); 362 goto error; 363 } 364 ksize = PyString_GET_SIZE(key); 365 vsize = PyString_GET_SIZE(value); 366 totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 + 367 vsize + 1 + 1; 368 if (totalsize > PyString_GET_SIZE(out)) { 369 int offset = p - PyString_AS_STRING(out); 370 _PyString_Resize(&out, totalsize + 1024); 371 p = PyString_AS_STRING(out) + offset; 372 } 373 memcpy(p, PyString_AS_STRING(key), ksize); 374 p += ksize; 375 *p++ = '='; 376 memcpy(p, PyString_AS_STRING(value), vsize); 377 p += vsize; 378 *p++ = '\0'; 379 } 380 381 /* add trailing null byte */ 382 *p++ = '\0'; 383 _PyString_Resize(&out, p - PyString_AS_STRING(out)); 384 385 /* PyObject_Print(out, stdout, 0); */ 386 387 Py_XDECREF(keys); 388 Py_XDECREF(values); 389 390 return out; 360 391 361 392 error: 362 Py_XDECREF(out); 363 Py_XDECREF(keys); 364 Py_XDECREF(values); 365 return NULL; 366 } 393 Py_XDECREF(out); 394 Py_XDECREF(keys); 395 Py_XDECREF(values); 396 return NULL; 397 } 398 399 PyDoc_STRVAR(CreateProcess_doc, 400 "CreateProcess(app_name, cmd_line, proc_attrs, thread_attrs,\n\ 401 inherit, flags, env_mapping, curdir,\n\ 402 startup_info) -> (proc_handle, thread_handle,\n\ 403 pid, tid)\n\ 404 \n\ 405 Create a new process and its primary thread. The return\n\ 406 value is a tuple of the process handle, thread handle,\n\ 407 process ID, and thread ID.\n\ 408 \n\ 409 proc_attrs and thread_attrs are ignored internally and can be None."); 367 410 368 411 static PyObject * 369 412 sp_CreateProcess(PyObject* self, PyObject* args) 370 413 { 371 BOOL result; 372 PROCESS_INFORMATION pi; 373 STARTUPINFO si; 374 PyObject* environment; 375 376 char* application_name; 377 char* command_line; 378 PyObject* process_attributes; /* ignored */ 379 PyObject* thread_attributes; /* ignored */ 380 int inherit_handles; 381 int creation_flags; 382 PyObject* env_mapping; 383 char* current_directory; 384 PyObject* startup_info; 385 386 if (! PyArg_ParseTuple(args, "zzOOiiOzO:CreateProcess", 387 &application_name, 388 &command_line, 389 &process_attributes, 390 &thread_attributes, 391 &inherit_handles, 392 &creation_flags, 393 &env_mapping, 394 ¤t_directory, 395 &startup_info)) 396 return NULL; 397 398 ZeroMemory(&si, sizeof(si)); 399 si.cb = sizeof(si); 400 401 /* note: we only support a small subset of all SI attributes */ 402 si.dwFlags = getint(startup_info, "dwFlags"); 403 si.wShowWindow = getint(startup_info, "wShowWindow"); 404 si.hStdInput = gethandle(startup_info, "hStdInput"); 405 si.hStdOutput = gethandle(startup_info, "hStdOutput"); 406 si.hStdError = gethandle(startup_info, "hStdError"); 407 408 if (PyErr_Occurred()) 409 return NULL; 410 411 if (env_mapping == Py_None) 412 environment = NULL; 413 else { 414 environment = getenvironment(env_mapping); 415 if (! environment) 416 return NULL; 417 } 418 419 Py_BEGIN_ALLOW_THREADS 420 result = CreateProcess(application_name, 421 command_line, 422 NULL, 423 NULL, 424 inherit_handles, 425 creation_flags, 426 environment ? PyString_AS_STRING(environment) : NULL, 427 current_directory, 428 &si, 429 &pi); 430 Py_END_ALLOW_THREADS 431 432 Py_XDECREF(environment); 433 434 if (! result) 435 return PyErr_SetFromWindowsErr(GetLastError()); 436 437 return Py_BuildValue("NNii", 438 sp_handle_new(pi.hProcess), 439 sp_handle_new(pi.hThread), 440 pi.dwProcessId, 441 pi.dwThreadId); 442 } 414 BOOL result; 415 PROCESS_INFORMATION pi; 416 STARTUPINFO si; 417 PyObject* environment; 418 419 char* application_name; 420 char* command_line; 421 PyObject* process_attributes; /* ignored */ 422 PyObject* thread_attributes; /* ignored */ 423 int inherit_handles; 424 int creation_flags; 425 PyObject* env_mapping; 426 char* current_directory; 427 PyObject* startup_info; 428 429 if (! PyArg_ParseTuple(args, "zzOOiiOzO:CreateProcess", 430 &application_name, 431 &command_line, 432 &process_attributes, 433 &thread_attributes, 434 &inherit_handles, 435 &creation_flags, 436 &env_mapping, 437 ¤t_directory, 438 &startup_info)) 439 return NULL; 440 441 ZeroMemory(&si, sizeof(si)); 442 si.cb = sizeof(si); 443 444 /* note: we only support a small subset of all SI attributes */ 445 si.dwFlags = getint(startup_info, "dwFlags"); 446 si.wShowWindow = getint(startup_info, "wShowWindow"); 447 si.hStdInput = gethandle(startup_info, "hStdInput"); 448 si.hStdOutput = gethandle(startup_info, "hStdOutput"); 449 si.hStdError = gethandle(startup_info, "hStdError"); 450 451 if (PyErr_Occurred()) 452 return NULL; 453 454 if (env_mapping == Py_None) 455 environment = NULL; 456 else { 457 environment = getenvironment(env_mapping); 458 if (! environment) 459 return NULL; 460 } 461 462 Py_BEGIN_ALLOW_THREADS 463 result = CreateProcess(application_name, 464 command_line, 465 NULL, 466 NULL, 467 inherit_handles, 468 creation_flags, 469 environment ? PyString_AS_STRING(environment) : NULL, 470 current_directory, 471 &si, 472 &pi); 473 Py_END_ALLOW_THREADS 474 475 Py_XDECREF(environment); 476 477 if (! result) 478 return PyErr_SetFromWindowsErr(GetLastError()); 479 480 return Py_BuildValue("NNii", 481 sp_handle_new(pi.hProcess), 482 sp_handle_new(pi.hThread), 483 pi.dwProcessId, 484 pi.dwThreadId); 485 } 486 487 PyDoc_STRVAR(TerminateProcess_doc, 488 "TerminateProcess(handle, exit_code) -> None\n\ 489 \n\ 490 Terminate the specified process and all of its threads."); 443 491 444 492 static PyObject * 445 493 sp_TerminateProcess(PyObject* self, PyObject* args) 446 494 { 447 BOOL result; 448 449 HANDLE process; 450 int exit_code; 451 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:TerminateProcess", 452 &process, &exit_code)) 453 return NULL; 454 455 result = TerminateProcess(process, exit_code); 456 457 if (! result) 458 return PyErr_SetFromWindowsErr(GetLastError()); 459 460 Py_INCREF(Py_None); 461 return Py_None; 462 } 495 BOOL result; 496 497 HANDLE process; 498 int exit_code; 499 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:TerminateProcess", 500 &process, &exit_code)) 501 return NULL; 502 503 result = TerminateProcess(process, exit_code); 504 505 if (! result) 506 return PyErr_SetFromWindowsErr(GetLastError()); 507 508 Py_INCREF(Py_None); 509 return Py_None; 510 } 511 512 PyDoc_STRVAR(GetExitCodeProcess_doc, 513 "GetExitCodeProcess(handle) -> Exit code\n\ 514 \n\ 515 Return the termination status of the specified process."); 463 516 464 517 static PyObject * 465 518 sp_GetExitCodeProcess(PyObject* self, PyObject* args) 466 519 { 467 DWORD exit_code; 468 BOOL result; 469 470 HANDLE process; 471 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM ":GetExitCodeProcess", &process)) 472 return NULL; 473 474 result = GetExitCodeProcess(process, &exit_code); 475 476 if (! result) 477 return PyErr_SetFromWindowsErr(GetLastError()); 478 479 return PyInt_FromLong(exit_code); 480 } 520 DWORD exit_code; 521 BOOL result; 522 523 HANDLE process; 524 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM ":GetExitCodeProcess", &process)) 525 return NULL; 526 527 result = GetExitCodeProcess(process, &exit_code); 528 529 if (! result) 530 return PyErr_SetFromWindowsErr(GetLastError()); 531 532 return PyInt_FromLong(exit_code); 533 } 534 535 PyDoc_STRVAR(WaitForSingleObject_doc, 536 "WaitForSingleObject(handle, timeout) -> result\n\ 537 \n\ 538 Wait until the specified object is in the signaled state or\n\ 539 the time-out interval elapses. The timeout value is specified\n\ 540 in milliseconds."); 481 541 482 542 static PyObject * 483 543 sp_WaitForSingleObject(PyObject* self, PyObject* args) 484 544 { 485 DWORD result; 486 487 HANDLE handle; 488 int milliseconds; 489 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:WaitForSingleObject", 490 &handle, 491 &milliseconds)) 492 return NULL; 493 494 Py_BEGIN_ALLOW_THREADS 495 result = WaitForSingleObject(handle, (DWORD) milliseconds); 496 Py_END_ALLOW_THREADS 497 498 if (result == WAIT_FAILED) 499 return PyErr_SetFromWindowsErr(GetLastError()); 500 501 return PyInt_FromLong((int) result); 502 } 545 DWORD result; 546 547 HANDLE handle; 548 int milliseconds; 549 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:WaitForSingleObject", 550 &handle, 551 &milliseconds)) 552 return NULL; 553 554 Py_BEGIN_ALLOW_THREADS 555 result = WaitForSingleObject(handle, (DWORD) milliseconds); 556 Py_END_ALLOW_THREADS 557 558 if (result == WAIT_FAILED) 559 return PyErr_SetFromWindowsErr(GetLastError()); 560 561 return PyInt_FromLong((int) result); 562 } 563 564 PyDoc_STRVAR(GetVersion_doc, 565 "GetVersion() -> version\n\ 566 \n\ 567 Return the version number of the current operating system."); 503 568 504 569 static PyObject * 505 570 sp_GetVersion(PyObject* self, PyObject* args) 506 571 { 507 if (! PyArg_ParseTuple(args, ":GetVersion")) 508 return NULL; 509 510 return PyInt_FromLong((int) GetVersion()); 511 } 572 if (! PyArg_ParseTuple(args, ":GetVersion")) 573 return NULL; 574 575 return PyInt_FromLong((int) GetVersion()); 576 } 577 578 PyDoc_STRVAR(GetModuleFileName_doc, 579 "GetModuleFileName(module) -> path\n\ 580 \n\ 581 Return the fully-qualified path for the file that contains\n\ 582 the specified module. The module must have been loaded by the\n\ 583 current process.\n\ 584 \n\ 585 The module parameter should be a handle to the loaded module\n\ 586 whose path is being requested. If this parameter is 0, \n\ 587 GetModuleFileName retrieves the path of the executable file\n\ 588 of the current process."); 512 589 513 590 static PyObject * 514 591 sp_GetModuleFileName(PyObject* self, PyObject* args) 515 592 { 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 593 BOOL result; 594 HMODULE module; 595 TCHAR filename[MAX_PATH]; 596 597 if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM ":GetModuleFileName", 598 &module)) 599 return NULL; 600 601 result = GetModuleFileName(module, filename, MAX_PATH); 602 filename[MAX_PATH-1] = '\0'; 603 604 if (! result) 605 return PyErr_SetFromWindowsErr(GetLastError()); 606 607 return PyString_FromString(filename); 531 608 } 532 609 533 610 static PyMethodDef sp_functions[] = { 534 {"GetStdHandle", sp_GetStdHandle, METH_VARARGS}, 535 {"GetCurrentProcess", sp_GetCurrentProcess, METH_VARARGS}, 536 {"DuplicateHandle", sp_DuplicateHandle, METH_VARARGS}, 537 {"CreatePipe", sp_CreatePipe, METH_VARARGS}, 538 {"CreateProcess", sp_CreateProcess, METH_VARARGS}, 539 {"TerminateProcess", sp_TerminateProcess, METH_VARARGS}, 540 {"GetExitCodeProcess", sp_GetExitCodeProcess, METH_VARARGS}, 541 {"WaitForSingleObject", sp_WaitForSingleObject, METH_VARARGS}, 542 {"GetVersion", sp_GetVersion, METH_VARARGS}, 543 {"GetModuleFileName", sp_GetModuleFileName, METH_VARARGS}, 544 {NULL, NULL} 611 {"GetStdHandle", sp_GetStdHandle, METH_VARARGS, GetStdHandle_doc}, 612 {"GetCurrentProcess", sp_GetCurrentProcess, METH_VARARGS, 613 GetCurrentProcess_doc}, 614 {"DuplicateHandle", sp_DuplicateHandle, METH_VARARGS, 615 DuplicateHandle_doc}, 616 {"CreatePipe", sp_CreatePipe, METH_VARARGS, CreatePipe_doc}, 617 {"CreateProcess", sp_CreateProcess, METH_VARARGS, CreateProcess_doc}, 618 {"TerminateProcess", sp_TerminateProcess, METH_VARARGS, 619 TerminateProcess_doc}, 620 {"GetExitCodeProcess", sp_GetExitCodeProcess, METH_VARARGS, 621 GetExitCodeProcess_doc}, 622 {"WaitForSingleObject", sp_WaitForSingleObject, METH_VARARGS, 623 WaitForSingleObject_doc}, 624 {"GetVersion", sp_GetVersion, METH_VARARGS, GetVersion_doc}, 625 {"GetModuleFileName", sp_GetModuleFileName, METH_VARARGS, 626 GetModuleFileName_doc}, 627 {NULL, NULL} 545 628 }; 546 629 … … 550 633 defint(PyObject* d, const char* name, int value) 551 634 { 552 553 554 555 556 635 PyObject* v = PyInt_FromLong((long) value); 636 if (v) { 637 PyDict_SetItemString(d, (char*) name, v); 638 Py_DECREF(v); 639 } 557 640 } 558 641 … … 564 647 init_subprocess() 565 648 { 566 PyObject *d; 567 PyObject *m; 568 569 /* patch up object descriptors */ 570 sp_handle_type.ob_type = &PyType_Type; 571 sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; 572 573 m = Py_InitModule("_subprocess", sp_functions); 574 if (m == NULL) 575 return; 576 d = PyModule_GetDict(m); 577 578 /* constants */ 579 defint(d, "STD_INPUT_HANDLE", STD_INPUT_HANDLE); 580 defint(d, "STD_OUTPUT_HANDLE", STD_OUTPUT_HANDLE); 581 defint(d, "STD_ERROR_HANDLE", STD_ERROR_HANDLE); 582 defint(d, "DUPLICATE_SAME_ACCESS", DUPLICATE_SAME_ACCESS); 583 defint(d, "STARTF_USESTDHANDLES", STARTF_USESTDHANDLES); 584 defint(d, "STARTF_USESHOWWINDOW", STARTF_USESHOWWINDOW); 585 defint(d, "SW_HIDE", SW_HIDE); 586 defint(d, "INFINITE", INFINITE); 587 defint(d, "WAIT_OBJECT_0", WAIT_OBJECT_0); 588 defint(d, "CREATE_NEW_CONSOLE", CREATE_NEW_CONSOLE); 589 } 649 PyObject *d; 650 PyObject *m; 651 652 /* patch up object descriptors */ 653 sp_handle_type.ob_type = &PyType_Type; 654 sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; 655 656 m = Py_InitModule("_subprocess", sp_functions); 657 if (m == NULL) 658 return; 659 d = PyModule_GetDict(m); 660 661 /* constants */ 662 defint(d, "STD_INPUT_HANDLE", STD_INPUT_HANDLE); 663 defint(d, "STD_OUTPUT_HANDLE", STD_OUTPUT_HANDLE); 664 defint(d, "STD_ERROR_HANDLE", STD_ERROR_HANDLE); 665 defint(d, "DUPLICATE_SAME_ACCESS", DUPLICATE_SAME_ACCESS); 666 defint(d, "STARTF_USESTDHANDLES", STARTF_USESTDHANDLES); 667 defint(d, "STARTF_USESHOWWINDOW", STARTF_USESHOWWINDOW); 668 defint(d, "SW_HIDE", SW_HIDE); 669 defint(d, "INFINITE", INFINITE); 670 defint(d, "WAIT_OBJECT_0", WAIT_OBJECT_0); 671 defint(d, "CREATE_NEW_CONSOLE", CREATE_NEW_CONSOLE); 672 defint(d, "CREATE_NEW_PROCESS_GROUP", CREATE_NEW_PROCESS_GROUP); 673 defint(d, "STILL_ACTIVE", STILL_ACTIVE); 674 } -
python/vendor/current/PC/_winreg.c
r2 r388 5 5 6 6 * Simple registry access written by Mark Hammond in win32api 7 7 module circa 1995. 8 8 * Bill Tutt expanded the support significantly not long after. 9 9 * Numerous other people have submitted patches since then. … … 30 30 */ 31 31 #define PyErr_SetFromWindowsErrWithFunction(rc, fnname) \ 32 32 PyErr_SetFromWindowsErr(rc) 33 33 34 34 /* Forward declares */ … … 90 90 "\n" 91 91 "The return value is the handle of the opened key.\n" 92 "If the function fails, a n EnvironmentError exception is raised.");92 "If the function fails, a WindowsError exception is raised."); 93 93 94 94 PyDoc_STRVAR(CreateKey_doc, … … 105 105 "If the function fails, an exception is raised."); 106 106 107 PyDoc_STRVAR(CreateKeyEx_doc, 108 "key = CreateKeyEx(key, sub_key, res, sam) - Creates or opens the specified key.\n" 109 "\n" 110 "key is an already open key, or one of the predefined HKEY_* constants\n" 111 "sub_key is a string that names the key this method opens or creates.\n" 112 "res is a reserved integer, and must be zero. Default is zero.\n" 113 "sam is an integer that specifies an access mask that describes the desired\n" 114 " If key is one of the predefined keys, sub_key may be None. In that case,\n" 115 " the handle returned is the same key handle passed in to the function.\n" 116 "\n" 117 "If the key already exists, this function opens the existing key\n" 118 "\n" 119 "The return value is the handle of the opened key.\n" 120 "If the function fails, an exception is raised."); 121 107 122 PyDoc_STRVAR(DeleteKey_doc, 108 123 "DeleteKey(key, sub_key) - Deletes the specified key.\n" … … 115 130 "\n" 116 131 "If the method succeeds, the entire key, including all of its values,\n" 117 "is removed. If the method fails, an EnvironmentError exception is raised."); 132 "is removed. If the method fails, a WindowsError exception is raised."); 133 134 PyDoc_STRVAR(DeleteKeyEx_doc, 135 "DeleteKeyEx(key, sub_key, sam, res) - Deletes the specified key.\n" 136 "\n" 137 "key is an already open key, or any one of the predefined HKEY_* constants.\n" 138 "sub_key is a string that must be a subkey of the key identified by the key parameter.\n" 139 "res is a reserved integer, and must be zero. Default is zero.\n" 140 "sam is an integer that specifies an access mask that describes the desired\n" 141 " This value must not be None, and the key may not have subkeys.\n" 142 "\n" 143 "This method can not delete keys with subkeys.\n" 144 "\n" 145 "If the method succeeds, the entire key, including all of its values,\n" 146 "is removed. If the method fails, a WindowsError exception is raised.\n" 147 "On unsupported Windows versions, NotImplementedError is raised."); 118 148 119 149 PyDoc_STRVAR(DeleteValue_doc, … … 130 160 "\n" 131 161 "The function retrieves the name of one subkey each time it is called.\n" 132 "It is typically called repeatedly until a n EnvironmentError exception is\n"162 "It is typically called repeatedly until a WindowsError exception is\n" 133 163 "raised, indicating no more values are available."); 134 164 … … 139 169 "\n" 140 170 "The function retrieves the name of one subkey each time it is called.\n" 141 "It is typically called repeatedly, until a n EnvironmentError exception\n"171 "It is typically called repeatedly, until a WindowsError exception\n" 142 172 "is raised, indicating no more values.\n" 143 173 "\n" … … 193 223 "\n" 194 224 "The result is a new handle to the specified key\n" 195 "If the function fails, a n EnvironmentError exception is raised.");225 "If the function fails, a WindowsError exception is raised."); 196 226 197 227 PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()"); … … 355 385 ************************************************************************/ 356 386 typedef struct { 357 358 387 PyObject_VAR_HEAD 388 HKEY hkey; 359 389 } PyHKEYObject; 360 390 … … 366 396 PyHKEY_unaryFailureFunc(PyObject *ob) 367 397 { 368 369 398 PyErr_SetString(PyExc_TypeError, failMsg); 399 return NULL; 370 400 } 371 401 static PyObject * 372 402 PyHKEY_binaryFailureFunc(PyObject *ob1, PyObject *ob2) 373 403 { 374 375 404 PyErr_SetString(PyExc_TypeError, failMsg); 405 return NULL; 376 406 } 377 407 static PyObject * 378 408 PyHKEY_ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3) 379 409 { 380 381 410 PyErr_SetString(PyExc_TypeError, failMsg); 411 return NULL; 382 412 } 383 413 … … 385 415 PyHKEY_deallocFunc(PyObject *ob) 386 416 { 387 388 389 390 391 392 393 394 417 /* Can not call PyHKEY_Close, as the ob->tp_type 418 has already been cleared, thus causing the type 419 check to fail! 420 */ 421 PyHKEYObject *obkey = (PyHKEYObject *)ob; 422 if (obkey->hkey) 423 RegCloseKey((HKEY)obkey->hkey); 424 PyObject_DEL(ob); 395 425 } 396 426 … … 398 428 PyHKEY_nonzeroFunc(PyObject *ob) 399 429 { 400 430 return ((PyHKEYObject *)ob)->hkey != 0; 401 431 } 402 432 … … 404 434 PyHKEY_intFunc(PyObject *ob) 405 435 { 406 407 436 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; 437 return PyLong_FromVoidPtr(pyhkey->hkey); 408 438 } 409 439 … … 411 441 PyHKEY_printFunc(PyObject *ob, FILE *fp, int flags) 412 442 { 413 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; 414 char resBuf[160]; 415 wsprintf(resBuf, "<PyHKEY at %p (%p)>", 416 ob, pyhkey->hkey); 417 fputs(resBuf, fp); 418 return 0; 443 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; 444 fprintf(fp, "<PyHKEY at %p (%p)>", 445 ob, pyhkey->hkey); 446 return 0; 419 447 } 420 448 … … 422 450 PyHKEY_strFunc(PyObject *ob) 423 451 { 424 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; 425 char resBuf[160]; 426 wsprintf(resBuf, "<PyHKEY:%p>", pyhkey->hkey); 427 return PyString_FromString(resBuf); 452 PyHKEYObject *pyhkey = (PyHKEYObject *)ob; 453 return PyString_FromFormat("<PyHKEY:%p>", pyhkey->hkey); 428 454 } 429 455 … … 431 457 PyHKEY_compareFunc(PyObject *ob1, PyObject *ob2) 432 458 { 433 434 435 436 459 PyHKEYObject *pyhkey1 = (PyHKEYObject *)ob1; 460 PyHKEYObject *pyhkey2 = (PyHKEYObject *)ob2; 461 return pyhkey1 == pyhkey2 ? 0 : 462 (pyhkey1 < pyhkey2 ? -1 : 1); 437 463 } 438 464 … … 440 466 PyHKEY_hashFunc(PyObject *ob) 441 467 { 442 443 444 445 468 /* Just use the address. 469 XXX - should we use the handle value? 470 */ 471 return _Py_HashPointer(ob); 446 472 } 447 473 … … 449 475 static PyNumberMethods PyHKEY_NumberMethods = 450 476 { 451 PyHKEY_binaryFailureFunc,/* nb_add */452 PyHKEY_binaryFailureFunc,/* nb_subtract */453 PyHKEY_binaryFailureFunc,/* nb_multiply */454 PyHKEY_binaryFailureFunc,/* nb_divide */455 PyHKEY_binaryFailureFunc,/* nb_remainder */456 PyHKEY_binaryFailureFunc,/* nb_divmod */457 PyHKEY_ternaryFailureFunc,/* nb_power */458 PyHKEY_unaryFailureFunc,/* nb_negative */459 PyHKEY_unaryFailureFunc,/* nb_positive */460 PyHKEY_unaryFailureFunc,/* nb_absolute */461 PyHKEY_nonzeroFunc,/* nb_nonzero */462 PyHKEY_unaryFailureFunc,/* nb_invert */463 PyHKEY_binaryFailureFunc,/* nb_lshift */464 PyHKEY_binaryFailureFunc,/* nb_rshift */465 PyHKEY_binaryFailureFunc,/* nb_and */466 PyHKEY_binaryFailureFunc,/* nb_xor */467 PyHKEY_binaryFailureFunc,/* nb_or */468 0,/* nb_coerce (allowed to be zero) */469 PyHKEY_intFunc,/* nb_int */470 PyHKEY_unaryFailureFunc,/* nb_long */471 PyHKEY_unaryFailureFunc,/* nb_float */472 PyHKEY_unaryFailureFunc,/* nb_oct */473 PyHKEY_unaryFailureFunc,/* nb_hex */477 PyHKEY_binaryFailureFunc, /* nb_add */ 478 PyHKEY_binaryFailureFunc, /* nb_subtract */ 479 PyHKEY_binaryFailureFunc, /* nb_multiply */ 480 PyHKEY_binaryFailureFunc, /* nb_divide */ 481 PyHKEY_binaryFailureFunc, /* nb_remainder */ 482 PyHKEY_binaryFailureFunc, /* nb_divmod */ 483 PyHKEY_ternaryFailureFunc, /* nb_power */ 484 PyHKEY_unaryFailureFunc, /* nb_negative */ 485 PyHKEY_unaryFailureFunc, /* nb_positive */ 486 PyHKEY_unaryFailureFunc, /* nb_absolute */ 487 PyHKEY_nonzeroFunc, /* nb_nonzero */ 488 PyHKEY_unaryFailureFunc, /* nb_invert */ 489 PyHKEY_binaryFailureFunc, /* nb_lshift */ 490 PyHKEY_binaryFailureFunc, /* nb_rshift */ 491 PyHKEY_binaryFailureFunc, /* nb_and */ 492 PyHKEY_binaryFailureFunc, /* nb_xor */ 493 PyHKEY_binaryFailureFunc, /* nb_or */ 494 0, /* nb_coerce (allowed to be zero) */ 495 PyHKEY_intFunc, /* nb_int */ 496 PyHKEY_unaryFailureFunc, /* nb_long */ 497 PyHKEY_unaryFailureFunc, /* nb_float */ 498 PyHKEY_unaryFailureFunc, /* nb_oct */ 499 PyHKEY_unaryFailureFunc, /* nb_hex */ 474 500 }; 475 501 476 477 /* fwd declare __getattr__ */ 478 static PyObject *PyHKEY_getattr(PyObject *self, const char *name); 502 static PyObject *PyHKEY_CloseMethod(PyObject *self, PyObject *args); 503 static PyObject *PyHKEY_DetachMethod(PyObject *self, PyObject *args); 504 static PyObject *PyHKEY_Enter(PyObject *self); 505 static PyObject *PyHKEY_Exit(PyObject *self, PyObject *args); 506 507 static struct PyMethodDef PyHKEY_methods[] = { 508 {"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc}, 509 {"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc}, 510 {"__enter__", (PyCFunction)PyHKEY_Enter, METH_NOARGS, NULL}, 511 {"__exit__", PyHKEY_Exit, METH_VARARGS, NULL}, 512 {NULL} 513 }; 514 515 static PyMemberDef PyHKEY_memberlist[] = { 516 {"handle", T_PYSSIZET, offsetof(PyHKEYObject, hkey), READONLY}, 517 {NULL} /* Sentinel */ 518 }; 479 519 480 520 /* The type itself */ 481 521 PyTypeObject PyHKEY_Type = 482 522 { 483 PyVarObject_HEAD_INIT(0, 0) /* fill in type at module init */ 484 "PyHKEY", 485 sizeof(PyHKEYObject), 486 0, 487 PyHKEY_deallocFunc, /* tp_dealloc */ 488 PyHKEY_printFunc, /* tp_print */ 489 PyHKEY_getattr, /* tp_getattr */ 490 0, /* tp_setattr */ 491 PyHKEY_compareFunc, /* tp_compare */ 492 0, /* tp_repr */ 493 &PyHKEY_NumberMethods, /* tp_as_number */ 494 0, /* tp_as_sequence */ 495 0, /* tp_as_mapping */ 496 PyHKEY_hashFunc, /* tp_hash */ 497 0, /* tp_call */ 498 PyHKEY_strFunc, /* tp_str */ 499 0, /* tp_getattro */ 500 0, /* tp_setattro */ 501 0, /* tp_as_buffer */ 502 0, /* tp_flags */ 503 PyHKEY_doc, /* tp_doc */ 523 PyVarObject_HEAD_INIT(0, 0) /* fill in type at module init */ 524 "PyHKEY", 525 sizeof(PyHKEYObject), 526 0, 527 PyHKEY_deallocFunc, /* tp_dealloc */ 528 PyHKEY_printFunc, /* tp_print */ 529 0, /* tp_getattr */ 530 0, /* tp_setattr */ 531 PyHKEY_compareFunc, /* tp_compare */ 532 0, /* tp_repr */ 533 &PyHKEY_NumberMethods, /* tp_as_number */ 534 0, /* tp_as_sequence */ 535 0, /* tp_as_mapping */ 536 PyHKEY_hashFunc, /* tp_hash */ 537 0, /* tp_call */ 538 PyHKEY_strFunc, /* tp_str */ 539 0, /* tp_getattro */ 540 0, /* tp_setattro */ 541 0, /* tp_as_buffer */ 542 Py_TPFLAGS_DEFAULT, /* tp_flags */ 543 PyHKEY_doc, /* tp_doc */ 544 0, /* tp_traverse */ 545 0, /* tp_clear */ 546 0, /* tp_richcompare */ 547 0, /* tp_weaklistoffset */ 548 0, /* tp_iter */ 549 0, /* tp_iternext */ 550 PyHKEY_methods, /* tp_methods */ 551 PyHKEY_memberlist, /* tp_members */ 504 552 }; 505 553 506 #define OFF(e) offsetof(PyHKEYObject, e)507 508 static struct memberlist PyHKEY_memberlist[] = {509 {"handle", T_INT, OFF(hkey)},510 {NULL} /* Sentinel */511 };512 513 554 /************************************************************************ 514 555 … … 519 560 PyHKEY_CloseMethod(PyObject *self, PyObject *args) 520 561 { 521 522 523 524 525 526 562 if (!PyArg_ParseTuple(args, ":Close")) 563 return NULL; 564 if (!PyHKEY_Close(self)) 565 return NULL; 566 Py_INCREF(Py_None); 567 return Py_None; 527 568 } 528 569 … … 530 571 PyHKEY_DetachMethod(PyObject *self, PyObject *args) 531 572 { 532 533 534 535 536 537 538 573 void* ret; 574 PyHKEYObject *pThis = (PyHKEYObject *)self; 575 if (!PyArg_ParseTuple(args, ":Detach")) 576 return NULL; 577 ret = (void*)pThis->hkey; 578 pThis->hkey = 0; 579 return PyLong_FromVoidPtr(ret); 539 580 } 540 581 … … 542 583 PyHKEY_Enter(PyObject *self) 543 584 { 544 545 585 Py_XINCREF(self); 586 return self; 546 587 } 547 588 … … 549 590 PyHKEY_Exit(PyObject *self, PyObject *args) 550 591 { 551 if (!PyHKEY_Close(self)) 552 return NULL; 553 Py_RETURN_NONE; 554 } 555 556 557 static struct PyMethodDef PyHKEY_methods[] = { 558 {"Close", PyHKEY_CloseMethod, METH_VARARGS, PyHKEY_Close_doc}, 559 {"Detach", PyHKEY_DetachMethod, METH_VARARGS, PyHKEY_Detach_doc}, 560 {"__enter__", (PyCFunction)PyHKEY_Enter, METH_NOARGS, NULL}, 561 {"__exit__", PyHKEY_Exit, METH_VARARGS, NULL}, 562 {NULL} 563 }; 564 565 /*static*/ PyObject * 566 PyHKEY_getattr(PyObject *self, const char *name) 567 { 568 PyObject *res; 569 570 res = Py_FindMethod(PyHKEY_methods, self, name); 571 if (res != NULL) 572 return res; 573 PyErr_Clear(); 574 if (strcmp(name, "handle") == 0) 575 return PyLong_FromVoidPtr(((PyHKEYObject *)self)->hkey); 576 return PyMember_Get((char *)self, PyHKEY_memberlist, name); 577 } 592 if (!PyHKEY_Close(self)) 593 return NULL; 594 Py_RETURN_NONE; 595 } 596 578 597 579 598 /************************************************************************ … … 583 602 PyHKEY_New(HKEY hInit) 584 603 { 585 586 587 588 604 PyHKEYObject *key = PyObject_NEW(PyHKEYObject, &PyHKEY_Type); 605 if (key) 606 key->hkey = hInit; 607 return (PyObject *)key; 589 608 } 590 609 … … 592 611 PyHKEY_Close(PyObject *ob_handle) 593 612 { 594 595 596 597 598 599 600 601 602 603 604 605 606 613 LONG rc; 614 PyHKEYObject *key; 615 616 if (!PyHKEY_Check(ob_handle)) { 617 PyErr_SetString(PyExc_TypeError, "bad operand type"); 618 return FALSE; 619 } 620 key = (PyHKEYObject *)ob_handle; 621 rc = key->hkey ? RegCloseKey((HKEY)key->hkey) : ERROR_SUCCESS; 622 key->hkey = 0; 623 if (rc != ERROR_SUCCESS) 624 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); 625 return rc == ERROR_SUCCESS; 607 626 } 608 627 … … 610 629 PyHKEY_AsHKEY(PyObject *ob, HKEY *pHANDLE, BOOL bNoneOK) 611 630 { 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 631 if (ob == Py_None) { 632 if (!bNoneOK) { 633 PyErr_SetString( 634 PyExc_TypeError, 635 "None is not a valid HKEY in this context"); 636 return FALSE; 637 } 638 *pHANDLE = (HKEY)0; 639 } 640 else if (PyHKEY_Check(ob)) { 641 PyHKEYObject *pH = (PyHKEYObject *)ob; 642 *pHANDLE = pH->hkey; 643 } 644 else if (PyInt_Check(ob) || PyLong_Check(ob)) { 645 /* We also support integers */ 646 PyErr_Clear(); 647 *pHANDLE = (HKEY)PyLong_AsVoidPtr(ob); 648 if (PyErr_Occurred()) 649 return FALSE; 650 } 651 else { 652 PyErr_SetString( 653 PyExc_TypeError, 654 "The object is not a PyHKEY object"); 655 return FALSE; 656 } 657 return TRUE; 639 658 } 640 659 … … 642 661 PyHKEY_FromHKEY(HKEY h) 643 662 { 644 645 646 647 648 649 650 651 652 663 PyHKEYObject *op; 664 665 /* Inline PyObject_New */ 666 op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject)); 667 if (op == NULL) 668 return PyErr_NoMemory(); 669 PyObject_INIT(op, &PyHKEY_Type); 670 op->hkey = h; 671 return (PyObject *)op; 653 672 } 654 673 … … 660 679 PyWinObject_CloseHKEY(PyObject *obHandle) 661 680 { 662 663 664 665 681 BOOL ok; 682 if (PyHKEY_Check(obHandle)) { 683 ok = PyHKEY_Close(obHandle); 684 } 666 685 #if SIZEOF_LONG >= SIZEOF_HKEY 667 668 669 670 671 672 686 else if (PyInt_Check(obHandle)) { 687 long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); 688 ok = (rc == ERROR_SUCCESS); 689 if (!ok) 690 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); 691 } 673 692 #else 674 675 676 677 678 679 693 else if (PyLong_Check(obHandle)) { 694 long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); 695 ok = (rc == ERROR_SUCCESS); 696 if (!ok) 697 PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); 698 } 680 699 #endif 681 682 683 684 685 686 687 700 else { 701 PyErr_SetString( 702 PyExc_TypeError, 703 "A handle must be a HKEY object or an integer"); 704 return FALSE; 705 } 706 return ok; 688 707 } 689 708 … … 702 721 fixupMultiSZ(char **str, char *data, int len) 703 722 { 704 705 706 707 708 709 710 711 712 713 723 char *P; 724 int i; 725 char *Q; 726 727 Q = data + len; 728 for (P = data, i = 0; P < Q && *P != '\0'; P++, i++) { 729 str[i] = P; 730 for(; *P != '\0'; P++) 731 ; 732 } 714 733 } 715 734 … … 717 736 countStrings(char *data, int len) 718 737 { 719 720 721 722 723 724 725 726 738 int strings; 739 char *P; 740 char *Q = data + len; 741 742 for (P = data, strings = 0; P < Q && *P != '\0'; P++, strings++) 743 for (; P < Q && *P != '\0'; P++) 744 ; 745 return strings; 727 746 } 728 747 … … 732 751 Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize) 733 752 { 734 Py_ssize_t i,j; 735 switch (typ) { 736 case REG_DWORD: 737 if (value != Py_None && !PyInt_Check(value)) 738 return FALSE; 739 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); 740 if (*retDataBuf==NULL){ 741 PyErr_NoMemory(); 742 return FALSE; 743 } 744 *retDataSize = sizeof(DWORD); 745 if (value == Py_None) { 746 DWORD zero = 0; 747 memcpy(*retDataBuf, &zero, sizeof(DWORD)); 748 } 749 else 750 memcpy(*retDataBuf, 751 &PyInt_AS_LONG((PyIntObject *)value), 752 sizeof(DWORD)); 753 break; 754 case REG_SZ: 755 case REG_EXPAND_SZ: 756 { 757 int need_decref = 0; 758 if (value == Py_None) 759 *retDataSize = 1; 760 else { 761 if (PyUnicode_Check(value)) { 762 value = PyUnicode_AsEncodedString( 763 value, 764 "mbcs", 765 NULL); 766 if (value==NULL) 767 return FALSE; 768 need_decref = 1; 769 } 770 if (!PyString_Check(value)) 771 return FALSE; 772 *retDataSize = 1 + strlen( 773 PyString_AS_STRING( 774 (PyStringObject *)value)); 775 } 776 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize); 777 if (*retDataBuf==NULL){ 778 PyErr_NoMemory(); 779 return FALSE; 780 } 781 if (value == Py_None) 782 strcpy((char *)*retDataBuf, ""); 783 else 784 strcpy((char *)*retDataBuf, 785 PyString_AS_STRING( 786 (PyStringObject *)value)); 787 if (need_decref) 788 Py_DECREF(value); 789 break; 790 } 791 case REG_MULTI_SZ: 792 { 793 DWORD size = 0; 794 char *P; 795 PyObject **obs = NULL; 796 797 if (value == Py_None) 798 i = 0; 799 else { 800 if (!PyList_Check(value)) 801 return FALSE; 802 i = PyList_Size(value); 803 } 804 obs = malloc(sizeof(PyObject *) * i); 805 memset(obs, 0, sizeof(PyObject *) * i); 806 for (j = 0; j < i; j++) 807 { 808 PyObject *t; 809 t = PyList_GET_ITEM( 810 (PyListObject *)value,j); 811 if (PyString_Check(t)) { 812 obs[j] = t; 813 Py_INCREF(t); 814 } else if (PyUnicode_Check(t)) { 815 obs[j] = PyUnicode_AsEncodedString( 816 t, 817 "mbcs", 818 NULL); 819 if (obs[j]==NULL) 820 goto reg_multi_fail; 821 } else 822 goto reg_multi_fail; 823 size += 1 + strlen( 824 PyString_AS_STRING( 825 (PyStringObject *)obs[j])); 826 } 827 828 *retDataSize = size + 1; 829 *retDataBuf = (BYTE *)PyMem_NEW(char, 830 *retDataSize); 831 if (*retDataBuf==NULL){ 832 PyErr_NoMemory(); 833 goto reg_multi_fail; 834 } 835 P = (char *)*retDataBuf; 836 837 for (j = 0; j < i; j++) 838 { 839 PyObject *t; 840 t = obs[j]; 841 strcpy(P, 842 PyString_AS_STRING( 843 (PyStringObject *)t)); 844 P += 1 + strlen( 845 PyString_AS_STRING( 846 (PyStringObject *)t)); 847 Py_DECREF(obs[j]); 848 } 849 /* And doubly-terminate the list... */ 850 *P = '\0'; 851 free(obs); 852 break; 853 reg_multi_fail: 854 if (obs) { 855 for (j = 0; j < i; j++) 856 Py_XDECREF(obs[j]); 857 858 free(obs); 859 } 860 return FALSE; 861 } 862 case REG_BINARY: 863 /* ALSO handle ALL unknown data types here. Even if we can't 864 support it natively, we should handle the bits. */ 865 default: 866 if (value == Py_None) 867 *retDataSize = 0; 868 else { 869 void *src_buf; 870 PyBufferProcs *pb = value->ob_type->tp_as_buffer; 871 if (pb==NULL) { 872 PyErr_Format(PyExc_TypeError, 873 "Objects of type '%s' can not " 874 "be used as binary registry values", 875 value->ob_type->tp_name); 876 return FALSE; 877 } 878 *retDataSize = (*pb->bf_getreadbuffer)(value, 0, &src_buf); 879 *retDataBuf = (BYTE *)PyMem_NEW(char, 880 *retDataSize); 881 if (*retDataBuf==NULL){ 882 PyErr_NoMemory(); 883 return FALSE; 884 } 885 memcpy(*retDataBuf, src_buf, *retDataSize); 886 } 887 break; 888 } 889 return TRUE; 753 Py_ssize_t i,j; 754 switch (typ) { 755 case REG_DWORD: 756 if (value != Py_None && 757 !(PyInt_Check(value) || PyLong_Check(value))) 758 return FALSE; 759 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1); 760 if (*retDataBuf==NULL){ 761 PyErr_NoMemory(); 762 return FALSE; 763 } 764 *retDataSize = sizeof(DWORD); 765 if (value == Py_None) { 766 DWORD zero = 0; 767 memcpy(*retDataBuf, &zero, sizeof(DWORD)); 768 } 769 else { 770 DWORD d = PyLong_AsUnsignedLong(value); 771 memcpy(*retDataBuf, &d, sizeof(DWORD)); 772 } 773 break; 774 case REG_SZ: 775 case REG_EXPAND_SZ: 776 { 777 int need_decref = 0; 778 if (value == Py_None) 779 *retDataSize = 1; 780 else { 781 if (PyUnicode_Check(value)) { 782 value = PyUnicode_AsEncodedString( 783 value, 784 "mbcs", 785 NULL); 786 if (value==NULL) 787 return FALSE; 788 need_decref = 1; 789 } 790 if (!PyString_Check(value)) 791 return FALSE; 792 *retDataSize = 1 + strlen( 793 PyString_AS_STRING( 794 (PyStringObject *)value)); 795 } 796 *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize); 797 if (*retDataBuf==NULL){ 798 PyErr_NoMemory(); 799 return FALSE; 800 } 801 if (value == Py_None) 802 strcpy((char *)*retDataBuf, ""); 803 else 804 strcpy((char *)*retDataBuf, 805 PyString_AS_STRING( 806 (PyStringObject *)value)); 807 if (need_decref) 808 Py_DECREF(value); 809 break; 810 } 811 case REG_MULTI_SZ: 812 { 813 DWORD size = 0; 814 char *P; 815 PyObject **obs = NULL; 816 817 if (value == Py_None) 818 i = 0; 819 else { 820 if (!PyList_Check(value)) 821 return FALSE; 822 i = PyList_Size(value); 823 } 824 obs = malloc(sizeof(PyObject *) * i); 825 memset(obs, 0, sizeof(PyObject *) * i); 826 for (j = 0; j < i; j++) 827 { 828 PyObject *t; 829 t = PyList_GET_ITEM( 830 (PyListObject *)value,j); 831 if (PyString_Check(t)) { 832 obs[j] = t; 833 Py_INCREF(t); 834 } else if (PyUnicode_Check(t)) { 835 obs[j] = PyUnicode_AsEncodedString( 836 t, 837 "mbcs", 838 NULL); 839 if (obs[j]==NULL) 840 goto reg_multi_fail; 841 } else 842 goto reg_multi_fail; 843 size += 1 + strlen( 844 PyString_AS_STRING( 845 (PyStringObject *)obs[j])); 846 } 847 848 *retDataSize = size + 1; 849 *retDataBuf = (BYTE *)PyMem_NEW(char, 850 *retDataSize); 851 if (*retDataBuf==NULL){ 852 PyErr_NoMemory(); 853 goto reg_multi_fail; 854 } 855 P = (char *)*retDataBuf; 856 857 for (j = 0; j < i; j++) 858 { 859 PyObject *t; 860 t = obs[j]; 861 strcpy(P, 862 PyString_AS_STRING( 863 (PyStringObject *)t)); 864 P += 1 + strlen( 865 PyString_AS_STRING( 866 (PyStringObject *)t)); 867 Py_DECREF(obs[j]); 868 } 869 /* And doubly-terminate the list... */ 870 *P = '\0'; 871 free(obs); 872 break; 873 reg_multi_fail: 874 if (obs) { 875 for (j = 0; j < i; j++) 876 Py_XDECREF(obs[j]); 877 878 free(obs); 879 } 880 return FALSE; 881 } 882 case REG_BINARY: 883 /* ALSO handle ALL unknown data types here. Even if we can't 884 support it natively, we should handle the bits. */ 885 default: 886 if (value == Py_None) 887 *retDataSize = 0; 888 else { 889 void *src_buf; 890 PyBufferProcs *pb = value->ob_type->tp_as_buffer; 891 if (pb==NULL) { 892 PyErr_Format(PyExc_TypeError, 893 "Objects of type '%s' can not " 894 "be used as binary registry values", 895 value->ob_type->tp_name); 896 return FALSE; 897 } 898 *retDataSize = (*pb->bf_getreadbuffer)(value, 0, &src_buf); 899 *retDataBuf = (BYTE *)PyMem_NEW(char, 900 *retDataSize); 901 if (*retDataBuf==NULL){ 902 PyErr_NoMemory(); 903 return FALSE; 904 } 905 memcpy(*retDataBuf, src_buf, *retDataSize); 906 } 907 break; 908 } 909 return TRUE; 890 910 } 891 911 … … 894 914 Reg2Py(char *retDataBuf, DWORD retDataSize, DWORD typ) 895 915 { 896 897 898 899 900 901 obData = Py_BuildValue("i", 0);902 903 obData = Py_BuildValue("i",904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 916 PyObject *obData; 917 918 switch (typ) { 919 case REG_DWORD: 920 if (retDataSize == 0) 921 obData = Py_BuildValue("k", 0); 922 else 923 obData = Py_BuildValue("k", 924 *(int *)retDataBuf); 925 break; 926 case REG_SZ: 927 case REG_EXPAND_SZ: 928 /* retDataBuf may or may not have a trailing NULL in 929 the buffer. */ 930 if (retDataSize && retDataBuf[retDataSize-1] == '\0') 931 --retDataSize; 932 if (retDataSize ==0) 933 retDataBuf = ""; 934 obData = PyUnicode_DecodeMBCS(retDataBuf, 935 retDataSize, 936 NULL); 937 break; 938 case REG_MULTI_SZ: 939 if (retDataSize == 0) 940 obData = PyList_New(0); 941 else 942 { 943 int index = 0; 944 int s = countStrings(retDataBuf, retDataSize); 945 char **str = (char **)malloc(sizeof(char *)*s); 946 if (str == NULL) 947 return PyErr_NoMemory(); 948 949 fixupMultiSZ(str, retDataBuf, retDataSize); 950 obData = PyList_New(s); 951 if (obData == NULL) 952 return NULL; 953 for (index = 0; index < s; index++) 954 { 955 size_t len = _mbstrlen(str[index]); 956 if (len > INT_MAX) { 957 PyErr_SetString(PyExc_OverflowError, 958 "registry string is too long for a Python string"); 959 Py_DECREF(obData); 960 return NULL; 961 } 962 PyList_SetItem(obData, 963 index, 964 PyUnicode_DecodeMBCS( 965 (const char *)str[index], 966 (int)len, 967 NULL) 968 ); 969 } 970 free(str); 971 972 break; 973 } 974 case REG_BINARY: 975 /* ALSO handle ALL unknown data types here. Even if we can't 976 support it natively, we should handle the bits. */ 977 default: 978 if (retDataSize == 0) { 979 Py_INCREF(Py_None); 980 obData = Py_None; 981 } 982 else 983 obData = Py_BuildValue("s#", 984 (char *)retDataBuf, 985 retDataSize); 986 break; 987 } 988 if (obData == NULL) 989 return NULL; 990 else 991 return obData; 972 992 } 973 993 … … 977 997 PyCloseKey(PyObject *self, PyObject *args) 978 998 { 979 980 981 982 983 984 985 999 PyObject *obKey; 1000 if (!PyArg_ParseTuple(args, "O:CloseKey", &obKey)) 1001 return NULL; 1002 if (!PyHKEY_Close(obKey)) 1003 return NULL; 1004 Py_INCREF(Py_None); 1005 return Py_None; 986 1006 } 987 1007 … … 989 1009 PyConnectRegistry(PyObject *self, PyObject *args) 990 1010 { 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1011 HKEY hKey; 1012 PyObject *obKey; 1013 char *szCompName = NULL; 1014 HKEY retKey; 1015 long rc; 1016 if (!PyArg_ParseTuple(args, "zO:ConnectRegistry", &szCompName, &obKey)) 1017 return NULL; 1018 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1019 return NULL; 1020 Py_BEGIN_ALLOW_THREADS 1021 rc = RegConnectRegistry(szCompName, hKey, &retKey); 1022 Py_END_ALLOW_THREADS 1023 if (rc != ERROR_SUCCESS) 1024 return PyErr_SetFromWindowsErrWithFunction(rc, 1025 "ConnectRegistry"); 1026 return PyHKEY_FromHKEY(retKey); 1007 1027 } 1008 1028 … … 1010 1030 PyCreateKey(PyObject *self, PyObject *args) 1011 1031 { 1012 HKEY hKey; 1013 PyObject *obKey; 1014 char *subKey; 1015 HKEY retKey; 1016 long rc; 1017 if (!PyArg_ParseTuple(args, "Oz:CreateKey", &obKey, &subKey)) 1018 return NULL; 1019 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1020 return NULL; 1021 rc = RegCreateKey(hKey, subKey, &retKey); 1022 if (rc != ERROR_SUCCESS) 1023 return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); 1024 return PyHKEY_FromHKEY(retKey); 1032 HKEY hKey; 1033 PyObject *obKey; 1034 char *subKey; 1035 HKEY retKey; 1036 long rc; 1037 if (!PyArg_ParseTuple(args, "Oz:CreateKey", &obKey, &subKey)) 1038 return NULL; 1039 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1040 return NULL; 1041 rc = RegCreateKey(hKey, subKey, &retKey); 1042 if (rc != ERROR_SUCCESS) 1043 return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKey"); 1044 return PyHKEY_FromHKEY(retKey); 1045 } 1046 1047 static PyObject * 1048 PyCreateKeyEx(PyObject *self, PyObject *args) 1049 { 1050 HKEY hKey; 1051 PyObject *obKey; 1052 char *subKey; 1053 HKEY retKey; 1054 int res = 0; 1055 REGSAM sam = KEY_WRITE; 1056 long rc; 1057 if (!PyArg_ParseTuple(args, "Oz|ii:CreateKeyEx", &obKey, &subKey, 1058 &res, &sam)) 1059 return NULL; 1060 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1061 return NULL; 1062 1063 rc = RegCreateKeyEx(hKey, subKey, res, NULL, (DWORD)NULL, 1064 sam, NULL, &retKey, NULL); 1065 if (rc != ERROR_SUCCESS) 1066 return PyErr_SetFromWindowsErrWithFunction(rc, "CreateKeyEx"); 1067 return PyHKEY_FromHKEY(retKey); 1025 1068 } 1026 1069 … … 1028 1071 PyDeleteKey(PyObject *self, PyObject *args) 1029 1072 { 1030 HKEY hKey; 1031 PyObject *obKey; 1032 char *subKey; 1033 long rc; 1034 if (!PyArg_ParseTuple(args, "Os:DeleteKey", &obKey, &subKey)) 1035 return NULL; 1036 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1037 return NULL; 1038 rc = RegDeleteKey(hKey, subKey ); 1039 if (rc != ERROR_SUCCESS) 1040 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); 1041 Py_INCREF(Py_None); 1042 return Py_None; 1073 HKEY hKey; 1074 PyObject *obKey; 1075 char *subKey; 1076 long rc; 1077 if (!PyArg_ParseTuple(args, "Os:DeleteKey", &obKey, &subKey)) 1078 return NULL; 1079 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1080 return NULL; 1081 rc = RegDeleteKey(hKey, subKey ); 1082 if (rc != ERROR_SUCCESS) 1083 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKey"); 1084 Py_INCREF(Py_None); 1085 return Py_None; 1086 } 1087 1088 static PyObject * 1089 PyDeleteKeyEx(PyObject *self, PyObject *args) 1090 { 1091 HKEY hKey; 1092 PyObject *obKey; 1093 HMODULE hMod; 1094 typedef LONG (WINAPI *RDKEFunc)(HKEY, const char*, REGSAM, int); 1095 RDKEFunc pfn = NULL; 1096 char *subKey; 1097 long rc; 1098 int res = 0; 1099 REGSAM sam = KEY_WOW64_64KEY; 1100 1101 if (!PyArg_ParseTuple(args, "Os|ii:DeleteKeyEx", 1102 &obKey, &subKey, &sam, &res)) 1103 return NULL; 1104 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1105 return NULL; 1106 1107 /* Only available on 64bit platforms, so we must load it 1108 dynamically. */ 1109 hMod = GetModuleHandle("advapi32.dll"); 1110 if (hMod) 1111 pfn = (RDKEFunc)GetProcAddress(hMod, 1112 "RegDeleteKeyExA"); 1113 if (!pfn) { 1114 PyErr_SetString(PyExc_NotImplementedError, 1115 "not implemented on this platform"); 1116 return NULL; 1117 } 1118 Py_BEGIN_ALLOW_THREADS 1119 rc = (*pfn)(hKey, subKey, sam, res); 1120 Py_END_ALLOW_THREADS 1121 1122 if (rc != ERROR_SUCCESS) 1123 return PyErr_SetFromWindowsErrWithFunction(rc, "RegDeleteKeyEx"); 1124 Py_INCREF(Py_None); 1125 return Py_None; 1043 1126 } 1044 1127 … … 1046 1129 PyDeleteValue(PyObject *self, PyObject *args) 1047 1130 { 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1131 HKEY hKey; 1132 PyObject *obKey; 1133 char *subKey; 1134 long rc; 1135 if (!PyArg_ParseTuple(args, "Oz:DeleteValue", &obKey, &subKey)) 1136 return NULL; 1137 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1138 return NULL; 1139 Py_BEGIN_ALLOW_THREADS 1140 rc = RegDeleteValue(hKey, subKey); 1141 Py_END_ALLOW_THREADS 1142 if (rc !=ERROR_SUCCESS) 1143 return PyErr_SetFromWindowsErrWithFunction(rc, 1144 "RegDeleteValue"); 1145 Py_INCREF(Py_None); 1146 return Py_None; 1064 1147 } 1065 1148 … … 1067 1150 PyEnumKey(PyObject *self, PyObject *args) 1068 1151 { 1069 HKEY hKey; 1070 PyObject *obKey; 1071 int index; 1072 long rc; 1073 PyObject *retStr; 1074 char tmpbuf[256]; /* max key name length is 255 */ 1075 DWORD len = sizeof(tmpbuf); /* includes NULL terminator */ 1076 1077 if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) 1078 return NULL; 1079 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1080 return NULL; 1081 1082 Py_BEGIN_ALLOW_THREADS 1083 rc = RegEnumKeyEx(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL); 1084 Py_END_ALLOW_THREADS 1085 if (rc != ERROR_SUCCESS) 1086 return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx"); 1087 1088 retStr = PyString_FromStringAndSize(tmpbuf, len); 1089 return retStr; /* can be NULL */ 1152 HKEY hKey; 1153 PyObject *obKey; 1154 int index; 1155 long rc; 1156 PyObject *retStr; 1157 1158 /* The Windows docs claim that the max key name length is 255 1159 * characters, plus a terminating nul character. However, 1160 * empirical testing demonstrates that it is possible to 1161 * create a 256 character key that is missing the terminating 1162 * nul. RegEnumKeyEx requires a 257 character buffer to 1163 * retrieve such a key name. */ 1164 char tmpbuf[257]; 1165 DWORD len = sizeof(tmpbuf); /* includes NULL terminator */ 1166 1167 if (!PyArg_ParseTuple(args, "Oi:EnumKey", &obKey, &index)) 1168 return NULL; 1169 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1170 return NULL; 1171 1172 Py_BEGIN_ALLOW_THREADS 1173 rc = RegEnumKeyEx(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL); 1174 Py_END_ALLOW_THREADS 1175 if (rc != ERROR_SUCCESS) 1176 return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx"); 1177 1178 retStr = PyString_FromStringAndSize(tmpbuf, len); 1179 return retStr; /* can be NULL */ 1090 1180 } 1091 1181 … … 1093 1183 PyEnumValue(PyObject *self, PyObject *args) 1094 1184 { 1095 HKEY hKey; 1096 PyObject *obKey; 1097 int index; 1098 long rc; 1099 char *retValueBuf; 1100 char *retDataBuf; 1101 DWORD retValueSize; 1102 DWORD retDataSize; 1103 DWORD typ; 1104 PyObject *obData; 1105 PyObject *retVal; 1106 1107 if (!PyArg_ParseTuple(args, "Oi:EnumValue", &obKey, &index)) 1108 return NULL; 1109 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1110 return NULL; 1111 1112 if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, 1113 NULL, 1114 &retValueSize, &retDataSize, NULL, NULL)) 1115 != ERROR_SUCCESS) 1116 return PyErr_SetFromWindowsErrWithFunction(rc, 1117 "RegQueryInfoKey"); 1118 ++retValueSize; /* include null terminators */ 1119 ++retDataSize; 1120 retValueBuf = (char *)PyMem_Malloc(retValueSize); 1121 if (retValueBuf == NULL) 1122 return PyErr_NoMemory(); 1123 retDataBuf = (char *)PyMem_Malloc(retDataSize); 1124 if (retDataBuf == NULL) { 1125 PyMem_Free(retValueBuf); 1126 return PyErr_NoMemory(); 1127 } 1128 1129 Py_BEGIN_ALLOW_THREADS 1130 rc = RegEnumValue(hKey, 1131 index, 1132 retValueBuf, 1133 &retValueSize, 1134 NULL, 1135 &typ, 1136 (BYTE *)retDataBuf, 1137 &retDataSize); 1138 Py_END_ALLOW_THREADS 1139 1140 if (rc != ERROR_SUCCESS) { 1141 retVal = PyErr_SetFromWindowsErrWithFunction(rc, 1142 "PyRegEnumValue"); 1143 goto fail; 1144 } 1145 obData = Reg2Py(retDataBuf, retDataSize, typ); 1146 if (obData == NULL) { 1147 retVal = NULL; 1148 goto fail; 1149 } 1150 retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); 1151 Py_DECREF(obData); 1185 HKEY hKey; 1186 PyObject *obKey; 1187 int index; 1188 long rc; 1189 char *retValueBuf; 1190 char *retDataBuf; 1191 char *tmpBuf; 1192 DWORD retValueSize, bufValueSize; 1193 DWORD retDataSize, bufDataSize; 1194 DWORD typ; 1195 PyObject *obData; 1196 PyObject *retVal; 1197 1198 if (!PyArg_ParseTuple(args, "Oi:EnumValue", &obKey, &index)) 1199 return NULL; 1200 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1201 return NULL; 1202 1203 if ((rc = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, 1204 NULL, 1205 &retValueSize, &retDataSize, NULL, NULL)) 1206 != ERROR_SUCCESS) 1207 return PyErr_SetFromWindowsErrWithFunction(rc, 1208 "RegQueryInfoKey"); 1209 ++retValueSize; /* include null terminators */ 1210 ++retDataSize; 1211 bufDataSize = retDataSize; 1212 bufValueSize = retValueSize; 1213 retValueBuf = (char *)PyMem_Malloc(retValueSize); 1214 if (retValueBuf == NULL) 1215 return PyErr_NoMemory(); 1216 retDataBuf = (char *)PyMem_Malloc(retDataSize); 1217 if (retDataBuf == NULL) { 1218 PyMem_Free(retValueBuf); 1219 return PyErr_NoMemory(); 1220 } 1221 1222 while (1) { 1223 Py_BEGIN_ALLOW_THREADS 1224 rc = RegEnumValue(hKey, 1225 index, 1226 retValueBuf, 1227 &retValueSize, 1228 NULL, 1229 &typ, 1230 (BYTE *)retDataBuf, 1231 &retDataSize); 1232 Py_END_ALLOW_THREADS 1233 1234 if (rc != ERROR_MORE_DATA) 1235 break; 1236 1237 bufDataSize *= 2; 1238 tmpBuf = (char *)PyMem_Realloc(retDataBuf, bufDataSize); 1239 if (tmpBuf == NULL) { 1240 PyErr_NoMemory(); 1241 retVal = NULL; 1242 goto fail; 1243 } 1244 retDataBuf = tmpBuf; 1245 retDataSize = bufDataSize; 1246 retValueSize = bufValueSize; 1247 } 1248 1249 if (rc != ERROR_SUCCESS) { 1250 retVal = PyErr_SetFromWindowsErrWithFunction(rc, 1251 "PyRegEnumValue"); 1252 goto fail; 1253 } 1254 obData = Reg2Py(retDataBuf, retDataSize, typ); 1255 if (obData == NULL) { 1256 retVal = NULL; 1257 goto fail; 1258 } 1259 retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); 1260 Py_DECREF(obData); 1152 1261 fail: 1153 1154 1155 1262 PyMem_Free(retValueBuf); 1263 PyMem_Free(retDataBuf); 1264 return retVal; 1156 1265 } 1157 1266 … … 1159 1268 PyExpandEnvironmentStrings(PyObject *self, PyObject *args) 1160 1269 { 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1270 Py_UNICODE *retValue = NULL; 1271 Py_UNICODE *src; 1272 DWORD retValueSize; 1273 DWORD rc; 1274 PyObject *o; 1275 1276 if (!PyArg_ParseTuple(args, "u:ExpandEnvironmentStrings", &src)) 1277 return NULL; 1278 1279 retValueSize = ExpandEnvironmentStringsW(src, retValue, 0); 1280 if (retValueSize == 0) { 1281 return PyErr_SetFromWindowsErrWithFunction(retValueSize, 1282 "ExpandEnvironmentStrings"); 1283 } 1284 retValue = (Py_UNICODE *)PyMem_Malloc(retValueSize * sizeof(Py_UNICODE)); 1285 if (retValue == NULL) { 1286 return PyErr_NoMemory(); 1287 } 1288 1289 rc = ExpandEnvironmentStringsW(src, retValue, retValueSize); 1290 if (rc == 0) { 1291 PyMem_Free(retValue); 1292 return PyErr_SetFromWindowsErrWithFunction(retValueSize, 1293 "ExpandEnvironmentStrings"); 1294 } 1295 o = PyUnicode_FromUnicode(retValue, wcslen(retValue)); 1296 PyMem_Free(retValue); 1297 return o; 1189 1298 } 1190 1299 … … 1192 1301 PyFlushKey(PyObject *self, PyObject *args) 1193 1302 { 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1303 HKEY hKey; 1304 PyObject *obKey; 1305 long rc; 1306 if (!PyArg_ParseTuple(args, "O:FlushKey", &obKey)) 1307 return NULL; 1308 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1309 return NULL; 1310 Py_BEGIN_ALLOW_THREADS 1311 rc = RegFlushKey(hKey); 1312 Py_END_ALLOW_THREADS 1313 if (rc != ERROR_SUCCESS) 1314 return PyErr_SetFromWindowsErrWithFunction(rc, "RegFlushKey"); 1315 Py_INCREF(Py_None); 1316 return Py_None; 1208 1317 } 1209 1318 static PyObject * 1210 1319 PyLoadKey(PyObject *self, PyObject *args) 1211 1320 { 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1321 HKEY hKey; 1322 PyObject *obKey; 1323 char *subKey; 1324 char *fileName; 1325 1326 long rc; 1327 if (!PyArg_ParseTuple(args, "Oss:LoadKey", &obKey, &subKey, &fileName)) 1328 return NULL; 1329 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1330 return NULL; 1331 Py_BEGIN_ALLOW_THREADS 1332 rc = RegLoadKey(hKey, subKey, fileName ); 1333 Py_END_ALLOW_THREADS 1334 if (rc != ERROR_SUCCESS) 1335 return PyErr_SetFromWindowsErrWithFunction(rc, "RegLoadKey"); 1336 Py_INCREF(Py_None); 1337 return Py_None; 1229 1338 } 1230 1339 … … 1232 1341 PyOpenKey(PyObject *self, PyObject *args) 1233 1342 { 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1343 HKEY hKey; 1344 PyObject *obKey; 1345 1346 char *subKey; 1347 int res = 0; 1348 HKEY retKey; 1349 long rc; 1350 REGSAM sam = KEY_READ; 1351 if (!PyArg_ParseTuple(args, "Oz|ii:OpenKey", &obKey, &subKey, 1352 &res, &sam)) 1353 return NULL; 1354 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1355 return NULL; 1356 1357 Py_BEGIN_ALLOW_THREADS 1358 rc = RegOpenKeyEx(hKey, subKey, res, sam, &retKey); 1359 Py_END_ALLOW_THREADS 1360 if (rc != ERROR_SUCCESS) 1361 return PyErr_SetFromWindowsErrWithFunction(rc, "RegOpenKeyEx"); 1362 return PyHKEY_FromHKEY(retKey); 1254 1363 } 1255 1364 … … 1267 1376 PyObject *ret; 1268 1377 if (!PyArg_ParseTuple(args, "O:QueryInfoKey", &obKey)) 1269 1378 return NULL; 1270 1379 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1271 1380 return NULL; 1272 1381 if ((rc = RegQueryInfoKey(hKey, NULL, NULL, 0, &nSubKeys, NULL, NULL, 1273 1382 &nValues, NULL, NULL, NULL, &ft)) 1274 1383 != ERROR_SUCCESS) 1275 1384 return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); 1276 1385 li.LowPart = ft.dwLowDateTime; 1277 1386 li.HighPart = ft.dwHighDateTime; 1278 1387 l = PyLong_FromLongLong(li.QuadPart); 1279 1388 if (l == NULL) 1280 1389 return NULL; 1281 1390 ret = Py_BuildValue("iiO", nSubKeys, nValues, l); 1282 1391 Py_DECREF(l); … … 1287 1396 PyQueryValue(PyObject *self, PyObject *args) 1288 1397 { 1289 HKEY hKey; 1290 PyObject *obKey; 1291 char *subKey; 1292 long rc; 1293 PyObject *retStr; 1294 char *retBuf; 1295 long bufSize = 0; 1296 1297 if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) 1298 return NULL; 1299 1300 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1301 return NULL; 1302 if ((rc = RegQueryValue(hKey, subKey, NULL, &bufSize)) 1303 != ERROR_SUCCESS) 1304 return PyErr_SetFromWindowsErrWithFunction(rc, 1305 "RegQueryValue"); 1306 retStr = PyString_FromStringAndSize(NULL, bufSize); 1307 if (retStr == NULL) 1308 return NULL; 1309 retBuf = PyString_AS_STRING(retStr); 1310 if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) 1311 != ERROR_SUCCESS) { 1312 Py_DECREF(retStr); 1313 return PyErr_SetFromWindowsErrWithFunction(rc, 1314 "RegQueryValue"); 1315 } 1316 _PyString_Resize(&retStr, strlen(retBuf)); 1317 return retStr; 1398 HKEY hKey; 1399 PyObject *obKey; 1400 char *subKey; 1401 long rc; 1402 PyObject *retStr; 1403 char *retBuf; 1404 DWORD bufSize = 0; 1405 DWORD retSize = 0; 1406 char *tmp; 1407 1408 if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) 1409 return NULL; 1410 1411 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1412 return NULL; 1413 1414 rc = RegQueryValue(hKey, subKey, NULL, &retSize); 1415 if (rc == ERROR_MORE_DATA) 1416 retSize = 256; 1417 else if (rc != ERROR_SUCCESS) 1418 return PyErr_SetFromWindowsErrWithFunction(rc, 1419 "RegQueryValue"); 1420 1421 bufSize = retSize; 1422 retBuf = (char *) PyMem_Malloc(bufSize); 1423 if (retBuf == NULL) 1424 return PyErr_NoMemory(); 1425 1426 while (1) { 1427 retSize = bufSize; 1428 rc = RegQueryValue(hKey, subKey, retBuf, &retSize); 1429 if (rc != ERROR_MORE_DATA) 1430 break; 1431 1432 bufSize *= 2; 1433 tmp = (char *) PyMem_Realloc(retBuf, bufSize); 1434 if (tmp == NULL) { 1435 PyMem_Free(retBuf); 1436 return PyErr_NoMemory(); 1437 } 1438 retBuf = tmp; 1439 } 1440 1441 if (rc != ERROR_SUCCESS) { 1442 PyMem_Free(retBuf); 1443 return PyErr_SetFromWindowsErrWithFunction(rc, 1444 "RegQueryValue"); 1445 } 1446 1447 if (retBuf[retSize-1] == '\x00') 1448 retSize--; 1449 retStr = PyString_FromStringAndSize(retBuf, retSize); 1450 if (retStr == NULL) { 1451 PyMem_Free(retBuf); 1452 return NULL; 1453 } 1454 return retStr; 1318 1455 } 1319 1456 … … 1321 1458 PyQueryValueEx(PyObject *self, PyObject *args) 1322 1459 { 1323 HKEY hKey; 1324 PyObject *obKey; 1325 char *valueName; 1326 1327 long rc; 1328 char *retBuf; 1329 DWORD bufSize = 0; 1330 DWORD typ; 1331 PyObject *obData; 1332 PyObject *result; 1333 1334 if (!PyArg_ParseTuple(args, "Oz:QueryValueEx", &obKey, &valueName)) 1335 return NULL; 1336 1337 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1338 return NULL; 1339 if ((rc = RegQueryValueEx(hKey, valueName, 1340 NULL, NULL, NULL, 1341 &bufSize)) 1342 != ERROR_SUCCESS) 1343 return PyErr_SetFromWindowsErrWithFunction(rc, 1344 "RegQueryValueEx"); 1345 retBuf = (char *)PyMem_Malloc(bufSize); 1346 if (retBuf == NULL) 1347 return PyErr_NoMemory(); 1348 if ((rc = RegQueryValueEx(hKey, valueName, NULL, 1349 &typ, (BYTE *)retBuf, &bufSize)) 1350 != ERROR_SUCCESS) { 1351 PyMem_Free(retBuf); 1352 return PyErr_SetFromWindowsErrWithFunction(rc, 1353 "RegQueryValueEx"); 1354 } 1355 obData = Reg2Py(retBuf, bufSize, typ); 1356 PyMem_Free((void *)retBuf); 1357 if (obData == NULL) 1358 return NULL; 1359 result = Py_BuildValue("Oi", obData, typ); 1360 Py_DECREF(obData); 1361 return result; 1460 HKEY hKey; 1461 PyObject *obKey; 1462 char *valueName; 1463 1464 long rc; 1465 char *retBuf, *tmp; 1466 DWORD bufSize = 0, retSize; 1467 DWORD typ; 1468 PyObject *obData; 1469 PyObject *result; 1470 1471 if (!PyArg_ParseTuple(args, "Oz:QueryValueEx", &obKey, &valueName)) 1472 return NULL; 1473 1474 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1475 return NULL; 1476 1477 rc = RegQueryValueEx(hKey, valueName, NULL, NULL, NULL, &bufSize); 1478 if (rc == ERROR_MORE_DATA) 1479 bufSize = 256; 1480 else if (rc != ERROR_SUCCESS) 1481 return PyErr_SetFromWindowsErrWithFunction(rc, 1482 "RegQueryValueEx"); 1483 retBuf = (char *)PyMem_Malloc(bufSize); 1484 if (retBuf == NULL) 1485 return PyErr_NoMemory(); 1486 1487 while (1) { 1488 retSize = bufSize; 1489 rc = RegQueryValueEx(hKey, valueName, NULL, &typ, 1490 (BYTE *)retBuf, &retSize); 1491 if (rc != ERROR_MORE_DATA) 1492 break; 1493 1494 bufSize *= 2; 1495 tmp = (char *) PyMem_Realloc(retBuf, bufSize); 1496 if (tmp == NULL) { 1497 PyMem_Free(retBuf); 1498 return PyErr_NoMemory(); 1499 } 1500 retBuf = tmp; 1501 } 1502 1503 if (rc != ERROR_SUCCESS) { 1504 PyMem_Free(retBuf); 1505 return PyErr_SetFromWindowsErrWithFunction(rc, 1506 "RegQueryValueEx"); 1507 } 1508 obData = Reg2Py(retBuf, bufSize, typ); 1509 PyMem_Free((void *)retBuf); 1510 if (obData == NULL) 1511 return NULL; 1512 result = Py_BuildValue("Oi", obData, typ); 1513 Py_DECREF(obData); 1514 return result; 1362 1515 } 1363 1516 … … 1366 1519 PySaveKey(PyObject *self, PyObject *args) 1367 1520 { 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1521 HKEY hKey; 1522 PyObject *obKey; 1523 char *fileName; 1524 LPSECURITY_ATTRIBUTES pSA = NULL; 1525 1526 long rc; 1527 if (!PyArg_ParseTuple(args, "Os:SaveKey", &obKey, &fileName)) 1528 return NULL; 1529 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1530 return NULL; 1378 1531 /* One day we may get security into the core? 1379 1380 1532 if (!PyWinObject_AsSECURITY_ATTRIBUTES(obSA, &pSA, TRUE)) 1533 return NULL; 1381 1534 */ 1382 1383 1384 1385 1386 1387 1388 1535 Py_BEGIN_ALLOW_THREADS 1536 rc = RegSaveKey(hKey, fileName, pSA ); 1537 Py_END_ALLOW_THREADS 1538 if (rc != ERROR_SUCCESS) 1539 return PyErr_SetFromWindowsErrWithFunction(rc, "RegSaveKey"); 1540 Py_INCREF(Py_None); 1541 return Py_None; 1389 1542 } 1390 1543 … … 1392 1545 PySetValue(PyObject *self, PyObject *args) 1393 1546 { 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1547 HKEY hKey; 1548 PyObject *obKey; 1549 char *subKey; 1550 char *str; 1551 DWORD typ; 1552 DWORD len; 1553 long rc; 1554 PyObject *obStrVal; 1555 PyObject *obSubKey; 1556 if (!PyArg_ParseTuple(args, "OOiO:SetValue", 1557 &obKey, 1558 &obSubKey, 1559 &typ, 1560 &obStrVal)) 1561 return NULL; 1562 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1563 return NULL; 1564 if (typ != REG_SZ) { 1565 PyErr_SetString(PyExc_TypeError, 1566 "Type must be _winreg.REG_SZ"); 1567 return NULL; 1568 } 1569 /* XXX - need Unicode support */ 1570 str = PyString_AsString(obStrVal); 1571 if (str == NULL) 1572 return NULL; 1573 len = PyString_Size(obStrVal); 1574 if (obSubKey == Py_None) 1575 subKey = NULL; 1576 else { 1577 subKey = PyString_AsString(obSubKey); 1578 if (subKey == NULL) 1579 return NULL; 1580 } 1581 Py_BEGIN_ALLOW_THREADS 1582 rc = RegSetValue(hKey, subKey, REG_SZ, str, len+1); 1583 Py_END_ALLOW_THREADS 1584 if (rc != ERROR_SUCCESS) 1585 return PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValue"); 1586 Py_INCREF(Py_None); 1587 return Py_None; 1435 1588 } 1436 1589 … … 1438 1591 PySetValueEx(PyObject *self, PyObject *args) 1439 1592 { 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1593 HKEY hKey; 1594 PyObject *obKey; 1595 char *valueName; 1596 PyObject *obRes; 1597 PyObject *value; 1598 BYTE *data; 1599 DWORD len; 1600 DWORD typ; 1601 1602 LONG rc; 1603 1604 if (!PyArg_ParseTuple(args, "OzOiO:SetValueEx", 1605 &obKey, 1606 &valueName, 1607 &obRes, 1608 &typ, 1609 &value)) 1610 return NULL; 1611 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1612 return NULL; 1613 if (!Py2Reg(value, typ, &data, &len)) 1614 { 1615 if (!PyErr_Occurred()) 1616 PyErr_SetString(PyExc_ValueError, 1617 "Could not convert the data to the specified type."); 1618 return NULL; 1619 } 1620 Py_BEGIN_ALLOW_THREADS 1621 rc = RegSetValueEx(hKey, valueName, 0, typ, data, len); 1622 Py_END_ALLOW_THREADS 1623 PyMem_DEL(data); 1624 if (rc != ERROR_SUCCESS) 1625 return PyErr_SetFromWindowsErrWithFunction(rc, 1626 "RegSetValueEx"); 1627 Py_INCREF(Py_None); 1628 return Py_None; 1476 1629 } 1477 1630 … … 1479 1632 PyDisableReflectionKey(PyObject *self, PyObject *args) 1480 1633 { 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 //Only available on 64bit platforms, so we must load it1494 // dynamically. 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1634 HKEY hKey; 1635 PyObject *obKey; 1636 HMODULE hMod; 1637 typedef LONG (WINAPI *RDRKFunc)(HKEY); 1638 RDRKFunc pfn = NULL; 1639 LONG rc; 1640 1641 if (!PyArg_ParseTuple(args, "O:DisableReflectionKey", &obKey)) 1642 return NULL; 1643 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1644 return NULL; 1645 1646 /* Only available on 64bit platforms, so we must load it 1647 dynamically. */ 1648 hMod = GetModuleHandle("advapi32.dll"); 1649 if (hMod) 1650 pfn = (RDRKFunc)GetProcAddress(hMod, 1651 "RegDisableReflectionKey"); 1652 if (!pfn) { 1653 PyErr_SetString(PyExc_NotImplementedError, 1654 "not implemented on this platform"); 1655 return NULL; 1656 } 1657 Py_BEGIN_ALLOW_THREADS 1658 rc = (*pfn)(hKey); 1659 Py_END_ALLOW_THREADS 1660 if (rc != ERROR_SUCCESS) 1661 return PyErr_SetFromWindowsErrWithFunction(rc, 1662 "RegDisableReflectionKey"); 1663 Py_INCREF(Py_None); 1664 return Py_None; 1512 1665 } 1513 1666 … … 1515 1668 PyEnableReflectionKey(PyObject *self, PyObject *args) 1516 1669 { 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 //Only available on 64bit platforms, so we must load it1530 // dynamically. 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1670 HKEY hKey; 1671 PyObject *obKey; 1672 HMODULE hMod; 1673 typedef LONG (WINAPI *RERKFunc)(HKEY); 1674 RERKFunc pfn = NULL; 1675 LONG rc; 1676 1677 if (!PyArg_ParseTuple(args, "O:EnableReflectionKey", &obKey)) 1678 return NULL; 1679 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1680 return NULL; 1681 1682 /* Only available on 64bit platforms, so we must load it 1683 dynamically. */ 1684 hMod = GetModuleHandle("advapi32.dll"); 1685 if (hMod) 1686 pfn = (RERKFunc)GetProcAddress(hMod, 1687 "RegEnableReflectionKey"); 1688 if (!pfn) { 1689 PyErr_SetString(PyExc_NotImplementedError, 1690 "not implemented on this platform"); 1691 return NULL; 1692 } 1693 Py_BEGIN_ALLOW_THREADS 1694 rc = (*pfn)(hKey); 1695 Py_END_ALLOW_THREADS 1696 if (rc != ERROR_SUCCESS) 1697 return PyErr_SetFromWindowsErrWithFunction(rc, 1698 "RegEnableReflectionKey"); 1699 Py_INCREF(Py_None); 1700 return Py_None; 1548 1701 } 1549 1702 … … 1551 1704 PyQueryReflectionKey(PyObject *self, PyObject *args) 1552 1705 { 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 //Only available on 64bit platforms, so we must load it1567 // dynamically. 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 return PyBool_FromLong(rc);1706 HKEY hKey; 1707 PyObject *obKey; 1708 HMODULE hMod; 1709 typedef LONG (WINAPI *RQRKFunc)(HKEY, BOOL *); 1710 RQRKFunc pfn = NULL; 1711 BOOL result; 1712 LONG rc; 1713 1714 if (!PyArg_ParseTuple(args, "O:QueryReflectionKey", &obKey)) 1715 return NULL; 1716 if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE)) 1717 return NULL; 1718 1719 /* Only available on 64bit platforms, so we must load it 1720 dynamically. */ 1721 hMod = GetModuleHandle("advapi32.dll"); 1722 if (hMod) 1723 pfn = (RQRKFunc)GetProcAddress(hMod, 1724 "RegQueryReflectionKey"); 1725 if (!pfn) { 1726 PyErr_SetString(PyExc_NotImplementedError, 1727 "not implemented on this platform"); 1728 return NULL; 1729 } 1730 Py_BEGIN_ALLOW_THREADS 1731 rc = (*pfn)(hKey, &result); 1732 Py_END_ALLOW_THREADS 1733 if (rc != ERROR_SUCCESS) 1734 return PyErr_SetFromWindowsErrWithFunction(rc, 1735 "RegQueryReflectionKey"); 1736 return PyBool_FromLong(result); 1584 1737 } 1585 1738 1586 1739 static struct PyMethodDef winreg_methods[] = { 1587 {"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc}, 1588 {"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc}, 1589 {"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc}, 1590 {"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc}, 1591 {"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc}, 1592 {"DisableReflectionKey", PyDisableReflectionKey, METH_VARARGS, DisableReflectionKey_doc}, 1593 {"EnableReflectionKey", PyEnableReflectionKey, METH_VARARGS, EnableReflectionKey_doc}, 1594 {"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc}, 1595 {"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc}, 1596 {"ExpandEnvironmentStrings", PyExpandEnvironmentStrings, METH_VARARGS, 1597 ExpandEnvironmentStrings_doc }, 1598 {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, 1599 {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, 1600 {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, 1601 {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, 1602 {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, 1603 {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, 1604 {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc}, 1605 {"QueryReflectionKey",PyQueryReflectionKey,METH_VARARGS, QueryReflectionKey_doc}, 1606 {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, 1607 {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, 1608 {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, 1609 NULL, 1740 {"CloseKey", PyCloseKey, METH_VARARGS, CloseKey_doc}, 1741 {"ConnectRegistry", PyConnectRegistry, METH_VARARGS, ConnectRegistry_doc}, 1742 {"CreateKey", PyCreateKey, METH_VARARGS, CreateKey_doc}, 1743 {"CreateKeyEx", PyCreateKeyEx, METH_VARARGS, CreateKeyEx_doc}, 1744 {"DeleteKey", PyDeleteKey, METH_VARARGS, DeleteKey_doc}, 1745 {"DeleteKeyEx", PyDeleteKeyEx, METH_VARARGS, DeleteKeyEx_doc}, 1746 {"DeleteValue", PyDeleteValue, METH_VARARGS, DeleteValue_doc}, 1747 {"DisableReflectionKey", PyDisableReflectionKey, METH_VARARGS, DisableReflectionKey_doc}, 1748 {"EnableReflectionKey", PyEnableReflectionKey, METH_VARARGS, EnableReflectionKey_doc}, 1749 {"EnumKey", PyEnumKey, METH_VARARGS, EnumKey_doc}, 1750 {"EnumValue", PyEnumValue, METH_VARARGS, EnumValue_doc}, 1751 {"ExpandEnvironmentStrings", PyExpandEnvironmentStrings, METH_VARARGS, 1752 ExpandEnvironmentStrings_doc }, 1753 {"FlushKey", PyFlushKey, METH_VARARGS, FlushKey_doc}, 1754 {"LoadKey", PyLoadKey, METH_VARARGS, LoadKey_doc}, 1755 {"OpenKey", PyOpenKey, METH_VARARGS, OpenKey_doc}, 1756 {"OpenKeyEx", PyOpenKey, METH_VARARGS, OpenKeyEx_doc}, 1757 {"QueryValue", PyQueryValue, METH_VARARGS, QueryValue_doc}, 1758 {"QueryValueEx", PyQueryValueEx, METH_VARARGS, QueryValueEx_doc}, 1759 {"QueryInfoKey", PyQueryInfoKey, METH_VARARGS, QueryInfoKey_doc}, 1760 {"QueryReflectionKey",PyQueryReflectionKey,METH_VARARGS, QueryReflectionKey_doc}, 1761 {"SaveKey", PySaveKey, METH_VARARGS, SaveKey_doc}, 1762 {"SetValue", PySetValue, METH_VARARGS, SetValue_doc}, 1763 {"SetValueEx", PySetValueEx, METH_VARARGS, SetValueEx_doc}, 1764 NULL, 1610 1765 }; 1611 1766 … … 1613 1768 insint(PyObject * d, char * name, long value) 1614 1769 { 1615 1616 1617 1618 1770 PyObject *v = PyInt_FromLong(value); 1771 if (!v || PyDict_SetItemString(d, name, v)) 1772 PyErr_Clear(); 1773 Py_XDECREF(v); 1619 1774 } 1620 1775 … … 1624 1779 inskey(PyObject * d, char * name, HKEY key) 1625 1780 { 1626 1627 1628 1629 1781 PyObject *v = PyLong_FromVoidPtr(key); 1782 if (!v || PyDict_SetItemString(d, name, v)) 1783 PyErr_Clear(); 1784 Py_XDECREF(v); 1630 1785 } 1631 1786 … … 1634 1789 PyMODINIT_FUNC init_winreg(void) 1635 1790 { 1636 PyObject *m, *d; 1637 m = Py_InitModule3("_winreg", winreg_methods, module_doc); 1638 if (m == NULL) 1639 return; 1640 d = PyModule_GetDict(m); 1641 PyHKEY_Type.ob_type = &PyType_Type; 1642 PyHKEY_Type.tp_doc = PyHKEY_doc; 1643 Py_INCREF(&PyHKEY_Type); 1644 if (PyDict_SetItemString(d, "HKEYType", 1645 (PyObject *)&PyHKEY_Type) != 0) 1646 return; 1647 Py_INCREF(PyExc_WindowsError); 1648 if (PyDict_SetItemString(d, "error", 1649 PyExc_WindowsError) != 0) 1650 return; 1651 1652 /* Add the relevant constants */ 1653 ADD_KEY(HKEY_CLASSES_ROOT); 1654 ADD_KEY(HKEY_CURRENT_USER); 1655 ADD_KEY(HKEY_LOCAL_MACHINE); 1656 ADD_KEY(HKEY_USERS); 1657 ADD_KEY(HKEY_PERFORMANCE_DATA); 1791 PyObject *m, *d; 1792 m = Py_InitModule3("_winreg", winreg_methods, module_doc); 1793 if (m == NULL) 1794 return; 1795 d = PyModule_GetDict(m); 1796 if (PyType_Ready(&PyHKEY_Type) < 0) 1797 return; 1798 PyHKEY_Type.tp_doc = PyHKEY_doc; 1799 Py_INCREF(&PyHKEY_Type); 1800 if (PyDict_SetItemString(d, "HKEYType", 1801 (PyObject *)&PyHKEY_Type) != 0) 1802 return; 1803 Py_INCREF(PyExc_WindowsError); 1804 if (PyDict_SetItemString(d, "error", 1805 PyExc_WindowsError) != 0) 1806 return; 1807 1808 /* Add the relevant constants */ 1809 ADD_KEY(HKEY_CLASSES_ROOT); 1810 ADD_KEY(HKEY_CURRENT_USER); 1811 ADD_KEY(HKEY_LOCAL_MACHINE); 1812 ADD_KEY(HKEY_USERS); 1813 ADD_KEY(HKEY_PERFORMANCE_DATA); 1658 1814 #ifdef HKEY_CURRENT_CONFIG 1659 1815 ADD_KEY(HKEY_CURRENT_CONFIG); 1660 1816 #endif 1661 1817 #ifdef HKEY_DYN_DATA 1662 1818 ADD_KEY(HKEY_DYN_DATA); 1663 1819 #endif 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1820 ADD_INT(KEY_QUERY_VALUE); 1821 ADD_INT(KEY_SET_VALUE); 1822 ADD_INT(KEY_CREATE_SUB_KEY); 1823 ADD_INT(KEY_ENUMERATE_SUB_KEYS); 1824 ADD_INT(KEY_NOTIFY); 1825 ADD_INT(KEY_CREATE_LINK); 1826 ADD_INT(KEY_READ); 1827 ADD_INT(KEY_WRITE); 1828 ADD_INT(KEY_EXECUTE); 1829 ADD_INT(KEY_ALL_ACCESS); 1674 1830 #ifdef KEY_WOW64_64KEY 1675 1831 ADD_INT(KEY_WOW64_64KEY); 1676 1832 #endif 1677 1833 #ifdef KEY_WOW64_32KEY 1678 1834 ADD_INT(KEY_WOW64_32KEY); 1679 1835 #endif 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 } 1710 1836 ADD_INT(REG_OPTION_RESERVED); 1837 ADD_INT(REG_OPTION_NON_VOLATILE); 1838 ADD_INT(REG_OPTION_VOLATILE); 1839 ADD_INT(REG_OPTION_CREATE_LINK); 1840 ADD_INT(REG_OPTION_BACKUP_RESTORE); 1841 ADD_INT(REG_OPTION_OPEN_LINK); 1842 ADD_INT(REG_LEGAL_OPTION); 1843 ADD_INT(REG_CREATED_NEW_KEY); 1844 ADD_INT(REG_OPENED_EXISTING_KEY); 1845 ADD_INT(REG_WHOLE_HIVE_VOLATILE); 1846 ADD_INT(REG_REFRESH_HIVE); 1847 ADD_INT(REG_NO_LAZY_FLUSH); 1848 ADD_INT(REG_NOTIFY_CHANGE_NAME); 1849 ADD_INT(REG_NOTIFY_CHANGE_ATTRIBUTES); 1850 ADD_INT(REG_NOTIFY_CHANGE_LAST_SET); 1851 ADD_INT(REG_NOTIFY_CHANGE_SECURITY); 1852 ADD_INT(REG_LEGAL_CHANGE_FILTER); 1853 ADD_INT(REG_NONE); 1854 ADD_INT(REG_SZ); 1855 ADD_INT(REG_EXPAND_SZ); 1856 ADD_INT(REG_BINARY); 1857 ADD_INT(REG_DWORD); 1858 ADD_INT(REG_DWORD_LITTLE_ENDIAN); 1859 ADD_INT(REG_DWORD_BIG_ENDIAN); 1860 ADD_INT(REG_LINK); 1861 ADD_INT(REG_MULTI_SZ); 1862 ADD_INT(REG_RESOURCE_LIST); 1863 ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR); 1864 ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST); 1865 } 1866 -
python/vendor/current/PC/bdist_wininst/archive.h
r2 r388 15 15 16 16 struct eof_cdir { 17 long tag;/* must be 0x06054b50 */18 19 20 21 22 23 24 17 long tag; /* must be 0x06054b50 */ 18 short disknum; 19 short firstdisk; 20 short nTotalCDirThis; 21 short nTotalCDir; 22 long nBytesCDir; 23 long ofsCDir; 24 short commentlen; 25 25 }; 26 26 27 27 struct cdir { 28 long tag;/* must be 0x02014b50 */29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 28 long tag; /* must be 0x02014b50 */ 29 short version_made; 30 short version_extract; 31 short gp_bitflag; 32 short comp_method; 33 short last_mod_file_time; 34 short last_mod_file_date; 35 long crc32; 36 long comp_size; 37 long uncomp_size; 38 short fname_length; 39 short extra_length; 40 short comment_length; 41 short disknum_start; 42 short int_file_attr; 43 long ext_file_attr; 44 long ofs_local_header; 45 45 }; 46 46 47 47 struct fhdr { 48 long tag;/* must be 0x04034b50 */49 50 51 52 53 54 55 56 57 58 48 long tag; /* must be 0x04034b50 */ 49 short version_needed; 50 short flags; 51 short method; 52 short last_mod_file_time; 53 short last_mod_file_date; 54 long crc32; 55 long comp_size; 56 long uncomp_size; 57 short fname_length; 58 short extra_length; 59 59 }; 60 60 61 61 62 62 struct meta_data_hdr { 63 64 65 63 int tag; 64 int uncomp_size; 65 int bitmap_size; 66 66 }; 67 67 … … 71 71 72 72 typedef struct tagSCHEME { 73 74 73 char *name; 74 char *prefix; 75 75 } SCHEME; 76 76 … … 79 79 extern BOOL 80 80 extract_file(char *dst, char *src, int method, int comp_size, 81 81 int uncomp_size, NOTIFYPROC notify); 82 82 83 83 extern BOOL 84 84 unzip_archive(SCHEME *scheme, char *dirname, char *data, 85 85 DWORD size, NOTIFYPROC notify); 86 86 87 87 extern char * 88 88 map_new_file(DWORD flags, char *filename, char 89 90 91 89 *pathname_part, int size, 90 WORD wFatDate, WORD wFatTime, 91 NOTIFYPROC callback); 92 92 93 93 extern BOOL 94 94 ensure_directory (char *pathname, char *new_part, 95 95 NOTIFYPROC callback); 96 96 97 97 /* codes for NOITIFYPROC */ -
python/vendor/current/PC/bdist_wininst/extract.c
r2 r388 20 20 static void normpath(char *path) 21 21 { 22 23 24 25 26 22 while (path && *path) { 23 if (*path == '/') 24 *path = '\\'; 25 ++path; 26 } 27 27 } 28 28 29 29 BOOL ensure_directory(char *pathname, char *new_part, NOTIFYPROC notify) 30 30 { 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 } 56 57 /* XXX Should better explicit ely specify31 while (new_part && *new_part && (new_part = strchr(new_part, '\\'))) { 32 DWORD attr; 33 *new_part = '\0'; 34 attr = GetFileAttributes(pathname); 35 if (attr == -1) { 36 /* nothing found */ 37 if (!CreateDirectory(pathname, NULL) && notify) 38 notify(SYSTEM_ERROR, 39 "CreateDirectory (%s)", pathname); 40 else 41 notify(DIR_CREATED, pathname); 42 } 43 if (attr & FILE_ATTRIBUTE_DIRECTORY) { 44 ; 45 } else { 46 SetLastError(183); 47 if (notify) 48 notify(SYSTEM_ERROR, 49 "CreateDirectory (%s)", pathname); 50 } 51 *new_part = '\\'; 52 ++new_part; 53 } 54 return TRUE; 55 } 56 57 /* XXX Should better explicitly specify 58 58 * uncomp_size and file_times instead of pfhdr! 59 59 */ 60 60 char *map_new_file(DWORD flags, char *filename, 61 62 63 64 { 65 66 67 61 char *pathname_part, int size, 62 WORD wFatDate, WORD wFatTime, 63 NOTIFYPROC notify) 64 { 65 HANDLE hFile, hFileMapping; 66 char *dst; 67 FILETIME ft; 68 68 69 69 try_again: 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 70 if (!flags) 71 flags = CREATE_NEW; 72 hFile = CreateFile(filename, 73 GENERIC_WRITE | GENERIC_READ, 74 0, NULL, 75 flags, 76 FILE_ATTRIBUTE_NORMAL, NULL); 77 if (hFile == INVALID_HANDLE_VALUE) { 78 DWORD x = GetLastError(); 79 switch (x) { 80 case ERROR_FILE_EXISTS: 81 if (notify && notify(CAN_OVERWRITE, filename)) 82 hFile = CreateFile(filename, 83 GENERIC_WRITE|GENERIC_READ, 84 0, NULL, 85 CREATE_ALWAYS, 86 FILE_ATTRIBUTE_NORMAL, 87 NULL); 88 else { 89 if (notify) 90 notify(FILE_OVERWRITTEN, filename); 91 return NULL; 92 } 93 break; 94 case ERROR_PATH_NOT_FOUND: 95 if (ensure_directory(filename, pathname_part, notify)) 96 goto try_again; 97 else 98 return FALSE; 99 break; 100 default: 101 SetLastError(x); 102 break; 103 } 104 } 105 if (hFile == INVALID_HANDLE_VALUE) { 106 if (notify) 107 notify (SYSTEM_ERROR, "CreateFile (%s)", filename); 108 return NULL; 109 } 110 111 if (notify) 112 notify(FILE_CREATED, filename); 113 114 DosDateTimeToFileTime(wFatDate, wFatTime, &ft); 115 SetFileTime(hFile, &ft, &ft, &ft); 116 117 118 if (size == 0) { 119 /* We cannot map a zero-length file (Also it makes 120 no sense */ 121 CloseHandle(hFile); 122 return NULL; 123 } 124 125 hFileMapping = CreateFileMapping(hFile, 126 NULL, PAGE_READWRITE, 0, size, NULL); 127 128 CloseHandle(hFile); 129 130 if (hFileMapping == INVALID_HANDLE_VALUE) { 131 if (notify) 132 notify(SYSTEM_ERROR, 133 "CreateFileMapping (%s)", filename); 134 return NULL; 135 } 136 137 dst = MapViewOfFile(hFileMapping, 138 FILE_MAP_WRITE, 0, 0, 0); 139 140 CloseHandle(hFileMapping); 141 142 if (!dst) { 143 if (notify) 144 notify(SYSTEM_ERROR, "MapViewOfFile (%s)", filename); 145 return NULL; 146 } 147 return dst; 148 148 } 149 149 … … 151 151 BOOL 152 152 extract_file(char *dst, char *src, int method, int comp_size, 153 154 { 155 156 157 158 159 160 161 162 163 164 153 int uncomp_size, NOTIFYPROC notify) 154 { 155 z_stream zstream; 156 int result; 157 158 if (method == Z_DEFLATED) { 159 int x; 160 memset(&zstream, 0, sizeof(zstream)); 161 zstream.next_in = src; 162 zstream.avail_in = comp_size+1; 163 zstream.next_out = dst; 164 zstream.avail_out = uncomp_size; 165 165 166 166 /* Apparently an undocumented feature of zlib: Set windowsize 167 to negative values to sup ress the gzip header and be compatible with167 to negative values to suppress the gzip header and be compatible with 168 168 zip! */ 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 169 result = TRUE; 170 if (Z_OK != (x = inflateInit2(&zstream, -15))) { 171 if (notify) 172 notify(ZLIB_ERROR, 173 "inflateInit2 returns %d", x); 174 result = FALSE; 175 goto cleanup; 176 } 177 if (Z_STREAM_END != (x = inflate(&zstream, Z_FINISH))) { 178 if (notify) 179 notify(ZLIB_ERROR, 180 "inflate returns %d", x); 181 result = FALSE; 182 } 183 cleanup: 184 if (Z_OK != (x = inflateEnd(&zstream))) { 185 if (notify) 186 notify (ZLIB_ERROR, 187 "inflateEnd returns %d", x); 188 result = FALSE; 189 } 190 } else if (method == 0) { 191 memcpy(dst, src, uncomp_size); 192 result = TRUE; 193 } else 194 result = FALSE; 195 UnmapViewOfFile(dst); 196 return result; 197 197 } 198 198 … … 202 202 BOOL 203 203 unzip_archive(SCHEME *scheme, char *dirname, char *data, DWORD size, 204 205 { 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 } 204 NOTIFYPROC notify) 205 { 206 int n; 207 char pathname[MAX_PATH]; 208 char *new_part; 209 210 /* read the end of central directory record */ 211 struct eof_cdir *pe = (struct eof_cdir *)&data[size - sizeof 212 (struct eof_cdir)]; 213 214 int arc_start = size - sizeof (struct eof_cdir) - pe->nBytesCDir - 215 pe->ofsCDir; 216 217 /* set position to start of central directory */ 218 int pos = arc_start + pe->ofsCDir; 219 220 /* make sure this is a zip file */ 221 if (pe->tag != 0x06054b50) 222 return FALSE; 223 224 /* Loop through the central directory, reading all entries */ 225 for (n = 0; n < pe->nTotalCDir; ++n) { 226 int i; 227 char *fname; 228 char *pcomp; 229 char *dst; 230 struct cdir *pcdir; 231 struct fhdr *pfhdr; 232 233 pcdir = (struct cdir *)&data[pos]; 234 pfhdr = (struct fhdr *)&data[pcdir->ofs_local_header + 235 arc_start]; 236 237 if (pcdir->tag != 0x02014b50) 238 return FALSE; 239 if (pfhdr->tag != 0x04034b50) 240 return FALSE; 241 pos += sizeof(struct cdir); 242 fname = (char *)&data[pos]; /* This is not null terminated! */ 243 pos += pcdir->fname_length + pcdir->extra_length + 244 pcdir->comment_length; 245 246 pcomp = &data[pcdir->ofs_local_header 247 + sizeof(struct fhdr) 248 + arc_start 249 + pfhdr->fname_length 250 + pfhdr->extra_length]; 251 252 /* dirname is the Python home directory (prefix) */ 253 strcpy(pathname, dirname); 254 if (pathname[strlen(pathname)-1] != '\\') 255 strcat(pathname, "\\"); 256 new_part = &pathname[lstrlen(pathname)]; 257 /* we must now match the first part of the pathname 258 * in the archive to a component in the installation 259 * scheme (PURELIB, PLATLIB, HEADERS, SCRIPTS, or DATA) 260 * and replace this part by the one in the scheme to use 261 */ 262 for (i = 0; scheme[i].name; ++i) { 263 if (0 == strnicmp(scheme[i].name, fname, 264 strlen(scheme[i].name))) { 265 char *rest; 266 int len; 267 268 /* length of the replaced part */ 269 int namelen = strlen(scheme[i].name); 270 271 strcat(pathname, scheme[i].prefix); 272 273 rest = fname + namelen; 274 len = pfhdr->fname_length - namelen; 275 276 if ((pathname[strlen(pathname)-1] != '\\') 277 && (pathname[strlen(pathname)-1] != '/')) 278 strcat(pathname, "\\"); 279 /* Now that pathname ends with a separator, 280 * we must make sure rest does not start with 281 * an additional one. 282 */ 283 if ((rest[0] == '\\') || (rest[0] == '/')) { 284 ++rest; 285 --len; 286 } 287 288 strncat(pathname, rest, len); 289 goto Done; 290 } 291 } 292 /* no prefix to replace found, go unchanged */ 293 strncat(pathname, fname, pfhdr->fname_length); 294 Done: 295 normpath(pathname); 296 if (pathname[strlen(pathname)-1] != '\\') { 297 /* 298 * The local file header (pfhdr) does not always 299 * contain the compressed and uncompressed sizes of 300 * the data depending on bit 3 of the flags field. So 301 * it seems better to use the data from the central 302 * directory (pcdir). 303 */ 304 dst = map_new_file(0, pathname, new_part, 305 pcdir->uncomp_size, 306 pcdir->last_mod_file_date, 307 pcdir->last_mod_file_time, notify); 308 if (dst) { 309 if (!extract_file(dst, pcomp, pfhdr->method, 310 pcdir->comp_size, 311 pcdir->uncomp_size, 312 notify)) 313 return FALSE; 314 } /* else ??? */ 315 } 316 if (notify) 317 notify(NUM_FILES, new_part, (int)pe->nTotalCDir, 318 (int)n+1); 319 } 320 return TRUE; 321 } -
python/vendor/current/PC/bdist_wininst/install.c
r2 r388 11 11 * Written by Thomas Heller, May 2000 12 12 * 13 * $Id : install.c 69095 2009-01-29 12:31:51Z mark.hammond$13 * $Id$ 14 14 */ 15 15 … … 21 21 * At runtime, the exefile has appended: 22 22 * - compressed setup-data in ini-format, containing the following sections: 23 * 24 * 25 * 26 * 27 * 28 * 29 * 30 * 23 * [metadata] 24 * author=Greg Ward 25 * author_email=gward@python.net 26 * description=Python Distribution Utilities 27 * licence=Python 28 * name=Distutils 29 * url=http://www.python.org/sigs/distutils-sig/ 30 * version=0.9pre 31 31 * 32 * 33 * 34 * 35 * 36 * 37 * 32 * [Setup] 33 * info= text to be displayed in the edit-box 34 * title= to be displayed by this program 35 * target_version = if present, python version required 36 * pyc_compile = if 0, do not compile py to pyc 37 * pyo_compile = if 0, do not compile py to pyo 38 38 * 39 39 * - a struct meta_data_hdr, describing the above … … 63 63 * 64 64 * Finish the code so that we can use other python installations 65 * additional y to those found in the registry,65 * additionally to those found in the registry, 66 66 * and then #define USE_OTHER_PYTHON_VERSIONS 67 67 * … … 119 119 HWND hDialog; 120 120 121 char *ini_file; 121 char *ini_file; /* Full pathname of ini-file */ 122 122 /* From ini-file */ 123 char info[4096]; 124 char title[80]; 125 126 char target_version[10]; 127 128 char build_info[80]; 129 130 131 char meta_name[80]; 132 123 char info[4096]; /* [Setup] info= */ 124 char title[80]; /* [Setup] title=, contains package name 125 including version: "Distutils-1.0.1" */ 126 char target_version[10]; /* [Setup] target_version=, required python 127 version or empty string */ 128 char build_info[80]; /* [Setup] build_info=, distutils version 129 and build date */ 130 131 char meta_name[80]; /* package name without version like 132 'Distutils' */ 133 133 char install_script[MAX_PATH]; 134 134 char *pre_install_script; /* run before we install a single file */ … … 136 136 char user_access_control[10]; // one of 'auto', 'force', otherwise none. 137 137 138 int py_major, py_minor; 139 140 char *arc_data; 141 DWORD arc_size; 142 int exe_size; 138 int py_major, py_minor; /* Python version selected for installation */ 139 140 char *arc_data; /* memory mapped archive */ 141 DWORD arc_size; /* number of bytes in archive */ 142 int exe_size; /* number of bytes for exe-file portion */ 143 143 char python_dir[MAX_PATH]; 144 144 char pythondll[MAX_PATH]; … … 148 148 HKEY hkey_root = (HKEY)-1; 149 149 150 BOOL success; /* Installation successfull? */150 BOOL success; /* Installation successful? */ 151 151 char *failure_reason = NULL; 152 152 … … 166 166 /* Note: purelib must be the FIRST entry! */ 167 167 SCHEME old_scheme[] = { 168 169 170 171 172 173 168 { "PURELIB", "" }, 169 { "PLATLIB", "" }, 170 { "HEADERS", "" }, /* 'Include/dist_name' part already in archive */ 171 { "SCRIPTS", "Scripts\\" }, 172 { "DATA", "" }, 173 { NULL, NULL }, 174 174 }; 175 175 176 176 SCHEME new_scheme[] = { 177 178 179 180 181 182 177 { "PURELIB", "Lib\\site-packages\\" }, 178 { "PLATLIB", "Lib\\site-packages\\" }, 179 { "HEADERS", "" }, /* 'Include/dist_name' part already in archive */ 180 { "SCRIPTS", "Scripts\\" }, 181 { "DATA", "" }, 182 { NULL, NULL }, 183 183 }; 184 184 185 185 static void unescape(char *dst, char *src, unsigned size) 186 186 { 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 187 char *eon; 188 char ch; 189 190 while (src && *src && (size > 2)) { 191 if (*src == '\\') { 192 switch (*++src) { 193 case 'n': 194 ++src; 195 *dst++ = '\r'; 196 *dst++ = '\n'; 197 size -= 2; 198 break; 199 case 'r': 200 ++src; 201 *dst++ = '\r'; 202 --size; 203 break; 204 case '0': case '1': case '2': case '3': 205 ch = (char)strtol(src, &eon, 8); 206 if (ch == '\n') { 207 *dst++ = '\r'; 208 --size; 209 } 210 *dst++ = ch; 211 --size; 212 src = eon; 213 } 214 } else { 215 *dst++ = *src++; 216 --size; 217 } 218 } 219 *dst = '\0'; 220 220 } 221 221 222 222 static struct tagFile { 223 224 223 char *path; 224 struct tagFile *next; 225 225 } *file_list = NULL; 226 226 … … 228 228 { 229 229 if (failure_reason) 230 230 free(failure_reason); 231 231 failure_reason = strdup(reason); 232 232 success = FALSE; … … 235 235 { 236 236 if (!failure_reason) 237 237 return "Installation failed."; 238 238 return failure_reason; 239 239 } … … 241 241 static void add_to_filelist(char *path) 242 242 { 243 244 245 246 247 243 struct tagFile *p; 244 p = (struct tagFile *)malloc(sizeof(struct tagFile)); 245 p->path = strdup(path); 246 p->next = file_list; 247 file_list = p; 248 248 } 249 249 250 250 static int do_compile_files(int (__cdecl * PyRun_SimpleString)(char *), 251 252 { 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 251 int optimize) 252 { 253 struct tagFile *p; 254 int total, n; 255 char Buffer[MAX_PATH + 64]; 256 int errors = 0; 257 258 total = 0; 259 p = file_list; 260 while (p) { 261 ++total; 262 p = p->next; 263 } 264 SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETRANGE, 0, 265 MAKELPARAM(0, total)); 266 SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETPOS, 0, 0); 267 268 n = 0; 269 p = file_list; 270 while (p) { 271 ++n; 272 wsprintf(Buffer, 273 "import py_compile; py_compile.compile (r'%s')", 274 p->path); 275 if (PyRun_SimpleString(Buffer)) { 276 ++errors; 277 } 278 /* We send the notification even if the files could not 279 * be created so that the uninstaller will remove them 280 * in case they are created later. 281 */ 282 wsprintf(Buffer, "%s%c", p->path, optimize ? 'o' : 'c'); 283 notify(FILE_CREATED, Buffer); 284 285 SendDlgItemMessage(hDialog, IDC_PROGRESS, PBM_SETPOS, n, 0); 286 SetDlgItemText(hDialog, IDC_INFO, p->path); 287 p = p->next; 288 } 289 return errors; 290 290 } 291 291 … … 307 307 static int compile_filelist(HINSTANCE hPython, BOOL optimize_flag) 308 308 { 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 309 DECLPROC(hPython, void, Py_Initialize, (void)); 310 DECLPROC(hPython, void, Py_SetProgramName, (char *)); 311 DECLPROC(hPython, void, Py_Finalize, (void)); 312 DECLPROC(hPython, int, PyRun_SimpleString, (char *)); 313 DECLPROC(hPython, PyObject *, PySys_GetObject, (char *)); 314 DECLVAR(hPython, int, Py_OptimizeFlag); 315 316 int errors = 0; 317 struct tagFile *p = file_list; 318 319 if (!p) 320 return 0; 321 322 if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize) 323 return -1; 324 325 if (!PyRun_SimpleString || !PySys_GetObject || !Py_OptimizeFlag) 326 return -1; 327 328 *Py_OptimizeFlag = optimize_flag ? 1 : 0; 329 Py_SetProgramName(modulename); 330 Py_Initialize(); 331 332 errors += do_compile_files(PyRun_SimpleString, optimize_flag); 333 Py_Finalize(); 334 335 return errors; 336 336 } 337 337 … … 339 339 340 340 struct PyMethodDef { 341 char*ml_name;342 343 intml_flags;344 char*ml_doc;341 char *ml_name; 342 PyCFunction ml_meth; 343 int ml_flags; 344 char *ml_doc; 345 345 }; 346 346 typedef struct PyMethodDef PyMethodDef; 347 347 348 348 // XXX - all of these are potentially fragile! We load and unload 349 // the Python DLL multiple times - so storing functions pointers 349 // the Python DLL multiple times - so storing functions pointers 350 350 // is dangerous (although things *look* OK at present) 351 351 // Better might be to roll prepare_script_environment() into … … 364 364 365 365 struct { 366 367 366 int nFolder; 367 char *name; 368 368 } csidl_names[] = { 369 370 371 372 373 369 /* Startup menu for all users. 370 NT only */ 371 DEF_CSIDL(CSIDL_COMMON_STARTMENU), 372 /* Startup menu. */ 373 DEF_CSIDL(CSIDL_STARTMENU), 374 374 375 375 /* DEF_CSIDL(CSIDL_COMMON_APPDATA), */ 376 376 /* DEF_CSIDL(CSIDL_LOCAL_APPDATA), */ 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 377 /* Repository for application-specific data. 378 Needs Internet Explorer 4.0 */ 379 DEF_CSIDL(CSIDL_APPDATA), 380 381 /* The desktop for all users. 382 NT only */ 383 DEF_CSIDL(CSIDL_COMMON_DESKTOPDIRECTORY), 384 /* The desktop. */ 385 DEF_CSIDL(CSIDL_DESKTOPDIRECTORY), 386 387 /* Startup folder for all users. 388 NT only */ 389 DEF_CSIDL(CSIDL_COMMON_STARTUP), 390 /* Startup folder. */ 391 DEF_CSIDL(CSIDL_STARTUP), 392 393 /* Programs item in the start menu for all users. 394 NT only */ 395 DEF_CSIDL(CSIDL_COMMON_PROGRAMS), 396 /* Program item in the user's start menu. */ 397 DEF_CSIDL(CSIDL_PROGRAMS), 398 398 399 399 /* DEF_CSIDL(CSIDL_PROGRAM_FILES_COMMON), */ 400 400 /* DEF_CSIDL(CSIDL_PROGRAM_FILES), */ 401 401 402 403 402 /* Virtual folder containing fonts. */ 403 DEF_CSIDL(CSIDL_FONTS), 404 404 }; 405 405 … … 408 408 static PyObject *FileCreated(PyObject *self, PyObject *args) 409 409 { 410 411 412 413 414 410 char *path; 411 if (!g_PyArg_ParseTuple(args, "s", &path)) 412 return NULL; 413 notify(FILE_CREATED, path); 414 return g_Py_BuildValue(""); 415 415 } 416 416 417 417 static PyObject *DirectoryCreated(PyObject *self, PyObject *args) 418 418 { 419 420 421 422 423 419 char *path; 420 if (!g_PyArg_ParseTuple(args, "s", &path)) 421 return NULL; 422 notify(DIR_CREATED, path); 423 return g_Py_BuildValue(""); 424 424 } 425 425 426 426 static PyObject *GetSpecialFolderPath(PyObject *self, PyObject *args) 427 427 { 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 428 char *name; 429 char lpszPath[MAX_PATH]; 430 int i; 431 static HRESULT (WINAPI *My_SHGetSpecialFolderPath)(HWND hwnd, 432 LPTSTR lpszPath, 433 int nFolder, 434 BOOL fCreate); 435 436 if (!My_SHGetSpecialFolderPath) { 437 HINSTANCE hLib = LoadLibrary("shell32.dll"); 438 if (!hLib) { 439 g_PyErr_Format(g_PyExc_OSError, 440 "function not available"); 441 return NULL; 442 } 443 My_SHGetSpecialFolderPath = (BOOL (WINAPI *)(HWND, LPTSTR, 444 int, BOOL)) 445 GetProcAddress(hLib, 446 "SHGetSpecialFolderPathA"); 447 } 448 449 if (!g_PyArg_ParseTuple(args, "s", &name)) 450 return NULL; 451 452 if (!My_SHGetSpecialFolderPath) { 453 g_PyErr_Format(g_PyExc_OSError, "function not available"); 454 return NULL; 455 } 456 457 for (i = 0; i < DIM(csidl_names); ++i) { 458 if (0 == strcmpi(csidl_names[i].name, name)) { 459 int nFolder; 460 nFolder = csidl_names[i].nFolder; 461 if (My_SHGetSpecialFolderPath(NULL, lpszPath, 462 nFolder, 0)) 463 return g_Py_BuildValue("s", lpszPath); 464 else { 465 g_PyErr_Format(g_PyExc_OSError, 466 "no such folder (%s)", name); 467 return NULL; 468 } 469 470 } 471 }; 472 g_PyErr_Format(g_PyExc_ValueError, "unknown CSIDL (%s)", name); 473 return NULL; 474 474 } 475 475 476 476 static PyObject *CreateShortcut(PyObject *self, PyObject *args) 477 477 { 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 478 char *path; /* path and filename */ 479 char *description; 480 char *filename; 481 482 char *arguments = NULL; 483 char *iconpath = NULL; 484 int iconindex = 0; 485 char *workdir = NULL; 486 487 WCHAR wszFilename[MAX_PATH]; 488 489 IShellLink *ps1 = NULL; 490 IPersistFile *pPf = NULL; 491 492 HRESULT hr; 493 494 hr = CoInitialize(NULL); 495 if (FAILED(hr)) { 496 g_PyErr_Format(g_PyExc_OSError, 497 "CoInitialize failed, error 0x%x", hr); 498 goto error; 499 } 500 501 if (!g_PyArg_ParseTuple(args, "sss|sssi", 502 &path, &description, &filename, 503 &arguments, &workdir, &iconpath, &iconindex)) 504 return NULL; 505 506 hr = CoCreateInstance(&CLSID_ShellLink, 507 NULL, 508 CLSCTX_INPROC_SERVER, 509 &IID_IShellLink, 510 &ps1); 511 if (FAILED(hr)) { 512 g_PyErr_Format(g_PyExc_OSError, 513 "CoCreateInstance failed, error 0x%x", hr); 514 goto error; 515 } 516 517 hr = ps1->lpVtbl->QueryInterface(ps1, &IID_IPersistFile, 518 (void **)&pPf); 519 if (FAILED(hr)) { 520 g_PyErr_Format(g_PyExc_OSError, 521 "QueryInterface(IPersistFile) error 0x%x", hr); 522 goto error; 523 } 524 525 526 hr = ps1->lpVtbl->SetPath(ps1, path); 527 if (FAILED(hr)) { 528 g_PyErr_Format(g_PyExc_OSError, 529 "SetPath() failed, error 0x%x", hr); 530 goto error; 531 } 532 533 hr = ps1->lpVtbl->SetDescription(ps1, description); 534 if (FAILED(hr)) { 535 g_PyErr_Format(g_PyExc_OSError, 536 "SetDescription() failed, error 0x%x", hr); 537 goto error; 538 } 539 540 if (arguments) { 541 hr = ps1->lpVtbl->SetArguments(ps1, arguments); 542 if (FAILED(hr)) { 543 g_PyErr_Format(g_PyExc_OSError, 544 "SetArguments() error 0x%x", hr); 545 goto error; 546 } 547 } 548 549 if (iconpath) { 550 hr = ps1->lpVtbl->SetIconLocation(ps1, iconpath, iconindex); 551 if (FAILED(hr)) { 552 g_PyErr_Format(g_PyExc_OSError, 553 "SetIconLocation() error 0x%x", hr); 554 goto error; 555 } 556 } 557 558 if (workdir) { 559 hr = ps1->lpVtbl->SetWorkingDirectory(ps1, workdir); 560 if (FAILED(hr)) { 561 g_PyErr_Format(g_PyExc_OSError, 562 "SetWorkingDirectory() error 0x%x", hr); 563 goto error; 564 } 565 } 566 567 MultiByteToWideChar(CP_ACP, 0, 568 filename, -1, 569 wszFilename, MAX_PATH); 570 571 hr = pPf->lpVtbl->Save(pPf, wszFilename, TRUE); 572 if (FAILED(hr)) { 573 g_PyErr_Format(g_PyExc_OSError, 574 "Failed to create shortcut '%s' - error 0x%x", filename, hr); 575 goto error; 576 } 577 578 pPf->lpVtbl->Release(pPf); 579 ps1->lpVtbl->Release(ps1); 580 CoUninitialize(); 581 return g_Py_BuildValue(""); 582 583 583 error: 584 585 586 587 588 589 590 591 592 584 if (pPf) 585 pPf->lpVtbl->Release(pPf); 586 587 if (ps1) 588 ps1->lpVtbl->Release(ps1); 589 590 CoUninitialize(); 591 592 return NULL; 593 593 } 594 594 595 595 static PyObject *PyMessageBox(PyObject *self, PyObject *args) 596 596 { 597 598 599 600 601 602 603 597 int rc; 598 char *text, *caption; 599 int flags; 600 if (!g_PyArg_ParseTuple(args, "ssi", &text, &caption, &flags)) 601 return NULL; 602 rc = MessageBox(GetFocus(), text, caption, flags); 603 return g_Py_BuildValue("i", rc); 604 604 } 605 605 606 606 static PyObject *GetRootHKey(PyObject *self) 607 607 { 608 608 return g_PyLong_FromVoidPtr(hkey_root); 609 609 } 610 610 … … 614 614 615 615 PyMethodDef meth[] = { 616 617 618 619 620 621 616 {"create_shortcut", CreateShortcut, METH_VARARGS, NULL}, 617 {"get_special_folder_path", GetSpecialFolderPath, METH_VARARGS, NULL}, 618 {"get_root_hkey", (PyCFunction)GetRootHKey, METH_NOARGS, NULL}, 619 {"file_created", FileCreated, METH_VARARGS, NULL}, 620 {"directory_created", DirectoryCreated, METH_VARARGS, NULL}, 621 {"message_box", PyMessageBox, METH_VARARGS, NULL}, 622 622 }; 623 623 624 624 static HINSTANCE LoadPythonDll(char *fname) 625 625 { 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 626 char fullpath[_MAX_PATH]; 627 LONG size = sizeof(fullpath); 628 char subkey_name[80]; 629 char buffer[260 + 12]; 630 HINSTANCE h; 631 632 /* make sure PYTHONHOME is set, to that sys.path is initialized correctly */ 633 wsprintf(buffer, "PYTHONHOME=%s", python_dir); 634 _putenv(buffer); 635 h = LoadLibrary(fname); 636 if (h) 637 return h; 638 wsprintf(subkey_name, 639 "SOFTWARE\\Python\\PythonCore\\%d.%d\\InstallPath", 640 py_major, py_minor); 641 if (ERROR_SUCCESS != RegQueryValue(HKEY_CURRENT_USER, subkey_name, 642 fullpath, &size) && 643 ERROR_SUCCESS != RegQueryValue(HKEY_LOCAL_MACHINE, subkey_name, 644 fullpath, &size)) 645 return NULL; 646 strcat(fullpath, "\\"); 647 strcat(fullpath, fname); 648 return LoadLibrary(fullpath); 649 649 } 650 650 651 651 static int prepare_script_environment(HINSTANCE hPython) 652 652 { 653 654 655 656 657 658 659 660 661 662 if (!PyImport_ImportModule || !PyObject_GetAttrString || 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 653 PyObject *mod; 654 DECLPROC(hPython, PyObject *, PyImport_ImportModule, (char *)); 655 DECLPROC(hPython, int, PyObject_SetAttrString, (PyObject *, char *, PyObject *)); 656 DECLPROC(hPython, PyObject *, PyObject_GetAttrString, (PyObject *, char *)); 657 DECLPROC(hPython, PyObject *, PyCFunction_New, (PyMethodDef *, PyObject *)); 658 DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); 659 DECLPROC(hPython, int, PyArg_ParseTuple, (PyObject *, char *, ...)); 660 DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); 661 DECLPROC(hPython, PyObject *, PyLong_FromVoidPtr, (void *)); 662 if (!PyImport_ImportModule || !PyObject_GetAttrString || 663 !PyObject_SetAttrString || !PyCFunction_New) 664 return 1; 665 if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format) 666 return 1; 667 668 mod = PyImport_ImportModule("__builtin__"); 669 if (mod) { 670 int i; 671 g_PyExc_ValueError = PyObject_GetAttrString(mod, "ValueError"); 672 g_PyExc_OSError = PyObject_GetAttrString(mod, "OSError"); 673 for (i = 0; i < DIM(meth); ++i) { 674 PyObject_SetAttrString(mod, meth[i].ml_name, 675 PyCFunction_New(&meth[i], NULL)); 676 } 677 } 678 g_Py_BuildValue = Py_BuildValue; 679 g_PyArg_ParseTuple = PyArg_ParseTuple; 680 g_PyErr_Format = PyErr_Format; 681 g_PyLong_FromVoidPtr = PyLong_FromVoidPtr; 682 683 return 0; 684 684 } 685 685 … … 697 697 do_run_installscript(HINSTANCE hPython, char *pathname, int argc, char **argv) 698 698 { 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 699 int fh, result; 700 DECLPROC(hPython, void, Py_Initialize, (void)); 701 DECLPROC(hPython, int, PySys_SetArgv, (int, char **)); 702 DECLPROC(hPython, int, PyRun_SimpleString, (char *)); 703 DECLPROC(hPython, void, Py_Finalize, (void)); 704 DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); 705 DECLPROC(hPython, PyObject *, PyCFunction_New, 706 (PyMethodDef *, PyObject *)); 707 DECLPROC(hPython, int, PyArg_ParseTuple, (PyObject *, char *, ...)); 708 DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); 709 710 if (!Py_Initialize || !PySys_SetArgv 711 || !PyRun_SimpleString || !Py_Finalize) 712 return 1; 713 714 if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format) 715 return 1; 716 717 if (!PyCFunction_New || !PyArg_ParseTuple || !PyErr_Format) 718 return 1; 719 720 if (pathname == NULL || pathname[0] == '\0') 721 return 2; 722 723 fh = open(pathname, _O_RDONLY); 724 if (-1 == fh) { 725 fprintf(stderr, "Could not open postinstall-script %s\n", 726 pathname); 727 return 3; 728 } 729 730 SetDlgItemText(hDialog, IDC_INFO, "Running Script..."); 731 732 Py_Initialize(); 733 734 prepare_script_environment(hPython); 735 PySys_SetArgv(argc, argv); 736 result = 3; 737 { 738 struct _stat statbuf; 739 if(0 == _fstat(fh, &statbuf)) { 740 char *script = alloca(statbuf.st_size + 5); 741 int n = read(fh, script, statbuf.st_size); 742 if (n > 0) { 743 script[n] = '\n'; 744 script[n+1] = 0; 745 result = PyRun_SimpleString(script); 746 } 747 } 748 } 749 Py_Finalize(); 750 751 close(fh); 752 return result; 753 753 } 754 754 … … 756 756 run_installscript(char *pathname, int argc, char **argv, char **pOutput) 757 757 { 758 759 760 761 762 763 764 765 766 767 768 // the CRT from one of various possibile DLLs. As a result we769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 758 HINSTANCE hPython; 759 int result = 1; 760 int out_buf_size; 761 HANDLE redirected, old_stderr, old_stdout; 762 char *tempname; 763 764 *pOutput = NULL; 765 766 tempname = tempnam(NULL, NULL); 767 // We use a static CRT while the Python version we load uses 768 // the CRT from one of various possible DLLs. As a result we 769 // need to redirect the standard handles using the API rather 770 // than the CRT. 771 redirected = CreateFile( 772 tempname, 773 GENERIC_WRITE | GENERIC_READ, 774 FILE_SHARE_READ, 775 NULL, 776 CREATE_ALWAYS, 777 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 778 NULL); 779 old_stdout = GetStdHandle(STD_OUTPUT_HANDLE); 780 old_stderr = GetStdHandle(STD_ERROR_HANDLE); 781 SetStdHandle(STD_OUTPUT_HANDLE, redirected); 782 SetStdHandle(STD_ERROR_HANDLE, redirected); 783 784 hPython = LoadPythonDll(pythondll); 785 if (hPython) { 786 result = do_run_installscript(hPython, pathname, argc, argv); 787 FreeLibrary(hPython); 788 } else { 789 fprintf(stderr, "*** Could not load Python ***"); 790 } 791 SetStdHandle(STD_OUTPUT_HANDLE, old_stdout); 792 SetStdHandle(STD_ERROR_HANDLE, old_stderr); 793 out_buf_size = min(GetFileSize(redirected, NULL), 4096); 794 *pOutput = malloc(out_buf_size+1); 795 if (*pOutput) { 796 DWORD nread = 0; 797 SetFilePointer(redirected, 0, 0, FILE_BEGIN); 798 ReadFile(redirected, *pOutput, out_buf_size, &nread, NULL); 799 (*pOutput)[nread] = '\0'; 800 } 801 CloseHandle(redirected); 802 DeleteFile(tempname); 803 return result; 804 804 } 805 805 806 806 static int do_run_simple_script(HINSTANCE hPython, char *script) 807 807 { 808 809 810 811 812 813 814 815 if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize || 816 817 818 819 820 821 822 823 824 825 826 808 int rc; 809 DECLPROC(hPython, void, Py_Initialize, (void)); 810 DECLPROC(hPython, void, Py_SetProgramName, (char *)); 811 DECLPROC(hPython, void, Py_Finalize, (void)); 812 DECLPROC(hPython, int, PyRun_SimpleString, (char *)); 813 DECLPROC(hPython, void, PyErr_Print, (void)); 814 815 if (!Py_Initialize || !Py_SetProgramName || !Py_Finalize || 816 !PyRun_SimpleString || !PyErr_Print) 817 return -1; 818 819 Py_SetProgramName(modulename); 820 Py_Initialize(); 821 prepare_script_environment(hPython); 822 rc = PyRun_SimpleString(script); 823 if (rc) 824 PyErr_Print(); 825 Py_Finalize(); 826 return rc; 827 827 } 828 828 829 829 static int run_simple_script(char *script) 830 830 { 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 831 int rc; 832 HINSTANCE hPython; 833 char *tempname = tempnam(NULL, NULL); 834 // Redirect output using win32 API - see comments above... 835 HANDLE redirected = CreateFile( 836 tempname, 837 GENERIC_WRITE | GENERIC_READ, 838 FILE_SHARE_READ, 839 NULL, 840 CREATE_ALWAYS, 841 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 842 NULL); 843 HANDLE old_stdout = GetStdHandle(STD_OUTPUT_HANDLE); 844 HANDLE old_stderr = GetStdHandle(STD_ERROR_HANDLE); 845 SetStdHandle(STD_OUTPUT_HANDLE, redirected); 846 SetStdHandle(STD_ERROR_HANDLE, redirected); 847 848 hPython = LoadPythonDll(pythondll); 849 if (!hPython) { 850 char reason[128]; 851 wsprintf(reason, "Can't load Python for pre-install script (%d)", GetLastError()); 852 set_failure_reason(reason); 853 return -1; 854 } 855 rc = do_run_simple_script(hPython, script); 856 FreeLibrary(hPython); 857 SetStdHandle(STD_OUTPUT_HANDLE, old_stdout); 858 SetStdHandle(STD_ERROR_HANDLE, old_stderr); 859 /* We only care about the output when we fail. If the script works 860 OK, then we discard it 861 */ 862 if (rc) { 863 int err_buf_size; 864 char *err_buf; 865 const char *prefix = "Running the pre-installation script failed\r\n"; 866 int prefix_len = strlen(prefix); 867 err_buf_size = GetFileSize(redirected, NULL); 868 if (err_buf_size==INVALID_FILE_SIZE) // an error - let's try anyway... 869 err_buf_size = 4096; 870 err_buf = malloc(prefix_len + err_buf_size + 1); 871 if (err_buf) { 872 DWORD n = 0; 873 strcpy(err_buf, prefix); 874 SetFilePointer(redirected, 0, 0, FILE_BEGIN); 875 ReadFile(redirected, err_buf+prefix_len, err_buf_size, &n, NULL); 876 err_buf[prefix_len+n] = '\0'; 877 set_failure_reason(err_buf); 878 free(err_buf); 879 } else { 880 set_failure_reason("Out of memory!"); 881 } 882 } 883 CloseHandle(redirected); 884 DeleteFile(tempname); 885 return rc; 886 886 } 887 887 … … 889 889 static BOOL SystemError(int error, char *msg) 890 890 { 891 892 893 894 895 896 FormatMessage( 897 FORMAT_MESSAGE_ALLOCATE_BUFFER | 898 899 900 901 902 903 904 NULL 905 906 907 908 909 910 911 912 913 891 char Buffer[1024]; 892 int n; 893 894 if (error) { 895 LPVOID lpMsgBuf; 896 FormatMessage( 897 FORMAT_MESSAGE_ALLOCATE_BUFFER | 898 FORMAT_MESSAGE_FROM_SYSTEM, 899 NULL, 900 error, 901 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 902 (LPSTR)&lpMsgBuf, 903 0, 904 NULL 905 ); 906 strncpy(Buffer, lpMsgBuf, sizeof(Buffer)); 907 LocalFree(lpMsgBuf); 908 } else 909 Buffer[0] = '\0'; 910 n = lstrlen(Buffer); 911 _snprintf(Buffer+n, sizeof(Buffer)-n, msg); 912 MessageBox(hwndMain, Buffer, "Runtime Error", MB_OK | MB_ICONSTOP); 913 return FALSE; 914 914 } 915 915 916 916 static BOOL notify (int code, char *fmt, ...) 917 917 { 918 919 920 921 922 923 924 925 926 927 918 char Buffer[1024]; 919 va_list marker; 920 BOOL result = TRUE; 921 int a, b; 922 char *cp; 923 924 va_start(marker, fmt); 925 _vsnprintf(Buffer, sizeof(Buffer), fmt, marker); 926 927 switch (code) { 928 928 /* Questions */ 929 930 929 case CAN_OVERWRITE: 930 break; 931 931 932 932 /* Information notification */ 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 933 case DIR_CREATED: 934 if (logfile) 935 fprintf(logfile, "100 Made Dir: %s\n", fmt); 936 break; 937 938 case FILE_CREATED: 939 if (logfile) 940 fprintf(logfile, "200 File Copy: %s\n", fmt); 941 goto add_to_filelist_label; 942 break; 943 944 case FILE_OVERWRITTEN: 945 if (logfile) 946 fprintf(logfile, "200 File Overwrite: %s\n", fmt); 947 add_to_filelist_label: 948 if ((cp = strrchr(fmt, '.')) && (0 == strcmp (cp, ".py"))) 949 add_to_filelist(fmt); 950 break; 951 951 952 952 /* Error Messages */ 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 953 case ZLIB_ERROR: 954 MessageBox(GetFocus(), Buffer, "Error", 955 MB_OK | MB_ICONWARNING); 956 break; 957 958 case SYSTEM_ERROR: 959 SystemError(GetLastError(), Buffer); 960 break; 961 962 case NUM_FILES: 963 a = va_arg(marker, int); 964 b = va_arg(marker, int); 965 SendMessage(hDialog, WM_NUMFILES, 0, MAKELPARAM(0, a)); 966 SendMessage(hDialog, WM_NEXTFILE, b,(LPARAM)fmt); 967 } 968 va_end(marker); 969 970 return result; 971 971 } 972 972 973 973 static char *MapExistingFile(char *pathname, DWORD *psize) 974 974 { 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 975 HANDLE hFile, hFileMapping; 976 DWORD nSizeLow, nSizeHigh; 977 char *data; 978 979 hFile = CreateFile(pathname, 980 GENERIC_READ, FILE_SHARE_READ, NULL, 981 OPEN_EXISTING, 982 FILE_ATTRIBUTE_NORMAL, NULL); 983 if (hFile == INVALID_HANDLE_VALUE) 984 return NULL; 985 nSizeLow = GetFileSize(hFile, &nSizeHigh); 986 hFileMapping = CreateFileMapping(hFile, 987 NULL, PAGE_READONLY, 0, 0, NULL); 988 CloseHandle(hFile); 989 990 if (hFileMapping == INVALID_HANDLE_VALUE) 991 return NULL; 992 993 data = MapViewOfFile(hFileMapping, 994 FILE_MAP_READ, 0, 0, 0); 995 996 CloseHandle(hFileMapping); 997 *psize = nSizeLow; 998 return data; 999 999 } 1000 1000 … … 1002 1002 static void create_bitmap(HWND hwnd) 1003 1003 { 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1004 BITMAPFILEHEADER *bfh; 1005 BITMAPINFO *bi; 1006 HDC hdc; 1007 1008 if (!bitmap_bytes) 1009 return; 1010 1011 if (hBitmap) 1012 return; 1013 1014 hdc = GetDC(hwnd); 1015 1016 bfh = (BITMAPFILEHEADER *)bitmap_bytes; 1017 bi = (BITMAPINFO *)(bitmap_bytes + sizeof(BITMAPFILEHEADER)); 1018 1019 hBitmap = CreateDIBitmap(hdc, 1020 &bi->bmiHeader, 1021 CBM_INIT, 1022 bitmap_bytes + bfh->bfOffBits, 1023 bi, 1024 DIB_RGB_COLORS); 1025 ReleaseDC(hwnd, hdc); 1026 1026 } 1027 1027 … … 1030 1030 */ 1031 1031 static BOOL ExtractInstallData(char *data, DWORD size, int *pexe_size, 1032 1033 { 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1032 char **out_ini_file, char **out_preinstall_script) 1033 { 1034 /* read the end of central directory record */ 1035 struct eof_cdir *pe = (struct eof_cdir *)&data[size - sizeof 1036 (struct eof_cdir)]; 1037 1038 int arc_start = size - sizeof (struct eof_cdir) - pe->nBytesCDir - 1039 pe->ofsCDir; 1040 1041 int ofs = arc_start - sizeof (struct meta_data_hdr); 1042 1043 /* read meta_data info */ 1044 struct meta_data_hdr *pmd = (struct meta_data_hdr *)&data[ofs]; 1045 char *src, *dst; 1046 char *ini_file; 1047 char tempdir[MAX_PATH]; 1048 1049 /* ensure that if we fail, we don't have garbage out pointers */ 1050 *out_ini_file = *out_preinstall_script = NULL; 1051 1052 if (pe->tag != 0x06054b50) { 1053 return FALSE; 1054 } 1055 1056 if (pmd->tag != 0x1234567B) { 1057 return SystemError(0, 1058 "Invalid cfgdata magic number (see bdist_wininst.py)"); 1059 } 1060 if (ofs < 0) { 1061 return FALSE; 1062 } 1063 1064 if (pmd->bitmap_size) { 1065 /* Store pointer to bitmap bytes */ 1066 bitmap_bytes = (char *)pmd - pmd->uncomp_size - pmd->bitmap_size; 1067 } 1068 1069 *pexe_size = ofs - pmd->uncomp_size - pmd->bitmap_size; 1070 1071 src = ((char *)pmd) - pmd->uncomp_size; 1072 ini_file = malloc(MAX_PATH); /* will be returned, so do not free it */ 1073 if (!ini_file) 1074 return FALSE; 1075 if (!GetTempPath(sizeof(tempdir), tempdir) 1076 || !GetTempFileName(tempdir, "~du", 0, ini_file)) { 1077 SystemError(GetLastError(), 1078 "Could not create temporary file"); 1079 return FALSE; 1080 } 1081 1082 dst = map_new_file(CREATE_ALWAYS, ini_file, NULL, pmd->uncomp_size, 1083 0, 0, NULL/*notify*/); 1084 if (!dst) 1085 return FALSE; 1086 /* Up to the first \0 is the INI file data. */ 1087 strncpy(dst, src, pmd->uncomp_size); 1088 src += strlen(dst) + 1; 1089 /* Up to next \0 is the pre-install script */ 1090 *out_preinstall_script = strdup(src); 1091 *out_ini_file = ini_file; 1092 UnmapViewOfFile(dst); 1093 return TRUE; 1094 1094 } 1095 1095 1096 1096 static void PumpMessages(void) 1097 1097 { 1098 1099 1100 1101 1102 1098 MSG msg; 1099 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { 1100 TranslateMessage(&msg); 1101 DispatchMessage(&msg); 1102 } 1103 1103 } 1104 1104 … … 1106 1106 WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1107 1107 { 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1108 HDC hdc; 1109 HFONT hFont; 1110 int h; 1111 PAINTSTRUCT ps; 1112 switch (msg) { 1113 case WM_PAINT: 1114 hdc = BeginPaint(hwnd, &ps); 1115 h = GetSystemMetrics(SM_CYSCREEN) / 10; 1116 hFont = CreateFont(h, 0, 0, 0, 700, TRUE, 1117 0, 0, 0, 0, 0, 0, 0, "Times Roman"); 1118 hFont = SelectObject(hdc, hFont); 1119 SetBkMode(hdc, TRANSPARENT); 1120 TextOut(hdc, 15, 15, title, strlen(title)); 1121 SetTextColor(hdc, RGB(255, 255, 255)); 1122 TextOut(hdc, 10, 10, title, strlen(title)); 1123 DeleteObject(SelectObject(hdc, hFont)); 1124 EndPaint(hwnd, &ps); 1125 return 0; 1126 } 1127 return DefWindowProc(hwnd, msg, wParam, lParam); 1128 1128 } 1129 1129 1130 1130 static HWND CreateBackground(char *title) 1131 1131 { 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1132 WNDCLASS wc; 1133 HWND hwnd; 1134 char buffer[4096]; 1135 1136 wc.style = CS_VREDRAW | CS_HREDRAW; 1137 wc.lpfnWndProc = WindowProc; 1138 wc.cbWndExtra = 0; 1139 wc.cbClsExtra = 0; 1140 wc.hInstance = GetModuleHandle(NULL); 1141 wc.hIcon = NULL; 1142 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 1143 wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 128)); 1144 wc.lpszMenuName = NULL; 1145 wc.lpszClassName = "SetupWindowClass"; 1146 1147 if (!RegisterClass(&wc)) 1148 MessageBox(hwndMain, 1149 "Could not register window class", 1150 "Setup.exe", MB_OK); 1151 1152 wsprintf(buffer, "Setup %s", title); 1153 hwnd = CreateWindow("SetupWindowClass", 1154 buffer, 1155 0, 1156 0, 0, 1157 GetSystemMetrics(SM_CXFULLSCREEN), 1158 GetSystemMetrics(SM_CYFULLSCREEN), 1159 NULL, 1160 NULL, 1161 GetModuleHandle(NULL), 1162 NULL); 1163 ShowWindow(hwnd, SW_SHOWMAXIMIZED); 1164 UpdateWindow(hwnd); 1165 return hwnd; 1166 1166 } 1167 1167 … … 1171 1171 static void CenterWindow(HWND hwnd) 1172 1172 { 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1173 RECT rc; 1174 int w, h; 1175 1176 GetWindowRect(hwnd, &rc); 1177 w = GetSystemMetrics(SM_CXSCREEN); 1178 h = GetSystemMetrics(SM_CYSCREEN); 1179 MoveWindow(hwnd, 1180 (w - (rc.right-rc.left))/2, 1181 (h - (rc.bottom-rc.top))/2, 1182 rc.right-rc.left, rc.bottom-rc.top, FALSE); 1183 1183 } 1184 1184 … … 1188 1188 IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1189 1189 { 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1190 LPNMHDR lpnm; 1191 char Buffer[4096]; 1192 1193 switch (msg) { 1194 case WM_INITDIALOG: 1195 create_bitmap(hwnd); 1196 if(hBitmap) 1197 SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, 1198 IMAGE_BITMAP, (LPARAM)hBitmap); 1199 CenterWindow(GetParent(hwnd)); 1200 wsprintf(Buffer, 1201 "This Wizard will install %s on your computer. " 1202 "Click Next to continue " 1203 "or Cancel to exit the Setup Wizard.", 1204 meta_name); 1205 SetDlgItemText(hwnd, IDC_TITLE, Buffer); 1206 SetDlgItemText(hwnd, IDC_INTRO_TEXT, info); 1207 SetDlgItemText(hwnd, IDC_BUILD_INFO, build_info); 1208 return FALSE; 1209 1210 case WM_NOTIFY: 1211 lpnm = (LPNMHDR) lParam; 1212 1213 switch (lpnm->code) { 1214 case PSN_SETACTIVE: 1215 PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_NEXT); 1216 break; 1217 1218 case PSN_WIZNEXT: 1219 break; 1220 1221 case PSN_RESET: 1222 break; 1223 1224 default: 1225 break; 1226 } 1227 } 1228 return FALSE; 1229 1229 } 1230 1230 … … 1238 1238 1239 1239 static BOOL __stdcall StatusRoutine(IMAGEHLP_STATUS_REASON reason, 1240 1241 1242 1243 1244 { 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1240 PSTR ImageName, 1241 PSTR DllName, 1242 ULONG Va, 1243 ULONG Parameter) 1244 { 1245 char fname[_MAX_PATH]; 1246 int int_version; 1247 1248 switch(reason) { 1249 case BindOutOfMemory: 1250 case BindRvaToVaFailed: 1251 case BindNoRoomInImage: 1252 case BindImportProcedureFailed: 1253 break; 1254 1255 case BindImportProcedure: 1256 case BindForwarder: 1257 case BindForwarderNOT: 1258 case BindImageModified: 1259 case BindExpandFileHeaders: 1260 case BindImageComplete: 1261 case BindSymbolsNotUpdated: 1262 case BindMismatchedSymbols: 1263 case BindImportModuleFailed: 1264 break; 1265 1266 case BindImportModule: 1267 if (1 == sscanf(DllName, "python%d", &int_version)) { 1268 SearchPath(NULL, DllName, NULL, sizeof(fname), 1269 fname, NULL); 1270 strcpy(bound_image_dll, fname); 1271 bound_image_major = int_version / 10; 1272 bound_image_minor = int_version % 10; 1273 OutputDebugString("BOUND "); 1274 OutputDebugString(fname); 1275 OutputDebugString("\n"); 1276 } 1277 break; 1278 } 1279 return TRUE; 1280 1280 } 1281 1281 … … 1284 1284 static LPSTR get_sys_prefix(LPSTR exe, LPSTR dll) 1285 1285 { 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 // 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1286 void (__cdecl * Py_Initialize)(void); 1287 void (__cdecl * Py_SetProgramName)(char *); 1288 void (__cdecl * Py_Finalize)(void); 1289 void* (__cdecl * PySys_GetObject)(char *); 1290 void (__cdecl * PySys_SetArgv)(int, char **); 1291 char* (__cdecl * Py_GetPrefix)(void); 1292 char* (__cdecl * Py_GetPath)(void); 1293 HINSTANCE hPython; 1294 LPSTR prefix = NULL; 1295 int (__cdecl * PyRun_SimpleString)(char *); 1296 1297 { 1298 char Buffer[256]; 1299 wsprintf(Buffer, "PYTHONHOME=%s", exe); 1300 *strrchr(Buffer, '\\') = '\0'; 1301 // MessageBox(GetFocus(), Buffer, "PYTHONHOME", MB_OK); 1302 _putenv(Buffer); 1303 _putenv("PYTHONPATH="); 1304 } 1305 1306 hPython = LoadLibrary(dll); 1307 if (!hPython) 1308 return NULL; 1309 Py_Initialize = (void (*)(void))GetProcAddress 1310 (hPython,"Py_Initialize"); 1311 1312 PySys_SetArgv = (void (*)(int, char **))GetProcAddress 1313 (hPython,"PySys_SetArgv"); 1314 1315 PyRun_SimpleString = (int (*)(char *))GetProcAddress 1316 (hPython,"PyRun_SimpleString"); 1317 1318 Py_SetProgramName = (void (*)(char *))GetProcAddress 1319 (hPython,"Py_SetProgramName"); 1320 1321 PySys_GetObject = (void* (*)(char *))GetProcAddress 1322 (hPython,"PySys_GetObject"); 1323 1324 Py_GetPrefix = (char * (*)(void))GetProcAddress 1325 (hPython,"Py_GetPrefix"); 1326 1327 Py_GetPath = (char * (*)(void))GetProcAddress 1328 (hPython,"Py_GetPath"); 1329 1330 Py_Finalize = (void (*)(void))GetProcAddress(hPython, 1331 "Py_Finalize"); 1332 Py_SetProgramName(exe); 1333 Py_Initialize(); 1334 PySys_SetArgv(1, &exe); 1335 1336 MessageBox(GetFocus(), Py_GetPrefix(), "PREFIX", MB_OK); 1337 MessageBox(GetFocus(), Py_GetPath(), "PATH", MB_OK); 1338 1339 Py_Finalize(); 1340 FreeLibrary(hPython); 1341 1342 return prefix; 1343 1343 } 1344 1344 … … 1346 1346 CheckPythonExe(LPSTR pathname, LPSTR version, int *pmajor, int *pminor) 1347 1347 { 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1348 bound_image_dll[0] = '\0'; 1349 if (!BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES, 1350 pathname, 1351 NULL, 1352 NULL, 1353 StatusRoutine)) 1354 return SystemError(0, "Could not bind image"); 1355 if (bound_image_dll[0] == '\0') 1356 return SystemError(0, "Does not seem to be a python executable"); 1357 *pmajor = bound_image_major; 1358 *pminor = bound_image_minor; 1359 if (version && *version) { 1360 char core_version[12]; 1361 wsprintf(core_version, "%d.%d", bound_image_major, bound_image_minor); 1362 if (strcmp(version, core_version)) 1363 return SystemError(0, "Wrong Python version"); 1364 } 1365 get_sys_prefix(pathname, bound_image_dll); 1366 return TRUE; 1367 1367 } 1368 1368 … … 1373 1373 static BOOL GetOtherPythonVersion(HWND hwnd, LPSTR version) 1374 1374 { 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1375 char vers_name[_MAX_PATH + 80]; 1376 DWORD itemindex; 1377 OPENFILENAME of; 1378 char pathname[_MAX_PATH]; 1379 DWORD result; 1380 1381 strcpy(pathname, "python.exe"); 1382 1383 memset(&of, 0, sizeof(of)); 1384 of.lStructSize = sizeof(OPENFILENAME); 1385 of.hwndOwner = GetParent(hwnd); 1386 of.hInstance = NULL; 1387 of.lpstrFilter = "python.exe\0python.exe\0"; 1388 of.lpstrCustomFilter = NULL; 1389 of.nMaxCustFilter = 0; 1390 of.nFilterIndex = 1; 1391 of.lpstrFile = pathname; 1392 of.nMaxFile = sizeof(pathname); 1393 of.lpstrFileTitle = NULL; 1394 of.nMaxFileTitle = 0; 1395 of.lpstrInitialDir = NULL; 1396 of.lpstrTitle = "Python executable"; 1397 of.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; 1398 of.lpstrDefExt = "exe"; 1399 1400 result = GetOpenFileName(&of); 1401 if (result) { 1402 int major, minor; 1403 if (!CheckPythonExe(pathname, version, &major, &minor)) { 1404 return FALSE; 1405 } 1406 *strrchr(pathname, '\\') = '\0'; 1407 wsprintf(vers_name, "Python Version %d.%d in %s", 1408 major, minor, pathname); 1409 itemindex = SendMessage(hwnd, LB_INSERTSTRING, -1, 1410 (LPARAM)(LPSTR)vers_name); 1411 SendMessage(hwnd, LB_SETCURSEL, itemindex, 0); 1412 SendMessage(hwnd, LB_SETITEMDATA, itemindex, 1413 (LPARAM)(LPSTR)strdup(pathname)); 1414 return TRUE; 1415 } 1416 return FALSE; 1417 1417 } 1418 1418 #endif /* USE_OTHER_PYTHON_VERSIONS */ … … 1431 1431 static BOOL GetPythonVersions(HWND hwnd, HKEY hkRoot, LPSTR version) 1432 1432 { 1433 1434 1435 1436 1437 1438 1439 1440 1441 0,KEY_READ, &hKey))1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 InstalledVersionInfo *ivi = 1464 1465 1466 if (ivi && 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1433 DWORD index = 0; 1434 char core_version[80]; 1435 HKEY hKey; 1436 BOOL result = TRUE; 1437 DWORD bufsize; 1438 1439 if (ERROR_SUCCESS != RegOpenKeyEx(hkRoot, 1440 "Software\\Python\\PythonCore", 1441 0, KEY_READ, &hKey)) 1442 return FALSE; 1443 bufsize = sizeof(core_version); 1444 while (ERROR_SUCCESS == RegEnumKeyEx(hKey, index, 1445 core_version, &bufsize, NULL, 1446 NULL, NULL, NULL)) { 1447 char subkey_name[80], vers_name[80]; 1448 int itemindex; 1449 DWORD value_size; 1450 HKEY hk; 1451 1452 bufsize = sizeof(core_version); 1453 ++index; 1454 if (version && *version && strcmp(version, core_version)) 1455 continue; 1456 1457 wsprintf(vers_name, "Python Version %s (found in registry)", 1458 core_version); 1459 wsprintf(subkey_name, 1460 "Software\\Python\\PythonCore\\%s\\InstallPath", 1461 core_version); 1462 if (ERROR_SUCCESS == RegOpenKeyEx(hkRoot, subkey_name, 0, KEY_READ, &hk)) { 1463 InstalledVersionInfo *ivi = 1464 (InstalledVersionInfo *)malloc(sizeof(InstalledVersionInfo)); 1465 value_size = sizeof(ivi->prefix); 1466 if (ivi && 1467 ERROR_SUCCESS == RegQueryValueEx(hk, NULL, NULL, NULL, 1468 ivi->prefix, &value_size)) { 1469 itemindex = SendMessage(hwnd, LB_ADDSTRING, 0, 1470 (LPARAM)(LPSTR)vers_name); 1471 ivi->hkey = hkRoot; 1472 SendMessage(hwnd, LB_SETITEMDATA, itemindex, 1473 (LPARAM)(LPSTR)ivi); 1474 } 1475 RegCloseKey(hk); 1476 } 1477 } 1478 RegCloseKey(hKey); 1479 return result; 1480 1480 } 1481 1481 … … 1483 1483 BOOL HasLocalMachinePrivs() 1484 1484 { 1485 1486 1487 static char KeyName[] = 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1485 HKEY hKey; 1486 DWORD result; 1487 static char KeyName[] = 1488 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; 1489 1490 result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 1491 KeyName, 1492 0, 1493 KEY_CREATE_SUB_KEY, 1494 &hKey); 1495 if (result==0) 1496 RegCloseKey(hKey); 1497 return result==0; 1498 1498 } 1499 1499 … … 1508 1508 void CheckRootKey(HWND hwnd) 1509 1509 { 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1510 if (hkey_root==HKEY_CURRENT_USER) { 1511 ; // as above, always install ourself in HKCU too. 1512 } else if (hkey_root==HKEY_LOCAL_MACHINE) { 1513 // Python in HKLM, but we may or may not have permissions there. 1514 // Open the uninstall key with 'create' permissions - if this fails, 1515 // we don't have permission. 1516 if (!HasLocalMachinePrivs()) 1517 hkey_root = HKEY_CURRENT_USER; 1518 } else { 1519 MessageBox(hwnd, "Don't know Python's installation type", 1520 "Strange", MB_OK | MB_ICONSTOP); 1521 /* Default to wherever they can, but preferring HKLM */ 1522 hkey_root = HasLocalMachinePrivs() ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 1523 } 1524 1524 } 1525 1525 … … 1527 1527 SCHEME *GetScheme(int major, int minor) 1528 1528 { 1529 1530 1531 1532 1533 1529 if (major > 2) 1530 return new_scheme; 1531 else if((major == 2) && (minor >= 2)) 1532 return new_scheme; 1533 return old_scheme; 1534 1534 } 1535 1535 … … 1537 1537 SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1538 1538 { 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 {/* select the last entry which is the highest python1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1539 LPNMHDR lpnm; 1540 1541 switch (msg) { 1542 case WM_INITDIALOG: 1543 if (hBitmap) 1544 SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, 1545 IMAGE_BITMAP, (LPARAM)hBitmap); 1546 GetPythonVersions(GetDlgItem(hwnd, IDC_VERSIONS_LIST), 1547 HKEY_LOCAL_MACHINE, target_version); 1548 GetPythonVersions(GetDlgItem(hwnd, IDC_VERSIONS_LIST), 1549 HKEY_CURRENT_USER, target_version); 1550 { /* select the last entry which is the highest python 1551 version found */ 1552 int count; 1553 count = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, 1554 LB_GETCOUNT, 0, 0); 1555 if (count && count != LB_ERR) 1556 SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, LB_SETCURSEL, 1557 count-1, 0); 1558 1559 /* If a specific Python version is required, 1560 * display a prominent notice showing this fact. 1561 */ 1562 if (target_version && target_version[0]) { 1563 char buffer[4096]; 1564 wsprintf(buffer, 1565 "Python %s is required for this package. " 1566 "Select installation to use:", 1567 target_version); 1568 SetDlgItemText(hwnd, IDC_TITLE, buffer); 1569 } 1570 1571 if (count == 0) { 1572 char Buffer[4096]; 1573 char *msg; 1574 if (target_version && target_version[0]) { 1575 wsprintf(Buffer, 1576 "Python version %s required, which was not found" 1577 " in the registry.", target_version); 1578 msg = Buffer; 1579 } else 1580 msg = "No Python installation found in the registry."; 1581 MessageBox(hwnd, msg, "Cannot install", 1582 MB_OK | MB_ICONSTOP); 1583 } 1584 } 1585 goto UpdateInstallDir; 1586 break; 1587 1588 case WM_COMMAND: 1589 switch (LOWORD(wParam)) { 1590 1590 /* 1591 1591 case IDC_OTHERPYTHON: … … 1595 1595 break; 1596 1596 */ 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1597 case IDC_VERSIONS_LIST: 1598 switch (HIWORD(wParam)) { 1599 int id; 1600 case LBN_SELCHANGE: 1601 UpdateInstallDir: 1602 PropSheet_SetWizButtons(GetParent(hwnd), 1603 PSWIZB_BACK | PSWIZB_NEXT); 1604 id = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, 1605 LB_GETCURSEL, 0, 0); 1606 if (id == LB_ERR) { 1607 PropSheet_SetWizButtons(GetParent(hwnd), 1608 PSWIZB_BACK); 1609 SetDlgItemText(hwnd, IDC_PATH, ""); 1610 SetDlgItemText(hwnd, IDC_INSTALL_PATH, ""); 1611 strcpy(python_dir, ""); 1612 strcpy(pythondll, ""); 1613 } else { 1614 char *pbuf; 1615 int result; 1616 InstalledVersionInfo *ivi; 1617 PropSheet_SetWizButtons(GetParent(hwnd), 1618 PSWIZB_BACK | PSWIZB_NEXT); 1619 /* Get the python directory */ 1620 ivi = (InstalledVersionInfo *) 1621 SendDlgItemMessage(hwnd, 1622 IDC_VERSIONS_LIST, 1623 LB_GETITEMDATA, 1624 id, 1625 0); 1626 hkey_root = ivi->hkey; 1627 strcpy(python_dir, ivi->prefix); 1628 SetDlgItemText(hwnd, IDC_PATH, python_dir); 1629 /* retrieve the python version and pythondll to use */ 1630 result = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, 1631 LB_GETTEXTLEN, (WPARAM)id, 0); 1632 pbuf = (char *)malloc(result + 1); 1633 if (pbuf) { 1634 /* guess the name of the python-dll */ 1635 SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, 1636 LB_GETTEXT, (WPARAM)id, 1637 (LPARAM)pbuf); 1638 result = sscanf(pbuf, "Python Version %d.%d", 1639 &py_major, &py_minor); 1640 if (result == 2) { 1641 1641 #ifdef _DEBUG 1642 1643 1642 wsprintf(pythondll, "python%d%d_d.dll", 1643 py_major, py_minor); 1644 1644 #else 1645 1646 1645 wsprintf(pythondll, "python%d%d.dll", 1646 py_major, py_minor); 1647 1647 #endif 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1648 } 1649 free(pbuf); 1650 } else 1651 strcpy(pythondll, ""); 1652 /* retrieve the scheme for this version */ 1653 { 1654 char install_path[_MAX_PATH]; 1655 SCHEME *scheme = GetScheme(py_major, py_minor); 1656 strcpy(install_path, python_dir); 1657 if (install_path[strlen(install_path)-1] != '\\') 1658 strcat(install_path, "\\"); 1659 strcat(install_path, scheme[0].prefix); 1660 SetDlgItemText(hwnd, IDC_INSTALL_PATH, install_path); 1661 } 1662 } 1663 } 1664 break; 1665 } 1666 return 0; 1667 1668 case WM_NOTIFY: 1669 lpnm = (LPNMHDR) lParam; 1670 1671 switch (lpnm->code) { 1672 int id; 1673 case PSN_SETACTIVE: 1674 id = SendDlgItemMessage(hwnd, IDC_VERSIONS_LIST, 1675 LB_GETCURSEL, 0, 0); 1676 if (id == LB_ERR) 1677 PropSheet_SetWizButtons(GetParent(hwnd), 1678 PSWIZB_BACK); 1679 else 1680 PropSheet_SetWizButtons(GetParent(hwnd), 1681 PSWIZB_BACK | PSWIZB_NEXT); 1682 break; 1683 1684 case PSN_WIZNEXT: 1685 break; 1686 1687 case PSN_WIZFINISH: 1688 break; 1689 1690 case PSN_RESET: 1691 break; 1692 1693 default: 1694 break; 1695 } 1696 } 1697 return 0; 1698 1698 } 1699 1699 1700 1700 static BOOL OpenLogfile(char *dir) 1701 1701 { 1702 1703 1704 1705 1706 1707 1708 static char KeyName[] = 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1702 char buffer[_MAX_PATH+1]; 1703 time_t ltime; 1704 struct tm *now; 1705 long result; 1706 HKEY hKey, hSubkey; 1707 char subkey_name[256]; 1708 static char KeyName[] = 1709 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; 1710 const char *root_name = (hkey_root==HKEY_LOCAL_MACHINE ? 1711 "HKEY_LOCAL_MACHINE" : "HKEY_CURRENT_USER"); 1712 DWORD disposition; 1713 1714 /* Use Create, as the Uninstall subkey may not exist under HKCU. 1715 Use CreateKeyEx, so we can specify a SAM specifying write access 1716 */ 1717 result = RegCreateKeyEx(hkey_root, 1718 KeyName, 1719 0, /* reserved */ 1720 NULL, /* class */ 1721 0, /* options */ 1722 KEY_CREATE_SUB_KEY, /* sam */ 1723 NULL, /* security */ 1724 &hKey, /* result key */ 1725 NULL); /* disposition */ 1726 if (result != ERROR_SUCCESS) { 1727 if (result == ERROR_ACCESS_DENIED) { 1728 /* This should no longer be able to happen - we have already 1729 checked if they have permissions in HKLM, and all users 1730 should have write access to HKCU. 1731 */ 1732 MessageBox(GetFocus(), 1733 "You do not seem to have sufficient access rights\n" 1734 "on this machine to install this software", 1735 NULL, 1736 MB_OK | MB_ICONSTOP); 1737 return FALSE; 1738 } else { 1739 MessageBox(GetFocus(), KeyName, "Could not open key", MB_OK); 1740 } 1741 } 1742 1743 sprintf(buffer, "%s\\%s-wininst.log", dir, meta_name); 1744 logfile = fopen(buffer, "a"); 1745 time(<ime); 1746 now = localtime(<ime); 1747 strftime(buffer, sizeof(buffer), 1748 "*** Installation started %Y/%m/%d %H:%M ***\n", 1749 localtime(<ime)); 1750 fprintf(logfile, buffer); 1751 fprintf(logfile, "Source: %s\n", modulename); 1752 1753 /* Root key must be first entry processed by uninstaller. */ 1754 fprintf(logfile, "999 Root Key: %s\n", root_name); 1755 1756 sprintf(subkey_name, "%s-py%d.%d", meta_name, py_major, py_minor); 1757 1758 result = RegCreateKeyEx(hKey, subkey_name, 1759 0, NULL, 0, 1760 KEY_WRITE, 1761 NULL, 1762 &hSubkey, 1763 &disposition); 1764 1765 if (result != ERROR_SUCCESS) 1766 MessageBox(GetFocus(), subkey_name, "Could not create key", MB_OK); 1767 1768 RegCloseKey(hKey); 1769 1770 if (disposition == REG_CREATED_NEW_KEY) 1771 fprintf(logfile, "020 Reg DB Key: [%s]%s\n", KeyName, subkey_name); 1772 1773 sprintf(buffer, "Python %d.%d %s", py_major, py_minor, title); 1774 1775 result = RegSetValueEx(hSubkey, "DisplayName", 1776 0, 1777 REG_SZ, 1778 buffer, 1779 strlen(buffer)+1); 1780 1781 if (result != ERROR_SUCCESS) 1782 MessageBox(GetFocus(), buffer, "Could not set key value", MB_OK); 1783 1784 fprintf(logfile, "040 Reg DB Value: [%s\\%s]%s=%s\n", 1785 KeyName, subkey_name, "DisplayName", buffer); 1786 1787 { 1788 FILE *fp; 1789 sprintf(buffer, "%s\\Remove%s.exe", dir, meta_name); 1790 fp = fopen(buffer, "wb"); 1791 fwrite(arc_data, exe_size, 1, fp); 1792 fclose(fp); 1793 1794 sprintf(buffer, "\"%s\\Remove%s.exe\" -u \"%s\\%s-wininst.log\"", 1795 dir, meta_name, dir, meta_name); 1796 1797 result = RegSetValueEx(hSubkey, "UninstallString", 1798 0, 1799 REG_SZ, 1800 buffer, 1801 strlen(buffer)+1); 1802 1803 if (result != ERROR_SUCCESS) 1804 MessageBox(GetFocus(), buffer, "Could not set key value", MB_OK); 1805 1806 fprintf(logfile, "040 Reg DB Value: [%s\\%s]%s=%s\n", 1807 KeyName, subkey_name, "UninstallString", buffer); 1808 } 1809 return TRUE; 1810 1810 } 1811 1811 1812 1812 static void CloseLogfile(void) 1813 1813 { 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1814 char buffer[_MAX_PATH+1]; 1815 time_t ltime; 1816 struct tm *now; 1817 1818 time(<ime); 1819 now = localtime(<ime); 1820 strftime(buffer, sizeof(buffer), 1821 "*** Installation finished %Y/%m/%d %H:%M ***\n", 1822 localtime(<ime)); 1823 fprintf(logfile, buffer); 1824 if (logfile) 1825 fclose(logfile); 1826 1826 } 1827 1827 … … 1829 1829 InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1830 1830 { 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1831 LPNMHDR lpnm; 1832 char Buffer[4096]; 1833 SCHEME *scheme; 1834 1835 switch (msg) { 1836 case WM_INITDIALOG: 1837 if (hBitmap) 1838 SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, 1839 IMAGE_BITMAP, (LPARAM)hBitmap); 1840 wsprintf(Buffer, 1841 "Click Next to begin the installation of %s. " 1842 "If you want to review or change any of your " 1843 " installation settings, click Back. " 1844 "Click Cancel to exit the wizard.", 1845 meta_name); 1846 SetDlgItemText(hwnd, IDC_TITLE, Buffer); 1847 SetDlgItemText(hwnd, IDC_INFO, "Ready to install"); 1848 break; 1849 1850 case WM_NUMFILES: 1851 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETRANGE, 0, lParam); 1852 PumpMessages(); 1853 return TRUE; 1854 1855 case WM_NEXTFILE: 1856 SendDlgItemMessage(hwnd, IDC_PROGRESS, PBM_SETPOS, wParam, 1857 0); 1858 SetDlgItemText(hwnd, IDC_INFO, (LPSTR)lParam); 1859 PumpMessages(); 1860 return TRUE; 1861 1862 case WM_NOTIFY: 1863 lpnm = (LPNMHDR) lParam; 1864 1865 switch (lpnm->code) { 1866 case PSN_SETACTIVE: 1867 PropSheet_SetWizButtons(GetParent(hwnd), 1868 PSWIZB_BACK | PSWIZB_NEXT); 1869 break; 1870 1871 case PSN_WIZFINISH: 1872 break; 1873 1874 case PSN_WIZNEXT: 1875 /* Handle a Next button click here */ 1876 hDialog = hwnd; 1877 success = TRUE; 1878 1879 /* Disable the buttons while we work. Sending CANCELTOCLOSE has 1880 the effect of disabling the cancel button, which is a) as we 1881 do everything synchronously we can't cancel, and b) the next 1882 step is 'finished', when it is too late to cancel anyway. 1883 The next step being 'Finished' means we also don't need to 1884 restore the button state back */ 1885 PropSheet_SetWizButtons(GetParent(hwnd), 0); 1886 SendMessage(GetParent(hwnd), PSM_CANCELTOCLOSE, 0, 0); 1887 /* Make sure the installation directory name ends in a */ 1888 /* backslash */ 1889 if (python_dir[strlen(python_dir)-1] != '\\') 1890 strcat(python_dir, "\\"); 1891 /* Strip the trailing backslash again */ 1892 python_dir[strlen(python_dir)-1] = '\0'; 1893 1894 CheckRootKey(hwnd); 1895 1896 if (!OpenLogfile(python_dir)) 1897 break; 1898 1898 1899 1899 /* … … 1916 1916 } 1917 1917 */ 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1918 scheme = GetScheme(py_major, py_minor); 1919 /* Run the pre-install script. */ 1920 if (pre_install_script && *pre_install_script) { 1921 SetDlgItemText (hwnd, IDC_TITLE, 1922 "Running pre-installation script"); 1923 run_simple_script(pre_install_script); 1924 } 1925 if (!success) { 1926 break; 1927 } 1928 /* Extract all files from the archive */ 1929 SetDlgItemText(hwnd, IDC_TITLE, "Installing files..."); 1930 if (!unzip_archive (scheme, 1931 python_dir, arc_data, 1932 arc_size, notify)) 1933 set_failure_reason("Failed to unzip installation files"); 1934 /* Compile the py-files */ 1935 if (success && pyc_compile) { 1936 int errors; 1937 HINSTANCE hPython; 1938 SetDlgItemText(hwnd, IDC_TITLE, 1939 "Compiling files to .pyc..."); 1940 1941 SetDlgItemText(hDialog, IDC_INFO, "Loading python..."); 1942 hPython = LoadPythonDll(pythondll); 1943 if (hPython) { 1944 errors = compile_filelist(hPython, FALSE); 1945 FreeLibrary(hPython); 1946 } 1947 /* Compilation errors are intentionally ignored: 1948 * Python2.0 contains a bug which will result 1949 * in sys.path containing garbage under certain 1950 * circumstances, and an error message will only 1951 * confuse the user. 1952 */ 1953 } 1954 if (success && pyo_compile) { 1955 int errors; 1956 HINSTANCE hPython; 1957 SetDlgItemText(hwnd, IDC_TITLE, 1958 "Compiling files to .pyo..."); 1959 1960 SetDlgItemText(hDialog, IDC_INFO, "Loading python..."); 1961 hPython = LoadPythonDll(pythondll); 1962 if (hPython) { 1963 errors = compile_filelist(hPython, TRUE); 1964 FreeLibrary(hPython); 1965 } 1966 /* Errors ignored: see above */ 1967 } 1968 1969 1970 break; 1971 1972 case PSN_RESET: 1973 break; 1974 1975 default: 1976 break; 1977 } 1978 } 1979 return 0; 1980 1980 } 1981 1981 … … 1984 1984 FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 1985 1985 { 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 1986 LPNMHDR lpnm; 1987 1988 switch (msg) { 1989 case WM_INITDIALOG: 1990 if (hBitmap) 1991 SendDlgItemMessage(hwnd, IDC_BITMAP, STM_SETIMAGE, 1992 IMAGE_BITMAP, (LPARAM)hBitmap); 1993 if (!success) 1994 SetDlgItemText(hwnd, IDC_INFO, get_failure_reason()); 1995 1996 /* async delay: will show the dialog box completely before 1997 the install_script is started */ 1998 PostMessage(hwnd, WM_USER, 0, 0L); 1999 return TRUE; 2000 2001 case WM_USER: 2002 2003 if (success && install_script && install_script[0]) { 2004 char fname[MAX_PATH]; 2005 char *buffer; 2006 HCURSOR hCursor; 2007 int result; 2008 2009 char *argv[3] = {NULL, "-install", NULL}; 2010 2011 SetDlgItemText(hwnd, IDC_TITLE, 2012 "Please wait while running postinstall script..."); 2013 strcpy(fname, python_dir); 2014 strcat(fname, "\\Scripts\\"); 2015 strcat(fname, install_script); 2016 2017 if (logfile) 2018 fprintf(logfile, "300 Run Script: [%s]%s\n", pythondll, fname); 2019 2020 hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); 2021 2022 argv[0] = fname; 2023 2024 result = run_installscript(fname, 2, argv, &buffer); 2025 if (0 != result) { 2026 fprintf(stderr, "*** run_installscript: internal error 0x%X ***\n", result); 2027 } 2028 if (buffer) 2029 SetDlgItemText(hwnd, IDC_INFO, buffer); 2030 SetDlgItemText(hwnd, IDC_TITLE, 2031 "Postinstall script finished.\n" 2032 "Click the Finish button to exit the Setup wizard."); 2033 2034 free(buffer); 2035 SetCursor(hCursor); 2036 CloseLogfile(); 2037 } 2038 2039 return TRUE; 2040 2041 case WM_NOTIFY: 2042 lpnm = (LPNMHDR) lParam; 2043 2044 switch (lpnm->code) { 2045 case PSN_SETACTIVE: /* Enable the Finish button */ 2046 PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_FINISH); 2047 break; 2048 2049 case PSN_WIZNEXT: 2050 break; 2051 2052 case PSN_WIZFINISH: 2053 break; 2054 2055 case PSN_RESET: 2056 break; 2057 2058 default: 2059 break; 2060 } 2061 } 2062 return 0; 2063 2063 } 2064 2064 2065 2065 void RunWizard(HWND hwnd) 2066 2066 { 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 psp.dwFlags =PSP_DEFAULT|PSP_HIDEHEADER;2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2067 PROPSHEETPAGE psp = {0}; 2068 HPROPSHEETPAGE ahpsp[4] = {0}; 2069 PROPSHEETHEADER psh = {0}; 2070 2071 /* Display module information */ 2072 psp.dwSize = sizeof(psp); 2073 psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; 2074 psp.hInstance = GetModuleHandle (NULL); 2075 psp.lParam = 0; 2076 psp.pfnDlgProc = IntroDlgProc; 2077 psp.pszTemplate = MAKEINTRESOURCE(IDD_INTRO); 2078 2079 ahpsp[0] = CreatePropertySheetPage(&psp); 2080 2081 /* Select python version to use */ 2082 psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; 2083 psp.pszTemplate = MAKEINTRESOURCE(IDD_SELECTPYTHON); 2084 psp.pfnDlgProc = SelectPythonDlgProc; 2085 2086 ahpsp[1] = CreatePropertySheetPage(&psp); 2087 2088 /* Install the files */ 2089 psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; 2090 psp.pszTemplate = MAKEINTRESOURCE(IDD_INSTALLFILES); 2091 psp.pfnDlgProc = InstallFilesDlgProc; 2092 2093 ahpsp[2] = CreatePropertySheetPage(&psp); 2094 2095 /* Show success or failure */ 2096 psp.dwFlags = PSP_DEFAULT|PSP_HIDEHEADER; 2097 psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHED); 2098 psp.pfnDlgProc = FinishedDlgProc; 2099 2100 ahpsp[3] = CreatePropertySheetPage(&psp); 2101 2102 /* Create the property sheet */ 2103 psh.dwSize = sizeof(psh); 2104 psh.hInstance = GetModuleHandle(NULL); 2105 psh.hwndParent = hwnd; 2106 psh.phpage = ahpsp; 2107 psh.dwFlags = PSH_WIZARD/*97*//*|PSH_WATERMARK|PSH_HEADER*/; 2108 psh.pszbmWatermark = NULL; 2109 psh.pszbmHeader = NULL; 2110 psh.nStartPage = 0; 2111 psh.nPages = 4; 2112 2113 PropertySheet(&psh); 2114 2114 } 2115 2115 … … 2119 2119 BOOL MyIsUserAnAdmin() 2120 2120 { 2121 2122 2123 2124 // This function isn't guaranteed to be available (and it can't hurt 2125 2126 2127 2128 2129 2130 2121 typedef BOOL (WINAPI *PFNIsUserAnAdmin)(); 2122 static PFNIsUserAnAdmin pfnIsUserAnAdmin = NULL; 2123 HMODULE shell32; 2124 // This function isn't guaranteed to be available (and it can't hurt 2125 // to leave the library loaded) 2126 if (0 == (shell32=LoadLibrary("shell32.dll"))) 2127 return FALSE; 2128 if (0 == (pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin"))) 2129 return FALSE; 2130 return (*pfnIsUserAnAdmin)(); 2131 2131 } 2132 2132 … … 2140 2140 BOOL NeedAutoUAC() 2141 2141 { 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, 2152 2153 2154 2155 2156 2142 HKEY hk; 2143 char key_name[80]; 2144 // no Python version info == we can't know yet. 2145 if (target_version[0] == '\0') 2146 return FALSE; 2147 // see how python is current installed 2148 wsprintf(key_name, 2149 "Software\\Python\\PythonCore\\%s\\InstallPath", 2150 target_version); 2151 if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, 2152 key_name, 0, KEY_READ, &hk)) 2153 return FALSE; 2154 RegCloseKey(hk); 2155 // Python is installed in HKLM - we must elevate. 2156 return TRUE; 2157 2157 } 2158 2158 … … 2160 2160 BOOL PlatformSupportsUAC() 2161 2161 { 2162 2163 2164 2165 2166 2167 2168 2169 2170 bIsWindowsXPorLater = 2162 // Note that win2k does seem to support ShellExecute with 'runas', 2163 // but does *not* support IsUserAnAdmin - so we just pretend things 2164 // only work on XP and later. 2165 BOOL bIsWindowsXPorLater; 2166 OSVERSIONINFO winverinfo; 2167 winverinfo.dwOSVersionInfoSize = sizeof(winverinfo); 2168 if (!GetVersionEx(&winverinfo)) 2169 return FALSE; // something bad has gone wrong 2170 bIsWindowsXPorLater = 2171 2171 ( (winverinfo.dwMajorVersion > 5) || 2172 2172 ( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) )); 2173 2173 return bIsWindowsXPorLater; 2174 2174 } 2175 2175 … … 2179 2179 void SpawnUAC() 2180 2180 { 2181 2182 2183 2184 int ret = (int)ShellExecute(0, "runas", modulename, "", NULL, 2185 2186 2187 2188 2189 2190 2181 // interesting failure scenario that has been seen: initial executable 2182 // runs from a network drive - but once elevated, that network share 2183 // isn't seen, and ShellExecute fails with SE_ERR_ACCESSDENIED. 2184 int ret = (int)ShellExecute(0, "runas", modulename, "", NULL, 2185 SW_SHOWNORMAL); 2186 if (ret <= 32) { 2187 char msg[128]; 2188 wsprintf(msg, "Failed to start elevated process (ShellExecute returned %d)", ret); 2189 MessageBox(0, msg, "Setup", MB_OK | MB_ICONERROR); 2190 } 2191 2191 } 2192 2192 2193 2193 int DoInstall(void) 2194 2194 { 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2195 char ini_buffer[4096]; 2196 2197 /* Read installation information */ 2198 GetPrivateProfileString("Setup", "title", "", ini_buffer, 2199 sizeof(ini_buffer), ini_file); 2200 unescape(title, ini_buffer, sizeof(title)); 2201 2202 GetPrivateProfileString("Setup", "info", "", ini_buffer, 2203 sizeof(ini_buffer), ini_file); 2204 unescape(info, ini_buffer, sizeof(info)); 2205 2206 GetPrivateProfileString("Setup", "build_info", "", build_info, 2207 sizeof(build_info), ini_file); 2208 2209 pyc_compile = GetPrivateProfileInt("Setup", "target_compile", 1, 2210 ini_file); 2211 pyo_compile = GetPrivateProfileInt("Setup", "target_optimize", 1, 2212 ini_file); 2213 2214 GetPrivateProfileString("Setup", "target_version", "", 2215 target_version, sizeof(target_version), 2216 ini_file); 2217 2218 GetPrivateProfileString("metadata", "name", "", 2219 meta_name, sizeof(meta_name), 2220 ini_file); 2221 2222 GetPrivateProfileString("Setup", "install_script", "", 2223 install_script, sizeof(install_script), 2224 ini_file); 2225 2226 GetPrivateProfileString("Setup", "user_access_control", "", 2227 user_access_control, sizeof(user_access_control), ini_file); 2228 2229 // See if we need to do the Vista UAC magic. 2230 if (strcmp(user_access_control, "force")==0) { 2231 if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) { 2232 SpawnUAC(); 2233 return 0; 2234 } 2235 // already admin - keep going 2236 } else if (strcmp(user_access_control, "auto")==0) { 2237 // Check if it looks like we need UAC control, based 2238 // on how Python itself was installed. 2239 if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) { 2240 SpawnUAC(); 2241 return 0; 2242 } 2243 } else { 2244 // display a warning about unknown values - only the developer 2245 // of the extension will see it (until they fix it!) 2246 if (user_access_control[0] && strcmp(user_access_control, "none") != 0) { 2247 MessageBox(GetFocus(), "Bad user_access_control value", "oops", MB_OK); 2248 // nothing to do. 2249 } 2250 } 2251 2252 hwndMain = CreateBackground(title); 2253 2254 RunWizard(hwndMain); 2255 2256 /* Clean up */ 2257 UnmapViewOfFile(arc_data); 2258 if (ini_file) 2259 DeleteFile(ini_file); 2260 2261 if (hBitmap) 2262 DeleteObject(hBitmap); 2263 2264 return 0; 2265 2265 } 2266 2266 … … 2269 2269 static int compare(const void *p1, const void *p2) 2270 2270 { 2271 2271 return strcmp(*(char **)p2, *(char **)p1); 2272 2272 } 2273 2273 … … 2283 2283 void remove_exe(void) 2284 2284 { 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2285 char exename[_MAX_PATH]; 2286 char batname[_MAX_PATH]; 2287 FILE *fp; 2288 STARTUPINFO si; 2289 PROCESS_INFORMATION pi; 2290 2291 GetModuleFileName(NULL, exename, sizeof(exename)); 2292 sprintf(batname, "%s.bat", exename); 2293 fp = fopen(batname, "w"); 2294 fprintf(fp, ":Repeat\n"); 2295 fprintf(fp, "del \"%s\"\n", exename); 2296 fprintf(fp, "if exist \"%s\" goto Repeat\n", exename); 2297 fprintf(fp, "del \"%s\"\n", batname); 2298 fclose(fp); 2299 2300 ZeroMemory(&si, sizeof(si)); 2301 si.cb = sizeof(si); 2302 si.dwFlags = STARTF_USESHOWWINDOW; 2303 si.wShowWindow = SW_HIDE; 2304 if (CreateProcess(NULL, 2305 batname, 2306 NULL, 2307 NULL, 2308 FALSE, 2309 CREATE_SUSPENDED | IDLE_PRIORITY_CLASS, 2310 NULL, 2311 "\\", 2312 &si, 2313 &pi)) { 2314 SetThreadPriority(pi.hThread, THREAD_PRIORITY_IDLE); 2315 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); 2316 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 2317 CloseHandle(pi.hProcess); 2318 ResumeThread(pi.hThread); 2319 CloseHandle(pi.hThread); 2320 } 2321 2321 } 2322 2322 2323 2323 void DeleteRegistryKey(char *string) 2324 2324 { 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2325 char *keyname; 2326 char *subkeyname; 2327 char *delim; 2328 HKEY hKey; 2329 long result; 2330 char *line; 2331 2332 line = strdup(string); /* so we can change it */ 2333 2334 keyname = strchr(line, '['); 2335 if (!keyname) 2336 return; 2337 ++keyname; 2338 2339 subkeyname = strchr(keyname, ']'); 2340 if (!subkeyname) 2341 return; 2342 *subkeyname++='\0'; 2343 delim = strchr(subkeyname, '\n'); 2344 if (delim) 2345 *delim = '\0'; 2346 2347 result = RegOpenKeyEx(hkey_root, 2348 keyname, 2349 0, 2350 KEY_WRITE, 2351 &hKey); 2352 2353 if (result != ERROR_SUCCESS) 2354 MessageBox(GetFocus(), string, "Could not open key", MB_OK); 2355 else { 2356 result = RegDeleteKey(hKey, subkeyname); 2357 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) 2358 MessageBox(GetFocus(), string, "Could not delete key", MB_OK); 2359 RegCloseKey(hKey); 2360 } 2361 free(line); 2362 2362 } 2363 2363 2364 2364 void DeleteRegistryValue(char *string) 2365 2365 { 2366 2367 2368 2369 2370 2371 2372 2373 2366 char *keyname; 2367 char *valuename; 2368 char *value; 2369 HKEY hKey; 2370 long result; 2371 char *line; 2372 2373 line = strdup(string); /* so we can change it */ 2374 2374 2375 2375 /* Format is 'Reg DB Value: [key]name=value' */ 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2376 keyname = strchr(line, '['); 2377 if (!keyname) 2378 return; 2379 ++keyname; 2380 valuename = strchr(keyname, ']'); 2381 if (!valuename) 2382 return; 2383 *valuename++ = '\0'; 2384 value = strchr(valuename, '='); 2385 if (!value) 2386 return; 2387 2388 *value++ = '\0'; 2389 2390 result = RegOpenKeyEx(hkey_root, 2391 keyname, 2392 0, 2393 KEY_WRITE, 2394 &hKey); 2395 if (result != ERROR_SUCCESS) 2396 MessageBox(GetFocus(), string, "Could not open key", MB_OK); 2397 else { 2398 result = RegDeleteValue(hKey, valuename); 2399 if (result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) 2400 MessageBox(GetFocus(), string, "Could not delete value", MB_OK); 2401 RegCloseKey(hKey); 2402 } 2403 free(line); 2404 2404 } 2405 2405 2406 2406 BOOL MyDeleteFile(char *line) 2407 2407 { 2408 2409 2410 2411 2412 2413 2414 2408 char *pathname = strchr(line, ':'); 2409 if (!pathname) 2410 return FALSE; 2411 ++pathname; 2412 while (isspace(*pathname)) 2413 ++pathname; 2414 return DeleteFile(pathname); 2415 2415 } 2416 2416 2417 2417 BOOL MyRemoveDirectory(char *line) 2418 2418 { 2419 2420 2421 2422 2423 2424 2425 2419 char *pathname = strchr(line, ':'); 2420 if (!pathname) 2421 return FALSE; 2422 ++pathname; 2423 while (isspace(*pathname)) 2424 ++pathname; 2425 return RemoveDirectory(pathname); 2426 2426 } 2427 2427 2428 2428 BOOL Run_RemoveScript(char *line) 2429 2429 { 2430 2431 2432 2430 char *dllname; 2431 char *scriptname; 2432 static char lastscript[MAX_PATH]; 2433 2433 2434 2434 /* Format is 'Run Scripts: [pythondll]scriptname' */ 2435 2435 /* XXX Currently, pythondll carries no path!!! */ 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2436 dllname = strchr(line, '['); 2437 if (!dllname) 2438 return FALSE; 2439 ++dllname; 2440 scriptname = strchr(dllname, ']'); 2441 if (!scriptname) 2442 return FALSE; 2443 *scriptname++ = '\0'; 2444 /* this function may be called more than one time with the same 2445 script, only run it one time */ 2446 if (strcmp(lastscript, scriptname)) { 2447 char *argv[3] = {NULL, "-remove", NULL}; 2448 char *buffer = NULL; 2449 2450 argv[0] = scriptname; 2451 2452 if (0 != run_installscript(scriptname, 2, argv, &buffer)) 2453 fprintf(stderr, "*** Could not run installation script ***"); 2454 2455 if (buffer && buffer[0]) 2456 MessageBox(GetFocus(), buffer, "uninstall-script", MB_OK); 2457 free(buffer); 2458 2459 strcpy(lastscript, scriptname); 2460 } 2461 return TRUE; 2462 2462 } 2463 2463 2464 2464 int DoUninstall(int argc, char **argv) 2465 2465 { 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2466 FILE *logfile; 2467 char buffer[4096]; 2468 int nLines = 0; 2469 int i; 2470 char *cp; 2471 int nFiles = 0; 2472 int nDirs = 0; 2473 int nErrors = 0; 2474 char **lines; 2475 int lines_buffer_size = 10; 2476 2477 if (argc != 3) { 2478 MessageBox(NULL, 2479 "Wrong number of args", 2480 NULL, 2481 MB_OK); 2482 return 1; /* Error */ 2483 } 2484 if (strcmp(argv[1], "-u")) { 2485 MessageBox(NULL, 2486 "2. arg is not -u", 2487 NULL, 2488 MB_OK); 2489 return 1; /* Error */ 2490 } 2491 2492 logfile = fopen(argv[2], "r"); 2493 if (!logfile) { 2494 MessageBox(NULL, 2495 "could not open logfile", 2496 NULL, 2497 MB_OK); 2498 return 1; /* Error */ 2499 } 2500 2501 lines = (char **)malloc(sizeof(char *) * lines_buffer_size); 2502 if (!lines) 2503 return SystemError(0, "Out of memory"); 2504 2505 /* Read the whole logfile, realloacting the buffer */ 2506 while (fgets(buffer, sizeof(buffer), logfile)) { 2507 int len = strlen(buffer); 2508 /* remove trailing white space */ 2509 while (isspace(buffer[len-1])) 2510 len -= 1; 2511 buffer[len] = '\0'; 2512 lines[nLines++] = strdup(buffer); 2513 if (nLines >= lines_buffer_size) { 2514 lines_buffer_size += 10; 2515 lines = (char **)realloc(lines, 2516 sizeof(char *) * lines_buffer_size); 2517 if (!lines) 2518 return SystemError(0, "Out of memory"); 2519 } 2520 } 2521 fclose(logfile); 2522 2523 /* Sort all the lines, so that highest 3-digit codes are first */ 2524 qsort(&lines[0], nLines, sizeof(char *), 2525 compare); 2526 2527 if (IDYES != MessageBox(NULL, 2528 "Are you sure you want to remove\n" 2529 "this package from your computer?", 2530 "Please confirm", 2531 MB_YESNO | MB_ICONQUESTION)) 2532 return 0; 2533 2534 hkey_root = HKEY_LOCAL_MACHINE; 2535 cp = ""; 2536 for (i = 0; i < nLines; ++i) { 2537 /* Ignore duplicate lines */ 2538 if (strcmp(cp, lines[i])) { 2539 int ign; 2540 cp = lines[i]; 2541 /* Parse the lines */ 2542 if (2 == sscanf(cp, "%d Root Key: %s", &ign, &buffer)) { 2543 if (strcmp(buffer, "HKEY_CURRENT_USER")==0) 2544 hkey_root = HKEY_CURRENT_USER; 2545 else { 2546 // HKLM - check they have permissions. 2547 if (!HasLocalMachinePrivs()) { 2548 MessageBox(GetFocus(), 2549 "You do not seem to have sufficient access rights\n" 2550 "on this machine to uninstall this software", 2551 NULL, 2552 MB_OK | MB_ICONSTOP); 2553 return 1; /* Error */ 2554 } 2555 } 2556 } else if (2 == sscanf(cp, "%d Made Dir: %s", &ign, &buffer)) { 2557 if (MyRemoveDirectory(cp)) 2558 ++nDirs; 2559 else { 2560 int code = GetLastError(); 2561 if (code != 2 && code != 3) { /* file or path not found */ 2562 ++nErrors; 2563 } 2564 } 2565 } else if (2 == sscanf(cp, "%d File Copy: %s", &ign, &buffer)) { 2566 if (MyDeleteFile(cp)) 2567 ++nFiles; 2568 else { 2569 int code = GetLastError(); 2570 if (code != 2 && code != 3) { /* file or path not found */ 2571 ++nErrors; 2572 } 2573 } 2574 } else if (2 == sscanf(cp, "%d File Overwrite: %s", &ign, &buffer)) { 2575 if (MyDeleteFile(cp)) 2576 ++nFiles; 2577 else { 2578 int code = GetLastError(); 2579 if (code != 2 && code != 3) { /* file or path not found */ 2580 ++nErrors; 2581 } 2582 } 2583 } else if (2 == sscanf(cp, "%d Reg DB Key: %s", &ign, &buffer)) { 2584 DeleteRegistryKey(cp); 2585 } else if (2 == sscanf(cp, "%d Reg DB Value: %s", &ign, &buffer)) { 2586 DeleteRegistryValue(cp); 2587 } else if (2 == sscanf(cp, "%d Run Script: %s", &ign, &buffer)) { 2588 Run_RemoveScript(cp); 2589 } 2590 } 2591 } 2592 2593 if (DeleteFile(argv[2])) { 2594 ++nFiles; 2595 } else { 2596 ++nErrors; 2597 SystemError(GetLastError(), argv[2]); 2598 } 2599 if (nErrors) 2600 wsprintf(buffer, 2601 "%d files and %d directories removed\n" 2602 "%d files or directories could not be removed", 2603 nFiles, nDirs, nErrors); 2604 else 2605 wsprintf(buffer, "%d files and %d directories removed", 2606 nFiles, nDirs); 2607 MessageBox(NULL, buffer, "Uninstall Finished!", 2608 MB_OK | MB_ICONINFORMATION); 2609 remove_exe(); 2610 return 0; 2611 2611 } 2612 2612 2613 2613 int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, 2614 2615 { 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 } 2614 LPSTR lpszCmdLine, INT nCmdShow) 2615 { 2616 extern int __argc; 2617 extern char **__argv; 2618 char *basename; 2619 2620 GetModuleFileName(NULL, modulename, sizeof(modulename)); 2621 2622 /* Map the executable file to memory */ 2623 arc_data = MapExistingFile(modulename, &arc_size); 2624 if (!arc_data) { 2625 SystemError(GetLastError(), "Could not open archive"); 2626 return 1; 2627 } 2628 2629 /* OK. So this program can act as installer (self-extracting 2630 * zip-file, or as uninstaller when started with '-u logfile' 2631 * command line flags. 2632 * 2633 * The installer is usually started without command line flags, 2634 * and the uninstaller is usually started with the '-u logfile' 2635 * flag. What to do if some innocent user double-clicks the 2636 * exe-file? 2637 * The following implements a defensive strategy... 2638 */ 2639 2640 /* Try to extract the configuration data into a temporary file */ 2641 if (ExtractInstallData(arc_data, arc_size, &exe_size, 2642 &ini_file, &pre_install_script)) 2643 return DoInstall(); 2644 2645 if (!ini_file && __argc > 1) { 2646 return DoUninstall(__argc, __argv); 2647 } 2648 2649 2650 basename = strrchr(modulename, '\\'); 2651 if (basename) 2652 ++basename; 2653 2654 /* Last guess about the purpose of this program */ 2655 if (basename && (0 == strncmp(basename, "Remove", 6))) 2656 SystemError(0, "This program is normally started by windows"); 2657 else 2658 SystemError(0, "Setup program invalid or damaged"); 2659 return 1; 2660 } -
python/vendor/current/PC/config.c
r2 r388 53 53 extern void init_struct(void); 54 54 extern void initdatetime(void); 55 extern void init_fileio(void);56 extern void init_bytesio(void);57 55 extern void init_functools(void); 58 56 extern void init_json(void); … … 69 67 extern void init_lsprof(void); 70 68 extern void init_ast(void); 69 extern void init_io(void); 71 70 extern void _PyWarnings_Init(void); 72 71 … … 79 78 struct _inittab _PyImport_Inittab[] = { 80 79 81 82 80 {"array", initarray}, 81 {"_ast", init_ast}, 83 82 #ifdef MS_WINDOWS 84 83 #ifndef MS_WINI64 85 84 {"audioop", initaudioop}, 86 85 #endif 87 86 #endif 88 89 90 91 92 87 {"binascii", initbinascii}, 88 {"cmath", initcmath}, 89 {"errno", initerrno}, 90 {"future_builtins", initfuture_builtins}, 91 {"gc", initgc}, 93 92 #ifndef MS_WINI64 94 93 {"imageop", initimageop}, 95 94 #endif 96 97 98 99 100 101 102 103 104 105 95 {"math", initmath}, 96 {"_md5", init_md5}, 97 {"nt", initnt}, /* Use the NT os functions, not posix */ 98 {"operator", initoperator}, 99 {"signal", initsignal}, 100 {"_sha", init_sha}, 101 {"_sha256", init_sha256}, 102 {"_sha512", init_sha512}, 103 {"strop", initstrop}, 104 {"time", inittime}, 106 105 #ifdef WITH_THREAD 107 106 {"thread", initthread}, 108 107 #endif 109 110 108 {"cStringIO", initcStringIO}, 109 {"cPickle", initcPickle}, 111 110 #ifdef WIN32 112 113 111 {"msvcrt", initmsvcrt}, 112 {"_locale", init_locale}, 114 113 #endif 115 116 114 /* XXX Should _subprocess go in a WIN32 block? not WIN64? */ 115 {"_subprocess", init_subprocess}, 117 116 118 {"_codecs", init_codecs}, 119 {"_weakref", init_weakref}, 120 {"_hotshot", init_hotshot}, 121 {"_random", init_random}, 122 {"_bisect", init_bisect}, 123 {"_heapq", init_heapq}, 124 {"_lsprof", init_lsprof}, 125 {"itertools", inititertools}, 126 {"_collections", init_collections}, 127 {"_symtable", init_symtable}, 128 {"mmap", initmmap}, 129 {"_csv", init_csv}, 130 {"_sre", init_sre}, 131 {"parser", initparser}, 132 {"_winreg", init_winreg}, 133 {"_struct", init_struct}, 134 {"datetime", initdatetime}, 135 {"_fileio", init_fileio}, 136 {"_bytesio", init_bytesio}, 137 {"_functools", init_functools}, 138 {"_json", init_json}, 117 {"_codecs", init_codecs}, 118 {"_weakref", init_weakref}, 119 {"_hotshot", init_hotshot}, 120 {"_random", init_random}, 121 {"_bisect", init_bisect}, 122 {"_heapq", init_heapq}, 123 {"_lsprof", init_lsprof}, 124 {"itertools", inititertools}, 125 {"_collections", init_collections}, 126 {"_symtable", init_symtable}, 127 {"mmap", initmmap}, 128 {"_csv", init_csv}, 129 {"_sre", init_sre}, 130 {"parser", initparser}, 131 {"_winreg", init_winreg}, 132 {"_struct", init_struct}, 133 {"datetime", initdatetime}, 134 {"_functools", init_functools}, 135 {"_json", init_json}, 139 136 140 141 142 143 144 145 146 147 148 149 150 151 137 {"xxsubtype", initxxsubtype}, 138 {"zipimport", initzipimport}, 139 {"zlib", initzlib}, 140 141 /* CJK codecs */ 142 {"_multibytecodec", init_multibytecodec}, 143 {"_codecs_cn", init_codecs_cn}, 144 {"_codecs_hk", init_codecs_hk}, 145 {"_codecs_iso2022", init_codecs_iso2022}, 146 {"_codecs_jp", init_codecs_jp}, 147 {"_codecs_kr", init_codecs_kr}, 148 {"_codecs_tw", init_codecs_tw}, 152 149 153 150 /* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ 154 151 /* -- ADDMODULE MARKER 2 -- */ 155 152 156 157 153 /* This module "lives in" with marshal.c */ 154 {"marshal", PyMarshal_Init}, 158 155 159 160 156 /* This lives it with import.c */ 157 {"imp", initimp}, 161 158 162 163 164 165 166 167 159 /* These entries are here for sys.builtin_module_names */ 160 {"__main__", NULL}, 161 {"__builtin__", NULL}, 162 {"sys", NULL}, 163 {"exceptions", NULL}, 164 {"_warnings", _PyWarnings_Init}, 168 165 169 /* Sentinel */ 170 {0, 0} 166 {"_io", init_io}, 167 168 /* Sentinel */ 169 {0, 0} 171 170 }; -
python/vendor/current/PC/dl_nt.c
r2 r388 4 4 5 5 About the only reason for having this, is so initall() can automatically 6 be called, removing that burden (and possible source of frustration if 6 be called, removing that burden (and possible source of frustration if 7 7 forgotten) from the programmer. 8 8 … … 47 47 void _LoadActCtxPointers() 48 48 { 49 50 51 52 53 54 55 56 57 58 49 HINSTANCE hKernel32 = GetModuleHandleW(L"kernel32.dll"); 50 if (hKernel32) 51 pfnGetCurrentActCtx = (PFN_GETCURRENTACTCTX) GetProcAddress(hKernel32, "GetCurrentActCtx"); 52 // If we can't load GetCurrentActCtx (ie, pre XP) , don't bother with the rest. 53 if (pfnGetCurrentActCtx) { 54 pfnActivateActCtx = (PFN_ACTIVATEACTCTX) GetProcAddress(hKernel32, "ActivateActCtx"); 55 pfnDeactivateActCtx = (PFN_DEACTIVATEACTCTX) GetProcAddress(hKernel32, "DeactivateActCtx"); 56 pfnAddRefActCtx = (PFN_ADDREFACTCTX) GetProcAddress(hKernel32, "AddRefActCtx"); 57 pfnReleaseActCtx = (PFN_RELEASEACTCTX) GetProcAddress(hKernel32, "ReleaseActCtx"); 58 } 59 59 } 60 60 61 61 ULONG_PTR _Py_ActivateActCtx() 62 62 { 63 64 65 66 67 68 69 63 ULONG_PTR ret = 0; 64 if (PyWin_DLLhActivationContext && pfnActivateActCtx) 65 if (!(*pfnActivateActCtx)(PyWin_DLLhActivationContext, &ret)) { 66 OutputDebugString("Python failed to activate the activation context before loading a DLL\n"); 67 ret = 0; // no promise the failing function didn't change it! 68 } 69 return ret; 70 70 } 71 71 72 72 void _Py_DeactivateActCtx(ULONG_PTR cookie) 73 73 { 74 75 76 74 if (cookie && pfnDeactivateActCtx) 75 if (!(*pfnDeactivateActCtx)(0, cookie)) 76 OutputDebugString("Python failed to de-activate the activation context\n"); 77 77 } 78 78 79 BOOL WINAPI DllMain (HANDLE hInst,80 81 79 BOOL WINAPI DllMain (HANDLE hInst, 80 ULONG ul_reason_for_call, 81 LPVOID lpReserved) 82 82 { 83 84 85 86 87 88 83 switch (ul_reason_for_call) 84 { 85 case DLL_PROCESS_ATTACH: 86 PyWin_DLLhModule = hInst; 87 // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... 88 LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); 89 89 90 91 92 93 94 95 96 90 // and capture our activation context for use when loading extensions. 91 _LoadActCtxPointers(); 92 if (pfnGetCurrentActCtx && pfnAddRefActCtx) 93 if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) 94 if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) 95 OutputDebugString("Python failed to load the default activation context\n"); 96 break; 97 97 98 99 100 101 102 103 98 case DLL_PROCESS_DETACH: 99 if (pfnReleaseActCtx) 100 (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); 101 break; 102 } 103 return TRUE; 104 104 } 105 105 -
python/vendor/current/PC/errmap.h
r2 r388 2 2 int winerror_to_errno(int winerror) 3 3 { 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 4 switch(winerror) { 5 case 2: return 2; 6 case 3: return 2; 7 case 4: return 24; 8 case 5: return 13; 9 case 6: return 9; 10 case 7: return 12; 11 case 8: return 12; 12 case 9: return 12; 13 case 10: return 7; 14 case 11: return 8; 15 case 15: return 2; 16 case 16: return 13; 17 case 17: return 18; 18 case 18: return 2; 19 case 19: return 13; 20 case 20: return 13; 21 case 21: return 13; 22 case 22: return 13; 23 case 23: return 13; 24 case 24: return 13; 25 case 25: return 13; 26 case 26: return 13; 27 case 27: return 13; 28 case 28: return 13; 29 case 29: return 13; 30 case 30: return 13; 31 case 31: return 13; 32 case 32: return 13; 33 case 33: return 13; 34 case 34: return 13; 35 case 35: return 13; 36 case 36: return 13; 37 case 53: return 2; 38 case 65: return 13; 39 case 67: return 2; 40 case 80: return 17; 41 case 82: return 13; 42 case 83: return 13; 43 case 89: return 11; 44 case 108: return 13; 45 case 109: return 32; 46 case 112: return 28; 47 case 114: return 9; 48 case 128: return 10; 49 case 129: return 10; 50 case 130: return 9; 51 case 132: return 13; 52 case 145: return 41; 53 case 158: return 13; 54 case 161: return 2; 55 case 164: return 11; 56 case 167: return 13; 57 case 183: return 17; 58 case 188: return 8; 59 case 189: return 8; 60 case 190: return 8; 61 case 191: return 8; 62 case 192: return 8; 63 case 193: return 8; 64 case 194: return 8; 65 case 195: return 8; 66 case 196: return 8; 67 case 197: return 8; 68 case 198: return 8; 69 case 199: return 8; 70 case 200: return 8; 71 case 201: return 8; 72 case 202: return 8; 73 case 206: return 2; 74 case 215: return 11; 75 case 1816: return 12; 76 default: return EINVAL; 77 } 78 78 } -
python/vendor/current/PC/example_nt/example.vcproj
r2 r388 40 40 Name="VCLinkerTool" 41 41 AdditionalOptions="/export:initexample" 42 AdditionalDependencies="odbc32.lib odbccp32.lib python2 6.lib"42 AdditionalDependencies="odbc32.lib odbccp32.lib python27.lib" 43 43 OutputFile=".\Release/example.pyd" 44 44 LinkIncremental="1" … … 106 106 Name="VCLinkerTool" 107 107 AdditionalOptions="/export:initexample" 108 AdditionalDependencies="odbc32.lib odbccp32.lib python2 6_d.lib"108 AdditionalDependencies="odbc32.lib odbccp32.lib python27_d.lib" 109 109 OutputFile=".\Debug/example_d.pyd" 110 110 LinkIncremental="1" -
python/vendor/current/PC/frozen_dllmain.c
r2 r388 10 10 The solution is: 11 11 * Each module checks for a frozen build, and if so, defines its DLLMain 12 function as "__declspec(dllexport) DllMain%module%" 12 function as "__declspec(dllexport) DllMain%module%" 13 13 (eg, DllMainpythoncom, or DllMainpywintypes) 14 14 … … 48 48 49 49 static char *possibleModules[] = { 50 51 52 53 50 "pywintypes", 51 "pythoncom", 52 "win32ui", 53 NULL, 54 54 }; 55 55 … … 63 63 void PyWinFreeze_ExeInit(void) 64 64 { 65 66 67 /* 68 69 65 char **modName; 66 for (modName = possibleModules;*modName;*modName++) { 67 /* printf("Initialising '%s'\n", *modName); */ 68 CallModuleDllMain(*modName, DLL_PROCESS_ATTACH); 69 } 70 70 } 71 71 72 72 /* 73 73 Called by a frozen .EXE only, so that built-in extension 74 modules are cleaned up 74 modules are cleaned up 75 75 */ 76 76 void PyWinFreeze_ExeTerm(void) 77 77 { 78 79 80 81 82 83 /* 84 85 78 // Must go backwards 79 char **modName; 80 for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2; 81 modName >= possibleModules; 82 *modName--) { 83 /* printf("Terminating '%s'\n", *modName);*/ 84 CallModuleDllMain(*modName, DLL_PROCESS_DETACH); 85 } 86 86 } 87 87 88 88 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 89 89 { 90 91 92 case DLL_PROCESS_ATTACH: 93 94 95 96 97 98 99 100 101 102 case DLL_PROCESS_DETACH: 103 104 105 106 107 108 109 110 111 112 113 90 BOOL ret = TRUE; 91 switch (dwReason) { 92 case DLL_PROCESS_ATTACH: 93 { 94 char **modName; 95 for (modName = possibleModules;*modName;*modName++) { 96 BOOL ok = CallModuleDllMain(*modName, dwReason); 97 if (!ok) 98 ret = FALSE; 99 } 100 break; 101 } 102 case DLL_PROCESS_DETACH: 103 { 104 // Must go backwards 105 char **modName; 106 for (modName = possibleModules+(sizeof(possibleModules) / sizeof(char *))-2; 107 modName >= possibleModules; 108 *modName--) 109 CallModuleDllMain(*modName, DLL_PROCESS_DETACH); 110 break; 111 } 112 } 113 return ret; 114 114 } 115 115 116 116 BOOL CallModuleDllMain(char *modName, DWORD dwReason) 117 117 { 118 118 BOOL (WINAPI * pfndllmain)(HINSTANCE, DWORD, LPVOID); 119 119 120 121 122 123 124 125 126 127 128 129 130 131 132 120 char funcName[255]; 121 HMODULE hmod = GetModuleHandle(NULL); 122 strcpy(funcName, "_DllMain"); 123 strcat(funcName, modName); 124 strcat(funcName, "@12"); // stdcall convention. 125 pfndllmain = (BOOL (WINAPI *)(HINSTANCE, DWORD, LPVOID))GetProcAddress(hmod, funcName); 126 if (pfndllmain==NULL) { 127 /* No function by that name exported - then that module does 128 not appear in our frozen program - return OK 129 */ 130 return TRUE; 131 } 132 return (*pfndllmain)(hmod, dwReason, NULL); 133 133 } 134 134 -
python/vendor/current/PC/generrmap.c
r2 r388 6 6 int main() 7 7 { 8 9 10 11 12 13 14 15 16 17 18 19 8 int i; 9 printf("/* Generated file. Do not edit. */\n"); 10 printf("int winerror_to_errno(int winerror)\n"); 11 printf("{\n\tswitch(winerror) {\n"); 12 for(i=1; i < 65000; i++) { 13 _dosmaperr(i); 14 if (errno == EINVAL) 15 continue; 16 printf("\t\tcase %d: return %d;\n", i, errno); 17 } 18 printf("\t\tdefault: return EINVAL;\n"); 19 printf("\t}\n}\n"); 20 20 } -
python/vendor/current/PC/getpathp.c
r2 r388 5 5 /* ---------------------------------------------------------------- 6 6 PATH RULES FOR WINDOWS: 7 This describes how sys.path is formed on Windows. It describes the 8 functionality, not the implementation (ie, the order in which these 7 This describes how sys.path is formed on Windows. It describes the 8 functionality, not the implementation (ie, the order in which these 9 9 are actually fetched is different) 10 10 … … 25 25 is set, we believe it. Otherwise, we use the path of our host .EXE's 26 26 to try and locate our "landmark" (lib\\os.py) and deduce our home. 27 - If we DO have a Python Home: The relevant sub-directories (Lib, 27 - If we DO have a Python Home: The relevant sub-directories (Lib, 28 28 plat-win, lib-tk, etc) are based on the Python Home 29 29 - If we DO NOT have a Python Home, the core Python Path is 30 loaded from the registry. This is the main PythonPath key, 30 loaded from the registry. This is the main PythonPath key, 31 31 and both HKLM and HKCU are combined to form the path) 32 32 33 33 * Iff - we can not locate the Python Home, have not had a PYTHONPATH 34 34 specified, and can't locate any Registry entries (ie, we have _nothing_ 35 we can assume is a good path), a default path with relative entries is 35 we can assume is a good path), a default path with relative entries is 36 36 used (eg. .\Lib;.\plat-win, etc) 37 37 … … 43 43 ignored. Other "application paths" in the registry are always read. 44 44 45 * When Python is hosted in another exe (different directory, embedded via 45 * When Python is hosted in another exe (different directory, embedded via 46 46 COM, etc), the Python Home will not be deduced, so the core path from 47 the registry is used. Other "application paths" in the registry are 47 the registry is used. Other "application paths" in the registry are 48 48 always read. 49 49 … … 93 93 94 94 static int 95 is_sep(char ch) 95 is_sep(char ch) /* determine if "ch" is a separator character */ 96 96 { 97 97 #ifdef ALTSEP 98 98 return ch == SEP || ch == ALTSEP; 99 99 #else 100 100 return ch == SEP; 101 101 #endif 102 102 } … … 108 108 reduce(char *dir) 109 109 { 110 111 112 113 114 } 115 110 size_t i = strlen(dir); 111 while (i > 0 && !is_sep(dir[i])) 112 --i; 113 dir[i] = '\0'; 114 } 115 116 116 117 117 static int 118 118 exists(char *filename) 119 119 { 120 121 122 } 123 124 /* Assumes 'filename' MAXPATHLEN+1 bytes long - 120 struct stat buf; 121 return stat(filename, &buf) == 0; 122 } 123 124 /* Assumes 'filename' MAXPATHLEN+1 bytes long - 125 125 may extend 'filename' by one character. 126 126 */ 127 127 static int 128 ismodule(char *filename) 129 { 130 131 132 133 134 135 136 137 138 139 128 ismodule(char *filename) /* Is module -- check for .pyc/.pyo too */ 129 { 130 if (exists(filename)) 131 return 1; 132 133 /* Check for the compiled version of prefix. */ 134 if (strlen(filename) < MAXPATHLEN) { 135 strcat(filename, Py_OptimizeFlag ? "o" : "c"); 136 if (exists(filename)) 137 return 1; 138 } 139 return 0; 140 140 } 141 141 … … 152 152 join(char *buffer, char *stuff) 153 153 { 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 154 size_t n, k; 155 if (is_sep(stuff[0])) 156 n = 0; 157 else { 158 n = strlen(buffer); 159 if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) 160 buffer[n++] = SEP; 161 } 162 if (n > MAXPATHLEN) 163 Py_FatalError("buffer overflow in getpathp.c's joinpath()"); 164 k = strlen(stuff); 165 if (n + k > MAXPATHLEN) 166 k = MAXPATHLEN - n; 167 strncpy(buffer+n, stuff, k); 168 buffer[n+k] = '\0'; 169 169 } 170 170 … … 176 176 gotlandmark(char *landmark) 177 177 { 178 179 180 181 182 183 184 185 186 } 187 188 /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. 178 int ok; 179 Py_ssize_t n; 180 181 n = strlen(prefix); 182 join(prefix, landmark); 183 ok = ismodule(prefix); 184 prefix[n] = '\0'; 185 return ok; 186 } 187 188 /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. 189 189 assumption provided by only caller, calculate_path() */ 190 190 static int 191 191 search_for_prefix(char *argv0_path, char *landmark) 192 192 { 193 194 195 196 197 198 199 200 193 /* Search from argv0_path, until landmark is found */ 194 strcpy(prefix, argv0_path); 195 do { 196 if (gotlandmark(landmark)) 197 return 1; 198 reduce(prefix); 199 } while (prefix[0]); 200 return 0; 201 201 } 202 202 … … 224 224 getpythonregpath(HKEY keyBase, int skipcore) 225 225 { 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 keyBuf = keyBufPtr = malloc(sizeof(keyPrefix) + 244 sizeof(TCHAR)*(versionLen-1) + 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 rc = RegQueryInfoKey(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, 263 264 265 266 /* Allocate a temp array of char buffers, so we only need to loop 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 RegQueryValueEx(subKey, NULL, 0, NULL, 294 (LPBYTE)ppPaths[index], 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 /* Now append the core path entries - 333 this will include the NULL 334 335 rc = RegQueryValueEx(newKey, NULL, 0, NULL, 336 337 338 /* And set the result - caller must free 339 340 341 226 HKEY newKey = 0; 227 DWORD dataSize = 0; 228 DWORD numKeys = 0; 229 LONG rc; 230 char *retval = NULL; 231 TCHAR *dataBuf = NULL; 232 static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); 233 static const TCHAR keySuffix[] = _T("\\PythonPath"); 234 size_t versionLen; 235 DWORD index; 236 TCHAR *keyBuf = NULL; 237 TCHAR *keyBufPtr; 238 TCHAR **ppPaths = NULL; 239 240 /* Tried to use sysget("winver") but here is too early :-( */ 241 versionLen = _tcslen(PyWin_DLLVersionString); 242 /* Space for all the chars, plus one \0 */ 243 keyBuf = keyBufPtr = malloc(sizeof(keyPrefix) + 244 sizeof(TCHAR)*(versionLen-1) + 245 sizeof(keySuffix)); 246 if (keyBuf==NULL) goto done; 247 248 memcpy(keyBufPtr, keyPrefix, sizeof(keyPrefix)-sizeof(TCHAR)); 249 keyBufPtr += sizeof(keyPrefix)/sizeof(TCHAR) - 1; 250 memcpy(keyBufPtr, PyWin_DLLVersionString, versionLen * sizeof(TCHAR)); 251 keyBufPtr += versionLen; 252 /* NULL comes with this one! */ 253 memcpy(keyBufPtr, keySuffix, sizeof(keySuffix)); 254 /* Open the root Python key */ 255 rc=RegOpenKeyEx(keyBase, 256 keyBuf, /* subkey */ 257 0, /* reserved */ 258 KEY_READ, 259 &newKey); 260 if (rc!=ERROR_SUCCESS) goto done; 261 /* Find out how big our core buffer is, and how many subkeys we have */ 262 rc = RegQueryInfoKey(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL, 263 NULL, NULL, &dataSize, NULL, NULL); 264 if (rc!=ERROR_SUCCESS) goto done; 265 if (skipcore) dataSize = 0; /* Only count core ones if we want them! */ 266 /* Allocate a temp array of char buffers, so we only need to loop 267 reading the registry once 268 */ 269 ppPaths = malloc( sizeof(TCHAR *) * numKeys ); 270 if (ppPaths==NULL) goto done; 271 memset(ppPaths, 0, sizeof(TCHAR *) * numKeys); 272 /* Loop over all subkeys, allocating a temp sub-buffer. */ 273 for(index=0;index<numKeys;index++) { 274 TCHAR keyBuf[MAX_PATH+1]; 275 HKEY subKey = 0; 276 DWORD reqdSize = MAX_PATH+1; 277 /* Get the sub-key name */ 278 DWORD rc = RegEnumKeyEx(newKey, index, keyBuf, &reqdSize, 279 NULL, NULL, NULL, NULL ); 280 if (rc!=ERROR_SUCCESS) goto done; 281 /* Open the sub-key */ 282 rc=RegOpenKeyEx(newKey, 283 keyBuf, /* subkey */ 284 0, /* reserved */ 285 KEY_READ, 286 &subKey); 287 if (rc!=ERROR_SUCCESS) goto done; 288 /* Find the value of the buffer size, malloc, then read it */ 289 RegQueryValueEx(subKey, NULL, 0, NULL, NULL, &reqdSize); 290 if (reqdSize) { 291 ppPaths[index] = malloc(reqdSize); 292 if (ppPaths[index]) { 293 RegQueryValueEx(subKey, NULL, 0, NULL, 294 (LPBYTE)ppPaths[index], 295 &reqdSize); 296 dataSize += reqdSize + 1; /* 1 for the ";" */ 297 } 298 } 299 RegCloseKey(subKey); 300 } 301 302 /* return null if no path to return */ 303 if (dataSize == 0) goto done; 304 305 /* original datasize from RegQueryInfo doesn't include the \0 */ 306 dataBuf = malloc((dataSize+1) * sizeof(TCHAR)); 307 if (dataBuf) { 308 TCHAR *szCur = dataBuf; 309 DWORD reqdSize = dataSize; 310 /* Copy our collected strings */ 311 for (index=0;index<numKeys;index++) { 312 if (index > 0) { 313 *(szCur++) = _T(';'); 314 dataSize--; 315 } 316 if (ppPaths[index]) { 317 Py_ssize_t len = _tcslen(ppPaths[index]); 318 _tcsncpy(szCur, ppPaths[index], len); 319 szCur += len; 320 assert(dataSize > (DWORD)len); 321 dataSize -= (DWORD)len; 322 } 323 } 324 if (skipcore) 325 *szCur = '\0'; 326 else { 327 /* If we have no values, we dont need a ';' */ 328 if (numKeys) { 329 *(szCur++) = _T(';'); 330 dataSize--; 331 } 332 /* Now append the core path entries - 333 this will include the NULL 334 */ 335 rc = RegQueryValueEx(newKey, NULL, 0, NULL, 336 (LPBYTE)szCur, &dataSize); 337 } 338 /* And set the result - caller must free 339 If MBCS, it is fine as is. If Unicode, allocate new 340 buffer and convert. 341 */ 342 342 #ifdef UNICODE 343 344 345 WideCharToMultiByte(CP_ACP, 0, 346 dataBuf, -1, /* source */ 347 348 349 343 retval = (char *)malloc(reqdSize+1); 344 if (retval) 345 WideCharToMultiByte(CP_ACP, 0, 346 dataBuf, -1, /* source */ 347 retval, reqdSize+1, /* dest */ 348 NULL, NULL); 349 free(dataBuf); 350 350 #else 351 352 #endif 353 351 retval = dataBuf; 352 #endif 353 } 354 354 done: 355 356 357 358 359 360 361 362 363 364 365 355 /* Loop freeing my temp buffers */ 356 if (ppPaths) { 357 for(index=0;index<numKeys;index++) 358 if (ppPaths[index]) free(ppPaths[index]); 359 free(ppPaths); 360 } 361 if (newKey) 362 RegCloseKey(newKey); 363 if (keyBuf) 364 free(keyBuf); 365 return retval; 366 366 } 367 367 #endif /* Py_ENABLE_SHARED */ … … 371 371 get_progpath(void) 372 372 { 373 374 375 373 extern char *Py_GetProgramName(void); 374 char *path = getenv("PATH"); 375 char *prog = Py_GetProgramName(); 376 376 377 377 #ifdef MS_WINDOWS 378 378 extern HANDLE PyWin_DLLhModule; 379 379 #ifdef UNICODE 380 381 382 383 384 380 WCHAR wprogpath[MAXPATHLEN+1]; 381 /* Windows documents that GetModuleFileName() will "truncate", 382 but makes no mention of the null terminator. Play it safe. 383 PLUS Windows itself defines MAX_PATH as the same, but anyway... 384 */ 385 385 #ifdef Py_ENABLE_SHARED 386 387 388 389 WideCharToMultiByte(CP_ACP, 0, 390 wprogpath, -1, 391 dllpath, MAXPATHLEN+1, 392 393 386 wprogpath[MAXPATHLEN]=_T('\0'); 387 if (PyWin_DLLhModule && 388 GetModuleFileName(PyWin_DLLhModule, wprogpath, MAXPATHLEN)) { 389 WideCharToMultiByte(CP_ACP, 0, 390 wprogpath, -1, 391 dllpath, MAXPATHLEN+1, 392 NULL, NULL); 393 } 394 394 #else 395 396 #endif 397 398 399 WideCharToMultiByte(CP_ACP, 0, 400 wprogpath, -1, 401 progpath, MAXPATHLEN+1, 402 403 404 395 dllpath[0] = 0; 396 #endif 397 wprogpath[MAXPATHLEN]=_T('\0'); 398 if (GetModuleFileName(NULL, wprogpath, MAXPATHLEN)) { 399 WideCharToMultiByte(CP_ACP, 0, 400 wprogpath, -1, 401 progpath, MAXPATHLEN+1, 402 NULL, NULL); 403 return; 404 } 405 405 #else 406 406 /* static init of progpath ensures final char remains \0 */ 407 407 #ifdef Py_ENABLE_SHARED 408 409 410 408 if (PyWin_DLLhModule) 409 if (!GetModuleFileName(PyWin_DLLhModule, dllpath, MAXPATHLEN)) 410 dllpath[0] = 0; 411 411 #else 412 413 #endif 414 415 416 #endif 417 #endif 418 419 420 421 422 423 424 425 412 dllpath[0] = 0; 413 #endif 414 if (GetModuleFileName(NULL, progpath, MAXPATHLEN)) 415 return; 416 #endif 417 #endif 418 if (prog == NULL || *prog == '\0') 419 prog = "python"; 420 421 /* If there is no slash in the argv0 path, then we have to 422 * assume python is on the user's $PATH, since there's no 423 * other way to find a directory to start the search from. If 424 * $PATH isn't exported, you lose. 425 */ 426 426 #ifdef ALTSEP 427 427 if (strchr(prog, SEP) || strchr(prog, ALTSEP)) 428 428 #else 429 430 #endif 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 429 if (strchr(prog, SEP)) 430 #endif 431 strncpy(progpath, prog, MAXPATHLEN); 432 else if (path) { 433 while (1) { 434 char *delim = strchr(path, DELIM); 435 436 if (delim) { 437 size_t len = delim - path; 438 /* ensure we can't overwrite buffer */ 439 len = min(MAXPATHLEN,len); 440 strncpy(progpath, path, len); 441 *(progpath + len) = '\0'; 442 } 443 else 444 strncpy(progpath, path, MAXPATHLEN); 445 446 /* join() is safe for MAXPATHLEN+1 size buffer */ 447 join(progpath, prog); 448 if (exists(progpath)) 449 break; 450 451 if (!delim) { 452 progpath[0] = '\0'; 453 break; 454 } 455 path = delim + 1; 456 } 457 } 458 else 459 progpath[0] = '\0'; 460 460 } 461 461 … … 463 463 calculate_path(void) 464 464 { 465 466 467 468 469 465 char argv0_path[MAXPATHLEN+1]; 466 char *buf; 467 size_t bufsz; 468 char *pythonhome = Py_GetPythonHome(); 469 char *envpath = Py_GETENV("PYTHONPATH"); 470 470 471 471 #ifdef MS_WINDOWS 472 473 474 475 476 477 #endif 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 472 int skiphome, skipdefault; 473 char *machinepath = NULL; 474 char *userpath = NULL; 475 char zip_path[MAXPATHLEN+1]; 476 size_t len; 477 #endif 478 479 get_progpath(); 480 /* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */ 481 strcpy(argv0_path, progpath); 482 reduce(argv0_path); 483 if (pythonhome == NULL || *pythonhome == '\0') { 484 if (search_for_prefix(argv0_path, LANDMARK)) 485 pythonhome = prefix; 486 else 487 pythonhome = NULL; 488 } 489 else 490 strncpy(prefix, pythonhome, MAXPATHLEN); 491 492 if (envpath && *envpath == '\0') 493 envpath = NULL; 494 494 495 495 496 496 #ifdef MS_WINDOWS 497 498 if (dllpath[0])/* use name of python DLL */499 500 else/* use name of executable program */501 502 503 504 505 zip_path[len-3] = 'z';/* change ending to "zip" */506 507 508 509 510 511 512 513 497 /* Calculate zip archive path */ 498 if (dllpath[0]) /* use name of python DLL */ 499 strncpy(zip_path, dllpath, MAXPATHLEN); 500 else /* use name of executable program */ 501 strncpy(zip_path, progpath, MAXPATHLEN); 502 zip_path[MAXPATHLEN] = '\0'; 503 len = strlen(zip_path); 504 if (len > 4) { 505 zip_path[len-3] = 'z'; /* change ending to "zip" */ 506 zip_path[len-2] = 'i'; 507 zip_path[len-1] = 'p'; 508 } 509 else { 510 zip_path[0] = 0; 511 } 512 513 skiphome = pythonhome==NULL ? 0 : 1; 514 514 #ifdef Py_ENABLE_SHARED 515 516 517 #endif 518 519 520 521 522 #endif 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 bufsz = 1; 541 542 543 544 545 546 547 548 549 550 515 machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); 516 userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome); 517 #endif 518 /* We only use the default relative PYTHONPATH if we havent 519 anything better to use! */ 520 skipdefault = envpath!=NULL || pythonhome!=NULL || \ 521 machinepath!=NULL || userpath!=NULL; 522 #endif 523 524 /* We need to construct a path from the following parts. 525 (1) the PYTHONPATH environment variable, if set; 526 (2) for Win32, the zip archive file path; 527 (3) for Win32, the machinepath and userpath, if set; 528 (4) the PYTHONPATH config macro, with the leading "." 529 of each component replaced with pythonhome, if set; 530 (5) the directory containing the executable (argv0_path). 531 The length calculation calculates #4 first. 532 Extra rules: 533 - If PYTHONHOME is set (in any way) item (3) is ignored. 534 - If registry values are used, (4) and (5) are ignored. 535 */ 536 537 /* Calculate size of return buffer */ 538 if (pythonhome != NULL) { 539 char *p; 540 bufsz = 1; 541 for (p = PYTHONPATH; *p; p++) { 542 if (*p == DELIM) 543 bufsz++; /* number of DELIM plus one */ 544 } 545 bufsz *= strlen(pythonhome); 546 } 547 else 548 bufsz = 0; 549 bufsz += strlen(PYTHONPATH) + 1; 550 bufsz += strlen(argv0_path) + 1; 551 551 #ifdef MS_WINDOWS 552 553 554 555 556 557 #endif 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 552 if (userpath) 553 bufsz += strlen(userpath) + 1; 554 if (machinepath) 555 bufsz += strlen(machinepath) + 1; 556 bufsz += strlen(zip_path) + 1; 557 #endif 558 if (envpath != NULL) 559 bufsz += strlen(envpath) + 1; 560 561 module_search_path = buf = malloc(bufsz); 562 if (buf == NULL) { 563 /* We can't exit, so print a warning and limp along */ 564 fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); 565 if (envpath) { 566 fprintf(stderr, "Using environment $PYTHONPATH.\n"); 567 module_search_path = envpath; 568 } 569 else { 570 fprintf(stderr, "Using default static path.\n"); 571 module_search_path = PYTHONPATH; 572 } 573 573 #ifdef MS_WINDOWS 574 575 576 577 574 if (machinepath) 575 free(machinepath); 576 if (userpath) 577 free(userpath); 578 578 #endif /* MS_WINDOWS */ 579 580 581 582 583 584 585 586 579 return; 580 } 581 582 if (envpath) { 583 strcpy(buf, envpath); 584 buf = strchr(buf, '\0'); 585 *buf++ = DELIM; 586 } 587 587 #ifdef MS_WINDOWS 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 588 if (zip_path[0]) { 589 strcpy(buf, zip_path); 590 buf = strchr(buf, '\0'); 591 *buf++ = DELIM; 592 } 593 if (userpath) { 594 strcpy(buf, userpath); 595 buf = strchr(buf, '\0'); 596 *buf++ = DELIM; 597 free(userpath); 598 } 599 if (machinepath) { 600 strcpy(buf, machinepath); 601 buf = strchr(buf, '\0'); 602 *buf++ = DELIM; 603 free(machinepath); 604 } 605 if (pythonhome == NULL) { 606 if (!skipdefault) { 607 strcpy(buf, PYTHONPATH); 608 buf = strchr(buf, '\0'); 609 } 610 } 611 611 #else 612 613 614 615 612 if (pythonhome == NULL) { 613 strcpy(buf, PYTHONPATH); 614 buf = strchr(buf, '\0'); 615 } 616 616 #endif /* MS_WINDOWS */ 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 617 else { 618 char *p = PYTHONPATH; 619 char *q; 620 size_t n; 621 for (;;) { 622 q = strchr(p, DELIM); 623 if (q == NULL) 624 n = strlen(p); 625 else 626 n = q-p; 627 if (p[0] == '.' && is_sep(p[1])) { 628 strcpy(buf, pythonhome); 629 buf = strchr(buf, '\0'); 630 p++; 631 n--; 632 } 633 strncpy(buf, p, n); 634 buf += n; 635 if (q == NULL) 636 break; 637 *buf++ = DELIM; 638 p = q+1; 639 } 640 } 641 if (argv0_path) { 642 *buf++ = DELIM; 643 strcpy(buf, argv0_path); 644 buf = strchr(buf, '\0'); 645 } 646 *buf = '\0'; 647 /* Now to pull one last hack/trick. If sys.prefix is 648 empty, then try and find it somewhere on the paths 649 we calculated. We scan backwards, as our general policy 650 is that Python core directories are at the *end* of 651 sys.path. We assume that our "lib" directory is 652 on the path, and that our 'prefix' directory is 653 the parent of that. 654 */ 655 if (*prefix=='\0') { 656 char lookBuf[MAXPATHLEN+1]; 657 char *look = buf - 1; /* 'buf' is at the end of the buffer */ 658 while (1) { 659 Py_ssize_t nchars; 660 char *lookEnd = look; 661 /* 'look' will end up one character before the 662 start of the path in question - even if this 663 is one character before the start of the buffer 664 */ 665 while (look >= module_search_path && *look != DELIM) 666 look--; 667 nchars = lookEnd-look; 668 strncpy(lookBuf, look+1, nchars); 669 lookBuf[nchars] = '\0'; 670 /* Up one level to the parent */ 671 reduce(lookBuf); 672 if (search_for_prefix(lookBuf, LANDMARK)) { 673 break; 674 } 675 /* If we are out of paths to search - give up */ 676 if (look < module_search_path) 677 break; 678 look--; 679 } 680 } 681 681 } 682 682 … … 687 687 Py_GetPath(void) 688 688 { 689 690 691 689 if (!module_search_path) 690 calculate_path(); 691 return module_search_path; 692 692 } 693 693 … … 695 695 Py_GetPrefix(void) 696 696 { 697 698 699 697 if (!module_search_path) 698 calculate_path(); 699 return prefix; 700 700 } 701 701 … … 703 703 Py_GetExecPrefix(void) 704 704 { 705 705 return Py_GetPrefix(); 706 706 } 707 707 … … 709 709 Py_GetProgramFullPath(void) 710 710 { 711 712 713 714 } 711 if (!module_search_path) 712 calculate_path(); 713 return progpath; 714 } -
python/vendor/current/PC/import_nt.c
r2 r388 1 1 /******************************************************************** 2 2 3 import_nt.c 3 import_nt.c 4 4 5 5 Win32 specific import code. … … 17 17 18 18 FILE *PyWin_FindRegisteredModule(const char *moduleName, 19 20 21 19 struct filedescr **ppFileDesc, 20 char *pathBuf, 21 Py_ssize_t pathLen) 22 22 { 23 24 25 23 char *moduleKey; 24 const char keyPrefix[] = "Software\\Python\\PythonCore\\"; 25 const char keySuffix[] = "\\Modules\\"; 26 26 #ifdef _DEBUG 27 28 29 30 27 /* In debugging builds, we _must_ have the debug version 28 * registered. 29 */ 30 const char debugString[] = "\\Debug"; 31 31 #else 32 32 const char debugString[] = ""; 33 33 #endif 34 35 36 37 38 34 struct filedescr *fdp = NULL; 35 FILE *fp; 36 HKEY keyBase = HKEY_CURRENT_USER; 37 int modNameSize; 38 long regStat; 39 39 40 41 42 43 44 45 46 47 48 49 50 51 moduleKey = alloca(bufSize); 52 53 54 40 /* Calculate the size for the sprintf buffer. 41 * Get the size of the chars only, plus 1 NULL. 42 */ 43 size_t bufSize = sizeof(keyPrefix)-1 + 44 strlen(PyWin_DLLVersionString) + 45 sizeof(keySuffix) + 46 strlen(moduleName) + 47 sizeof(debugString) - 1; 48 /* alloca == no free required, but memory only local to fn, 49 * also no heap fragmentation! 50 */ 51 moduleKey = alloca(bufSize); 52 PyOS_snprintf(moduleKey, bufSize, 53 "Software\\Python\\PythonCore\\%s\\Modules\\%s%s", 54 PyWin_DLLVersionString, moduleName, debugString); 55 55 56 57 58 59 60 61 62 63 64 regStat = RegQueryValue(keyBase, moduleKey, 65 56 assert(pathLen < INT_MAX); 57 modNameSize = (int)pathLen; 58 regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize); 59 if (regStat != ERROR_SUCCESS) { 60 /* No user setting - lookup in machine settings */ 61 keyBase = HKEY_LOCAL_MACHINE; 62 /* be anal - failure may have reset size param */ 63 modNameSize = (int)pathLen; 64 regStat = RegQueryValue(keyBase, moduleKey, 65 pathBuf, &modNameSize); 66 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 67 if (regStat != ERROR_SUCCESS) 68 return NULL; 69 } 70 /* use the file extension to locate the type entry. */ 71 for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { 72 size_t extLen = strlen(fdp->suffix); 73 assert(modNameSize >= 0); /* else cast to size_t is wrong */ 74 if ((size_t)modNameSize > extLen && 75 strnicmp(pathBuf + ((size_t)modNameSize-extLen-1), 76 fdp->suffix, 77 extLen) == 0) 78 break; 79 } 80 if (fdp->suffix == NULL) 81 return NULL; 82 fp = fopen(pathBuf, fdp->mode); 83 if (fp != NULL) 84 *ppFileDesc = fdp; 85 return fp; 86 86 } -
python/vendor/current/PC/make_versioninfo.c
r2 r388 23 23 int main(int argc, char **argv) 24 24 { 25 26 27 28 29 30 31 32 33 34 35 36 37 25 printf("/* This file created by make_versioninfo.exe */\n"); 26 printf("#define FIELD3 %d\n", 27 PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL); 28 printf("#define MS_DLL_ID \"%d.%d\"\n", 29 PY_MAJOR_VERSION, PY_MINOR_VERSION); 30 printf("#ifndef _DEBUG\n"); 31 printf("#define PYTHON_DLL_NAME \"python%d%d.dll\"\n", 32 PY_MAJOR_VERSION, PY_MINOR_VERSION); 33 printf("#else\n"); 34 printf("#define PYTHON_DLL_NAME \"python%d%d_d.dll\"\n", 35 PY_MAJOR_VERSION, PY_MINOR_VERSION); 36 printf("#endif\n"); 37 return 0; 38 38 } -
python/vendor/current/PC/msvcrtmodule.c
r2 r388 1 1 /********************************************************* 2 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 msvcrtmodule.c 4 5 A Python interface to the Microsoft Visual C Runtime 6 Library, providing access to those non-portable, but 7 still useful routines. 8 9 Only ever compiled with an MS compiler, so no attempt 10 has been made to avoid MS language extensions, etc... 11 12 This may only work on NT or 95... 13 14 Author: Mark Hammond and Guido van Rossum. 15 Maintenance: Guido van Rossum. 16 16 17 17 ***********************************************************/ … … 34 34 msvcrt_heapmin(PyObject *self, PyObject *args) 35 35 { 36 if (!PyArg_ParseTuple(args, ":heapmin")) 37 return NULL; 38 39 if (_heapmin() != 0) 40 return PyErr_SetFromErrno(PyExc_IOError); 41 42 Py_INCREF(Py_None); 43 return Py_None; 44 } 36 if (!PyArg_ParseTuple(args, ":heapmin")) 37 return NULL; 38 39 if (_heapmin() != 0) 40 return PyErr_SetFromErrno(PyExc_IOError); 41 42 Py_INCREF(Py_None); 43 return Py_None; 44 } 45 46 PyDoc_STRVAR(heapmin_doc, 47 "heapmin() -> None\n\ 48 \n\ 49 Force the malloc() heap to clean itself up and return unused blocks\n\ 50 to the operating system. On failure, this raises IOError."); 45 51 46 52 // Perform locking operations on a C runtime file descriptor. … … 48 54 msvcrt_locking(PyObject *self, PyObject *args) 49 55 { 50 int fd; 51 int mode; 52 long nbytes; 53 int err; 54 55 if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes)) 56 return NULL; 57 58 Py_BEGIN_ALLOW_THREADS 59 err = _locking(fd, mode, nbytes); 60 Py_END_ALLOW_THREADS 61 if (err != 0) 62 return PyErr_SetFromErrno(PyExc_IOError); 63 64 Py_INCREF(Py_None); 65 return Py_None; 66 } 56 int fd; 57 int mode; 58 long nbytes; 59 int err; 60 61 if (!PyArg_ParseTuple(args, "iil:locking", &fd, &mode, &nbytes)) 62 return NULL; 63 64 Py_BEGIN_ALLOW_THREADS 65 err = _locking(fd, mode, nbytes); 66 Py_END_ALLOW_THREADS 67 if (err != 0) 68 return PyErr_SetFromErrno(PyExc_IOError); 69 70 Py_INCREF(Py_None); 71 return Py_None; 72 } 73 74 PyDoc_STRVAR(locking_doc, 75 "locking(fd, mode, nbytes) -> None\n\ 76 \n\ 77 Lock part of a file based on file descriptor fd from the C runtime.\n\ 78 Raises IOError on failure. The locked region of the file extends from\n\ 79 the current file position for nbytes bytes, and may continue beyond\n\ 80 the end of the file. mode must be one of the LK_* constants listed\n\ 81 below. Multiple regions in a file may be locked at the same time, but\n\ 82 may not overlap. Adjacent regions are not merged; they must be unlocked\n\ 83 individually."); 67 84 68 85 // Set the file translation mode for a C runtime file descriptor. … … 70 87 msvcrt_setmode(PyObject *self, PyObject *args) 71 88 { 72 int fd; 73 int flags; 74 if (!PyArg_ParseTuple(args,"ii:setmode", &fd, &flags)) 75 return NULL; 76 77 flags = _setmode(fd, flags); 78 if (flags == -1) 79 return PyErr_SetFromErrno(PyExc_IOError); 80 81 return PyInt_FromLong(flags); 82 } 89 int fd; 90 int flags; 91 if (!PyArg_ParseTuple(args,"ii:setmode", &fd, &flags)) 92 return NULL; 93 94 flags = _setmode(fd, flags); 95 if (flags == -1) 96 return PyErr_SetFromErrno(PyExc_IOError); 97 98 return PyInt_FromLong(flags); 99 } 100 101 PyDoc_STRVAR(setmode_doc, 102 "setmode(fd, mode) -> Previous mode\n\ 103 \n\ 104 Set the line-end translation mode for the file descriptor fd. To set\n\ 105 it to text mode, flags should be os.O_TEXT; for binary, it should be\n\ 106 os.O_BINARY."); 83 107 84 108 // Convert an OS file handle to a C runtime file descriptor. … … 86 110 msvcrt_open_osfhandle(PyObject *self, PyObject *args) 87 111 { 88 long handle; 89 int flags; 90 int fd; 91 92 if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags)) 93 return NULL; 94 95 fd = _open_osfhandle(handle, flags); 96 if (fd == -1) 97 return PyErr_SetFromErrno(PyExc_IOError); 98 99 return PyInt_FromLong(fd); 100 } 112 long handle; 113 int flags; 114 int fd; 115 116 if (!PyArg_ParseTuple(args, "li:open_osfhandle", &handle, &flags)) 117 return NULL; 118 119 fd = _open_osfhandle(handle, flags); 120 if (fd == -1) 121 return PyErr_SetFromErrno(PyExc_IOError); 122 123 return PyInt_FromLong(fd); 124 } 125 126 PyDoc_STRVAR(open_osfhandle_doc, 127 "open_osfhandle(handle, flags) -> file descriptor\n\ 128 \n\ 129 Create a C runtime file descriptor from the file handle handle. The\n\ 130 flags parameter should be a bitwise OR of os.O_APPEND, os.O_RDONLY,\n\ 131 and os.O_TEXT. The returned file descriptor may be used as a parameter\n\ 132 to os.fdopen() to create a file object."); 101 133 102 134 // Convert a C runtime file descriptor to an OS file handle. … … 104 136 msvcrt_get_osfhandle(PyObject *self, PyObject *args) 105 137 { 106 int fd; 107 Py_intptr_t handle; 108 109 if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) 110 return NULL; 111 112 handle = _get_osfhandle(fd); 113 if (handle == -1) 114 return PyErr_SetFromErrno(PyExc_IOError); 115 116 /* technically 'handle' is not a pointer, but a integer as 117 large as a pointer, Python's *VoidPtr interface is the 118 most appropriate here */ 119 return PyLong_FromVoidPtr((void*)handle); 120 } 138 int fd; 139 Py_intptr_t handle; 140 141 if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) 142 return NULL; 143 144 if (!_PyVerify_fd(fd)) 145 return PyErr_SetFromErrno(PyExc_IOError); 146 147 handle = _get_osfhandle(fd); 148 if (handle == -1) 149 return PyErr_SetFromErrno(PyExc_IOError); 150 151 /* technically 'handle' is not a pointer, but a integer as 152 large as a pointer, Python's *VoidPtr interface is the 153 most appropriate here */ 154 return PyLong_FromVoidPtr((void*)handle); 155 } 156 157 PyDoc_STRVAR(get_osfhandle_doc, 158 "get_osfhandle(fd) -> file handle\n\ 159 \n\ 160 Return the file handle for the file descriptor fd. Raises IOError\n\ 161 if fd is not recognized."); 121 162 122 163 /* Console I/O */ … … 125 166 msvcrt_kbhit(PyObject *self, PyObject *args) 126 167 { 127 int ok; 128 129 if (!PyArg_ParseTuple(args, ":kbhit")) 130 return NULL; 131 132 ok = _kbhit(); 133 return PyInt_FromLong(ok); 134 } 168 int ok; 169 170 if (!PyArg_ParseTuple(args, ":kbhit")) 171 return NULL; 172 173 ok = _kbhit(); 174 return PyInt_FromLong(ok); 175 } 176 177 PyDoc_STRVAR(kbhit_doc, 178 "kbhit() -> bool\n\ 179 \n\ 180 Return true if a keypress is waiting to be read."); 135 181 136 182 static PyObject * 137 183 msvcrt_getch(PyObject *self, PyObject *args) 138 184 { 139 int ch; 140 char s[1]; 141 142 if (!PyArg_ParseTuple(args, ":getch")) 143 return NULL; 144 145 Py_BEGIN_ALLOW_THREADS 146 ch = _getch(); 147 Py_END_ALLOW_THREADS 148 s[0] = ch; 149 return PyString_FromStringAndSize(s, 1); 150 } 185 int ch; 186 char s[1]; 187 188 if (!PyArg_ParseTuple(args, ":getch")) 189 return NULL; 190 191 Py_BEGIN_ALLOW_THREADS 192 ch = _getch(); 193 Py_END_ALLOW_THREADS 194 s[0] = ch; 195 return PyString_FromStringAndSize(s, 1); 196 } 197 198 PyDoc_STRVAR(getch_doc, 199 "getch() -> key character\n\ 200 \n\ 201 Read a keypress and return the resulting character. Nothing is echoed to\n\ 202 the console. This call will block if a keypress is not already\n\ 203 available, but will not wait for Enter to be pressed. If the pressed key\n\ 204 was a special function key, this will return '\\000' or '\\xe0'; the next\n\ 205 call will return the keycode. The Control-C keypress cannot be read with\n\ 206 this function."); 151 207 152 208 #ifdef _WCONIO_DEFINED … … 154 210 msvcrt_getwch(PyObject *self, PyObject *args) 155 211 { 156 Py_UNICODE ch; 157 Py_UNICODE u[1]; 158 159 if (!PyArg_ParseTuple(args, ":getwch")) 160 return NULL; 161 162 Py_BEGIN_ALLOW_THREADS 163 ch = _getwch(); 164 Py_END_ALLOW_THREADS 165 u[0] = ch; 166 return PyUnicode_FromUnicode(u, 1); 167 } 212 Py_UNICODE ch; 213 Py_UNICODE u[1]; 214 215 if (!PyArg_ParseTuple(args, ":getwch")) 216 return NULL; 217 218 Py_BEGIN_ALLOW_THREADS 219 ch = _getwch(); 220 Py_END_ALLOW_THREADS 221 u[0] = ch; 222 return PyUnicode_FromUnicode(u, 1); 223 } 224 225 PyDoc_STRVAR(getwch_doc, 226 "getwch() -> Unicode key character\n\ 227 \n\ 228 Wide char variant of getch(), returning a Unicode value."); 168 229 #endif 169 230 … … 171 232 msvcrt_getche(PyObject *self, PyObject *args) 172 233 { 173 int ch; 174 char s[1]; 175 176 if (!PyArg_ParseTuple(args, ":getche")) 177 return NULL; 178 179 Py_BEGIN_ALLOW_THREADS 180 ch = _getche(); 181 Py_END_ALLOW_THREADS 182 s[0] = ch; 183 return PyString_FromStringAndSize(s, 1); 184 } 234 int ch; 235 char s[1]; 236 237 if (!PyArg_ParseTuple(args, ":getche")) 238 return NULL; 239 240 Py_BEGIN_ALLOW_THREADS 241 ch = _getche(); 242 Py_END_ALLOW_THREADS 243 s[0] = ch; 244 return PyString_FromStringAndSize(s, 1); 245 } 246 247 PyDoc_STRVAR(getche_doc, 248 "getche() -> key character\n\ 249 \n\ 250 Similar to getch(), but the keypress will be echoed if it represents\n\ 251 a printable character."); 185 252 186 253 #ifdef _WCONIO_DEFINED … … 188 255 msvcrt_getwche(PyObject *self, PyObject *args) 189 256 { 190 Py_UNICODE ch; 191 Py_UNICODE s[1]; 192 193 if (!PyArg_ParseTuple(args, ":getwche")) 194 return NULL; 195 196 Py_BEGIN_ALLOW_THREADS 197 ch = _getwche(); 198 Py_END_ALLOW_THREADS 199 s[0] = ch; 200 return PyUnicode_FromUnicode(s, 1); 201 } 257 Py_UNICODE ch; 258 Py_UNICODE s[1]; 259 260 if (!PyArg_ParseTuple(args, ":getwche")) 261 return NULL; 262 263 Py_BEGIN_ALLOW_THREADS 264 ch = _getwche(); 265 Py_END_ALLOW_THREADS 266 s[0] = ch; 267 return PyUnicode_FromUnicode(s, 1); 268 } 269 270 PyDoc_STRVAR(getwche_doc, 271 "getwche() -> Unicode key character\n\ 272 \n\ 273 Wide char variant of getche(), returning a Unicode value."); 202 274 #endif 203 275 … … 205 277 msvcrt_putch(PyObject *self, PyObject *args) 206 278 { 207 char ch; 208 209 if (!PyArg_ParseTuple(args, "c:putch", &ch)) 210 return NULL; 211 212 _putch(ch); 213 Py_INCREF(Py_None); 214 return Py_None; 215 } 279 char ch; 280 281 if (!PyArg_ParseTuple(args, "c:putch", &ch)) 282 return NULL; 283 284 _putch(ch); 285 Py_INCREF(Py_None); 286 return Py_None; 287 } 288 289 PyDoc_STRVAR(putch_doc, 290 "putch(char) -> None\n\ 291 \n\ 292 Print the character char to the console without buffering."); 216 293 217 294 #ifdef _WCONIO_DEFINED … … 219 296 msvcrt_putwch(PyObject *self, PyObject *args) 220 297 { 221 Py_UNICODE *ch; 222 int size; 223 224 if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size)) 225 return NULL; 226 227 if (size == 0) { 228 PyErr_SetString(PyExc_ValueError, 229 "Expected unicode string of length 1"); 230 return NULL; 231 } 232 _putwch(*ch); 233 Py_RETURN_NONE; 234 235 } 298 Py_UNICODE *ch; 299 int size; 300 301 if (!PyArg_ParseTuple(args, "u#:putwch", &ch, &size)) 302 return NULL; 303 304 if (size == 0) { 305 PyErr_SetString(PyExc_ValueError, 306 "Expected unicode string of length 1"); 307 return NULL; 308 } 309 _putwch(*ch); 310 Py_RETURN_NONE; 311 312 } 313 314 PyDoc_STRVAR(putwch_doc, 315 "putwch(unicode_char) -> None\n\ 316 \n\ 317 Wide char variant of putch(), accepting a Unicode value."); 236 318 #endif 237 319 … … 239 321 msvcrt_ungetch(PyObject *self, PyObject *args) 240 322 { 241 char ch; 242 243 if (!PyArg_ParseTuple(args, "c:ungetch", &ch)) 244 return NULL; 245 246 if (_ungetch(ch) == EOF) 247 return PyErr_SetFromErrno(PyExc_IOError); 248 Py_INCREF(Py_None); 249 return Py_None; 250 } 323 char ch; 324 325 if (!PyArg_ParseTuple(args, "c:ungetch", &ch)) 326 return NULL; 327 328 if (_ungetch(ch) == EOF) 329 return PyErr_SetFromErrno(PyExc_IOError); 330 Py_INCREF(Py_None); 331 return Py_None; 332 } 333 334 PyDoc_STRVAR(ungetch_doc, 335 "ungetch(char) -> None\n\ 336 \n\ 337 Cause the character char to be \"pushed back\" into the console buffer;\n\ 338 it will be the next character read by getch() or getche()."); 251 339 252 340 #ifdef _WCONIO_DEFINED … … 254 342 msvcrt_ungetwch(PyObject *self, PyObject *args) 255 343 { 256 Py_UNICODE ch; 257 258 if (!PyArg_ParseTuple(args, "u:ungetwch", &ch)) 259 return NULL; 260 261 if (_ungetch(ch) == EOF) 262 return PyErr_SetFromErrno(PyExc_IOError); 263 Py_INCREF(Py_None); 264 return Py_None; 265 } 344 Py_UNICODE ch; 345 346 if (!PyArg_ParseTuple(args, "u:ungetwch", &ch)) 347 return NULL; 348 349 if (_ungetch(ch) == EOF) 350 return PyErr_SetFromErrno(PyExc_IOError); 351 Py_INCREF(Py_None); 352 return Py_None; 353 } 354 355 PyDoc_STRVAR(ungetwch_doc, 356 "ungetwch(unicode_char) -> None\n\ 357 \n\ 358 Wide char variant of ungetch(), accepting a Unicode value."); 266 359 #endif 267 360 … … 269 362 insertint(PyObject *d, char *name, int value) 270 363 { 271 272 273 274 275 276 277 278 279 364 PyObject *v = PyInt_FromLong((long) value); 365 if (v == NULL) { 366 /* Don't bother reporting this error */ 367 PyErr_Clear(); 368 } 369 else { 370 PyDict_SetItemString(d, name, v); 371 Py_DECREF(v); 372 } 280 373 } 281 374 … … 283 376 /* List of functions exported by this module */ 284 377 static struct PyMethodDef msvcrt_functions[] = { 285 {"heapmin", msvcrt_heapmin, METH_VARARGS},286 {"locking", msvcrt_locking, METH_VARARGS},287 {"setmode", msvcrt_setmode, METH_VARARGS},288 {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS},289 {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS},290 {"kbhit", msvcrt_kbhit, METH_VARARGS},291 {"getch", msvcrt_getch, METH_VARARGS},292 {"getche", msvcrt_getche, METH_VARARGS},293 {"putch", msvcrt_putch, METH_VARARGS},294 {"ungetch", msvcrt_ungetch, METH_VARARGS},378 {"heapmin", msvcrt_heapmin, METH_VARARGS, heapmin_doc}, 379 {"locking", msvcrt_locking, METH_VARARGS, locking_doc}, 380 {"setmode", msvcrt_setmode, METH_VARARGS, setmode_doc}, 381 {"open_osfhandle", msvcrt_open_osfhandle, METH_VARARGS, open_osfhandle_doc}, 382 {"get_osfhandle", msvcrt_get_osfhandle, METH_VARARGS, get_osfhandle_doc}, 383 {"kbhit", msvcrt_kbhit, METH_VARARGS, kbhit_doc}, 384 {"getch", msvcrt_getch, METH_VARARGS, getch_doc}, 385 {"getche", msvcrt_getche, METH_VARARGS, getche_doc}, 386 {"putch", msvcrt_putch, METH_VARARGS, putch_doc}, 387 {"ungetch", msvcrt_ungetch, METH_VARARGS, ungetch_doc}, 295 388 #ifdef _WCONIO_DEFINED 296 {"getwch", msvcrt_getwch, METH_VARARGS},297 {"getwche", msvcrt_getwche, METH_VARARGS},298 {"putwch", msvcrt_putwch, METH_VARARGS},299 {"ungetwch", msvcrt_ungetwch, METH_VARARGS},300 #endif 301 {NULL,NULL}389 {"getwch", msvcrt_getwch, METH_VARARGS, getwch_doc}, 390 {"getwche", msvcrt_getwche, METH_VARARGS, getwche_doc}, 391 {"putwch", msvcrt_putwch, METH_VARARGS, putwch_doc}, 392 {"ungetwch", msvcrt_ungetwch, METH_VARARGS, ungetwch_doc}, 393 #endif 394 {NULL, NULL} 302 395 }; 303 396 … … 305 398 initmsvcrt(void) 306 399 { 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 400 int st; 401 PyObject *d; 402 PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); 403 if (m == NULL) 404 return; 405 d = PyModule_GetDict(m); 406 407 /* constants for the locking() function's mode argument */ 408 insertint(d, "LK_LOCK", _LK_LOCK); 409 insertint(d, "LK_NBLCK", _LK_NBLCK); 410 insertint(d, "LK_NBRLCK", _LK_NBRLCK); 411 insertint(d, "LK_RLCK", _LK_RLCK); 412 insertint(d, "LK_UNLCK", _LK_UNLCK); 413 414 /* constants for the crt versions */ 322 415 #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN 323 324 325 416 st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", 417 _VC_ASSEMBLY_PUBLICKEYTOKEN); 418 if (st < 0)return; 326 419 #endif 327 420 #ifdef _CRT_ASSEMBLY_VERSION 328 329 330 421 st = PyModule_AddStringConstant(m, "CRT_ASSEMBLY_VERSION", 422 _CRT_ASSEMBLY_VERSION); 423 if (st < 0)return; 331 424 #endif 332 425 #ifdef __LIBRARIES_ASSEMBLY_NAME_PREFIX 333 334 335 336 #endif 337 } 426 st = PyModule_AddStringConstant(m, "LIBRARIES_ASSEMBLY_NAME_PREFIX", 427 __LIBRARIES_ASSEMBLY_NAME_PREFIX); 428 if (st < 0)return; 429 #endif 430 } -
python/vendor/current/PC/os2emx/Makefile
r2 r388 238 238 # Output file names 239 239 PYTHON_VER= 2.6 240 PYTHON_LIB= python2 6240 PYTHON_LIB= python27 241 241 PYTHON.LIB= $(PYTHON_LIB)_s$A 242 242 PYTHON.IMPLIB= $(PYTHON_LIB)$A … … 352 352 Python/getcompiler.c \ 353 353 Python/getcopyright.c \ 354 Python/getmtime.c \355 354 Python/getplatform.c \ 356 355 Python/getversion.c \ … … 364 363 Python/peephole.c \ 365 364 Python/pyarena.c \ 365 Python/pyctype.c \ 366 366 Python/pyfpe.c \ 367 367 Python/pymath.c \ … … 385 385 Objects/cellobject.c \ 386 386 Objects/classobject.c \ 387 Objects/capsule.c \ 387 388 Objects/cobject.c \ 388 389 Objects/codeobject.c \ -
python/vendor/current/PC/os2emx/README.os2emx
r2 r388 310 310 the value of the Makefile variable EXE_DIR to the appropriate directory. 311 311 312 3. If you wish the Python core DLL (python2 6.dll) to be installed in a312 3. If you wish the Python core DLL (python27.dll) to be installed in a 313 313 directory other than the directory in which the Python executables are 314 314 installed (by default, the PYTHONHOME directory), set the value of the -
python/vendor/current/PC/os2emx/config.c
r2 r388 103 103 struct _inittab _PyImport_Inittab[] = { 104 104 105 106 105 {"os2", initos2}, 106 {"signal", initsignal}, 107 107 #ifdef WITH_THREAD 108 108 {"thread", initthread}, 109 109 #endif 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 110 {"_codecs", init_codecs}, 111 {"_csv", init_csv}, 112 {"_locale", init_locale}, 113 {"_random", init_random}, 114 {"_sre", init_sre}, 115 {"_symtable", init_symtable}, 116 {"_weakref", init_weakref}, 117 {"array", initarray}, 118 {"binascii", initbinascii}, 119 {"cPickle", initcPickle}, 120 {"cStringIO", initcStringIO}, 121 {"_collections", init_collections}, 122 {"cmath", initcmath}, 123 {"datetime", initdatetime}, 124 {"dl", initdl}, 125 {"errno", initerrno}, 126 {"fcntl", initfcntl}, 127 {"_fileio", init_fileio}, 128 {"_functools", init_functools}, 129 {"_heapq", init_heapq}, 130 {"imageop", initimageop}, 131 {"itertools", inititertools}, 132 {"math", initmath}, 133 {"_md5", init_md5}, 134 {"operator", initoperator}, 135 {"_sha", init_sha}, 136 {"_sha256", init_sha256}, 137 {"_sha512", init_sha512}, 138 {"strop", initstrop}, 139 {"_struct", init_struct}, 140 {"termios", inittermios}, 141 {"time", inittime}, 142 {"timing", inittiming}, 143 {"xxsubtype", initxxsubtype}, 144 {"zipimport", initzipimport}, 145 145 #if !HAVE_DYNAMIC_LOADING 146 147 148 149 150 151 152 153 154 155 156 157 146 {"_curses", init_curses}, 147 {"_curses_panel", init_curses_panel}, 148 {"_hotshot", init_hotshot}, 149 {"_testcapi", init_testcapi}, 150 {"bsddb185", initbsddb185}, 151 {"bz2", initbz2}, 152 {"fpectl", initfpectl}, 153 {"fpetest", initfpetest}, 154 {"parser", initparser}, 155 {"pwd", initpwd}, 156 {"unicodedata", initunicodedata}, 157 {"zlib", initzlib}, 158 158 #ifdef USE_SOCKET 159 160 159 {"_socket", init_socket}, 160 {"select", initselect}, 161 161 #endif 162 162 #endif 163 163 /* -- ADDMODULE MARKER 2 -- */ 164 164 165 166 165 /* This module "lives in" with marshal.c */ 166 {"marshal", PyMarshal_Init}, 167 167 168 169 168 /* This lives it with import.c */ 169 {"imp", initimp}, 170 170 171 172 173 174 175 171 /* These entries are here for sys.builtin_module_names */ 172 {"__main__", NULL}, 173 {"__builtin__", NULL}, 174 {"sys", NULL}, 175 {"exceptions", NULL}, 176 176 177 178 177 /* This lives in gcmodule.c */ 178 {"gc", initgc}, 179 179 180 181 180 /* Sentinel */ 181 {0, 0} 182 182 }; -
python/vendor/current/PC/os2emx/dlfcn.c
r2 r388 47 47 48 48 typedef struct _track_rec { 49 50 51 52 49 char *name; 50 HMODULE handle; 51 void *id; 52 struct _track_rec *next; 53 53 } tDLLchain, *DLLchain; 54 54 55 static DLLchain dlload = NULL; 56 static char dlerr [256]; 55 static DLLchain dlload = NULL; /* A simple chained list of DLL names */ 56 static char dlerr [256]; /* last error text string */ 57 57 static void *last_id; 58 58 59 59 static DLLchain find_id(void *id) 60 60 { 61 62 63 64 65 66 67 61 DLLchain tmp; 62 63 for (tmp = dlload; tmp; tmp = tmp->next) 64 if (id == tmp->id) 65 return tmp; 66 67 return NULL; 68 68 } 69 69 … … 71 71 void *dlopen(char *filename, int flags) 72 72 { 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 73 HMODULE hm; 74 DLLchain tmp; 75 char err[256]; 76 char *errtxt; 77 int rc = 0, set_chain = 0; 78 79 for (tmp = dlload; tmp; tmp = tmp->next) 80 if (strnicmp(tmp->name, filename, 999) == 0) 81 break; 82 83 if (!tmp) 84 { 85 tmp = (DLLchain) malloc(sizeof(tDLLchain)); 86 if (!tmp) 87 goto nomem; 88 tmp->name = strdup(filename); 89 tmp->next = dlload; 90 set_chain = 1; 91 } 92 93 switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm)) 94 { 95 case NO_ERROR: 96 tmp->handle = hm; 97 if (set_chain) 98 { 99 do 100 last_id++; 101 while ((last_id == 0) || (find_id(last_id))); 102 tmp->id = last_id; 103 dlload = tmp; 104 } 105 return tmp->id; 106 case ERROR_FILE_NOT_FOUND: 107 case ERROR_PATH_NOT_FOUND: 108 errtxt = "module `%s' not found"; 109 break; 110 case ERROR_TOO_MANY_OPEN_FILES: 111 case ERROR_NOT_ENOUGH_MEMORY: 112 case ERROR_SHARING_BUFFER_EXCEEDED: 113 113 nomem: 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 114 errtxt = "out of system resources"; 115 break; 116 case ERROR_ACCESS_DENIED: 117 errtxt = "access denied"; 118 break; 119 case ERROR_BAD_FORMAT: 120 case ERROR_INVALID_SEGMENT_NUMBER: 121 case ERROR_INVALID_ORDINAL: 122 case ERROR_INVALID_MODULETYPE: 123 case ERROR_INVALID_EXE_SIGNATURE: 124 case ERROR_EXE_MARKED_INVALID: 125 case ERROR_ITERATED_DATA_EXCEEDS_64K: 126 case ERROR_INVALID_MINALLOCSIZE: 127 case ERROR_INVALID_SEGDPL: 128 case ERROR_AUTODATASEG_EXCEEDS_64K: 129 case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT: 130 errtxt = "invalid module format"; 131 break; 132 case ERROR_INVALID_NAME: 133 errtxt = "filename doesn't match module name"; 134 break; 135 case ERROR_SHARING_VIOLATION: 136 case ERROR_LOCK_VIOLATION: 137 errtxt = "sharing violation"; 138 break; 139 case ERROR_INIT_ROUTINE_FAILED: 140 errtxt = "module initialization failed"; 141 break; 142 default: 143 errtxt = "cause `%s', error code = %d"; 144 break; 145 } 146 snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc); 147 if (tmp) 148 { 149 if (tmp->name) 150 free(tmp->name); 151 free(tmp); 152 } 153 return 0; 154 154 } 155 155 … … 157 157 void *dlsym(void *handle, char *symbol) 158 158 { 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 159 int rc = 0; 160 PFN addr; 161 char *errtxt; 162 int symord = 0; 163 DLLchain tmp = find_id(handle); 164 165 if (!tmp) 166 goto inv_handle; 167 168 if (*symbol == '#') 169 symord = atoi(symbol + 1); 170 171 switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr)) 172 { 173 case NO_ERROR: 174 return (void *)addr; 175 case ERROR_INVALID_HANDLE: 176 176 inv_handle: 177 178 179 180 181 182 183 184 185 186 187 188 189 } 190 191 /* free dynamical y-linked library */177 errtxt = "invalid module handle"; 178 break; 179 case ERROR_PROC_NOT_FOUND: 180 case ERROR_INVALID_NAME: 181 errtxt = "no symbol `%s' in module"; 182 break; 183 default: 184 errtxt = "symbol `%s', error code = %d"; 185 break; 186 } 187 snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc); 188 return NULL; 189 } 190 191 /* free dynamically-linked library */ 192 192 int dlclose(void *handle) 193 193 { 194 195 196 197 198 199 200 201 202 203 204 205 206 207 194 int rc; 195 DLLchain tmp = find_id(handle); 196 197 if (!tmp) 198 goto inv_handle; 199 200 switch (rc = DosFreeModule(tmp->handle)) 201 { 202 case NO_ERROR: 203 free(tmp->name); 204 dlload = tmp->next; 205 free(tmp); 206 return 0; 207 case ERROR_INVALID_HANDLE: 208 208 inv_handle: 209 210 211 212 213 214 215 216 209 strcpy(dlerr, "invalid module handle"); 210 return -1; 211 case ERROR_INVALID_ACCESS: 212 strcpy(dlerr, "access denied"); 213 return -1; 214 default: 215 return -1; 216 } 217 217 } 218 218 … … 220 220 char *dlerror() 221 221 { 222 223 } 222 return dlerr; 223 } -
python/vendor/current/PC/os2emx/dlfcn.h
r2 r388 43 43 void *dlsym(void *handle, char *symbol); 44 44 45 /* free dynamical y-linked library */45 /* free dynamically-linked library */ 46 46 int dlclose(void *handle); 47 47 -
python/vendor/current/PC/os2emx/dllentry.c
r2 r388 5 5 #define NULL 0 6 6 7 #define REF(s) 7 #define REF(s) extern void s(); void *____ref_##s = &s; 8 8 9 9 /* Make references to imported symbols to pull them from static library */ … … 19 19 unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag) 20 20 { 21 22 23 24 25 26 21 switch (flag) 22 { 23 case 0: 24 if (_CRT_init()) 25 return 0; 26 __ctordtorInit(); 27 27 28 29 30 28 /* Ignore fatal signals */ 29 signal(SIGSEGV, SIG_IGN); 30 signal(SIGFPE, SIG_IGN); 31 31 32 32 return 1; 33 33 34 35 36 37 34 case 1: 35 __ctordtorTerm(); 36 _CRT_term(); 37 return 1; 38 38 39 40 41 39 default: 40 return 0; 41 } 42 42 } -
python/vendor/current/PC/os2emx/getpathp.c
r2 r388 5 5 /* ---------------------------------------------------------------- 6 6 PATH RULES FOR OS/2+EMX: 7 This describes how sys.path is formed on OS/2+EMX. It describes the 8 functionality, not the implementation (ie, the order in which these 7 This describes how sys.path is formed on OS/2+EMX. It describes the 8 functionality, not the implementation (ie, the order in which these 9 9 are actually fetched is different) 10 10 … … 17 17 is set, we believe it. Otherwise, we use the path of our host .EXE's 18 18 to try and locate our "landmark" (lib\\os.py) and deduce our home. 19 - If we DO have a Python Home: The relevant sub-directories (Lib, 19 - If we DO have a Python Home: The relevant sub-directories (Lib, 20 20 plat-win, lib-tk, etc) are based on the Python Home 21 21 - If we DO NOT have a Python Home, the core Python Path is 22 loaded from the registry. This is the main PythonPath key, 22 loaded from the registry. This is the main PythonPath key, 23 23 and both HKLM and HKCU are combined to form the path) 24 24 … … 33 33 the core path is deduced. 34 34 35 * When Python is hosted in another exe (different directory, embedded via 35 * When Python is hosted in another exe (different directory, embedded via 36 36 COM, etc), the Python Home will not be deduced, so the core path from 37 the registry is used. Other "application paths "in the registry are 37 the registry is used. Other "application paths "in the registry are 38 38 always read. 39 39 … … 86 86 87 87 static int 88 is_sep(char ch) 88 is_sep(char ch) /* determine if "ch" is a separator character */ 89 89 { 90 90 #ifdef ALTSEP 91 91 return ch == SEP || ch == ALTSEP; 92 92 #else 93 93 return ch == SEP; 94 94 #endif 95 95 } … … 101 101 reduce(char *dir) 102 102 { 103 104 105 106 107 } 108 103 size_t i = strlen(dir); 104 while (i > 0 && !is_sep(dir[i])) 105 --i; 106 dir[i] = '\0'; 107 } 108 109 109 static int 110 110 exists(char *filename) 111 111 { 112 113 112 struct stat buf; 113 return stat(filename, &buf) == 0; 114 114 } 115 115 116 116 /* Is module (check for .pyc/.pyo too) 117 * Assumes 'filename' MAXPATHLEN+1 bytes long - 117 * Assumes 'filename' MAXPATHLEN+1 bytes long - 118 118 * may extend 'filename' by one character. 119 119 */ … … 121 121 ismodule(char *filename) 122 122 { 123 124 125 126 127 128 129 130 131 132 123 if (exists(filename)) 124 return 1; 125 126 /* Check for the compiled version of prefix. */ 127 if (strlen(filename) < MAXPATHLEN) { 128 strcat(filename, Py_OptimizeFlag ? "o" : "c"); 129 if (exists(filename)) 130 return 1; 131 } 132 return 0; 133 133 } 134 134 … … 146 146 join(char *buffer, char *stuff) 147 147 { 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 148 size_t n, k; 149 if (is_sep(stuff[0])) 150 n = 0; 151 else { 152 n = strlen(buffer); 153 if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) 154 buffer[n++] = SEP; 155 } 156 if (n > MAXPATHLEN) 157 Py_FatalError("buffer overflow in getpathp.c's joinpath()"); 158 k = strlen(stuff); 159 if (n + k > MAXPATHLEN) 160 k = MAXPATHLEN - n; 161 strncpy(buffer+n, stuff, k); 162 buffer[n+k] = '\0'; 163 163 } 164 164 … … 170 170 gotlandmark(char *landmark) 171 171 { 172 173 174 175 176 177 178 179 } 180 181 /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. 172 int n, ok; 173 174 n = strlen(prefix); 175 join(prefix, landmark); 176 ok = ismodule(prefix); 177 prefix[n] = '\0'; 178 return ok; 179 } 180 181 /* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd. 182 182 * assumption provided by only caller, calculate_path() 183 183 */ … … 185 185 search_for_prefix(char *argv0_path, char *landmark) 186 186 { 187 188 189 190 191 192 193 194 187 /* Search from argv0_path, until landmark is found */ 188 strcpy(prefix, argv0_path); 189 do { 190 if (gotlandmark(landmark)) 191 return 1; 192 reduce(prefix); 193 } while (prefix[0]); 194 return 0; 195 195 } 196 196 … … 199 199 get_progpath(void) 200 200 { 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 201 extern char *Py_GetProgramName(void); 202 char *path = getenv("PATH"); 203 char *prog = Py_GetProgramName(); 204 205 PPIB pib; 206 if ((DosGetInfoBlocks(NULL, &pib) == 0) && 207 (DosQueryModuleName(pib->pib_hmte, sizeof(progpath), progpath) == 0)) 208 return; 209 210 if (prog == NULL || *prog == '\0') 211 prog = "python"; 212 213 /* If there is no slash in the argv0 path, then we have to 214 * assume python is on the user's $PATH, since there's no 215 * other way to find a directory to start the search from. If 216 * $PATH isn't exported, you lose. 217 */ 218 218 #ifdef ALTSEP 219 219 if (strchr(prog, SEP) || strchr(prog, ALTSEP)) 220 220 #else 221 222 #endif 223 224 225 226 227 228 229 230 221 if (strchr(prog, SEP)) 222 #endif 223 strncpy(progpath, prog, MAXPATHLEN); 224 else if (path) { 225 while (1) { 226 char *delim = strchr(path, DELIM); 227 228 if (delim) { 229 size_t len = delim - path; 230 /* ensure we can't overwrite buffer */ 231 231 #if !defined(PYCC_GCC) 232 232 len = min(MAXPATHLEN,len); 233 233 #else 234 235 #endif 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 234 len = MAXPATHLEN < len ? MAXPATHLEN : len; 235 #endif 236 strncpy(progpath, path, len); 237 *(progpath + len) = '\0'; 238 } 239 else 240 strncpy(progpath, path, MAXPATHLEN); 241 242 /* join() is safe for MAXPATHLEN+1 size buffer */ 243 join(progpath, prog); 244 if (exists(progpath)) 245 break; 246 247 if (!delim) { 248 progpath[0] = '\0'; 249 break; 250 } 251 path = delim + 1; 252 } 253 } 254 else 255 progpath[0] = '\0'; 256 256 } 257 257 … … 259 259 calculate_path(void) 260 260 { 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 bufsz = 1; 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 261 char argv0_path[MAXPATHLEN+1]; 262 char *buf; 263 size_t bufsz; 264 char *pythonhome = Py_GetPythonHome(); 265 char *envpath = getenv("PYTHONPATH"); 266 char zip_path[MAXPATHLEN+1]; 267 size_t len; 268 269 get_progpath(); 270 /* progpath guaranteed \0 terminated in MAXPATH+1 bytes. */ 271 strcpy(argv0_path, progpath); 272 reduce(argv0_path); 273 if (pythonhome == NULL || *pythonhome == '\0') { 274 if (search_for_prefix(argv0_path, LANDMARK)) 275 pythonhome = prefix; 276 else 277 pythonhome = NULL; 278 } 279 else 280 strncpy(prefix, pythonhome, MAXPATHLEN); 281 282 if (envpath && *envpath == '\0') 283 envpath = NULL; 284 285 /* Calculate zip archive path */ 286 strncpy(zip_path, progpath, MAXPATHLEN); 287 zip_path[MAXPATHLEN] = '\0'; 288 len = strlen(zip_path); 289 if (len > 4) { 290 zip_path[len-3] = 'z'; /* change ending to "zip" */ 291 zip_path[len-2] = 'i'; 292 zip_path[len-1] = 'p'; 293 } 294 else { 295 zip_path[0] = 0; 296 } 297 298 /* We need to construct a path from the following parts. 299 * (1) the PYTHONPATH environment variable, if set; 300 * (2) the zip archive file path; 301 * (3) the PYTHONPATH config macro, with the leading "." 302 * of each component replaced with pythonhome, if set; 303 * (4) the directory containing the executable (argv0_path). 304 * The length calculation calculates #3 first. 305 */ 306 307 /* Calculate size of return buffer */ 308 if (pythonhome != NULL) { 309 char *p; 310 bufsz = 1; 311 for (p = PYTHONPATH; *p; p++) { 312 if (*p == DELIM) 313 bufsz++; /* number of DELIM plus one */ 314 } 315 bufsz *= strlen(pythonhome); 316 } 317 else 318 bufsz = 0; 319 bufsz += strlen(PYTHONPATH) + 1; 320 bufsz += strlen(argv0_path) + 1; 321 bufsz += strlen(zip_path) + 1; 322 if (envpath != NULL) 323 bufsz += strlen(envpath) + 1; 324 325 module_search_path = buf = malloc(bufsz); 326 if (buf == NULL) { 327 /* We can't exit, so print a warning and limp along */ 328 fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); 329 if (envpath) { 330 fprintf(stderr, "Using environment $PYTHONPATH.\n"); 331 module_search_path = envpath; 332 } 333 else { 334 fprintf(stderr, "Using default static path.\n"); 335 module_search_path = PYTHONPATH; 336 } 337 return; 338 } 339 340 if (envpath) { 341 strcpy(buf, envpath); 342 buf = strchr(buf, '\0'); 343 *buf++ = DELIM; 344 } 345 if (zip_path[0]) { 346 strcpy(buf, zip_path); 347 buf = strchr(buf, '\0'); 348 *buf++ = DELIM; 349 } 350 351 if (pythonhome == NULL) { 352 strcpy(buf, PYTHONPATH); 353 buf = strchr(buf, '\0'); 354 } 355 else { 356 char *p = PYTHONPATH; 357 char *q; 358 size_t n; 359 for (;;) { 360 q = strchr(p, DELIM); 361 if (q == NULL) 362 n = strlen(p); 363 else 364 n = q-p; 365 if (p[0] == '.' && is_sep(p[1])) { 366 strcpy(buf, pythonhome); 367 buf = strchr(buf, '\0'); 368 p++; 369 n--; 370 } 371 strncpy(buf, p, n); 372 buf += n; 373 if (q == NULL) 374 break; 375 *buf++ = DELIM; 376 p = q+1; 377 } 378 } 379 if (argv0_path) { 380 *buf++ = DELIM; 381 strcpy(buf, argv0_path); 382 buf = strchr(buf, '\0'); 383 } 384 *buf = '\0'; 385 385 } 386 386 … … 391 391 Py_GetPath(void) 392 392 { 393 394 395 393 if (!module_search_path) 394 calculate_path(); 395 return module_search_path; 396 396 } 397 397 … … 399 399 Py_GetPrefix(void) 400 400 { 401 402 403 401 if (!module_search_path) 402 calculate_path(); 403 return prefix; 404 404 } 405 405 … … 407 407 Py_GetExecPrefix(void) 408 408 { 409 409 return Py_GetPrefix(); 410 410 } 411 411 … … 413 413 Py_GetProgramFullPath(void) 414 414 { 415 416 417 418 } 415 if (!module_search_path) 416 calculate_path(); 417 return progpath; 418 } -
python/vendor/current/PC/os2emx/python27.def
r385 r388 1 LIBRARY python2 6INITINSTANCE TERMINSTANCE1 LIBRARY python27 INITINSTANCE TERMINSTANCE 2 2 DESCRIPTION "Python 2.6 Core DLL" 3 3 PROTMODE … … 5 5 EXPORTS 6 6 7 ; From python2 6_s.lib(config)7 ; From python27_s.lib(config) 8 8 "_PyImport_Inittab" 9 9 10 ; From python2 6_s.lib(dlfcn)10 ; From python27_s.lib(dlfcn) 11 11 ; "dlopen" 12 12 ; "dlsym" … … 14 14 ; "dlerror" 15 15 16 ; From python2 6_s.lib(getpathp)16 ; From python27_s.lib(getpathp) 17 17 "Py_GetProgramFullPath" 18 18 "Py_GetPrefix" … … 20 20 "Py_GetPath" 21 21 22 ; From python2 6_s.lib(getbuildinfo)22 ; From python27_s.lib(getbuildinfo) 23 23 "Py_GetBuildInfo" 24 24 "_Py_svnversion" 25 25 26 ; From python2 6_s.lib(main)26 ; From python27_s.lib(main) 27 27 "Py_Main" 28 28 "Py_GetArgcArgv" 29 29 30 ; From python2 6_s.lib(acceler)30 ; From python27_s.lib(acceler) 31 31 "PyGrammar_AddAccelerators" 32 32 "PyGrammar_RemoveAccelerators" 33 33 34 ; From python2 6_s.lib(grammar1)34 ; From python27_s.lib(grammar1) 35 35 "PyGrammar_FindDFA" 36 36 "PyGrammar_LabelRepr" 37 37 38 ; From python2 6_s.lib(listnode)38 ; From python27_s.lib(listnode) 39 39 "PyNode_ListTree" 40 40 41 ; From python2 6_s.lib(node)41 ; From python27_s.lib(node) 42 42 "PyNode_New" 43 43 "PyNode_AddChild" 44 44 "PyNode_Free" 45 45 46 ; From python2 6_s.lib(parser)46 ; From python27_s.lib(parser) 47 47 "PyParser_AddToken" 48 48 "PyParser_New" 49 49 "PyParser_Delete" 50 50 51 ; From python2 6_s.lib(parsetok)51 ; From python27_s.lib(parsetok) 52 52 "Py_TabcheckFlag" 53 53 "PyParser_ParseString" … … 57 57 "PyParser_ParseStringFlags" 58 58 59 ; From python2 6_s.lib(bitset)59 ; From python27_s.lib(bitset) 60 60 "_Py_newbitset" 61 61 "_Py_delbitset" … … 64 64 "_Py_mergebitset" 65 65 66 ; From python2 6_s.lib(metagrammar)66 ; From python27_s.lib(metagrammar) 67 67 "_Py_meta_grammar" 68 68 "Py_meta_grammar" 69 69 70 ; From python2 6_s.lib(tokenizer)70 ; From python27_s.lib(tokenizer) 71 71 "PyToken_OneChar" 72 72 "PyToken_TwoChars" … … 78 78 "_PyParser_TokenNames" 79 79 80 ; From python2 6_s.lib(myreadline)80 ; From python27_s.lib(myreadline) 81 81 "_PyOS_ReadlineTState" 82 82 "PyOS_ReadlineFunctionPointer" … … 85 85 "PyOS_InputHook" 86 86 87 ; From python2 6_s.lib(abstract)87 ; From python27_s.lib(abstract) 88 88 "_PyObject_LengthHint" 89 89 "PyMapping_Size" … … 176 176 "PyObject_IsSubclass" 177 177 178 ; From python2 6_s.lib(boolobject)178 ; From python27_s.lib(boolobject) 179 179 "PyBool_FromLong" 180 180 "PyBool_Type" … … 182 182 "_Py_TrueStruct" 183 183 184 ; From python2 6_s.lib(bufferobject)184 ; From python27_s.lib(bufferobject) 185 185 "PyBuffer_FromObject" 186 186 "PyBuffer_FromReadWriteObject" … … 190 190 "PyBuffer_Type" 191 191 192 ; From python2 6_s.lib(cellobject)192 ; From python27_s.lib(cellobject) 193 193 "PyCell_New" 194 194 "PyCell_Get" … … 196 196 "PyCell_Type" 197 197 198 ; From python2 6_s.lib(classobject)198 ; From python27_s.lib(classobject) 199 199 "PyClass_New" 200 200 "PyClass_IsSubclass" … … 211 211 "PyMethod_Type" 212 212 213 ; From python26_s.lib(cobject) 213 ; From python27_s.lib(capsule) 214 "PyCapsule_GetContext" 215 "PyCapsule_GetDestructor" 216 "PyCapsule_GetName" 217 "PyCapsule_GetPointer" 218 "PyCapsule_Import" 219 "PyCapsule_IsValid" 220 "PyCapsule_New" 221 "PyCapsule_SetContext" 222 "PyCapsule_SetDestructor" 223 "PyCapsule_SetName" 224 "PyCapsule_SetPointer" 225 226 ; From python27_s.lib(cobject) 214 227 "PyCObject_FromVoidPtr" 215 228 "PyCObject_FromVoidPtrAndDesc" … … 220 233 "PyCObject_Type" 221 234 222 ; From python2 6_s.lib(codeobject)235 ; From python27_s.lib(codeobject) 223 236 "PyCode_New" 224 237 "PyCode_Addr2Line" … … 226 239 "PyCode_Type" 227 240 228 ; From python2 6_s.lib(complexobject)241 ; From python27_s.lib(complexobject) 229 242 "_Py_c_pow" 230 243 "_Py_c_sum" … … 240 253 "PyComplex_Type" 241 254 242 ; From python2 6_s.lib(descrobject)255 ; From python27_s.lib(descrobject) 243 256 "PyWrapper_New" 244 257 "PyDescr_NewMethod" … … 251 264 "PyProperty_Type" 252 265 253 ; From python2 6_s.lib(dictobject)266 ; From python27_s.lib(dictobject) 254 267 "PyDict_New" 255 268 "PyDict_GetItem" … … 275 288 "PyDictIterItem_Type" 276 289 277 ; From python2 6_s.lib(enumobject)290 ; From python27_s.lib(enumobject) 278 291 "PyEnum_Type" 279 292 "PyReversed_Type" 280 293 281 ; From python2 6_s.lib(fileobject)294 ; From python27_s.lib(fileobject) 282 295 "PyFile_FromString" 283 296 "Py_UniversalNewlineFread" … … 295 308 "PyFile_Type" 296 309 297 ; From python2 6_s.lib(floatobject)310 ; From python27_s.lib(floatobject) 298 311 "PyFloat_FromString" 299 312 "PyFloat_AsDouble" … … 307 320 "PyFloat_AsString" 308 321 "_PyFloat_Init" 309 "PyFloat_AsStringEx"310 322 "PyFloat_Type" 311 323 312 ; From python2 6_s.lib(frameobject)324 ; From python27_s.lib(frameobject) 313 325 "PyFrame_New" 314 326 "PyFrame_FastToLocals" … … 320 332 "PyFrame_Type" 321 333 322 ; From python2 6_s.lib(funcobject)334 ; From python27_s.lib(funcobject) 323 335 "PyFunction_New" 324 336 "PyFunction_GetCode" … … 335 347 "PyStaticMethod_Type" 336 348 337 ; From python2 6_s.lib(genobject)349 ; From python27_s.lib(genobject) 338 350 "PyGen_New" 339 351 "PyGen_NeedsFinalizing" 340 352 "PyGen_Type" 341 353 342 ; From python2 6_s.lib(intobject)354 ; From python27_s.lib(intobject) 343 355 "PyInt_AsLong" 344 356 "PyInt_AsUnsignedLongMask" … … 355 367 "PyInt_Type" 356 368 357 ; From python2 6_s.lib(iterobject)369 ; From python27_s.lib(iterobject) 358 370 "PySeqIter_New" 359 371 "PyCallIter_New" … … 361 373 "PyCallIter_Type" 362 374 363 ; From python2 6_s.lib(listobject)375 ; From python27_s.lib(listobject) 364 376 "PyList_New" 365 377 "PyList_Append" … … 379 391 "PyListRevIter_Type" 380 392 381 ; From python2 6_s.lib(longobject)393 ; From python27_s.lib(longobject) 382 394 "PyLong_FromDouble" 383 395 "PyLong_AsLong" … … 409 421 "_PyLong_DigitValue" 410 422 411 ; From python2 6_s.lib(methodobject)423 ; From python27_s.lib(methodobject) 412 424 "PyCFunction_Call" 413 425 "Py_FindMethodInChain" … … 421 433 "PyCFunction_Type" 422 434 423 ; From python2 6_s.lib(moduleobject)435 ; From python27_s.lib(moduleobject) 424 436 "PyModule_New" 425 437 "_PyModule_Clear" … … 429 441 "PyModule_Type" 430 442 431 ; From python2 6_s.lib(object)443 ; From python27_s.lib(object) 432 444 "Py_DivisionWarningFlag" 433 445 "PyObject_Str" … … 482 494 "_PyTrash_delete_later" 483 495 484 ; From python2 6_s.lib(obmalloc)496 ; From python27_s.lib(obmalloc) 485 497 "PyObject_Malloc" 486 498 "PyObject_Free" 487 499 "PyObject_Realloc" 488 500 489 ; From python2 6_s.lib(rangeobject)501 ; From python27_s.lib(rangeobject) 490 502 "PyRange_Type" 491 503 492 ; From python2 6_s.lib(setobject)504 ; From python27_s.lib(setobject) 493 505 "PySet_Pop" 494 506 "PySet_New" … … 505 517 "PyFrozenSet_Type" 506 518 507 ; From python2 6_s.lib(sliceobject)519 ; From python27_s.lib(sliceobject) 508 520 "_PySlice_FromIndices" 509 521 "PySlice_GetIndices" … … 513 525 "PySlice_Type" 514 526 515 ; From python2 6_s.lib(stringobject)527 ; From python27_s.lib(stringobject) 516 528 "PyString_FromStringAndSize" 517 529 "PyString_InternInPlace" … … 544 556 "PyBaseString_Type" 545 557 546 ; From python2 6_s.lib(structseq)558 ; From python27_s.lib(structseq) 547 559 "PyStructSequence_InitType" 548 560 "PyStructSequence_New" 549 561 "PyStructSequence_UnnamedField" 550 562 551 ; From python2 6_s.lib(tupleobject)563 ; From python27_s.lib(tupleobject) 552 564 "PyTuple_New" 553 565 "PyTuple_Pack" … … 561 573 "PyTupleIter_Type" 562 574 563 ; From python2 6_s.lib(typeobject)575 ; From python27_s.lib(typeobject) 564 576 "PyType_IsSubtype" 565 577 "_PyType_Lookup" … … 572 584 "PySuper_Type" 573 585 574 ; From python2 6_s.lib(unicodeobject)586 ; From python27_s.lib(unicodeobject) 575 587 "PyUnicodeUCS2_Resize" 576 588 "PyUnicodeUCS2_FromOrdinal" … … 638 650 "PyUnicode_Type" 639 651 640 ; From python2 6_s.lib(unicodectype)652 ; From python27_s.lib(unicodectype) 641 653 "_PyUnicode_TypeRecords" 642 654 "_PyUnicodeUCS2_ToNumeric" … … 656 668 "_PyUnicodeUCS2_IsAlpha" 657 669 658 ; From python2 6_s.lib(weakrefobject)670 ; From python27_s.lib(weakrefobject) 659 671 "PyWeakref_NewRef" 660 672 "PyWeakref_NewProxy" … … 667 679 "_PyWeakref_CallableProxyType" 668 680 669 ; From python2 6_s.lib(Python-ast)681 ; From python27_s.lib(Python-ast) 670 682 ; "init_ast" 671 683 "Module" … … 726 738 "PyAST_mod2obj" 727 739 728 ; From python2 6_s.lib(asdl)740 ; From python27_s.lib(asdl) 729 741 "asdl_seq_new" 730 742 "asdl_int_seq_new" 731 743 732 ; From python2 6_s.lib(ast)744 ; From python27_s.lib(ast) 733 745 "PyAST_FromNode" 734 746 735 ; From python2 6_s.lib(bltinmodule)747 ; From python27_s.lib(bltinmodule) 736 748 "_PyBuiltin_Init" 737 749 "Py_FileSystemDefaultEncoding" 738 750 739 ; From python2 6_s.lib(exceptions)751 ; From python27_s.lib(exceptions) 740 752 "PyUnicodeEncodeError_GetStart" 741 753 "PyUnicodeDecodeError_GetStart" … … 813 825 "PyExc_MemoryErrorInst" 814 826 815 ; From python2 6_s.lib(ceval)827 ; From python27_s.lib(ceval) 816 828 "PyEval_EvalFrameEx" 817 829 "PyEval_CallObjectWithKeywords" … … 852 864 "_Py_Ticker" 853 865 854 ; From python2 6_s.lib(compile)866 ; From python27_s.lib(compile) 855 867 "_Py_Mangle" 856 868 "PyAST_Compile" … … 858 870 "Py_OptimizeFlag" 859 871 860 ; From python2 6_s.lib(codecs)872 ; From python27_s.lib(codecs) 861 873 "_PyCodec_Lookup" 862 874 "PyCodec_Encode" … … 877 889 "PyCodec_StrictErrors" 878 890 879 ; From python2 6_s.lib(errors)891 ; From python27_s.lib(errors) 880 892 "PyErr_SetNone" 881 893 "PyErr_SetString" … … 903 915 "PyErr_WarnExplicit" 904 916 905 ; From python2 6_s.lib(frozen)917 ; From python27_s.lib(frozen) 906 918 "PyImport_FrozenModules" 907 919 908 ; From python2 6_s.lib(frozenmain)920 ; From python27_s.lib(frozenmain) 909 921 "Py_FrozenMain" 910 922 911 ; From python2 6_s.lib(future)923 ; From python27_s.lib(future) 912 924 "PyFuture_FromAST" 913 925 914 ; From python2 6_s.lib(getargs)926 ; From python27_s.lib(getargs) 915 927 "PyArg_Parse" 916 928 "_PyArg_Parse_SizeT" … … 926 938 "_PyArg_VaParseTupleAndKeywords_SizeT" 927 939 928 ; From python2 6_s.lib(getcompiler)940 ; From python27_s.lib(getcompiler) 929 941 "Py_GetCompiler" 930 942 931 ; From python2 6_s.lib(getcopyright)943 ; From python27_s.lib(getcopyright) 932 944 "Py_GetCopyright" 933 945 934 ; From python26_s.lib(getmtime) 935 "PyOS_GetLastModificationTime" 936 937 ; From python26_s.lib(getplatform) 946 ; From python27_s.lib(getplatform) 938 947 "Py_GetPlatform" 939 948 940 ; From python2 6_s.lib(getversion)949 ; From python27_s.lib(getversion) 941 950 "Py_GetVersion" 942 951 943 ; From python2 6_s.lib(graminit)952 ; From python27_s.lib(graminit) 944 953 "_PyParser_Grammar" 945 954 946 ; From python2 6_s.lib(import)955 ; From python27_s.lib(import) 947 956 "_PyImport_Init" 948 957 "_PyImportHooks_Init" … … 971 980 "_PyImport_Filetab" 972 981 973 ; From python2 6_s.lib(importdl)982 ; From python27_s.lib(importdl) 974 983 "_PyImport_LoadDynamicModule" 975 984 976 ; From python2 6_s.lib(marshal)985 ; From python27_s.lib(marshal) 977 986 "PyMarshal_ReadLongFromFile" 978 987 "PyMarshal_WriteObjectToString" … … 985 994 "PyMarshal_Init" 986 995 987 ; From python2 6_s.lib(modsupport)996 ; From python27_s.lib(modsupport) 988 997 "Py_InitModule4" 989 998 "Py_BuildValue" … … 998 1007 "_Py_PackageContext" 999 1008 1000 ; From python2 6_s.lib(mysnprintf)1009 ; From python27_s.lib(mysnprintf) 1001 1010 "PyOS_snprintf" 1002 1011 "PyOS_vsnprintf" 1003 1012 1004 ; From python2 6_s.lib(mystrtoul)1013 ; From python27_s.lib(mystrtoul) 1005 1014 "PyOS_strtoul" 1006 1015 "PyOS_strtol" 1007 1016 1008 ; From python2 6_s.lib(pyarena)1017 ; From python27_s.lib(pyarena) 1009 1018 "PyArena_New" 1010 1019 "PyArena_Free" … … 1012 1021 "PyArena_AddPyObject" 1013 1022 1014 ; From python2 6_s.lib(pyfpe)1023 ; From python27_s.lib(pyfpe) 1015 1024 "PyFPE_dummy" 1016 1025 1017 ; From python2 6_s.lib(pystate)1026 ; From python27_s.lib(pystate) 1018 1027 "PyInterpreterState_Clear" 1019 1028 "PyThreadState_Clear" … … 1040 1049 "_PyThreadState_GetFrame" 1041 1050 1042 ; From python2 6_s.lib(pystrtod)1051 ; From python27_s.lib(pystrtod) 1043 1052 "PyOS_ascii_strtod" 1044 1053 "PyOS_ascii_formatd" 1045 1054 "PyOS_ascii_atof" 1046 1055 1047 ; From python2 6_s.lib(pythonrun)1056 ; From python27_s.lib(pythonrun) 1048 1057 "Py_IgnoreEnvironmentFlag" 1049 1058 "Py_DebugFlag" … … 1107 1116 "_Py_QnewFlag" 1108 1117 1109 ; From python2 6_s.lib(structmember)1118 ; From python27_s.lib(structmember) 1110 1119 "PyMember_Get" 1111 1120 "PyMember_GetOne" … … 1113 1122 "PyMember_Set" 1114 1123 1115 ; From python2 6_s.lib(symtable)1124 ; From python27_s.lib(symtable) 1116 1125 "PySymtable_Build" 1117 1126 "PySymtable_Free" … … 1120 1129 "PySTEntry_Type" 1121 1130 1122 ; From python2 6_s.lib(sysmodule)1131 ; From python27_s.lib(sysmodule) 1123 1132 "_PySys_Init" 1124 1133 "PySys_WriteStderr" … … 1134 1143 "PySys_AddWarnOption" 1135 1144 1136 ; From python2 6_s.lib(traceback)1145 ; From python27_s.lib(traceback) 1137 1146 "PyTraceBack_Here" 1138 1147 "PyTraceBack_Print" 1139 1148 "PyTraceBack_Type" 1140 1149 1141 ; From python2 6_s.lib(getopt)1150 ; From python27_s.lib(getopt) 1142 1151 "_PyOS_GetOpt" 1143 1152 "_PyOS_opterr" … … 1145 1154 "_PyOS_optarg" 1146 1155 1147 ; From python2 6_s.lib(dynload_shlib)1156 ; From python27_s.lib(dynload_shlib) 1148 1157 "_PyImport_DynLoadFiletab" 1149 1158 "_PyImport_GetDynLoadFunc" 1150 1159 1151 ; From python2 6_s.lib(thread)1160 ; From python27_s.lib(thread) 1152 1161 "PyThread_delete_key_value" 1153 1162 "PyThread_init_thread" … … 1165 1174 "PyThread_set_key_value" 1166 1175 "PyThread_get_key_value" 1167 "PyThread__exit_thread" 1168 1169 ; From python26_s.lib(gcmodule) 1176 1177 ; From python27_s.lib(gcmodule) 1170 1178 ; "initgc" 1171 1179 "_PyObject_GC_New" … … 1183 1191 "_PyGC_generation0" 1184 1192 1185 ; From python2 6_s.lib(signalmodule)1193 ; From python27_s.lib(signalmodule) 1186 1194 ; "initsignal" 1187 1195 "PyErr_CheckSignals" … … 1192 1200 "PyOS_AfterFork" 1193 1201 1194 ; From python2 6_s.lib(posixmodule)1202 ; From python27_s.lib(posixmodule) 1195 1203 ; "initos2" 1196 1204 1197 ; From python2 6_s.lib(threadmodule)1205 ; From python27_s.lib(threadmodule) 1198 1206 ; "initthread" 1199 1207 1200 ; From python2 6_s.lib(arraymodule)1208 ; From python27_s.lib(arraymodule) 1201 1209 ; "initarray" 1202 1210 ; "array_methods" 1203 1211 1204 ; From python2 6_s.lib(binascii)1212 ; From python27_s.lib(binascii) 1205 1213 ; "initbinascii" 1206 1214 1207 ; From python2 6_s.lib(cmathmodule)1215 ; From python27_s.lib(cmathmodule) 1208 1216 ; "initcmath" 1209 1217 1210 ; From python2 6_s.lib(_codecsmodule)1218 ; From python27_s.lib(_codecsmodule) 1211 1219 ; "init_codecs" 1212 1220 1213 ; From python2 6_s.lib(collectionsmodule)1221 ; From python27_s.lib(collectionsmodule) 1214 1222 ; "initcollections" 1215 1223 "dequeiter_type" 1216 1224 "dequereviter_type" 1217 1225 1218 ; From python2 6_s.lib(cPickle)1226 ; From python27_s.lib(cPickle) 1219 1227 ; "initcPickle" 1220 1228 ; "fast_save_leave" 1221 1229 1222 ; From python2 6_s.lib(cStringIO)1230 ; From python27_s.lib(cStringIO) 1223 1231 ; "initcStringIO" 1224 1232 1225 ; From python2 6_s.lib(_csv)1233 ; From python27_s.lib(_csv) 1226 1234 ; "init_csv" 1227 1235 1228 ; From python2 6_s.lib(datetimemodule)1236 ; From python27_s.lib(datetimemodule) 1229 1237 ; "initdatetime" 1230 1238 1231 ; From python2 6_s.lib(dlmodule)1239 ; From python27_s.lib(dlmodule) 1232 1240 ; "initdl" 1233 1241 1234 ; From python2 6_s.lib(errnomodule)1242 ; From python27_s.lib(errnomodule) 1235 1243 ; "initerrno" 1236 1244 1237 ; From python2 6_s.lib(fcntlmodule)1245 ; From python27_s.lib(fcntlmodule) 1238 1246 ; "initfcntl" 1239 1247 1240 ; From python2 6_s.lib(_functoolsmodule)1248 ; From python27_s.lib(_functoolsmodule) 1241 1249 ; "init_functools" 1242 1250 1243 ; From python2 6_s.lib(_heapqmodule)1251 ; From python27_s.lib(_heapqmodule) 1244 1252 ; "init_heapq" 1245 1253 1246 ; From python2 6_s.lib(imageop)1254 ; From python27_s.lib(imageop) 1247 1255 ; "initimageop" 1248 1256 1249 ; From python2 6_s.lib(itertoolsmodule)1257 ; From python27_s.lib(itertoolsmodule) 1250 1258 ; "inititertools" 1251 1259 1252 ; From python2 6_s.lib(_localemodule)1260 ; From python27_s.lib(_localemodule) 1253 1261 ; "init_locale" 1254 1262 1255 ; From python2 6_s.lib(mathmodule)1263 ; From python27_s.lib(mathmodule) 1256 1264 ; "initmath" 1257 1265 1258 ; From python2 6_s.lib(md5)1266 ; From python27_s.lib(md5) 1259 1267 "md5_finish" 1260 1268 "md5_init" 1261 1269 "md5_append" 1262 1270 1263 ; From python2 6_s.lib(md5module)1271 ; From python27_s.lib(md5module) 1264 1272 ; "init_md5" 1265 1273 1266 ; From python2 6_s.lib(operator)1274 ; From python27_s.lib(operator) 1267 1275 ; "initoperator" 1268 1276 1269 ; From python2 6_s.lib(_randommodule)1277 ; From python27_s.lib(_randommodule) 1270 1278 ; "init_random" 1271 1279 1272 ; From python2 6_s.lib(rgbimgmodule)1280 ; From python27_s.lib(rgbimgmodule) 1273 1281 ; "initrgbimg" 1274 1282 1275 ; From python2 6_s.lib(shamodule)1283 ; From python27_s.lib(shamodule) 1276 1284 ; "init_sha" 1277 1285 1278 ; From python2 6_s.lib(sha256module)1286 ; From python27_s.lib(sha256module) 1279 1287 ; "init_sha256" 1280 1288 1281 ; From python2 6_s.lib(sha512module)1289 ; From python27_s.lib(sha512module) 1282 1290 ; "init_sha512" 1283 1291 1284 ; From python2 6_s.lib(_sre)1292 ; From python27_s.lib(_sre) 1285 1293 ; "init_sre" 1286 1294 1287 ; From python2 6_s.lib(stropmodule)1295 ; From python27_s.lib(stropmodule) 1288 1296 ; "initstrop" 1289 1297 1290 ; From python2 6_s.lib(_struct)1298 ; From python27_s.lib(_struct) 1291 1299 ; "init_struct" 1292 1300 1293 ; From python2 6_s.lib(symtablemodule)1301 ; From python27_s.lib(symtablemodule) 1294 1302 ; "init_symtable" 1295 1303 1296 ; From python2 6_s.lib(termios)1304 ; From python27_s.lib(termios) 1297 1305 ; "inittermios" 1298 1306 1299 ; From python2 6_s.lib(timemodule)1307 ; From python27_s.lib(timemodule) 1300 1308 ; "inittime" 1301 1309 "_PyTime_DoubleToTimet" 1302 1310 ; "inittimezone" 1303 1311 1304 ; From python2 6_s.lib(timingmodule)1312 ; From python27_s.lib(timingmodule) 1305 1313 ; "inittiming" 1306 1314 1307 ; From python2 6_s.lib(_weakref)1315 ; From python27_s.lib(_weakref) 1308 1316 ; "init_weakref" 1309 1317 1310 ; From python2 6_s.lib(xxsubtype)1318 ; From python27_s.lib(xxsubtype) 1311 1319 ; "initxxsubtype" 1312 1320 1313 ; From python2 6_s.lib(zipimport)1321 ; From python27_s.lib(zipimport) 1314 1322 ; "initzipimport" -
python/vendor/current/PC/os2emx/pythonpm.c
r2 r388 28 28 typedef struct 29 29 { 30 31 32 33 30 int argc; 31 char **argv; 32 HWND Frame; 33 int running; 34 34 } arglist; 35 35 … … 46 46 main(int argc, char **argv) 47 47 { 48 49 50 51 52 53 54 55 56 57 58 59 48 ULONG FrameFlags = FCF_TITLEBAR | 49 FCF_SYSMENU | 50 FCF_SIZEBORDER | 51 FCF_HIDEBUTTON | 52 FCF_SHELLPOSITION | 53 FCF_TASKLIST; 54 HAB hab; 55 HMQ hmq; 56 HWND Client; 57 QMSG qmsg; 58 arglist args; 59 int python_tid; 60 60 61 62 63 61 /* init PM and create message queue */ 62 hab = WinInitialize(0); 63 hmq = WinCreateMsgQueue(hab, 0); 64 64 65 66 67 68 69 70 71 72 73 74 65 /* create a (hidden) Window to house the window procedure */ 66 args.Frame = WinCreateStdWindow(HWND_DESKTOP, 67 0, 68 &FrameFlags, 69 NULL, 70 "PythonPM", 71 0L, 72 0, 73 0, 74 &Client); 75 75 76 /* run Python interpreter in a thread */ 77 args.argc = argc; 78 args.argv = argv; 79 args.running = 0; 80 if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) 81 { 82 /* couldn't start thread */ 83 WinAlarm(HWND_DESKTOP, WA_ERROR); 84 PythonRC = 1; 85 } 86 else 87 { 88 /* process PM messages, until Python exits */ 89 while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) 90 WinDispatchMsg(hab, &qmsg); 91 if (args.running > 0) 92 DosKillThread(python_tid); 93 } 94 95 /* destroy window, shutdown message queue and PM */ 96 WinDestroyWindow(args.Frame); 97 WinDestroyMsgQueue(hmq); 98 WinTerminate(hab); 76 /* run Python interpreter in a thread */ 77 args.argc = argc; 78 args.argv = argv; 79 args.running = 0; 80 if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args))) 81 { 82 /* couldn't start thread */ 83 WinAlarm(HWND_DESKTOP, WA_ERROR); 84 PythonRC = 1; 85 } 86 else 87 { 88 /* process PM messages, until Python exits */ 89 while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0)) 90 WinDispatchMsg(hab, &qmsg); 91 if (args.running > 0) 92 DosKillThread(python_tid); 93 } 99 94 100 return PythonRC; 95 /* destroy window, shutdown message queue and PM */ 96 WinDestroyWindow(args.Frame); 97 WinDestroyMsgQueue(hmq); 98 WinTerminate(hab); 99 100 return PythonRC; 101 101 } 102 102 103 103 void PythonThread(void *argl) 104 104 { 105 106 105 HAB hab; 106 arglist *args; 107 107 108 109 108 /* PM initialisation */ 109 hab = WinInitialize(0); 110 110 111 112 113 114 111 /* start Python */ 112 args = (arglist *)argl; 113 args->running = 1; 114 PythonRC = Py_Main(args->argc, args->argv); 115 115 116 117 118 119 116 /* enter a critical section and send the termination message */ 117 DosEnterCritSec(); 118 args->running = 0; 119 WinPostMsg(args->Frame, WM_QUIT, NULL, NULL); 120 120 121 122 123 121 /* shutdown PM and terminate thread */ 122 WinTerminate(hab); 123 _endthread(); 124 124 } -
python/vendor/current/PC/os2vacpp/getpathp.c
r2 r388 56 56 57 57 static int 58 is_sep(char ch) 58 is_sep(char ch) /* determine if "ch" is a separator character */ 59 59 { 60 60 #ifdef ALTSEP 61 61 return ch == SEP || ch == ALTSEP; 62 62 #else 63 63 return ch == SEP; 64 64 #endif 65 65 } … … 69 69 reduce(char *dir) 70 70 { 71 72 73 74 75 } 76 71 int i = strlen(dir); 72 while (i > 0 && !is_sep(dir[i])) 73 --i; 74 dir[i] = '\0'; 75 } 76 77 77 78 78 static int 79 79 exists(char *filename) 80 80 { 81 82 81 struct stat buf; 82 return stat(filename, &buf) == 0; 83 83 } 84 84 … … 96 96 join(char *buffer, char *stuff) 97 97 { 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 98 int n, k; 99 if (is_sep(stuff[0])) 100 n = 0; 101 else { 102 n = strlen(buffer); 103 if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) 104 buffer[n++] = SEP; 105 } 106 if (n > MAXPATHLEN) 107 Py_FatalError("buffer overflow in getpathp.c's joinpath()"); 108 k = strlen(stuff); 109 if (n + k > MAXPATHLEN) 110 k = MAXPATHLEN - n; 111 strncpy(buffer+n, stuff, k); 112 buffer[n+k] = '\0'; 113 113 } 114 114 … … 117 117 search_for_prefix(char *argv0_path, char *landmark) 118 118 { 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 119 int n; 120 121 /* Search from argv0_path, until root is found */ 122 strcpy(prefix, argv0_path); 123 do { 124 n = strlen(prefix); 125 join(prefix, landmark); 126 if (exists(prefix)) { 127 prefix[n] = '\0'; 128 return 1; 129 } 130 prefix[n] = '\0'; 131 reduce(prefix); 132 } while (prefix[0]); 133 return 0; 134 134 } 135 135 … … 148 148 getpythonregpath(HKEY keyBase, BOOL bWin32s) 149 149 { 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 150 HKEY newKey = 0; 151 DWORD nameSize = 0; 152 DWORD dataSize = 0; 153 DWORD numEntries = 0; 154 LONG rc; 155 char *retval = NULL; 156 char *dataBuf; 157 const char keyPrefix[] = "Software\\Python\\PythonCore\\"; 158 const char keySuffix[] = "\\PythonPath"; 159 int versionLen; 160 char *keyBuf; 161 162 // Tried to use sysget("winver") but here is too early :-( 163 versionLen = strlen(PyWin_DLLVersionString); 164 // alloca == no free required, but memory only local to fn. 165 // also no heap fragmentation! Am I being silly? 166 keyBuf = alloca(sizeof(keyPrefix)-1 + versionLen + sizeof(keySuffix)); // chars only, plus 1 NULL. 167 // lots of constants here for the compiler to optimize away :-) 168 memcpy(keyBuf, keyPrefix, sizeof(keyPrefix)-1); 169 memcpy(keyBuf+sizeof(keyPrefix)-1, PyWin_DLLVersionString, versionLen); 170 memcpy(keyBuf+sizeof(keyPrefix)-1+versionLen, keySuffix, sizeof(keySuffix)); // NULL comes with this one! 171 172 rc=RegOpenKey(keyBase, 173 keyBuf, 174 &newKey); 175 if (rc==ERROR_SUCCESS) { 176 RegQueryInfoKey(newKey, NULL, NULL, NULL, NULL, NULL, NULL, 177 &numEntries, &nameSize, &dataSize, NULL, NULL); 178 } 179 if (bWin32s && numEntries==0 && dataSize==0) { 180 /* must hardcode for Win32s */ 181 numEntries = 1; 182 dataSize = 511; 183 } 184 if (numEntries) { 185 /* Loop over all subkeys. */ 186 /* Win32s doesnt know how many subkeys, so we do 187 it twice */ 188 char keyBuf[MAX_PATH+1]; 189 int index = 0; 190 int off = 0; 191 for(index=0;;index++) { 192 long reqdSize = 0; 193 DWORD rc = RegEnumKey(newKey, 194 index, keyBuf, MAX_PATH+1); 195 if (rc) break; 196 rc = RegQueryValue(newKey, keyBuf, NULL, &reqdSize); 197 if (rc) break; 198 if (bWin32s && reqdSize==0) reqdSize = 512; 199 dataSize += reqdSize + 1; /* 1 for the ";" */ 200 } 201 dataBuf = malloc(dataSize+1); 202 if (dataBuf==NULL) 203 return NULL; /* pretty serious? Raise error? */ 204 /* Now loop over, grabbing the paths. 205 Subkeys before main library */ 206 for(index=0;;index++) { 207 int adjust; 208 long reqdSize = dataSize; 209 DWORD rc = RegEnumKey(newKey, 210 index, keyBuf,MAX_PATH+1); 211 if (rc) break; 212 rc = RegQueryValue(newKey, 213 keyBuf, dataBuf+off, &reqdSize); 214 if (rc) break; 215 if (reqdSize>1) { 216 /* If Nothing, or only '\0' copied. */ 217 adjust = strlen(dataBuf+off); 218 dataSize -= adjust; 219 off += adjust; 220 dataBuf[off++] = ';'; 221 dataBuf[off] = '\0'; 222 dataSize--; 223 } 224 } 225 /* Additionally, win32s doesnt work as expected, so 226 the specific strlen() is required for 3.1. */ 227 rc = RegQueryValue(newKey, "", dataBuf+off, &dataSize); 228 if (rc==ERROR_SUCCESS) { 229 if (strlen(dataBuf)==0) 230 free(dataBuf); 231 else 232 retval = dataBuf; /* caller will free */ 233 } 234 else 235 free(dataBuf); 236 } 237 238 if (newKey) 239 RegCloseKey(newKey); 240 return retval; 241 241 } 242 242 #endif /* MS_WIN32 */ … … 245 245 get_progpath(void) 246 246 { 247 248 249 250 251 #ifdef MS_WIN32 252 253 254 #endif 255 256 257 258 259 260 261 262 247 extern char *Py_GetProgramName(void); 248 char *path = getenv("PATH"); 249 char *prog = Py_GetProgramName(); 250 251 #ifdef MS_WIN32 252 if (GetModuleFileName(NULL, progpath, MAXPATHLEN)) 253 return; 254 #endif 255 if (prog == NULL || *prog == '\0') 256 prog = "python"; 257 258 /* If there is no slash in the argv0 path, then we have to 259 * assume python is on the user's $PATH, since there's no 260 * other way to find a directory to start the search from. If 261 * $PATH isn't exported, you lose. 262 */ 263 263 #ifdef ALTSEP 264 264 if (strchr(prog, SEP) || strchr(prog, ALTSEP)) 265 265 #else 266 267 #endif 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 266 if (strchr(prog, SEP)) 267 #endif 268 strcpy(progpath, prog); 269 else if (path) { 270 while (1) { 271 char *delim = strchr(path, DELIM); 272 273 if (delim) { 274 int len = delim - path; 275 strncpy(progpath, path, len); 276 *(progpath + len) = '\0'; 277 } 278 else 279 strcpy(progpath, path); 280 281 join(progpath, prog); 282 if (exists(progpath)) 283 break; 284 285 if (!delim) { 286 progpath[0] = '\0'; 287 break; 288 } 289 path = delim + 1; 290 } 291 } 292 else 293 progpath[0] = '\0'; 294 294 } 295 295 … … 297 297 calculate_path(void) 298 298 { 299 300 301 302 303 304 #ifdef MS_WIN32 305 306 307 308 309 310 machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE); 311 312 313 314 315 316 #endif 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 } 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 bufsz = 1; 358 359 360 361 362 363 364 365 366 367 368 369 370 #ifdef MS_WIN32 371 372 373 374 375 #endif 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 #ifdef MS_WIN32 398 399 400 401 402 403 404 405 406 407 408 #endif 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 299 char argv0_path[MAXPATHLEN+1]; 300 char *buf; 301 int bufsz; 302 char *pythonhome = Py_GetPythonHome(); 303 char *envpath = Py_GETENV("PYTHONPATH"); 304 #ifdef MS_WIN32 305 char *machinepath, *userpath; 306 307 /* Are we running under Windows 3.1(1) Win32s? */ 308 if (PyWin_IsWin32s()) { 309 /* Only CLASSES_ROOT is supported */ 310 machinepath = getpythonregpath(HKEY_CLASSES_ROOT, TRUE); 311 userpath = NULL; 312 } else { 313 machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, FALSE); 314 userpath = getpythonregpath(HKEY_CURRENT_USER, FALSE); 315 } 316 #endif 317 318 get_progpath(); 319 strcpy(argv0_path, progpath); 320 reduce(argv0_path); 321 if (pythonhome == NULL || *pythonhome == '\0') { 322 if (search_for_prefix(argv0_path, LANDMARK)) 323 pythonhome = prefix; 324 else 325 pythonhome = NULL; 326 } 327 else { 328 char *delim; 329 330 strcpy(prefix, pythonhome); 331 332 /* Extract Any Optional Trailing EXEC_PREFIX */ 333 /* e.g. PYTHONHOME=<prefix>:<exec_prefix> */ 334 delim = strchr(prefix, DELIM); 335 if (delim) { 336 *delim = '\0'; 337 strcpy(exec_prefix, delim+1); 338 } else 339 strcpy(exec_prefix, EXEC_PREFIX); 340 } 341 342 if (envpath && *envpath == '\0') 343 envpath = NULL; 344 345 /* We need to construct a path from the following parts: 346 (1) the PYTHONPATH environment variable, if set; 347 (2) for Win32, the machinepath and userpath, if set; 348 (3) the PYTHONPATH config macro, with the leading "." 349 of each component replaced with pythonhome, if set; 350 (4) the directory containing the executable (argv0_path). 351 The length calculation calculates #3 first. 352 */ 353 354 /* Calculate size of return buffer */ 355 if (pythonhome != NULL) { 356 char *p; 357 bufsz = 1; 358 for (p = PYTHONPATH; *p; p++) { 359 if (*p == DELIM) 360 bufsz++; /* number of DELIM plus one */ 361 } 362 bufsz *= strlen(pythonhome); 363 } 364 else 365 bufsz = 0; 366 bufsz += strlen(PYTHONPATH) + 1; 367 if (envpath != NULL) 368 bufsz += strlen(envpath) + 1; 369 bufsz += strlen(argv0_path) + 1; 370 #ifdef MS_WIN32 371 if (machinepath) 372 bufsz += strlen(machinepath) + 1; 373 if (userpath) 374 bufsz += strlen(userpath) + 1; 375 #endif 376 377 module_search_path = buf = malloc(bufsz); 378 if (buf == NULL) { 379 /* We can't exit, so print a warning and limp along */ 380 fprintf(stderr, "Can't malloc dynamic PYTHONPATH.\n"); 381 if (envpath) { 382 fprintf(stderr, "Using default static $PYTHONPATH.\n"); 383 module_search_path = envpath; 384 } 385 else { 386 fprintf(stderr, "Using environment $PYTHONPATH.\n"); 387 module_search_path = PYTHONPATH; 388 } 389 return; 390 } 391 392 if (envpath) { 393 strcpy(buf, envpath); 394 buf = strchr(buf, '\0'); 395 *buf++ = DELIM; 396 } 397 #ifdef MS_WIN32 398 if (machinepath) { 399 strcpy(buf, machinepath); 400 buf = strchr(buf, '\0'); 401 *buf++ = DELIM; 402 } 403 if (userpath) { 404 strcpy(buf, userpath); 405 buf = strchr(buf, '\0'); 406 *buf++ = DELIM; 407 } 408 #endif 409 if (pythonhome == NULL) { 410 strcpy(buf, PYTHONPATH); 411 buf = strchr(buf, '\0'); 412 } 413 else { 414 char *p = PYTHONPATH; 415 char *q; 416 int n; 417 for (;;) { 418 q = strchr(p, DELIM); 419 if (q == NULL) 420 n = strlen(p); 421 else 422 n = q-p; 423 if (p[0] == '.' && is_sep(p[1])) { 424 strcpy(buf, pythonhome); 425 buf = strchr(buf, '\0'); 426 p++; 427 n--; 428 } 429 strncpy(buf, p, n); 430 buf += n; 431 if (q == NULL) 432 break; 433 *buf++ = DELIM; 434 p = q+1; 435 } 436 } 437 if (argv0_path) { 438 *buf++ = DELIM; 439 strcpy(buf, argv0_path); 440 buf = strchr(buf, '\0'); 441 } 442 *buf = '\0'; 443 443 } 444 444 … … 449 449 Py_GetPath(void) 450 450 { 451 452 453 454 451 if (!module_search_path) 452 calculate_path(); 453 454 return module_search_path; 455 455 } 456 456 … … 458 458 Py_GetPrefix(void) 459 459 { 460 461 462 463 460 if (!module_search_path) 461 calculate_path(); 462 463 return prefix; 464 464 } 465 465 … … 467 467 Py_GetExecPrefix(void) 468 468 { 469 470 471 472 469 if (!module_search_path) 470 calculate_path(); 471 472 return exec_prefix; 473 473 } 474 474 … … 476 476 Py_GetProgramFullPath(void) 477 477 { 478 479 480 481 482 } 478 if (!module_search_path) 479 calculate_path(); 480 481 return progpath; 482 } -
python/vendor/current/PC/os2vacpp/makefile
r2 r388 204 204 $(PATHOBJ)\StructModule.obj \ 205 205 $(PATHOBJ)\TimeModule.obj \ 206 $(PATHOBJ)\ThreadModule.obj \ 207 $(PATHOBJ)\YUVConvert.obj 206 $(PATHOBJ)\ThreadModule.obj 208 207 209 208 # Standalone Parser Generator Program (Shares Some of Python's Modules) … … 1114 1113 $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \ 1115 1114 $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ 1116 $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h \ 1117 $(PY_MODULES)\yuv.h 1115 $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h 1118 1116 1119 1117 syslogmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ … … 1198 1196 $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ 1199 1197 $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h 1200 1201 yuvconvert.obj: $(PY_MODULES)\yuv.h1202 1198 1203 1199 zlibmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ … … 1697 1693 $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ 1698 1694 $(PY_INCLUDE)\tupleobject.h 1699 1700 getmtime.obj: pyconfig.h1701 1695 1702 1696 getplatform.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \ -
python/vendor/current/PC/os2vacpp/makefile.omk
r2 r388 165 165 StructModule.obj \ 166 166 TimeModule.obj \ 167 ThreadModule.obj \ 168 YUVConvert.obj 167 ThreadModule.obj 169 168 170 169 # Omitted Modules (and Description/Reason): … … 804 803 moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \ 805 804 pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ 806 sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h \ 807 yuv.h 805 sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h 808 806 809 807 syslogmodule.obj: abstract.h ceval.h classobject.h cobject.h \ … … 854 852 pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \ 855 853 traceback.h tupleobject.h 856 857 yuvconvert.obj: yuv.h858 854 859 855 zlibmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ … … 1160 1156 stringobject.h sysmodule.h traceback.h tupleobject.h 1161 1157 1162 getmtime.obj: pyconfig.h1163 1164 1158 getplatform.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \ 1165 1159 pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \ -
python/vendor/current/PC/os2vacpp/python.def
r2 r388 7 7 ; Data 8 8 PyCFunction_Type 9 PyCapsule_Type 9 10 PyCObject_Type 10 11 PyClass_Type … … 76 77 _Py_ZeroStruct 77 78 _Py_abstract_hack 79 _Py_capsule_hack 78 80 _Py_cobject_hack 79 81 _Py_re_syntax … … 90 92 PyCFunction_GetSelf 91 93 PyCFunction_New 94 PyCapsule_GetContext 95 PyCapsule_GetDestructor 96 PyCapsule_GetName 97 PyCapsule_GetPointer 98 PyCapsule_Import 99 PyCapsule_IsValid 100 PyCapsule_New 101 PyCapsule_SetContext 102 PyCapsule_SetDestructor 103 PyCapsule_SetName 104 PyCapsule_SetPointer 92 105 PyCObject_AsVoidPtr 93 106 PyCObject_FromVoidPtrAndDesc … … 285 298 PyOS_AfterFork 286 299 PyOS_FiniInterrupts 287 PyOS_GetLastModificationTime288 300 PyOS_InitInterrupts 289 301 PyOS_InterruptOccurred … … 370 382 PyThreadState_New 371 383 PyThreadState_Swap 372 PyThread__exit_thread373 384 PyThread_acquire_lock 374 385 PyThread_allocate_lock -
python/vendor/current/PC/pyconfig.h
r2 r388 96 96 97 97 #ifdef MS_WINCE 98 /* Python uses GetVersion() to distinguish between99 * Windows NT and 9x/ME where OS Unicode support is concerned.100 * Windows CE supports Unicode in the same way as NT so we101 * define the missing GetVersion() accordingly.102 */103 #define GetVersion() (4)104 98 /* Windows CE does not support environment variables */ 105 99 #define getenv(v) (NULL) … … 330 324 taken care of by distutils.) */ 331 325 # ifdef _DEBUG 332 # pragma comment(lib,"python2 6_d.lib")326 # pragma comment(lib,"python27_d.lib") 333 327 # else 334 # pragma comment(lib,"python2 6.lib")328 # pragma comment(lib,"python27.lib") 335 329 # endif /* _DEBUG */ 336 330 # endif /* _MSC_VER */ … … 349 343 # define SIZEOF_HKEY 8 350 344 # define SIZEOF_SIZE_T 8 351 /* configure. indefines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,345 /* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, 352 346 sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t). 353 347 On Win64 the second condition is not true, but if fpos_t replaces off_t … … 401 395 #endif 402 396 397 /* define signed and unsigned exact-width 32-bit and 64-bit types, used in the 398 implementation of Python long integers. */ 399 #ifndef PY_UINT32_T 400 #if SIZEOF_INT == 4 401 #define HAVE_UINT32_T 1 402 #define PY_UINT32_T unsigned int 403 #elif SIZEOF_LONG == 4 404 #define HAVE_UINT32_T 1 405 #define PY_UINT32_T unsigned long 406 #endif 407 #endif 408 409 #ifndef PY_UINT64_T 410 #if SIZEOF_LONG_LONG == 8 411 #define HAVE_UINT64_T 1 412 #define PY_UINT64_T unsigned PY_LONG_LONG 413 #endif 414 #endif 415 416 #ifndef PY_INT32_T 417 #if SIZEOF_INT == 4 418 #define HAVE_INT32_T 1 419 #define PY_INT32_T int 420 #elif SIZEOF_LONG == 4 421 #define HAVE_INT32_T 1 422 #define PY_INT32_T long 423 #endif 424 #endif 425 426 #ifndef PY_INT64_T 427 #if SIZEOF_LONG_LONG == 8 428 #define HAVE_INT64_T 1 429 #define PY_INT64_T PY_LONG_LONG 430 #endif 431 #endif 432 403 433 /* Fairly standard from here! */ 404 434 … … 530 560 #define Py_UNICODE_SIZE 2 531 561 532 /* Define to indicate that the Python Unicode representation can be passed533 as-is to Win32 Wide API. */534 #define Py_WIN_WIDE_FILENAMES535 536 562 /* Use Python's own small-block memory-allocator. */ 537 563 #define WITH_PYMALLOC 1 … … 617 643 #define HAVE_WCSCOLL 1 618 644 #endif 645 646 /* Define if the zlib library has inflateCopy */ 647 #define HAVE_ZLIB_COPY 1 619 648 620 649 /* Define if you have the <dlfcn.h> header file. */ … … 724 753 #define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE 725 754 755 /* Define if C doubles are 64-bit IEEE 754 binary format, stored with the 756 least significant byte first */ 757 #define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1 758 726 759 #endif /* !Py_CONFIG_H */ -
python/vendor/current/PC/python_nt.rc
r2 r388 62 62 VALUE "FileVersion", PYTHON_VERSION 63 63 VALUE "InternalName", "Python DLL\0" 64 VALUE "LegalCopyright", "Copyright © 2001-20 10Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0"64 VALUE "LegalCopyright", "Copyright © 2001-2008 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0" 65 65 VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" 66 66 VALUE "ProductName", "Python\0" -
python/vendor/current/PC/winsound.c
r2 r388 79 79 80 80 if(!PyArg_ParseTuple(args,"z#i:PlaySound",&sound,&length,&flags)) { 81 81 return NULL; 82 82 } 83 83 84 84 if(flags&SND_ASYNC && flags &SND_MEMORY) { 85 86 87 88 85 /* Sidestep reference counting headache; unfortunately this also 86 prevent SND_LOOP from memory. */ 87 PyErr_SetString(PyExc_RuntimeError,"Cannot play asynchronously from memory"); 88 return NULL; 89 89 } 90 90 … … 94 94 if(!ok) 95 95 { 96 97 96 PyErr_SetString(PyExc_RuntimeError,"Failed to play sound"); 97 return NULL; 98 98 } 99 99 … … 105 105 sound_beep(PyObject *self, PyObject *args) 106 106 { 107 108 109 107 int freq; 108 int dur; 109 BOOL ok; 110 110 111 112 111 if (!PyArg_ParseTuple(args, "ii:Beep", &freq, &dur)) 112 return NULL; 113 113 114 115 116 117 118 114 if (freq < 37 || freq > 32767) { 115 PyErr_SetString(PyExc_ValueError, 116 "frequency must be in 37 thru 32767"); 117 return NULL; 118 } 119 119 120 121 122 123 124 125 126 120 Py_BEGIN_ALLOW_THREADS 121 ok = Beep(freq, dur); 122 Py_END_ALLOW_THREADS 123 if (!ok) { 124 PyErr_SetString(PyExc_RuntimeError,"Failed to beep"); 125 return NULL; 126 } 127 127 128 129 128 Py_INCREF(Py_None); 129 return Py_None; 130 130 } 131 131 … … 133 133 sound_msgbeep(PyObject *self, PyObject *args) 134 134 { 135 136 137 138 139 140 135 int x = MB_OK; 136 if (!PyArg_ParseTuple(args, "|i:MessageBeep", &x)) 137 return NULL; 138 MessageBeep(x); 139 Py_INCREF(Py_None); 140 return Py_None; 141 141 } 142 142 … … 156 156 if(v&&k) 157 157 { 158 158 PyDict_SetItem(dict,k,v); 159 159 } 160 160 Py_XDECREF(k); … … 167 167 initwinsound(void) 168 168 { 169 170 171 172 173 174 175 169 PyObject *dict; 170 PyObject *module = Py_InitModule3("winsound", 171 sound_methods, 172 sound_module_doc); 173 if (module == NULL) 174 return; 175 dict = PyModule_GetDict(module); 176 176 177 178 179 180 181 182 183 184 185 186 177 ADD_DEFINE(SND_ASYNC); 178 ADD_DEFINE(SND_NODEFAULT); 179 ADD_DEFINE(SND_NOSTOP); 180 ADD_DEFINE(SND_NOWAIT); 181 ADD_DEFINE(SND_ALIAS); 182 ADD_DEFINE(SND_FILENAME); 183 ADD_DEFINE(SND_MEMORY); 184 ADD_DEFINE(SND_PURGE); 185 ADD_DEFINE(SND_LOOP); 186 ADD_DEFINE(SND_APPLICATION); 187 187 188 189 190 191 192 188 ADD_DEFINE(MB_OK); 189 ADD_DEFINE(MB_ICONASTERISK); 190 ADD_DEFINE(MB_ICONEXCLAMATION); 191 ADD_DEFINE(MB_ICONHAND); 192 ADD_DEFINE(MB_ICONQUESTION); 193 193 }
Note:
See TracChangeset
for help on using the changeset viewer.