#ifndef PYWIN9X_COMPAT_MSVC600_PATHCCH_H #define PYWIN9X_COMPAT_MSVC600_PATHCCH_H /* * Narrow PathCchFindExtension compatibility for the VC6/MSVC600 probe. * * CPython 3.11's Modules/getpath.c includes only to call * PathCchFindExtension() from getpath_isxfile(). MSVC 6.0's Windows SDK * predates PathCch, so provide just that one API shape for the project-local * VC6 include path. Modern builds should keep using the platform SDK header; * this file is not installed into CPython or a system include directory. */ #if defined(_MSC_VER) && _MSC_VER <= 1200 #ifndef _WINDOWS_ #include #endif #include #ifndef PCWSTR typedef const WCHAR *PCWSTR; #endif #ifndef PWSTR typedef WCHAR *PWSTR; #endif #ifndef S_OK #define S_OK ((HRESULT)0L) #endif #ifndef E_INVALIDARG #define E_INVALIDARG ((HRESULT)0x80070057L) #endif static HRESULT PathCchFindExtension(PCWSTR pszPath, size_t cchPath, PCWSTR *ppszExt) { size_t i; size_t last_sep; size_t last_dot; int have_dot; if (pszPath == NULL || ppszExt == NULL || cchPath == 0) { return E_INVALIDARG; } last_sep = 0; last_dot = 0; have_dot = 0; for (i = 0; i < cchPath; ++i) { WCHAR ch = pszPath[i]; if (ch == L'\0') { if (have_dot) { *ppszExt = pszPath + last_dot; } else { *ppszExt = pszPath + i; } return S_OK; } if (ch == L'\\' || ch == L'/' || ch == L':') { last_sep = i + 1; have_dot = 0; } else if (ch == L'.' && i >= last_sep) { last_dot = i; have_dot = 1; } } *ppszExt = NULL; return E_INVALIDARG; } #else /* * This compatibility header is intentionally scoped to VC6. If a modern * compiler finds it, the include path is wrong: use the real Windows SDK * pathcch.h instead to avoid shadowing the platform declaration. */ #error "compat/msvc600/pathcch.h is only for MSVC 6.0; use the Windows SDK pathcch.h on modern compilers" #endif #endif /* PYWIN9X_COMPAT_MSVC600_PATHCCH_H */