source: docker/msys/pywin32.patch@ 920:42b14124051b

python3
Last change on this file since 920:42b14124051b was 920:42b14124051b, checked in by István Váradi <ivaradi@…>, 5 years ago

Win 10 Docker image for building the new Python3-based distribution

File size: 98.6 KB
  • com/win32com/src/ErrorUtils.cpp

    diff --git a/com/win32com/src/ErrorUtils.cpp b/com/win32com/src/ErrorUtils.cpp
    index 1186cd1..314aff8 100644
    a b LPCTSTR GetScodeRangeString(HRESULT hr)  
    11181118                HRESULT hrLast;
    11191119                LPCTSTR lpszName;
    11201120        };
     1121#if defined(__MINGW32__)
     1122        #define MAKE_RANGE_ENTRY(hrRange) \
     1123                { static_cast<HRESULT>(hrRange##_FIRST), static_cast<HRESULT>(hrRange##_LAST), \
     1124                        _T(#hrRange) _T("_FIRST...") _T(#hrRange) _T("_LAST") }
     1125#else
    11211126        #define MAKE_RANGE_ENTRY(hrRange) \
    11221127                { hrRange##_FIRST, hrRange##_LAST, \
    11231128                        _T(#hrRange) _T("_FIRST...") _T(#hrRange) _T("_LAST") }
     1129#endif
    11241130
    11251131        static const RANGE_ENTRY hrRangeTable[] =
    11261132        {
  • com/win32com/src/PyGatewayBase.cpp

    diff --git a/com/win32com/src/PyGatewayBase.cpp b/com/win32com/src/PyGatewayBase.cpp
    index fc091cb..2ed9acc 100644
    a b  
    77
    88#include "PythonCOMServer.h"
    99
     10#if defined(__MINGW32__)
     11#include <algorithm>
     12#endif
     13
    1014// {25D29CD0-9B98-11d0-AE79-4CF1CF000000}
    1115extern const GUID IID_IInternalUnwrapPythonObject =
    1216        { 0x25d29cd0, 0x9b98, 0x11d0, { 0xae, 0x79, 0x4c, 0xf1, 0xcf, 0x0, 0x0, 0x0 } };
    static HRESULT invoke_setup(  
    437441                // make sure its not a special DISPID we don't understand.
    438442                if (params->rgdispidNamedArgs[i] < 0)
    439443                        return DISP_E_PARAMNOTFOUND;
     444#if defined(__MINGW32__)
     445                numArgs = std::max(numArgs, (UINT)params->rgdispidNamedArgs[i]+1);
     446#else
    440447                numArgs = max(numArgs, (UINT)params->rgdispidNamedArgs[i]+1);
     448#endif
    441449        }
    442450
    443451        PyObject *argList = PyTuple_New(numArgs);
    static HRESULT invoke_finish(  
    658666                        ob = NULL;
    659667                        firstByRef = 1;
    660668                }
     669#if defined(__MINGW32__)
     670                UINT max_args = std::min(cUserResult-firstByRef, pDispParams->cArgs);
     671#else
    661672                UINT max_args = min(cUserResult-firstByRef, pDispParams->cArgs);
     673#endif
    662674                UINT *offsets = (UINT *)_malloca(sizeof(UINT) * max_args);
    663675                // Get the offsets into our params of all BYREF args, in order.
    664676                fill_byref_offsets(pDispParams, offsets, max_args);
  • com/win32com/src/PythonCOM.cpp

    diff --git a/com/win32com/src/PythonCOM.cpp b/com/win32com/src/PythonCOM.cpp
    index da00839..67983a4 100644
    a b static PyObject *pythoncom_CoInitializeSecurity(PyObject *self, PyObject *args)  
    342342                        pSD = (PSECURITY_DESCRIPTOR)&appid;
    343343                        }
    344344                }
     345#if !defined(__MINGW32__)
    345346        else if (dwCapabilities & EOAC_ACCESS_CONTROL){
    346347                if (!PyCom_InterfaceFromPyObject(obSD, IID_IAccessControl, (void **)&pIAC, FALSE))
    347348                        return NULL;
    348349                pSD = (PSECURITY_DESCRIPTOR)pIAC;
    349350                }
     351#endif
    350352        else{
    351353                if (!PyWinObject_AsSECURITY_DESCRIPTOR(obSD, &pSD, /*BOOL bNoneOK = */TRUE))
    352354                        return NULL;
  • com/win32com/src/PythonCOM.def

    diff --git a/com/win32com/src/PythonCOM.def b/com/win32com/src/PythonCOM.def
    index 58d030f..6d2a54b 100644
    a b  
    11EXPORTS
    2         DllCanUnloadNow     @1 PRIVATE
    3         DllGetClassObject   @2 PRIVATE
     2        DllCanUnloadNow
     3        DllGetClassObject
    44
    55        ; Some exports for clients who may "LoadLibrary"...
    6         PyCom_VariantFromPyObject
    7         PyCom_PyObjectFromVariant
    8         PyCom_InterfaceFromPyObject
    9         PyCom_PyObjectFromIUnknown
    10         PyCom_MakeOlePythonCall
     6        _PyCom_VariantFromPyObject
     7        _PyCom_PyObjectFromVariant
     8        _PyCom_InterfaceFromPyObject
     9        _PyCom_PyObjectFromIUnknown
     10        _PyCom_MakeOlePythonCall
    1111
    12         PyCom_CoInitializeEx
    13         PyCom_CoInitialize
    14         PyCom_CoUninitialize
     12        _PyCom_CoInitializeEx
     13        _PyCom_CoInitialize
     14        _PyCom_CoUninitialize
    1515
  • com/win32com/src/Register.cpp

    diff --git a/com/win32com/src/Register.cpp b/com/win32com/src/Register.cpp
    index 0b24ee2..d259aff 100644
    a b static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] =  
    322322        PYCOM_INTERFACE_FULL       ( CancelMethodCalls),
    323323        // No wrapper for IAccessControl yet, but you can still get the system implementation
    324324        //  by calling pythoncom.CoCreateInstance with IID_IUnknown as the returned interface
     325#if !defined(__MINGW32__)
    325326        PYCOM_INTERFACE_CLSID_ONLY (DCOMAccessControl),
     327#endif
    326328
    327329        // NULL, Unknown and dispatch special cases.
    328330        { &IID_NULL, "Null", "IID_NULL", NULL, NULL},
  • com/win32com/src/dllmain.cpp

    diff --git a/com/win32com/src/dllmain.cpp b/com/win32com/src/dllmain.cpp
    index fb81ddb..abf074c 100644
    a b typedef HRESULT (WINAPI *PFNCoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit);  
    175175// the Init for Term function explicitely, and the framework will detect
    176176// it no longer needs doing.
    177177// XXX - Needs more thought about threading implications.
     178#if defined(__MINGW32__)
     179extern "C"
     180#endif
    178181HRESULT PyCom_CoInitializeEx(LPVOID reserved, DWORD dwInit)
    179182{
    180183        // Must be thread-safe, although doesnt need the Python lock.
  • com/win32com/src/include/PythonCOM.h

    diff --git a/com/win32com/src/include/PythonCOM.h b/com/win32com/src/include/PythonCOM.h
    index 9e422e4..f3b1063 100644
    a b  
    111111#ifdef __MINGW32__
    112112// Special Mingw32 considerations.
    113113#define NO_PYCOM_IDISPATCHEX
    114 #define NO_PYCOM_IPROVIDECLASSINFO
    115114#define NO_PYCOM_ISERVICEPROVIDER
    116115#define NO_PYCOM_ENUMSTATPROPSTG
    117 #define NO_PYCOM_IPROPERTYSTORAGE
    118116#define __try try
    119117#define __except catch
    120118#include <olectl.h>
    PYCOM_EXPORT PyObject *PyObject_FromOLEMENUGROUPWIDTHS(const OLEMENUGROUPWIDTHS  
    305303
    306304/* Functions for Initializing COM, and also letting the core know about it!
    307305*/
     306#if defined(__MINGW32__)
     307extern "C"
     308#endif
    308309PYCOM_EXPORT HRESULT PyCom_CoInitializeEx(LPVOID reserved, DWORD dwInit);
    309310PYCOM_EXPORT HRESULT PyCom_CoInitialize(LPVOID reserved);
    310311PYCOM_EXPORT void PyCom_CoUninitialize();
  • new file com/win32com/src/initguid.cpp

    diff --git a/com/win32com/src/initguid.cpp b/com/win32com/src/initguid.cpp
    new file mode 100644
    index 0000000..33d5923
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
  • com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp

    diff --git a/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp b/com/win32comext/axcontrol/src/PyIOleCommandTarget.cpp
    index 61bd706..e7908e9 100644
    a b  
    44#include "axcontrol_pch.h"
    55#include "PyIOleCommandTarget.h"
    66
     7#if defined(__MINGW32__)
     8#include <algorithm>
     9#endif
     10
    711static BOOL FillOLECMDsWithSequence(OLECMD *pCmds, UINT ncmds, PyObject *obCmds)
    812{
    913        for (UINT i=0;i<ncmds;i++) {
    STDMETHODIMP PyGOleCommandTarget::QueryStatus(  
    211215                        ok = PyWinObject_AsAutoFreeBstr(obText, &tempString);
    212216                        if (ok) {
    213217                                UINT strLen = SysStringLen(tempString);
     218#if defined(__MINGW32__)
     219                                UINT nwrite = std::min((ULONG)strLen, pCmdText->cwBuf);
     220#else
    214221                                UINT nwrite = min(strLen, pCmdText->cwBuf);
     222#endif
    215223                                wcsncpy(pCmdText->rgwz, (WCHAR *)(BSTR)tempString,
    216224                                        nwrite);
    217225                                pCmdText->cwActual = nwrite;
  • new file com/win32comext/axcontrol/src/initguid.cpp

    diff --git a/com/win32comext/axcontrol/src/initguid.cpp b/com/win32comext/axcontrol/src/initguid.cpp
    new file mode 100644
    index 0000000..329e211
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
     8#include <docobj.h>
  • new file com/win32comext/axscript/src/initguid.cpp

    diff --git a/com/win32comext/axscript/src/initguid.cpp b/com/win32comext/axscript/src/initguid.cpp
    new file mode 100644
    index 0000000..ba6baa3
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
     8#include <objsafe.h>
  • com/win32comext/internet/src/PyIInternetProtocol.cpp

    diff --git a/com/win32comext/internet/src/PyIInternetProtocol.cpp b/com/win32comext/internet/src/PyIInternetProtocol.cpp
    index 43c25a8..b910c85 100644
    a b  
    55#include "PyIInternetProtocolRoot.h"
    66#include "PyIInternetProtocol.h"
    77
     8#if defined(__MINGW32__)
     9#include <algorithm>
     10#endif
     11
    812// @doc - This file contains autoduck documentation
    913// ---------------------------------------------------
    1014//
    STDMETHODIMP PyGInternetProtocol::Read(  
    181185                hr = PyCom_HandlePythonFailureToCOM();
    182186        } else {
    183187                char *buf = PyString_AsString(result);
     188#if defined(__MINGW32__)
     189                *pcbRead = std::min(cb, (ULONG)PyString_Size(result));
     190#else
    184191                *pcbRead = min(cb, (ULONG)PyString_Size(result));
     192#endif
    185193                memcpy( pv, buf, *pcbRead);
    186194        }
    187195        return hr;
  • com/win32comext/internet/src/PyIInternetProtocolInfo.cpp

    diff --git a/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp b/com/win32comext/internet/src/PyIInternetProtocolInfo.cpp
    index c00e43e..ef894ca 100644
    a b  
    44#include "internet_pch.h"
    55#include "PyIInternetProtocolInfo.h"
    66
     7#if defined(__MINGW32__)
     8#include <algorithm>
     9#endif
     10
    711// @doc - This file contains autoduck documentation
    812// ---------------------------------------------------
    913//
    STDMETHODIMP PyGInternetProtocolInfo::ParseUrl(  
    226230        if (!PyWinObject_AsBstr(result, &bstrTemp, FALSE, pcchResult)) bPythonIsHappy = FALSE;
    227231        if (!bPythonIsHappy) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
    228232        ++(*pcchResult); // Null terminator
     233#if defined(__MINGW32__)
     234        *pcchResult = std::min(*pcchResult, cchResult);
     235#else
    229236        *pcchResult = min(*pcchResult, cchResult);
     237#endif
    230238        memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR));
    231239        SysFreeString(bstrTemp);
    232240        Py_DECREF(result);
    STDMETHODIMP PyGInternetProtocolInfo::CombineUrl(  
    258266        if (!PyWinObject_AsBstr(result, &bstrTemp, FALSE, pcchResult)) bPythonIsHappy = FALSE;
    259267        if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/);
    260268        ++(*pcchResult); // Null terminator
     269#if defined(__MINGW32__)
     270        *pcchResult = std::min(*pcchResult, cchResult);
     271#else
    261272        *pcchResult = min(*pcchResult, cchResult);
     273#endif
    262274        memcpy(pwzResult, bstrTemp, *pcchResult * sizeof(WCHAR));
    263275        SysFreeString(bstrTemp);
    264276        Py_DECREF(result);
    STDMETHODIMP PyGInternetProtocolInfo::QueryInfo(  
    312324                        return PyCom_HandlePythonFailureToCOM();
    313325                }
    314326        } else {
     327#if defined(__MINGW32__)
     328                *pcbBuf = std::min(cbBuffer, (ULONG)PyString_Size(result));
     329#else
    315330                *pcbBuf = min(cbBuffer, (ULONG)PyString_Size(result));
     331#endif
    316332                memcpy(pBuffer, PyString_AsString(result), *pcbBuf);
    317333        }
    318334        Py_DECREF(result);
  • com/win32comext/internet/src/PyIInternetSecurityManager.cpp

    diff --git a/com/win32comext/internet/src/PyIInternetSecurityManager.cpp b/com/win32comext/internet/src/PyIInternetSecurityManager.cpp
    index 81439fc..a4cb106 100644
    a b  
    44#include "internet_pch.h"
    55#include "PyIInternetSecurityManager.h"
    66
     7#if defined(__MINGW32__)
     8#include <algorithm>
     9#endif
     10
    711// @doc - This file contains autoduck documentation
    812// ---------------------------------------------------
    913//
    STDMETHODIMP PyGInternetSecurityManager::GetSecurityId(  
    338342                Py_DECREF(result);
    339343                return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetSecurityId");
    340344        }
     345#if defined(__MINGW32__)
     346        *pcbSecurityId = std::min(buf_len, *pcbSecurityId);
     347#else
    341348        *pcbSecurityId = min(buf_len, *pcbSecurityId);
     349#endif
    342350        memcpy(pbSecurityId, buf, *pcbSecurityId);
    343351        Py_DECREF(result);
    344352        return hr;
  • new file com/win32comext/internet/src/initguid.cpp

    diff --git a/com/win32comext/internet/src/initguid.cpp b/com/win32comext/internet/src/initguid.cpp
    new file mode 100644
    index 0000000..1003585
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
     8#include <urlmon.h>
     9#include <mshtmhst.h>
  • com/win32comext/propsys/src/PyPROPVARIANT.cpp

    diff --git a/com/win32comext/propsys/src/PyPROPVARIANT.cpp b/com/win32comext/propsys/src/PyPROPVARIANT.cpp
    index b330129..694703f 100644
    a b  
    33
    44#include "PythonCOM.h"
    55#include "PyPROPVARIANT.h"
     6#if defined(__MINGW32__)
     7extern "C" {
     8#endif
    69#include "propvarutil.h"
     10#if defined(__MINGW32__)
     11}
     12#endif
    713#include "float.h"
    814
    915// @doc - This file contains autoduck documentation
  • com/win32comext/propsys/src/propsys.cpp

    diff --git a/com/win32comext/propsys/src/propsys.cpp b/com/win32comext/propsys/src/propsys.cpp
    index ef0a2f4..69ff21f 100644
    a b static PyObject *PyPSGetItemPropertyHandler(PyObject *self, PyObject *args)  
    279279        return PyCom_PyObjectFromIUnknown((IUnknown *)propertystore, riid, FALSE);
    280280}
    281281
     282#if !defined(__MINGW32__)
    282283// @pymethod bytes|propsys|StgSerializePropVariant|Serializes a <o PyPROPVARIANT>
    283284static PyObject *PyStgSerializePropVariant(PyObject *self, PyObject *args)
    284285{
    static PyObject *PyStgDeserializePropVariant(PyObject *self, PyObject *args)  
    319320                return PyCom_BuildPyException(hr);
    320321        return PyWinObject_FromPROPVARIANT(&pv);
    321322};
     323#endif
    322324
    323325// @pymethod <o PyIPropertyStore>|propsys|PSCreateMemoryPropertyStore|Creates a temporary property store that is not connected to any backing storage
    324326// @comm May also be used to create <o PyINamedPropertyStore>, <o PyIPropertyStoreCache>, <o PyIPersistStream>, or <o PyIPropertyBag>
    static struct PyMethodDef propsys_methods[]=  
    566568        { "PSRegisterPropertySchema", PyPSRegisterPropertySchema, 1 }, // @pymeth PSRegisterPropertySchema|Registers a group of properties described in a schema file
    567569        { "PSUnregisterPropertySchema", PyPSUnregisterPropertySchema, 1 }, // @pymeth PSUnregisterPropertySchema|Removes a property schema definition
    568570        { "SHGetPropertyStoreFromParsingName", PySHGetPropertyStoreFromParsingName, 1 }, // @pymeth SHGetPropertyStoreFromParsingName|Retrieves the property store for an item by path
     571#if !defined(__MINGW32__)
    569572        { "StgSerializePropVariant", PyStgSerializePropVariant, 1 }, // @pymeth StgSerializePropVariant|Serializes a <o PyPROPVARIANT>
    570573        { "StgDeserializePropVariant", PyStgDeserializePropVariant, 1 }, // @pymeth StgDeserializePropVariant|Creates a <o PyPROPVARIANT> from a serialized buffer
     574#endif
    571575        { "PSCreateMemoryPropertyStore", PyPSCreateMemoryPropertyStore, 1 }, // @pymeth PSCreateMemoryPropertyStore|Creates a temporary property store that is not connected to any backing storage
    572576        { "PSCreatePropertyStoreFromPropertySetStorage", PyPSCreatePropertyStoreFromPropertySetStorage, 1 }, // @pymeth PSCreatePropertyStoreFromPropertySetStorage|Wraps a <o PyIPropertySetStorage> interface in a <o PyIPropertyStore> object
    573577        { "PSLookupPropertyHandlerCLSID", PyPSLookupPropertyHandlerCLSID, 1 }, // @pymeth PSLookupPropertyHandlerCLSID|Returns the GUID of the property handler for a file
    static struct PyMethodDef propsys_methods[]=  
    583587        // MSDN says CLSID_PropertyChangeArray can be used to create IPropertyChangeArray, but
    584588        // I get "Class not registered".  Plus, it doesn't appear in any headers, although
    585589        // it's contained in uuid.lib.
    586 #ifndef CLSID_PropertyChangeArray
     590#if !defined(CLSID_PropertyChangeArray) && !defined(__MINGW32__)
    587591        EXTERN_C const CLSID CLSID_PropertyChangeArray;
    588592#endif
    589593
    static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] =  
    606610        PYCOM_INTERFACE_CLIENT_ONLY (ObjectWithPropertyKey),
    607611        PYCOM_INTERFACE_CLIENT_ONLY (PropertyChange),
    608612        PYCOM_INTERFACE_CLIENT_ONLY (PropertyChangeArray),
     613#if !defined(__MINGW32__)
    609614        PYCOM_INTERFACE_CLSID_ONLY (PropertyChangeArray),
     615#endif
    610616};
    611617
    612618/* Module initialisation */
  • com/win32comext/shell/src/PyICategoryProvider.cpp

    diff --git a/com/win32comext/shell/src/PyICategoryProvider.cpp b/com/win32comext/shell/src/PyICategoryProvider.cpp
    index e2f2ea8..0ecf0cf 100644
    a b  
    99//
    1010// Interface Implementation
    1111
     12#if defined(__MINGW32__)
     13__CRT_UUID_DECL(int, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
     14#endif
     15
    1216PyICategoryProvider::PyICategoryProvider(IUnknown *pdisp):
    1317        PyIUnknown(pdisp)
    1418{
  • new file com/win32comext/shell/src/initguid.cpp

    diff --git a/com/win32comext/shell/src/initguid.cpp b/com/win32comext/shell/src/initguid.cpp
    new file mode 100644
    index 0000000..8da5c87
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
     8#include <shlguid.h>
     9#include <shobjidl.h>
     10#include <emptyvc.h>
     11#include <_mingw.h>
  • com/win32comext/shell/src/shell.cpp

    diff --git a/com/win32comext/shell/src/shell.cpp b/com/win32comext/shell/src/shell.cpp
    index 8b6e78c..f19a021 100644
    a b generates Windows .hlp files.  
    2929#include "PyIShellExtInit.h"
    3030#include "PyIShellFolder.h"
    3131#include "PyIShellFolder2.h"
     32#if !defined(__MINGW32__)
    3233#include "PyIEmptyVolumeCache.h"
    3334#include "PyIEmptyVolumeCacheCallBack.h"
     35#endif
    3436#include "PyIEnumExplorerCommand.h"
    3537#include "PyIEnumIDList.h"
    3638#include "PyICopyHook.h"
    static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] =  
    36063608        PYCOM_INTERFACE_FULL(ColumnProvider),
    36073609        PYCOM_INTERFACE_CLIENT_ONLY(DefaultExtractIconInit),
    36083610        PYCOM_INTERFACE_FULL(DropTargetHelper),
     3611#if !defined(__MINGW32__)
    36093612        PYCOM_INTERFACE_CLIENT_ONLY(EmptyVolumeCacheCallBack),
     3613#endif
    36103614        PYCOM_INTERFACE_CLIENT_ONLY(QueryAssociations),
    36113615        PYCOM_INTERFACE_SERVER_ONLY(DeskBand),
    36123616        PYCOM_INTERFACE_SERVER_ONLY(DockingWindow),
     3617#if !defined(__MINGW32__)
    36133618        PYCOM_INTERFACE_SERVER_ONLY(EmptyVolumeCache),
    36143619        PYCOM_INTERFACE_SERVER_ONLY(EmptyVolumeCache2),
     3620#endif
    36153621        PYCOM_INTERFACE_CLIENT_ONLY(ExplorerBrowser),
    36163622        PYCOM_INTERFACE_FULL(ExplorerBrowserEvents),
    36173623        PYCOM_INTERFACE_FULL(ExplorerCommand),
    PYWIN_MODULE_INIT_FUNC(shell)  
    38503856        ADD_IID(FMTID_Briefcase);
    38513857        ADD_IID(FMTID_Misc);
    38523858        ADD_IID(FMTID_WebView);
     3859#if !defined(__MINGW32__)
    38533860        ADD_IID(FMTID_AudioSummaryInformation);
     3861#endif
    38543862        ADD_IID(FMTID_Volume);
    38553863        ADD_IID(FMTID_Query);
     3864#if !defined(__MINGW32__)
    38563865        ADD_IID(FMTID_SummaryInformation);
    38573866        ADD_IID(FMTID_MediaFileSummaryInformation);
    38583867        ADD_IID(FMTID_ImageSummaryInformation);
     3868#endif
    38593869        ADD_IID(IID_CDefView);
    38603870
    38613871        ADD_IID(EP_NavPane);
  • new file com/win32comext/taskscheduler/src/initguid.cpp

    diff --git a/com/win32comext/taskscheduler/src/initguid.cpp b/com/win32comext/taskscheduler/src/initguid.cpp
    new file mode 100644
    index 0000000..d588502
    - +  
     1#define INITGUID
     2#undef _OBJIDLBASE_
     3#define CINTERFACE
     4#define USE_COM_CONTEXT_DEF
     5#include <objidl.h>
     6#include <ksguid.h>
     7#include <ks.h>
     8#include <mstask.h>
  • isapi/src/Utils.cpp

    diff --git a/isapi/src/Utils.cpp b/isapi/src/Utils.cpp
    index 8f278f2..b8976ae 100644
    a b static void CheckRegisterEventSourceFile()  
    127127                return;
    128128
    129129        GetModuleFileNameW(g_hInstance, mod_name,
     130#if defined(__MINGW32__)
     131                          sizeof(mod_name)/sizeof(WCHAR));
     132#else
    130133                          sizeof mod_name/sizeof WCHAR);
     134#endif
    131135        if (!mod_name[0]) {
    132136                OutputDebugString(_T("GetModuleFileNameW failed!"));
    133137                return;
    static void CheckRegisterEventSourceFile()  
    160164}
    161165
    162166// Write stuff to the event log.
     167#if defined(__MINGW32__)
     168extern "C"
     169#endif
    163170BOOL WriteEventLogMessage(WORD eventType, DWORD eventID, WORD num_inserts,
    164171                          const char **inserts)
    165172{
  • isapi/src/Utils.h

    diff --git a/isapi/src/Utils.h b/isapi/src/Utils.h
    index 3779ca9..f076826 100644
    a b char *HTMLErrorResp(const char *msg);  
    5858TCHAR *GetModulePath(void);
    5959
    6060// Write entry to the event log
     61#if defined(__MINGW32__)
     62extern "C"
     63#endif
    6164BOOL WriteEventLogMessage(WORD eventType, DWORD eventID, WORD num_inserts,
    6265                          const char **inserts);
    6366
  • isapi/src/pyISAPI.cpp

    diff --git a/isapi/src/pyISAPI.cpp b/isapi/src/pyISAPI.cpp
    index 439d3ca..2c94610 100644
    a b char g_CallbackModuleName[_MAX_PATH + _MAX_FNAME] = "";  
    5252#define TRACE(x) OutputDebugString(_T(x))
    5353
    5454// This is an entry point for py2exe.
     55#if defined(__MINGW32__)
     56extern "C"
     57#endif
    5558void WINAPI PyISAPISetOptions(const char *modname, BOOL is_frozen)
    5659{
    5760        strncpy(g_CallbackModuleName, modname,
  • setup.py

    diff --git a/setup.py b/setup.py
    index 7c35d90..5872968 100644
    a b import shutil  
    7272
    7373is_py3k = sys.version_info > (3,) # get this out of the way early on...
    7474
     75build_mingw32=True
     76
    7577try:
    7678    import winreg # py3k
    7779except ImportError:
    dll_base_address = 0x1e200000  
    140142def find_platform_sdk_dir():
    141143    # The user might have their current environment setup for the
    142144    # SDK, in which case "MSSDK_INCLUDE" and "MSSDK_LIB" vars must be set.
     145    if build_mingw32:
     146        return { "include": ["c:/msys64/mingw32/include", "c:/msys64/mingw32/i686-w64-mingw32/include"],
     147                 "lib": ["c:/msys64/mingw32/lib", "c:/msys64//mingw32/i686-w64-mingw32/lib"] }
     148
    143149    if "MSSDK_INCLUDE" in os.environ and "MSSDK_LIB" in os.environ:
    144150        print("Using SDK as specified in the environment")
    145151        return {
    def find_platform_sdk_dir():  
    173179# to prevent the extension from loading.  For more details, see
    174180# http://bugs.python.org/issue7833 (which has landed for Python 2.7 and on 3.2
    175181# and later, which are all we care about currently)
    176 from distutils.msvc9compiler import MSVCCompiler
    177 MSVCCompiler._orig_spawn = MSVCCompiler.spawn
    178 MSVCCompiler._orig_link = MSVCCompiler.link
     182if not build_mingw32:
     183    from distutils.msvc9compiler import MSVCCompiler
     184    MSVCCompiler._orig_spawn = MSVCCompiler.spawn
     185    MSVCCompiler._orig_link = MSVCCompiler.link
    179186
    180187# We need to override this method for versions where issue7833 *has* landed
    181188# (ie, 2.7 and 3.2+)
    def manifest_get_embed_info(self, target_desc, ld_args):  
    195202
    196203# always monkeypatch it in even though it will only be called in 2.7
    197204# and 3.2+.
    198 MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info
     205if not build_mingw32:
     206    MSVCCompiler.manifest_get_embed_info = manifest_get_embed_info
    199207
    200208def monkeypatched_spawn(self, cmd):
    201209    is_link = cmd[0].endswith("link.exe") or cmd[0].endswith('"link.exe"')
    def monkeypatched_link(self, target_desc, objects, output_filename, *args, **kw)  
    239247        return self._orig_link(target_desc, objects, output_filename, *args, **kw)
    240248    finally:
    241249        delattr(self, '_want_assembly_kept')
    242 MSVCCompiler.spawn = monkeypatched_spawn
    243 MSVCCompiler.link = monkeypatched_link
     250if not build_mingw32:
     251    MSVCCompiler.spawn = monkeypatched_spawn
     252    MSVCCompiler.link = monkeypatched_link
    244253
    245254
    246255sdk_info = find_platform_sdk_dir()
    class WinExt (Extension):  
    449458                # Unicode, Windows executables seem to need this magic:
    450459                if "/SUBSYSTEM:WINDOWS" in self.extra_link_args:
    451460                    self.extra_link_args.append("/ENTRY:wWinMainCRTStartup")
     461        else:
     462            self.extra_compile_args.append("-fpermissive")
     463            unicode_mode = self.unicode_mode
     464            if unicode_mode is None:
     465                unicode_mode = is_py3k
     466            if unicode_mode:
     467                self.extra_compile_args.append("-DUNICODE")
     468                self.extra_compile_args.append("-D_UNICODE")
     469                self.extra_compile_args.append("-DWINNT")
     470                # Unicode, Windows executables seem to need this magic:
     471                #if "/SUBSYSTEM:WINDOWS" in self.extra_link_args:
     472                #    self.extra_link_args.append("/ENTRY:wWinMainCRTStartup")
    452473
    453474class WinExt_pythonwin(WinExt):
    454475    def __init__ (self, name, **kw):
    class my_build_ext(build_ext):  
    641662        # The pywintypes library is created in the build_temp
    642663        # directory, so we need to add this to library_dirs
    643664        self.library_dirs.append(self.build_temp)
    644         self.mingw32 = (self.compiler == "mingw32")
     665        self.mingw32 = build_mingw32
    645666        if self.mingw32:
    646667            self.libraries.append("stdc++")
    647668
    class my_build_ext(build_ext):  
    698719            self.compiler.add_include_dir(extra)
    699720        # and again for lib dirs.
    700721        for extra in sdk_info["lib"]:
    701             extra = os.path.join(extra, 'x64' if is_64bit else 'x86')
     722            if not build_mingw32:
     723                extra = os.path.join(extra, 'x64' if is_64bit else 'x86')
    702724            assert os.path.isdir(extra), extra
    703725            assert extra not in self.library_dirs # see above
    704726            assert os.path.isdir(extra), "%s doesn't exist!" % (extra,)
    class my_build_ext(build_ext):  
    714736        # includes interfaces for 64-bit builds.
    715737        if self.plat_name == 'win-amd64' and ext.name == 'exchdapi':
    716738            return "No 64-bit library for utility functions available."
    717         if get_build_version() >=14:
     739        if not build_mingw32 and get_build_version() >=14:
    718740            if ext.name == 'exchange':
    719741                ext.libraries.append('legacy_stdio_definitions')
    720742            elif ext.name == 'exchdapi':
    class my_build_ext(build_ext):  
    758780
    759781        # We update the .libraries list with the resolved library name.
    760782        # This is really only so "_d" works.
    761         ext.libraries = patched_libs
     783        if not build_mingw32:
     784            ext.libraries = patched_libs
    762785        return None # no reason - it can be built!
    763786
    764787    def _build_scintilla(self):
    class my_build_ext(build_ext):  
    972995        if sys.version_info > (2, 7) and sys.version_info < (3, 3):
    973996            # only stuff built with msvc9 needs this loader.
    974997            self._build_pycom_loader()
    975         self._build_scintilla()
     998        if not build_mingw32:
     999            self._build_scintilla()
    9761000        # Copy cpp lib files needed to create Python COM extensions
    977         clib_files = (['win32', 'pywintypes%s.lib'],
    978                       ['win32com', 'pythoncom%s.lib'],
    979                       ['win32com', 'axscript%s.lib'])
     1001        if build_mingw32:
     1002            clib_files = (['win32', 'libpywintypes%s.a'],
     1003                          ['win32com', 'libpythoncom%s.a'])
     1004        else:
     1005            clib_files = (['win32', 'pywintypes%s.lib'],
     1006                          ['win32com', 'pythoncom%s.lib'],
     1007                          ['win32com', 'axscript%s.lib'])
    9801008        for clib_file in clib_files:
    9811009            target_dir = os.path.join(self.build_lib, clib_file[0], "libs")
    9821010            if not os.path.exists(target_dir):
    class my_build_ext(build_ext):  
    9881016            self.copy_file(os.path.join(self.build_temp, fname),
    9891017                           target_dir
    9901018                           )
     1019        if build_mingw32:
     1020            return
    9911021        # The MFC DLLs.
    9921022        target_dir = os.path.join(self.build_lib, "pythonwin")
    9931023
    class my_build_ext(build_ext):  
    10811111        # this, distutils gets confused, as they both try and use the same
    10821112        # .obj.
    10831113        output_dir = os.path.join(self.build_temp, ext.name)
     1114        if build_mingw32:
     1115            include_dirs = [output_dir, os.path.join(output_dir, "win32", "src")] + ext.include_dirs
     1116        else:
     1117            include_dirs = ext.include_dirs
    10841118        kw = {'output_dir': output_dir,
    10851119              'macros': macros,
    1086               'include_dirs': ext.include_dirs,
     1120              'include_dirs': include_dirs,
    10871121              'debug': self.debug,
    10881122              'extra_postargs': extra_args,
    10891123              'depends': ext.depends,
    class my_build_ext(build_ext):  
    11151149               'extra_postargs': extra_args,
    11161150               'debug': self.debug,
    11171151               'build_temp': self.build_temp,
     1152               'extra_preargs': []
    11181153        }
    11191154
    11201155        # Detect target language, if not provided
    class my_build_ext(build_ext):  
    11621197        old_build_temp = self.build_temp
    11631198        want_static_crt = sys.version_info > (2,6) and ext.name in static_crt_modules
    11641199        if want_static_crt:
    1165             self.compiler.compile_options.remove('/MD')
    1166             self.compiler.compile_options.append('/MT')
    1167             self.compiler.compile_options_debug.remove('/MDd')
    1168             self.compiler.compile_options_debug.append('/MTd')
     1200            if not build_mingw32:
     1201                self.compiler.compile_options.remove('/MD')
     1202                self.compiler.compile_options.append('/MT')
     1203                self.compiler.compile_options_debug.remove('/MDd')
     1204                self.compiler.compile_options_debug.append('/MTd')
    11691205
    11701206        try:
     1207            if build_mingw32:
     1208                incs = set()
     1209                for source in ext.sources:
     1210                    output_dir = os.path.join(self.build_temp, os.path.dirname(source))
     1211                    if output_dir not in incs:
     1212                        ext.include_dirs.append(output_dir)
     1213                        incs.add(output_dir)
    11711214            build_ext.build_extension(self, ext)
    11721215            # XXX This has to be changed for mingw32
    11731216            # Get the .lib files we need.  This is limited to pywintypes,
    11741217            # pythoncom and win32ui - but the first 2 have special names
    1175             extra = self.debug and "_d.lib" or ".lib"
     1218            if build_mingw32:
     1219                extra = self.debug and "_d.a" or ".a"
     1220            else:
     1221                extra = self.debug and "_d.lib" or ".lib"
    11761222            if ext.name in ("pywintypes", "pythoncom"):
    11771223                # The import libraries are created as PyWinTypes23.lib, but
    11781224                # are expected to be pywintypes.lib.
    1179                 name1 = "%s%d%d%s" % (ext.name, sys.version_info[0], sys.version_info[1], extra)
    1180                 name2 = "%s%s" % (ext.name, extra)
     1225                if build_mingw32:
     1226                    name1 = "lib%s%d%d%s" % (ext.name, sys.version_info[0], sys.version_info[1], extra)
     1227                    name2 = "lib%s%s" % (ext.name, extra)
     1228                else:
     1229                    name1 = "%s%d%d%s" % (ext.name, sys.version_info[0], sys.version_info[1], extra)
     1230                    name2 = "%s%s" % (ext.name, extra)
    11811231            elif ext.name in ("win32ui",):
    11821232                name1 = name2 = ext.name + extra
    11831233            else:
    class my_build_ext(build_ext):  
    11991249        finally:
    12001250            self.build_temp = old_build_temp
    12011251            if want_static_crt:
    1202                 self.compiler.compile_options.remove('/MT')
    1203                 self.compiler.compile_options.append('/MD')
    1204                 self.compiler.compile_options_debug.remove('/MTd')
    1205                 self.compiler.compile_options_debug.append('/MDd')
     1252                if not build_mingw32:
     1253                    self.compiler.compile_options.remove('/MT')
     1254                    self.compiler.compile_options.append('/MD')
     1255                    self.compiler.compile_options_debug.remove('/MTd')
     1256                    self.compiler.compile_options_debug.append('/MDd')
    12061257
    12071258    def get_ext_filename(self, name):
    12081259        # The pywintypes and pythoncom extensions have special names
    class my_build_ext(build_ext):  
    12981349        for source in swig_sources:
    12991350            swig_cmd = [swig, "-python", "-c++"]
    13001351            swig_cmd.append("-dnone",) # we never use the .doc files.
     1352            if not build_mingw32:
     1353                swig_cmd.append("-I" + os.path.abspath("swig/swig_lib/python"))
    13011354            swig_cmd.extend(self.current_extension.extra_swig_commands)
    13021355            if not is_py3k:
    13031356                swig_cmd.append("-DSWIG_PY2K")
    class my_install(install):  
    13681421        if not self.dry_run and not self.root:
    13691422            # We must run the script we just installed into Scripts, as it
    13701423            # may have had 2to3 run over it.
    1371             filename = os.path.join(self.prefix, "Scripts", "pywin32_postinstall.py")
     1424            if build_mingw32:
     1425                filename = os.path.join(self.prefix, "bin", "pywin32_postinstall.py")
     1426            else:
     1427                filename = os.path.join(self.prefix, "Scripts", "pywin32_postinstall.py")
    13721428            if not os.path.isfile(filename):
    13731429                raise RuntimeError("Can't find '%s'" % (filename,))
    13741430            print("Executing post install script...")
    def my_new_compiler(**kw):  
    13881444    return orig_new_compiler(**kw)
    13891445
    13901446# No way to cleanly wedge our compiler sub-class in.
    1391 from distutils import ccompiler, msvccompiler
     1447from distutils import ccompiler
    13921448orig_new_compiler = ccompiler.new_compiler
    13931449ccompiler.new_compiler = my_new_compiler
    13941450
    1395 base_compiler = msvccompiler.MSVCCompiler
     1451if build_mingw32:
     1452    from distutils import cygwinccompiler
     1453    base_compiler = cygwinccompiler.Mingw32CCompiler
     1454else:
     1455    from distutils import msvccompiler
     1456    base_compiler = msvccompiler.MSVCCompiler
     1457
    13961458
    13971459class my_compiler(base_compiler):
    13981460    # Just one GUIDS.CPP and it gives trouble on mainwin too. Maybe I
    13991461    # should just rename the file, but a case-only rename is likely to be
    14001462    # worse!  This can probably go away once we kill the VS project files
    14011463    # though, as we can just specify the lowercase name in the module def.
    1402     _cpp_extensions = base_compiler._cpp_extensions + [".CPP"]
     1464    if not build_mingw32:
     1465        _cpp_extensions = base_compiler._cpp_extensions + [".CPP"]
    14031466    src_extensions = base_compiler.src_extensions + [".CPP"]
    14041467
    14051468    def link(self,
    class my_compiler(base_compiler):  
    14111474              library_dirs=None,
    14121475              runtime_library_dirs=None,
    14131476              export_symbols=None,
    1414               debug=0, *args, **kw):
    1415         msvccompiler.MSVCCompiler.link( self,
    1416                                         target_desc,
    1417                                         objects,
    1418                                         output_filename,
    1419                                         output_dir,
    1420                                         libraries,
    1421                                         library_dirs,
    1422                                         runtime_library_dirs,
    1423                                         export_symbols,
    1424                                         debug, *args, **kw)
     1477              debug=0, extra_preargs = None, *args, **kw):
     1478        if build_mingw32:
     1479            temp_dir = os.path.dirname(objects[0])
     1480            dll_name = os.path.splitext(os.path.basename(output_filename))[0]
     1481            lib_file = os.path.join(temp_dir, 'lib' + dll_name + ".a")
     1482            implib_arg="-Wl,--out-implib,%s" % lib_file
     1483
     1484            if extra_preargs:
     1485                extra_preargs.extend(implib_arg)
     1486            else:
     1487                extra_preargs = [implib_arg]
     1488
     1489            cygwinccompiler.Mingw32CCompiler.link( self,
     1490                                                   target_desc,
     1491                                                   objects,
     1492                                                   output_filename,
     1493                                                   output_dir,
     1494                                                   libraries,
     1495                                                   library_dirs,
     1496                                                   runtime_library_dirs,
     1497                                                   export_symbols,
     1498                                                   debug, extra_preargs,
     1499                                                   *args, **kw)
     1500        else:
     1501            msvccompiler.MSVCCompiler.link( self,
     1502                                            target_desc,
     1503                                            objects,
     1504                                            output_filename,
     1505                                            output_dir,
     1506                                            libraries,
     1507                                            library_dirs,
     1508                                            runtime_library_dirs,
     1509                                            export_symbols,
     1510                                            debug, *args, **kw)
     1511
    14251512        # Here seems a good place to stamp the version of the built
    14261513        # target.  Do this externally to avoid suddenly dragging in the
    14271514        # modules needed by this process, and which we will soon try and
    class my_compiler(base_compiler):  
    14571544        if not ok:
    14581545            log.info('Unable to import verstamp, no version info will be added')
    14591546
     1547    if build_mingw32:
     1548        def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
     1549            if ext == ".mc":
     1550                try:
     1551                    basename=os.path.basename(src)[:-3]
     1552                    outdir=os.path.dirname(obj)
     1553                    self.spawn(["windmc", "-h", outdir, "-r", outdir, src])
     1554                    self.spawn(["windres", "-i",
     1555                                os.path.join(outdir, basename + ".rc"),
     1556                                "-o", obj])
     1557                except DistutilsExecError as msg:
     1558                    raise CompileError(msg)
     1559            else:
     1560                cygwinccompiler.Mingw32CCompiler._compile(self,
     1561                                                          obj, src, ext, cc_args,
     1562                                                          extra_postargs, pp_opts)
     1563
     1564        def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
     1565            unproc_src_names = []
     1566            obj_names = []
     1567            for src_name in source_filenames:
     1568                base, ext = os.path.splitext(src_name)
     1569                if ext==".mc":
     1570                    if unproc_src_names:
     1571                        obj_names.extend(cygwinccompiler.Mingw32CCompiler.\
     1572                            object_filenames(self, unproc_src_names,
     1573                                             strip_dir = strip_dir,
     1574                                             output_dir = output_dir))
     1575                        unproc_src_names = []
     1576                    obj_names.append (os.path.join(output_dir,
     1577                                      base + ext + self.obj_extension))
     1578                else:
     1579                    unproc_src_names.append(src_name)
     1580            if unproc_src_names:
     1581                obj_names.extend(cygwinccompiler.Mingw32CCompiler.\
     1582                    object_filenames(self, unproc_src_names, strip_dir = strip_dir,
     1583                                     output_dir = output_dir))
     1584            return obj_names
     1585
    14601586
    14611587################################################################
    14621588
    for info in (  
    15501676            win32/src/win32crypt/PyCRYPTPROV.cpp
    15511677            win32/src/win32crypt/PyCTL_CONTEXT.cpp
    15521678            """),
    1553         ("win32file", "", None, 0x0500, """
     1679        ("win32file", "wsock32 ws2_32" if build_mingw32 else "", None, 0x0500, """
    15541680              win32/src/win32file.i
    15551681              win32/src/win32file_comm.cpp
    15561682              """),
    for info in (  
    16071733        sources = info[4].split()
    16081734    extra_compile_args = []
    16091735    ext = WinExt_win32(name,
    1610                  libraries=lib_names,
     1736                 libraries=lib_names + (" pywintypes" if build_mingw32 else ""),
    16111737                 extra_compile_args = extra_compile_args,
    16121738                 windows_h_version = windows_h_ver,
    16131739                 sources = sources,
    win32_extensions += [  
    16201746            sources = """
    16211747                win32\\src\\win32evtlog_messages.mc win32\\src\\win32evtlog.i
    16221748                """.split(),
    1623                 libraries="advapi32 oleaut32",
     1749                libraries="advapi32 oleaut32" + (" pywintypes" if build_mingw32 else ""),
    16241750                delay_load_libraries="wevtapi",
    16251751                windows_h_version=0x0600
    16261752        ),
    win32_extensions += [  
    16281754           sources = """
    16291755                win32/src/win32apimodule.cpp win32/src/win32api_display.cpp
    16301756                """.split(),
    1631            libraries="user32 advapi32 shell32 version",
     1757                 libraries="user32 advapi32 shell32 version" + (" pywintypes" if build_mingw32 else ""),
    16321758           delay_load_libraries="powrprof",
    16331759           windows_h_version=0x0500,
    16341760        ),
    win32_extensions += [  
    16381764                win32/src/win32gui.i
    16391765               """.split(),
    16401766           windows_h_version=0x0500,
    1641            libraries="gdi32 user32 comdlg32 comctl32 shell32",
     1767           libraries="gdi32 user32 comdlg32 comctl32 shell32" + (" pywintypes" if build_mingw32 else ""),
    16421768           define_macros = [("WIN32GUI", None)],
    16431769        ),
    16441770    # winxpgui is built from win32gui.i, but sets up different #defines before
    win32_extensions += [  
    16481774                win32/src/winxpgui.rc win32/src/win32dynamicdialog.cpp
    16491775                win32/src/win32gui.i
    16501776               """.split(),
    1651            libraries="gdi32 user32 comdlg32 comctl32 shell32",
     1777           libraries="gdi32 user32 comdlg32 comctl32 shell32" + (" pywintypes" if build_mingw32 else ""),
    16521778           windows_h_version=0x0500,
    16531779           define_macros = [("WIN32GUI",None), ("WINXPGUI",None)],
    16541780           extra_swig_commands=["-DWINXPGUI"],
    win32_extensions += [  
    16561782    # winxptheme
    16571783    WinExt_win32("_winxptheme",
    16581784           sources = ["win32/src/_winxptheme.i"],
    1659            libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme",
     1785           libraries="gdi32 user32 comdlg32 comctl32 shell32 Uxtheme" + (" pywintypes" if build_mingw32 else ""),
    16601786           windows_h_version=0x0500,
    16611787        ),
    16621788]
    win32_extensions += [  
    16641790    WinExt_win32('servicemanager',
    16651791           sources = ["win32/src/PythonServiceMessages.mc", "win32/src/PythonService.cpp"],
    16661792           extra_compile_args = ['-DPYSERVICE_BUILD_DLL'],
    1667            libraries = "user32 ole32 advapi32 shell32",
     1793           libraries = "user32 ole32 advapi32 shell32" + (" pywintypes" if build_mingw32 else ""),
    16681794           windows_h_version = 0x500,
    16691795           unicode_mode=True,),
    16701796]
    dirs = {  
    16951821
    16961822# The COM modules.
    16971823pythoncom = WinExt_system32('pythoncom',
    1698                    sources=("""
     1824                   sources=((("%(win32com)s/initguid.cpp"  if build_mingw32 else "") +
     1825                        """
    16991826                        %(win32com)s/dllmain.cpp            %(win32com)s/ErrorUtils.cpp
    17001827                        %(win32com)s/MiscTypes.cpp          %(win32com)s/oleargs.cpp
    17011828                        %(win32com)s/PyComHelpers.cpp       %(win32com)s/PyFactory.cpp
    pythoncom = WinExt_system32('pythoncom',  
    17371864                        %(win32com)s/extensions/PyICancelMethodCalls.cpp    %(win32com)s/extensions/PyIContext.cpp
    17381865                        %(win32com)s/extensions/PyIEnumContextProps.cpp     %(win32com)s/extensions/PyIClientSecurity.cpp
    17391866                        %(win32com)s/extensions/PyIServerSecurity.cpp
    1740                         """ % dirs).split(),
     1867                        """) % dirs).split(),
    17411868                   depends=("""
    17421869                        %(win32com)s/include\\propbag.h          %(win32com)s/include\\PyComTypeObjects.h
    17431870                        %(win32com)s/include\\PyFactory.h        %(win32com)s/include\\PyGConnectionPoint.h
    pythoncom = WinExt_system32('pythoncom',  
    17631890                        %(win32com)s/include\\PyIEnumContextProps.h     %(win32com)s/include\\PyIClientSecurity.h
    17641891                        %(win32com)s/include\\PyIServerSecurity.h
    17651892                        """ % dirs).split(),
    1766                    libraries = "oleaut32 ole32 user32 urlmon",
     1893                   libraries = "oleaut32 ole32 user32 urlmon uuid" + (" pywintypes" if build_mingw32 else ""),
    17671894                   export_symbol_file = 'com/win32com/src/PythonCOM.def',
    17681895                   extra_compile_args = ['-DBUILD_PYTHONCOM'],
    17691896                   pch_header = "stdafx.h",
    com_extensions += [  
    17881915                        %(adsi)s/PyIADs.cpp
    17891916                        """ % dirs).split()),
    17901917    WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h",
    1791                     sources=("""
     1918                    sources=(("""
    17921919                        %(axcontrol)s/AXControl.cpp
    17931920                        %(axcontrol)s/PyIOleControl.cpp          %(axcontrol)s/PyIOleControlSite.cpp
    17941921                        %(axcontrol)s/PyIOleInPlaceActiveObject.cpp
    com_extensions += [  
    17991926                        %(axcontrol)s/PyIOleClientSite.cpp       %(axcontrol)s/PyIOleInPlaceSite.cpp
    18001927                        %(axcontrol)s/PyIOleObject.cpp           %(axcontrol)s/PyIViewObject2.cpp
    18011928                        %(axcontrol)s/PyIOleCommandTarget.cpp
    1802                         """ % dirs).split()),
     1929                        """ + ("%(axcontrol)s/initguid.cpp" if build_mingw32 else "")) % dirs).split(),
     1930                        libraries="pythoncom pywintypes"),
    18031931    WinExt_win32com('axscript',
    1804                     sources=("""
    1805                         %(axscript)s/AXScript.cpp
     1932                    sources=(("""
     1933                        %(axscript)s/AXScript.cpp                %(axscript)s/initguid.cpp
    18061934                        %(axscript)s/GUIDS.CPP                   %(axscript)s/PyGActiveScript.cpp
    18071935                        %(axscript)s/PyGActiveScriptError.cpp    %(axscript)s/PyGActiveScriptParse.cpp
    18081936                        %(axscript)s/PyGActiveScriptSite.cpp     %(axscript)s/PyGObjectSafety.cpp
    com_extensions += [  
    18101938                        %(axscript)s/PyIActiveScriptParse.cpp    %(axscript)s/PyIActiveScriptParseProcedure.cpp
    18111939                        %(axscript)s/PyIActiveScriptSite.cpp     %(axscript)s/PyIMultiInfos.cpp
    18121940                        %(axscript)s/PyIObjectSafety.cpp         %(axscript)s/stdafx.cpp
    1813                         """ % dirs).split(),
     1941                        """ + ("%(axscript)s/initguid.cpp" if build_mingw32 else "")) % dirs).split(),
    18141942                    depends=("""
    18151943                             %(axscript)s/AXScript.h
    18161944                             %(axscript)s/guids.h                %(axscript)s/PyGActiveScriptError.h
    com_extensions += [  
    18201948                             """ % dirs).split(),
    18211949                    extra_compile_args = ['-DPY_BUILD_AXSCRIPT'],
    18221950                    implib_name="axscript",
    1823                     pch_header = "stdafx.h"
     1951                    pch_header = "stdafx.h",
     1952                    libraries="pythoncom pywintypes" if build_mingw32 else ""
    18241953    ),
    18251954    WinExt_win32com('axdebug',
    18261955            libraries="axscript",
    com_extensions += [  
    18701999                    %(axdebug)s/PyIRemoteDebugApplicationEvents.cpp
    18712000                    %(axdebug)s/PyIRemoteDebugApplicationThread.cpp
    18722001                    %(axdebug)s/stdafx.cpp
    1873                      """ % dirs).split(),
    1874     ),
     2002                     """ % dirs).split() ),
    18752003    WinExt_win32com('internet', pch_header="internet_pch.h",
    1876                     sources=("""
     2004                    sources=(("""
    18772005                        %(internet)s/internet.cpp                   %(internet)s/PyIDocHostUIHandler.cpp
    18782006                        %(internet)s/PyIHTMLOMWindowServices.cpp    %(internet)s/PyIInternetBindInfo.cpp
    18792007                        %(internet)s/PyIInternetPriority.cpp        %(internet)s/PyIInternetProtocol.cpp
    18802008                        %(internet)s/PyIInternetProtocolInfo.cpp    %(internet)s/PyIInternetProtocolRoot.cpp
    18812009                        %(internet)s/PyIInternetProtocolSink.cpp    %(internet)s/PyIInternetSecurityManager.cpp
    1882                     """ % dirs).split(),
    1883                     depends=["%(internet)s/internet_pch.h" % dirs]),
     2010                    """ + ("%(internet)s/initguid.cpp"  if build_mingw32 else "")) % dirs).split(),
     2011                    depends=["%(internet)s/internet_pch.h" % dirs],
     2012                    libraries="pythoncom pywintypes" if build_mingw32 else ""),
    18842013    WinExt_win32com('mapi', libraries="advapi32", pch_header="PythonCOM.h",
    18852014                    include_dirs=["%(mapi)s/mapi_headers" % dirs],
    18862015                    optional_headers=['edkmdb.h', 'edkguid.h'],
    com_extensions += [  
    19292058                                  %(mapi)s/mapi_stub_library/MapiStubLibrary.cpp
    19302059                                  %(mapi)s/mapi_stub_library/StubUtils.cpp
    19312060                                  """ % dirs).split()),
    1932     WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h",
     2061
     2062    WinExt_win32com('shell', libraries=('pythoncom pywintypes ' if build_mingw32 else '') + 'shell32', pch_header="shell_pch.h",
    19332063                    windows_h_version = 0x600,
    1934                     sources=("""
     2064                    sources=(("""
    19352065                        %(shell)s/PyIActiveDesktop.cpp
    19362066                        %(shell)s/PyIApplicationDestinations.cpp
    19372067                        %(shell)s/PyIApplicationDocumentLists.cpp
    com_extensions += [  
    19562086                        %(shell)s/PyIEnumObjects.cpp
    19572087                        %(shell)s/PyIEnumResources.cpp
    19582088                        %(shell)s/PyIEnumShellItems.cpp
    1959                         %(shell)s/PyIEmptyVolumeCache.cpp
    1960                         %(shell)s/PyIEmptyVolumeCacheCallBack.cpp
    19612089                        %(shell)s/PyIExplorerBrowser.cpp
    19622090                        %(shell)s/PyIExplorerBrowserEvents.cpp
    19632091                        %(shell)s/PyIExplorerCommand.cpp
    com_extensions += [  
    20022130                        %(shell)s/PyITransferSource.cpp
    20032131                        %(shell)s/PyIUniformResourceLocator.cpp
    20042132                        %(shell)s/shell.cpp
    2005 
    2006                         """ % dirs).split()),
     2133                        """ + ("%(shell)s/initguid.cpp" if build_mingw32 else
     2134                               "%(shell)s/PyIEmptyVolumeCache.cpp %(shell)s/PyIEmptyVolumeCacheCallBack.cpp"))
     2135                             % dirs).split()),
    20072136
    20082137    WinExt_win32com('propsys', libraries='propsys', delay_load_libraries='shell32',
    20092138                    unicode_mode=True,
    com_extensions += [  
    20312160                    implib_name="pypropsys",
    20322161                    ),
    20332162
    2034 
    2035     WinExt_win32com('taskscheduler', libraries='mstask',
    2036                     sources=("""
     2163    WinExt_win32com('taskscheduler', libraries='mstask' + (' pythoncom pywintypes'  if build_mingw32 else ''),
     2164                    sources=(("""
    20372165                        %(taskscheduler)s/taskscheduler.cpp
    20382166                        %(taskscheduler)s/PyIProvideTaskPage.cpp
    20392167                        %(taskscheduler)s/PyIScheduledWorkItem.cpp
    com_extensions += [  
    20412169                        %(taskscheduler)s/PyITaskScheduler.cpp
    20422170                        %(taskscheduler)s/PyITaskTrigger.cpp
    20432171
    2044                         """ % dirs).split()),
     2172                        """ + ("%(taskscheduler)s/initguid.cpp" if build_mingw32 else ""))% dirs).split()),
    20452173    WinExt_win32com('bits', libraries='Bits', pch_header="bits_pch.h",
    20462174                    sources=("""
    20472175                        %(bits)s/bits.cpp
    com_extensions += [  
    20772205                        %(directsound)s/PyIDirectSoundCaptureBuffer.h %(directsound)s/PyIDirectSoundNotify.h
    20782206                        """ % dirs).split(),
    20792207                    optional_headers = ['dsound.h'],
    2080                     libraries='user32 dsound dxguid'),
    2081     WinExt_win32com('authorization', libraries='aclui advapi32',
     2208                    libraries=('pythoncom pywintypes ' if build_mingw32 else '') + 'user32 dsound dxguid uuid'),
     2209    WinExt_win32com('authorization', libraries=('pythoncom pywintypes ' if build_mingw32 else '') + 'aclui advapi32',
    20822210                    sources=("""
    20832211                        %(authorization)s/authorization.cpp
    20842212                        %(authorization)s/PyGSecurityInformation.cpp
    2085                         """ % dirs).split()),
     2213                        """ % dirs).split())
    20862214]
    20872215
    20882216pythonwin_extensions = [
    other_extensions.append(  
    22532381W32_exe_files = [
    22542382    WinExt_win32("pythonservice",
    22552383         sources=[os.path.join("win32", "src", s) for s in
    2256                   "PythonService.cpp PythonService.rc".split()],
     2384                  (("PythonServiceMessages.mc " if build_mingw32 else "") + "PythonService.cpp PythonService.rc").split()],
    22572385         unicode_mode = True,
    2258          extra_link_args=["/SUBSYSTEM:CONSOLE"],
    2259          libraries = "user32 advapi32 ole32 shell32"),
    2260     WinExt_pythonwin("Pythonwin",
    2261         sources = [
    2262             "Pythonwin/pythonwin.cpp",
    2263             "Pythonwin/pythonwin.rc",
    2264             "Pythonwin/stdafxpw.cpp",
    2265             ],
    2266         extra_link_args=["/SUBSYSTEM:WINDOWS"],
    2267         optional_headers=['afxres.h']),
     2386         extra_link_args=[] if build_mingw32 else ["/SUBSYSTEM:CONSOLE"],
     2387         libraries = ("pywintypes " if build_mingw32 else "") + "user32 advapi32 ole32 shell32")
    22682388]
    22692389
     2390if not build_mingw32:
     2391    W32_exe_files.append(
     2392        WinExt_pythonwin("Pythonwin",
     2393            sources = [
     2394                "Pythonwin/pythonwin.cpp",
     2395                "Pythonwin/pythonwin.rc",
     2396                "Pythonwin/stdafxpw.cpp",
     2397            ],
     2398            extra_link_args=["/SUBSYSTEM:WINDOWS"],
     2399            optional_headers=['afxres.h'])
     2400        )
     2401
    22702402# Special definitions for SWIG.
    22712403swig_interface_parents = {
    22722404    # source file base,     "base class" for generated COM support
    packages=['win32com',  
    24152547          ]
    24162548
    24172549py_modules = expand_modules("win32\\lib")
    2418 ext_modules = win32_extensions + com_extensions + pythonwin_extensions + \
     2550if build_mingw32:
     2551    ext_modules = win32_extensions + com_extensions + other_extensions
     2552else:
     2553    ext_modules = win32_extensions + com_extensions + pythonwin_extensions + \
    24192554                    other_extensions
    24202555
    24212556# Build a map of DLL base addresses.  According to Python's PC\dllbase_nt.txt,
  • win32/src/PerfMon/perfmondata.cpp

    diff --git a/win32/src/PerfMon/perfmondata.cpp b/win32/src/PerfMon/perfmondata.cpp
    index 23e7557..c456d89 100644
    a b PPERF_COUNTER_BLOCK pCounterBlock;  
    8989//      these are used to insure that the data collection functions
    9090//      accessed by Perflib will have the correct calling format.
    9191//
     92
     93#if defined(__MINGW32__)
     94extern "C" {
     95#endif
     96
    9297PM_OPEN_PROC   OpenPerformanceData;
    9398PM_COLLECT_PROC    CollectPerformanceData;
    9499PM_CLOSE_PROC  ClosePerformanceData;
    95100
     101#if defined(__MINGW32__)
     102}
     103#endif
     104
    96105TCHAR szFullModulePath[MAX_PATH];
    97106TCHAR szModuleName[MAX_PATH]; // will point into the buffer above.
    98107
    BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)  
    130139
    131140
    132141
     142#if defined(__MINGW32__)
     143extern "C"
     144#endif
    133145DWORD APIENTRY OpenPerformanceData( LPWSTR lpDeviceNames )
    134146/*++
    135147    Routine Description:
    OpenExitPoint:  
    278290        return status;
    279291}
    280292
     293#if defined(__MINGW32__)
     294extern "C"
     295#endif
    281296DWORD APIENTRY CollectPerformanceData(
    282297    IN      LPWSTR  lpValueName,
    283298        IN OUT  LPVOID  *lppData,
    Arguments: IN LPWSTR lpValueName  
    379394    return ERROR_SUCCESS;
    380395}
    381396
     397#if defined(__MINGW32__)
     398extern "C"
     399#endif
    382400DWORD APIENTRY ClosePerformanceData()
    383401/*++
    384402Routine Description:
    HANDLE MonOpenEventLog (const TCHAR *szSourceName)  
    445463--*/
    446464{
    447465    HKEY hAppKey;
     466#if defined(__MINGW32__)
     467    TCHAR LogLevelKeyName[] = _T("SOFTWARE\\Microsoft\\Windows_NT\\CurrentVersion\\Perflib");
     468#else
    448469    TCHAR LogLevelKeyName[] = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib");
     470#endif
    449471
    450472    TCHAR LogLevelValueName[] = _T("EventLogLevel");
    451473        LONG lStatus;
  • win32/src/PySECURITY_DESCRIPTOR.cpp

    diff --git a/win32/src/PySECURITY_DESCRIPTOR.cpp b/win32/src/PySECURITY_DESCRIPTOR.cpp
    index 218daf9..2873603 100644
    a b  
    66#include "PySecurityObjects.h"
    77#include "structmember.h"
    88
     9#if defined(__MINGW32__)
     10#include <algorithm>
     11#endif
     12
    913#ifndef NO_PYWINTYPES_SECURITY
    1014BOOL (WINAPI *setsecuritydescriptorcontrol)(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL)=NULL;
    1115
    PySECURITY_DESCRIPTOR::PySECURITY_DESCRIPTOR(Py_ssize_t cb /*= 0*/)  
    786790{
    787791        ob_type = &PySECURITY_DESCRIPTORType;
    788792        _Py_NewReference(this);
     793#if defined(__MINGW32__)
     794        cb = std::max(cb, static_cast<Py_ssize_t>(SECURITY_DESCRIPTOR_MIN_LENGTH));
     795#else
    789796        cb = max(cb, SECURITY_DESCRIPTOR_MIN_LENGTH);
     797#endif
    790798        PSECURITY_DESCRIPTOR psd = malloc(cb);
    791799        this->m_psd=NULL;
    792800        if (::InitializeSecurityDescriptor(psd, SECURITY_DESCRIPTOR_REVISION))
  • win32/src/PyWinTypes.h

    diff --git a/win32/src/PyWinTypes.h b/win32/src/PyWinTypes.h
    index 00ac8a1..a5fc23e 100644
    a b PYWINTYPES_EXPORT PyObject *PyWinObject_FromULARGE_INTEGER(ULARGE_INTEGER &val);  
    393393// We also happen to know a LARGE_INTEGER is an __int64, so do it the easy way
    394394#define PyWinObject_AsPY_LONG_LONG(ob, pResult) PyWinObject_AsLARGE_INTEGER((ob), (LARGE_INTEGER *)(pResult))
    395395#define PyWinObject_AsUPY_LONG_LONG(ob, pResult) PyWinObject_AsULARGE_INTEGER((ob), (ULARGE_INTEGER *)(pResult))
     396#if defined(__MINGW32__)
     397#define PyWinObject_FromPY_LONG_LONG(val) PyWinObject_FromLARGE_INTEGER(val)
     398#define PyWinObject_FromUPY_LONG_LONG(val) PyWinObject_FromULARGE_INTEGER(val)
     399#else
    396400#define PyWinObject_FromPY_LONG_LONG(val) PyWinObject_FromLARGE_INTEGER((LARGE_INTEGER)val)
    397401#define PyWinObject_FromUPY_LONG_LONG(val) PyWinObject_FromULARGE_INTEGER((ULARGE_INTEGER)val)
     402#endif
    398403
    399404// A DWORD_PTR and ULONG_PTR appear to mean "integer long enough to hold a pointer"
    400405// It is *not* actually a pointer (but is the same size as a pointer)
    private:  
    797802
    798803// A helper for simple exception handling.
    799804// try/__try
    800 #ifdef MAINWIN
     805#if defined(__MINGW32__) || defined(MAINWIN)
    801806#define PYWINTYPES_TRY try
    802807#else
    803808#define PYWINTYPES_TRY __try
  • win32/src/PyWinTypesmodule.cpp

    diff --git a/win32/src/PyWinTypesmodule.cpp b/win32/src/PyWinTypesmodule.cpp
    index e136fff..77e10a4 100644
    a b BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)  
    11401140}
    11411141
    11421142// Function to format a python traceback into a character string.
     1143#if defined(__MINGW32__)
     1144#define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " what ">";goto done;}
     1145#else
    11431146#define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;}
     1147#endif
    11441148char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb)
    11451149{
    11461150        // Sleep (30000); // Time enough to attach the debugger (barely)
  • win32/src/PythonService.cpp

    diff --git a/win32/src/PythonService.cpp b/win32/src/PythonService.cpp
    index c7b7531..8a9121d 100644
    a b static PyObject *PySetEventSourceName(PyObject *self, PyObject *args)  
    302302        if (!PyWinObject_AsTCHAR(obName, &msg))
    303303                return NULL;
    304304        _tcsncpy(g_szEventSourceName, msg,
     305#if defined(__MINGW32__)
     306                         sizeof(g_szEventSourceName)/sizeof(TCHAR));
     307#else
    305308                         sizeof g_szEventSourceName/sizeof TCHAR);
     309#endif
    306310        PyWinObject_FreeTCHAR(msg);
    307311        g_bRegisteredEventSource = FALSE; // so this name re-registered.
    308312        if (registerNow)
    BOOL PythonService_Initialize( const TCHAR *evtsrc_name, const TCHAR *evtsrc_fil  
    680684{
    681685        if (evtsrc_name && *evtsrc_name)
    682686                _tcsncpy(g_szEventSourceName, evtsrc_name,
     687#if defined(__MINGW32__)
     688                                 sizeof(g_szEventSourceName)/sizeof(TCHAR));
     689#else
    683690                                 sizeof g_szEventSourceName/sizeof TCHAR);
     691#endif
    684692        if (evtsrc_file && *evtsrc_file)
    685693                _tcsncpy(g_szEventSourceFileName, evtsrc_file,
     694#if defined(__MINGW32__)
     695                                 sizeof(g_szEventSourceFileName)/sizeof(TCHAR));
     696#else
    686697                                 sizeof g_szEventSourceFileName/sizeof TCHAR);
     698#endif
    687699        return TRUE;
    688700}
    689701
    static void CheckRegisterEventSourceFile()  
    14431455
    14441456        if (!g_szEventSourceFileName[0])
    14451457                GetModuleFileName(g_hdll, g_szEventSourceFileName,
     1458#if defined(__MINGW32__)
     1459                                  sizeof(g_szEventSourceFileName)/sizeof(TCHAR));
     1460#else
    14461461                                  sizeof g_szEventSourceFileName/sizeof TCHAR);
     1462#endif
    14471463
    14481464        HKEY hkey;
    14491465        TCHAR keyName[MAX_PATH];
    BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)  
    15491565#else // PYSERVICE_BUILD_DLL
    15501566// Our EXE entry point.
    15511567
     1568#if defined(__MINGW32__)
     1569extern "C" int main(int argc, TCHAR **argv)
     1570#else
    15521571int _tmain(int argc, TCHAR **argv)
     1572#endif
    15531573{
    15541574        PyObject *module, *f;
    15551575        PyThreadState *threadState;
  • win32/src/PythonServiceMessages.mc

    diff --git a/win32/src/PythonServiceMessages.mc b/win32/src/PythonServiceMessages.mc
    index ef26675..c8787a4 100644
    a b MessageId=0x7  
    134134Severity=Error
    135135SymbolicName=E_UNUSED2
    136136Language=English
     137%1
    137138.
    138139
    139140MessageId=0x8
  • win32/src/odbc.cpp

    diff --git a/win32/src/odbc.cpp b/win32/src/odbc.cpp
    index c58aef5..9d3dc35 100644
    a b  
    1818#include "PyWinObjects.h"
    1919#include "structmember.h"
    2020
     21#if defined(__MINGW32__)
     22#include <algorithm>
     23#endif
     24
    2125#include <sql.h>
    2226#include <sqlext.h>
    2327
    static cursorObject *cursor(PyObject *o)  
    105109}
    106110
    107111static void cursorDealloc(PyObject *self);
    108 PyMethodDef cursorMethods[];
    109 PyMemberDef cursorMembers[];
    110112
    111 static PyTypeObject Cursor_Type =
    112 {
    113         PYWIN_OBJECT_HEAD
    114         "odbccur",                              /*tp_name */
    115         sizeof(cursorObject),   /*tp_basicsize */
    116         0,                                              /*tp_itemsize */
    117         cursorDealloc,                  /*tp_dealloc */
    118         0,                                              /*tp_print */
    119         0,                                              /*tp_getattr */
    120         0,                                              /*tp_setattr */
    121         0,                                              /*tp_compare */
    122         0,                                              /*tp_repr */
    123         0,                                              /*tp_as_number */
    124         0,                                              /* tp_as_sequence */
    125         0,                                              /* tp_as_mapping */
    126         0,                                              /* tp_hash */
    127         0,                                              /* tp_call */
    128         0,                                              /*tp_str */
    129         PyObject_GenericGetAttr,        /* tp_getattro dbiGetAttr */
    130         PyObject_GenericSetAttr,        /* tp_setattro */
    131         0,                                              /*tp_as_buffer*/
    132         Py_TPFLAGS_DEFAULT,             /* tp_flags */
    133         0,                                              /* tp_doc */
    134         0,                                              /* tp_traverse */
    135         0,                                              /* tp_clear */
    136         0,                                              /* tp_richcompare */
    137         0,                                              /* tp_weaklistoffset */
    138         0,                                              /* tp_iter */
    139         0,                                              /* tp_iternext */
    140         cursorMethods,                  /* tp_methods */
    141         cursorMembers,                  /* tp_members */
    142         0,                                              /* tp_getset */
    143         0,                                              /* tp_base */
    144         0,                                              /* tp_dict */
    145         0,                                              /* tp_descr_get */
    146         0,                                              /* tp_descr_set */
    147         0,                                              /* tp_dictoffset */
    148         0,                                              /* tp_init */
    149         0,                                              /* tp_alloc */
    150         0,                                              /* tp_new */
    151 };
    152113
    153114
    154115static void connectionDealloc(PyObject *self);
    155 PyMethodDef connectionMethods[];
    156 PyMemberDef connectionMembers[];
    157 static PyTypeObject Connection_Type =
    158 {
    159         PYWIN_OBJECT_HEAD
    160         "odbcconn",                             /*tp_name */
    161         sizeof (connectionObject),      /*tp_basicsize */
    162         0,                                              /*tp_itemsize */
    163         connectionDealloc,              /*tp_dealloc */
    164         0,                                              /*tp_print */
    165         0,                                              /*tp_getattr */
    166         0,                                              /*tp_setattr */
    167         0,                                              /*tp_compare */
    168         0,                                              /*tp_repr */
    169         0,                                              /*tp_as_number */
    170         0,                                              /* tp_as_sequence */
    171         0,                                              /* tp_as_mapping */
    172         0,                                              /* tp_hash */
    173         0,                                              /* tp_call */
    174         0,                                              /*tp_str */
    175         PyObject_GenericGetAttr,        /* tp_getattro dbiGetAttr */
    176         PyObject_GenericSetAttr,        /* tp_setattro */
    177         0,                                              /*tp_as_buffer*/
    178         Py_TPFLAGS_DEFAULT,             /* tp_flags */
    179         0,                                              /* tp_doc */
    180         0,                                              /* tp_traverse */
    181         0,                                              /* tp_clear */
    182         0,                                              /* tp_richcompare */
    183         0,                                              /* tp_weaklistoffset */
    184         0,                                              /* tp_iter */
    185         0,                                              /* tp_iternext */
    186         connectionMethods,              /* tp_methods */
    187         connectionMembers,              /* tp_members */
    188         0,                                              /* tp_getset */
    189         0,                                              /* tp_base */
    190         0,                                              /* tp_dict */
    191         0,                                              /* tp_descr_get */
    192         0,                                              /* tp_descr_set */
    193         0,                                              /* tp_dictoffset */
    194         0,                                              /* tp_init */
    195         0,                                              /* tp_alloc */
    196         0,                                              /* tp_new */
    197 };
    198116
    199117static int unsuccessful(RETCODE rc)
    200118{
    static int attemptReconnect(cursorObject *cur)  
    334252}
    335253
    336254
    337 /* @pymethod |connection|setautocommit|Sets the autocommit mode. */
    338 static PyObject *odbcSetAutoCommit(PyObject *self, PyObject *args)
    339 {
    340         int c;
    341         connectionObject *conn;
    342         /* @pyparm int|c||The boolean autocommit mode. */
    343         if (!PyArg_ParseTuple(args, "i",&c))
    344                 return NULL;
    345         conn=connection(self);
    346         if (c==0)
    347         {
    348                 if (unsuccessful(SQLSetConnectOption(
    349                         conn->hdbc,
    350                         SQL_AUTOCOMMIT,
    351                         SQL_AUTOCOMMIT_OFF)))
    352                 {
    353                         connectionError(conn, _T("SETAUTOCOMMIT"));
    354                         return NULL;
    355                 }
    356         }
    357         else
    358         {
    359                 if (unsuccessful(SQLSetConnectOption(
    360                         conn->hdbc,
    361                         SQL_AUTOCOMMIT,
    362                         SQL_AUTOCOMMIT_ON)))
    363                 {
    364                         connectionError(conn, _T("SETAUTOCOMMIT"));
    365                         return NULL;
    366                 };
    367         }
    368 
    369         Py_INCREF(Py_None);
    370         return Py_None;
    371 }
    372 
    373 
    374 /* @pymethod |connection|commit|Commits a transaction. */
    375 static PyObject *odbcCommit(PyObject *self, PyObject *args)
    376 {
    377         RETCODE rc;
    378         Py_BEGIN_ALLOW_THREADS
    379         rc = SQLTransact(
    380                 Env,
    381                 connection(self)->hdbc,
    382                 SQL_COMMIT);
    383         Py_END_ALLOW_THREADS
    384         if (unsuccessful(rc))
    385         {
    386                 connectionError(connection(self), _T("COMMIT"));
    387                 return 0;
    388         }
    389         else
    390         {
    391                 Py_INCREF(Py_None);
    392                 return Py_None;
    393         }
    394 }
    395 
    396 /* @pymethod |connection|rollback|Rollsback a transaction. */
    397 static PyObject *odbcRollback(PyObject *self, PyObject *args)
    398 {
    399         RETCODE rc;
    400         Py_BEGIN_ALLOW_THREADS
    401         rc = SQLTransact(
    402                 Env,
    403                 connection(self)->hdbc,
    404                 SQL_ROLLBACK);
    405         Py_END_ALLOW_THREADS
    406         if (unsuccessful(rc))
    407         {
    408                 connectionError(connection(self), _T("ROLLBACK"));
    409                 return 0;
    410         }
    411         else {
    412                 Py_INCREF(Py_None);
    413                 return Py_None;
    414         }
    415 }
    416 
    417 /* @pymethod |connection|cursor|Creates a <o cursor> object */
    418 static PyObject *odbcCursor(PyObject *self, PyObject *args)
    419 {
    420         connectionObject *conn = connection(self);
    421         if (conn->connected == 0)
    422         {
    423                 if (doConnect(conn))
    424                 {
    425                         return 0;
    426                 }
    427         }
    428 
    429         cursorObject *cur = PyObject_New(cursorObject, &Cursor_Type);
    430         if (cur == NULL)
    431                 return NULL;
    432 
    433         cur->outputVars = 0;
    434         cur->inputVars = 0;
    435         cur->description = 0;
    436         cur->max_width = 65536L;
    437         cur->my_conx = 0;
    438         cur->hstmt=NULL;
    439         cur->cursorError=odbcError;
    440         Py_INCREF(odbcError);
    441         if (unsuccessful(SQLAllocStmt(conn->hdbc, &cur->hstmt)))
    442         {
    443                 connectionError(cur->my_conx, _T("OPEN"));
    444                 Py_DECREF(cur);
    445                 return NULL;
    446         }
    447         cur->my_conx = conn;
    448         cur->connect_id = cur->my_conx->connect_id;
    449         Py_INCREF(self); /* the cursors owns a reference to the connection */
    450         return (PyObject*) cur;
    451 }
    452 
    453 /* @pymethod |connection|close|Closes the connection. */
    454 static PyObject *odbcClose(PyObject *self, PyObject *args)
    455 {
    456   Py_INCREF(Py_None);
    457   return Py_None;
    458 }
    459 
    460 /* @object connection|An object representing an ODBC connection */
    461 static struct PyMethodDef connectionMethods[] = {
    462         { "setautocommit", odbcSetAutoCommit, 1 }, /* @pymeth setautocommit|Sets the autocommit mode. */
    463         { "commit", odbcCommit, 1 } , /* @pymeth commit|Commits a transaction. */
    464         { "rollback", odbcRollback, 1 } , /* @pymeth rollback|Rollsback a transaction. */
    465         { "cursor", odbcCursor, 1 } , /* @pymeth cursor|Creates a <o cursor> object */
    466         { "close", odbcClose, 1 } , /* @pymeth close|Closes the connection. */
    467         {0,     0}
    468 };
    469 
    470 static PyMemberDef connectionMembers[] = {
    471         {"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY},
    472         {NULL}
    473 };
    474 
    475255static void connectionDealloc(PyObject *self)
    476256{
    477257        Py_XDECREF(connection(self)->connectionError);
    static int display_size(short coltype, int collen, const TCHAR *colname)  
    1192972    case SQL_DATE:
    1193973    case SQL_TIMESTAMP:
    1194974    case SQL_BIT:
     975#if defined(__MINGW32__)
     976      return(std::max(collen, (int)_tcslen(colname)));
     977#else
    1195978      return(max(collen, (int)_tcslen(colname)));
     979#endif
    1196980    case SQL_SMALLINT:
    1197981    case SQL_INTEGER:
    1198982    case SQL_TINYINT:
     983#if defined(__MINGW32__)
     984      return(std::max(collen+1, (int)_tcslen(colname)));
     985#else
    1199986      return(max(collen+1, (int)_tcslen(colname)));
     987#endif
    1200988    case SQL_DECIMAL:
    1201989    case SQL_NUMERIC:
     990#if defined(__MINGW32__)
     991      return(std::max(collen+2, (int)_tcslen(colname)));
     992#else
    1202993      return(max(collen+2, (int)_tcslen(colname)));
     994#endif
    1203995    case SQL_REAL:
    1204996    case SQL_FLOAT:
    1205997    case SQL_DOUBLE:
     998#if defined(__MINGW32__)
     999      return(std::max(20, (int)_tcslen(colname)));
     1000#else
    12061001      return(max(20, (int)_tcslen(colname)));
     1002#endif
    12071003    case SQL_BINARY:
    12081004    case SQL_VARBINARY:
     1005#if defined(__MINGW32__)
     1006      return(std::max(2*collen, (int)_tcslen(colname)));
     1007#else
    12091008      return(max(2*collen, (int)_tcslen(colname)));
     1009#endif
    12101010    case SQL_LONGVARBINARY:
    12111011    case SQL_LONGVARCHAR:
    12121012    default:
    static PyMemberDef cursorMembers[] = {  
    18141614        {NULL}
    18151615};
    18161616
     1617static PyTypeObject Cursor_Type =
     1618{
     1619        PYWIN_OBJECT_HEAD
     1620        "odbccur",                              /*tp_name */
     1621        sizeof(cursorObject),   /*tp_basicsize */
     1622        0,                                              /*tp_itemsize */
     1623        cursorDealloc,                  /*tp_dealloc */
     1624        0,                                              /*tp_print */
     1625        0,                                              /*tp_getattr */
     1626        0,                                              /*tp_setattr */
     1627        0,                                              /*tp_compare */
     1628        0,                                              /*tp_repr */
     1629        0,                                              /*tp_as_number */
     1630        0,                                              /* tp_as_sequence */
     1631        0,                                              /* tp_as_mapping */
     1632        0,                                              /* tp_hash */
     1633        0,                                              /* tp_call */
     1634        0,                                              /*tp_str */
     1635        PyObject_GenericGetAttr,        /* tp_getattro dbiGetAttr */
     1636        PyObject_GenericSetAttr,        /* tp_setattro */
     1637        0,                                              /*tp_as_buffer*/
     1638        Py_TPFLAGS_DEFAULT,             /* tp_flags */
     1639        0,                                              /* tp_doc */
     1640        0,                                              /* tp_traverse */
     1641        0,                                              /* tp_clear */
     1642        0,                                              /* tp_richcompare */
     1643        0,                                              /* tp_weaklistoffset */
     1644        0,                                              /* tp_iter */
     1645        0,                                              /* tp_iternext */
     1646        cursorMethods,                  /* tp_methods */
     1647        cursorMembers,                  /* tp_members */
     1648        0,                                              /* tp_getset */
     1649        0,                                              /* tp_base */
     1650        0,                                              /* tp_dict */
     1651        0,                                              /* tp_descr_get */
     1652        0,                                              /* tp_descr_set */
     1653        0,                                              /* tp_dictoffset */
     1654        0,                                              /* tp_init */
     1655        0,                                              /* tp_alloc */
     1656        0,                                              /* tp_new */
     1657};
     1658/* @pymethod |connection|setautocommit|Sets the autocommit mode. */
     1659static PyObject *odbcSetAutoCommit(PyObject *self, PyObject *args)
     1660{
     1661        int c;
     1662        connectionObject *conn;
     1663        /* @pyparm int|c||The boolean autocommit mode. */
     1664        if (!PyArg_ParseTuple(args, "i",&c))
     1665                return NULL;
     1666        conn=connection(self);
     1667        if (c==0)
     1668        {
     1669                if (unsuccessful(SQLSetConnectOption(
     1670                        conn->hdbc,
     1671                        SQL_AUTOCOMMIT,
     1672                        SQL_AUTOCOMMIT_OFF)))
     1673                {
     1674                        connectionError(conn, _T("SETAUTOCOMMIT"));
     1675                        return NULL;
     1676                }
     1677        }
     1678        else
     1679        {
     1680                if (unsuccessful(SQLSetConnectOption(
     1681                        conn->hdbc,
     1682                        SQL_AUTOCOMMIT,
     1683                        SQL_AUTOCOMMIT_ON)))
     1684                {
     1685                        connectionError(conn, _T("SETAUTOCOMMIT"));
     1686                        return NULL;
     1687                };
     1688        }
     1689
     1690        Py_INCREF(Py_None);
     1691        return Py_None;
     1692}
     1693
     1694
     1695/* @pymethod |connection|commit|Commits a transaction. */
     1696static PyObject *odbcCommit(PyObject *self, PyObject *args)
     1697{
     1698        RETCODE rc;
     1699        Py_BEGIN_ALLOW_THREADS
     1700        rc = SQLTransact(
     1701                Env,
     1702                connection(self)->hdbc,
     1703                SQL_COMMIT);
     1704        Py_END_ALLOW_THREADS
     1705        if (unsuccessful(rc))
     1706        {
     1707                connectionError(connection(self), _T("COMMIT"));
     1708                return 0;
     1709        }
     1710        else
     1711        {
     1712                Py_INCREF(Py_None);
     1713                return Py_None;
     1714        }
     1715}
     1716
     1717/* @pymethod |connection|rollback|Rollsback a transaction. */
     1718static PyObject *odbcRollback(PyObject *self, PyObject *args)
     1719{
     1720        RETCODE rc;
     1721        Py_BEGIN_ALLOW_THREADS
     1722        rc = SQLTransact(
     1723                Env,
     1724                connection(self)->hdbc,
     1725                SQL_ROLLBACK);
     1726        Py_END_ALLOW_THREADS
     1727        if (unsuccessful(rc))
     1728        {
     1729                connectionError(connection(self), _T("ROLLBACK"));
     1730                return 0;
     1731        }
     1732        else {
     1733                Py_INCREF(Py_None);
     1734                return Py_None;
     1735        }
     1736}
     1737
     1738/* @pymethod |connection|cursor|Creates a <o cursor> object */
     1739static PyObject *odbcCursor(PyObject *self, PyObject *args)
     1740{
     1741        connectionObject *conn = connection(self);
     1742        if (conn->connected == 0)
     1743        {
     1744                if (doConnect(conn))
     1745                {
     1746                        return 0;
     1747                }
     1748        }
     1749
     1750        cursorObject *cur = PyObject_New(cursorObject, &Cursor_Type);
     1751        if (cur == NULL)
     1752                return NULL;
     1753
     1754        cur->outputVars = 0;
     1755        cur->inputVars = 0;
     1756        cur->description = 0;
     1757        cur->max_width = 65536L;
     1758        cur->my_conx = 0;
     1759        cur->hstmt=NULL;
     1760        cur->cursorError=odbcError;
     1761        Py_INCREF(odbcError);
     1762        if (unsuccessful(SQLAllocStmt(conn->hdbc, &cur->hstmt)))
     1763        {
     1764                connectionError(cur->my_conx, _T("OPEN"));
     1765                Py_DECREF(cur);
     1766                return NULL;
     1767        }
     1768        cur->my_conx = conn;
     1769        cur->connect_id = cur->my_conx->connect_id;
     1770        Py_INCREF(self); /* the cursors owns a reference to the connection */
     1771        return (PyObject*) cur;
     1772}
     1773
     1774/* @pymethod |connection|close|Closes the connection. */
     1775static PyObject *odbcClose(PyObject *self, PyObject *args)
     1776{
     1777  Py_INCREF(Py_None);
     1778  return Py_None;
     1779}
     1780
     1781/* @object connection|An object representing an ODBC connection */
     1782static struct PyMethodDef connectionMethods[6] = {
     1783        { "setautocommit", odbcSetAutoCommit, 1 }, /* @pymeth setautocommit|Sets the autocommit mode. */
     1784        { "commit", odbcCommit, 1 } , /* @pymeth commit|Commits a transaction. */
     1785        { "rollback", odbcRollback, 1 } , /* @pymeth rollback|Rollsback a transaction. */
     1786        { "cursor", odbcCursor, 1 } , /* @pymeth cursor|Creates a <o cursor> object */
     1787        { "close", odbcClose, 1 } , /* @pymeth close|Closes the connection. */
     1788        {0,     0}
     1789};
     1790
     1791static PyMemberDef connectionMembers[2] = {
     1792        {"error", T_OBJECT, offsetof(connectionObject, connectionError), READONLY},
     1793        {NULL}
     1794};
     1795
     1796static PyTypeObject Connection_Type =
     1797{
     1798        PYWIN_OBJECT_HEAD
     1799        "odbcconn",                             /*tp_name */
     1800        sizeof (connectionObject),      /*tp_basicsize */
     1801        0,                                              /*tp_itemsize */
     1802        connectionDealloc,              /*tp_dealloc */
     1803        0,                                              /*tp_print */
     1804        0,                                              /*tp_getattr */
     1805        0,                                              /*tp_setattr */
     1806        0,                                              /*tp_compare */
     1807        0,                                              /*tp_repr */
     1808        0,                                              /*tp_as_number */
     1809        0,                                              /* tp_as_sequence */
     1810        0,                                              /* tp_as_mapping */
     1811        0,                                              /* tp_hash */
     1812        0,                                              /* tp_call */
     1813        0,                                              /*tp_str */
     1814        PyObject_GenericGetAttr,        /* tp_getattro dbiGetAttr */
     1815        PyObject_GenericSetAttr,        /* tp_setattro */
     1816        0,                                              /*tp_as_buffer*/
     1817        Py_TPFLAGS_DEFAULT,             /* tp_flags */
     1818        0,                                              /* tp_doc */
     1819        0,                                              /* tp_traverse */
     1820        0,                                              /* tp_clear */
     1821        0,                                              /* tp_richcompare */
     1822        0,                                              /* tp_weaklistoffset */
     1823        0,                                              /* tp_iter */
     1824        0,                                              /* tp_iternext */
     1825        connectionMethods,              /* tp_methods */
     1826        connectionMembers,              /* tp_members */
     1827        0,                                              /* tp_getset */
     1828        0,                                              /* tp_base */
     1829        0,                                              /* tp_dict */
     1830        0,                                              /* tp_descr_get */
     1831        0,                                              /* tp_descr_set */
     1832        0,                                              /* tp_dictoffset */
     1833        0,                                              /* tp_init */
     1834        0,                                              /* tp_alloc */
     1835        0,                                              /* tp_new */
     1836};
    18171837static void parseInfo(connectionObject *conn, const TCHAR *c)
    18181838{
    18191839        TCHAR *p;
  • win32/src/win32apimodule.cpp

    diff --git a/win32/src/win32apimodule.cpp b/win32/src/win32apimodule.cpp
    index f7e36b1..dd5223f 100644
    a b PyFormatMessageA(PyObject *self, PyObject *args)  
    817817       
    818818        {
    819819        PyW32_BEGIN_ALLOW_THREADS
     820#if !defined(__MINGW32__)
    820821        __try{
     822#endif
    821823                lrc = ::FormatMessageA(flags, pSource, msgId, langId, (LPSTR)&resultBuf, 0, (va_list *)pInserts );
     824#if !defined(__MINGW32__)
    822825                }
    823826        __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH){
    824827                baccessviolation=TRUE;
    825828                }
     829#endif
    826830        PyW32_END_ALLOW_THREADS
    827831        }
    828832
    PyFormatMessageW(PyObject *self, PyObject *args)  
    927931
    928932        {
    929933        PyW32_BEGIN_ALLOW_THREADS
     934#if !defined(__MINGW32__)
    930935        __try{
     936#endif
    931937                lrc = ::FormatMessageW(flags, pSource, msgId, langId, (LPWSTR)&resultBuf, 0, (va_list *)pInserts );
     938#if !defined(__MINGW32__)
    932939                }
    933940        __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH){
    934941                baccessviolation=TRUE;
    935942                }
     943#endif
    936944        PyW32_END_ALLOW_THREADS
    937945        }
    938946
    static PyObject *PyApply(PyObject *self, PyObject *args)  
    57745782        }
    57755783        PyThreadState *stateSave = PyThreadState_Swap(NULL);
    57765784        PyThreadState_Swap(stateSave);
     5785#if !defined(__MINGW32__)
    57775786        _try {
     5787#endif
    57785788                ret = PyObject_CallObject(obFunc, obArgs);
     5789#if !defined(__MINGW32__)
    57795790        }
    57805791        _except( PyApplyExceptionFilter( GetExceptionCode(),
    57815792                                         GetExceptionInformation(),
    static PyObject *PyApply(PyObject *self, PyObject *args)  
    58045815                Py_XDECREF(exc_value);
    58055816                ret = NULL;
    58065817        }
     5818#endif
    58075819        return ret;
    58085820// @comm Calls the specified function in a manner similar to
    58095821// the built-in function apply(), but allows Win32 exceptions
  • win32/src/win32crypt/PyCRYPTPROV.cpp

    diff --git a/win32/src/win32crypt/PyCRYPTPROV.cpp b/win32/src/win32crypt/PyCRYPTPROV.cpp
    index 140ddd3..3de895c 100644
    a b  
    11// @doc
    22#include "win32crypt.h"
    33
     4#if defined(__MINGW32__)
     5#include <algorithm>
     6#endif
     7
    48// @object PyCRYPTPROV|Handle to a cryptographic provider, created using <om cryptoapi.CryptAcquireContext>
    59struct PyMethodDef PyCRYPTPROV::methods[] = {
    610        // @pymeth CryptReleaseContext|Releases the CSP handle
    PyObject *PyCRYPTPROV::PyCryptGenRandom(PyObject *self, PyObject *args, PyObject  
    351355        //initialize buffer with char string if passed if
    352356        ZeroMemory(pbBuffer, dwLen+1);
    353357        if (seeddata != NULL)
     358#if defined(__MINGW32__)
     359                memcpy(pbBuffer, seeddata, std::min(dwLen,seedlen));
     360#else
    354361                memcpy(pbBuffer, seeddata, min(dwLen,seedlen));
     362#endif
    355363        if (CryptGenRandom(hcryptprov, dwLen, pbBuffer))
    356364                ret=PyString_FromStringAndSize((char *)pbBuffer, dwLen);
    357365        else
  • win32/src/win32crypt/win32cryptmodule.cpp

    diff --git a/win32/src/win32crypt/win32cryptmodule.cpp b/win32/src/win32crypt/win32cryptmodule.cpp
    index 29b2c80..5875294 100644
    a b static PyObject *PyCertOpenStore(PyObject *self, PyObject *args, PyObject *kwarg  
    597597                }
    598598        else{
    599599                switch((ULONG_PTR)StoreProvider){
     600#if defined(__MINGW32__)
     601                        case (ULONG_PTR)14:
     602                        case (ULONG_PTR)8:
     603                        case (ULONG_PTR)10:
     604                        case (ULONG_PTR)13:
     605                        case (ULONG_PTR)16:{
     606#else
    600607                        case CERT_STORE_PROV_PHYSICAL:
    601608                        case CERT_STORE_PROV_FILENAME:
    602609                        case CERT_STORE_PROV_SYSTEM:
    603610                        case CERT_STORE_PROV_SYSTEM_REGISTRY:
    604611                        case CERT_STORE_PROV_LDAP:{
     612#endif
    605613                                if (!PyWinObject_AsWCHAR(obpvPara, (WCHAR **)&pvPara))
    606614                                        return NULL;
    607615                                free_wchar=TRUE;
    608616                                break;
    609617                                }
     618#if defined(__MINGW32__)
     619                        case (ULONG_PTR)4:{
     620#else
    610621                        case CERT_STORE_PROV_REG:{
     622#endif
    611623                                if (!PyWinObject_AsHKEY(obpvPara, (HKEY *)&pvPara))
    612624                                        return NULL;
    613625                                break;
    614626                                }
     627#if defined(__MINGW32__)
     628                        case (ULONG_PTR)3:{
     629#else
    615630                        case CERT_STORE_PROV_FILE:{
     631#endif
    616632                                if (!PyWinObject_AsHANDLE(obpvPara, (HANDLE *)&pvPara))
    617633                                        return NULL;
    618634                                break;
    619635                                }
     636#if defined(__MINGW32__)
     637                        case (ULONG_PTR)6:
     638                        case (ULONG_PTR)5:{
     639#else
    620640                        case CERT_STORE_PROV_SERIALIZED:
    621641                        case CERT_STORE_PROV_PKCS7:{
     642#endif
    622643                                if (!PyWinObject_AsReadBuffer(obpvPara, (void **)&crypt_data_blob.pbData, &crypt_data_blob.cbData))
    623644                                        return NULL;
    624645                                pvPara=(void *)&crypt_data_blob;
    625646                                break;
    626647                                }
     648#if defined(__MINGW32__)
     649                        case (ULONG_PTR)2:{
     650#else
    627651                        case CERT_STORE_PROV_MEMORY:{
     652#endif
    628653                                // pvPara is not used, warn if something passed in
    629654                                if (obpvPara != Py_None)
    630655                                        PyErr_Warn(PyExc_RuntimeWarning, "Para ignored for CERT_STORE_PROV_MEMORY");
  • win32/src/win32evtlog.i

    diff --git a/win32/src/win32evtlog.i b/win32/src/win32evtlog.i
    index 847230c..142923b 100644
    a b PyCFunction pfnPyEvtUpdateBookmark = (PyCFunction) PyEvtUpdateBookmark;  
    10121012
    10131013PyObject *PyWinObject_FromEVT_VARIANT(PEVT_VARIANT val)
    10141014{
     1015#if defined(__MINGW32__)
     1016        DWORD val_type = val->Type;
     1017#else
    10151018        if (val->Type & EVT_VARIANT_TYPE_ARRAY){
    10161019                PyErr_SetString(PyExc_NotImplementedError, "EVT_VARIANT arrays not supported yet");
    10171020                return NULL;
    10181021                }
    10191022        DWORD val_type = val->Type & EVT_VARIANT_TYPE_MASK;
     1023#endif
    10201024        PyObject *obval = NULL;
    10211025        switch (val_type){
    10221026                case EvtVarTypeNull:
  • win32/src/win32file.i

    diff --git a/win32/src/win32file.i b/win32/src/win32file.i
    index 2b82d37..39e7cd1 100644
    a b static PyObject *PyObject_FromFILE_NOTIFY_INFORMATION(void *buffer, DWORD nbytes  
    14201420        // the filename is exactly 1 byte!  Not clear the best way to
    14211421        // check this, but this works for now - is it at least the size of
    14221422        // the *head* of the struct.
     1423#if defined(__MINGW32__)
     1424        if (nbytes < sizeof(DWORD)*3+2)
     1425#else
    14231426        if (nbytes < sizeof DWORD*3+2)
     1427#endif
    14241428                return ret;
    14251429        DWORD nbytes_read = 0;
    14261430        while (1) {
     1431#if defined(__MINGW32__)
     1432                PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof(WCHAR));
     1433#else
    14271434                PyObject *fname = PyWinObject_FromOLECHAR(p->FileName, p->FileNameLength/sizeof WCHAR);
     1435#endif
    14281436                if (!fname) {
    14291437                        Py_DECREF(ret);
    14301438                        return NULL;
  • win32/src/win32file_comm.cpp

    diff --git a/win32/src/win32file_comm.cpp b/win32/src/win32file_comm.cpp
    index 19f2eb7..d16fb76 100644
    a b PyDCB::~PyDCB(void)  
    173173{
    174174}
    175175
     176#if defined(__MINGW32__)
     177#define GET_BITFIELD_ENTRY(bitfield_name) \
     178        else if (strcmp(name, #bitfield_name)==0) { \
     179                return PyInt_FromLong(pydcb->m_DCB. bitfield_name); \
     180        } \
     181
     182#else
    176183#define GET_BITFIELD_ENTRY(bitfield_name) \
    177184        else if (strcmp(name, #bitfield_name)==0) { \
    178185                return PyInt_FromLong(pydcb->m_DCB.##bitfield_name); \
    179186        } \
    180187
     188#endif
    181189PyObject *PyDCB::getattro(PyObject *self, PyObject *obname)
    182190{
    183191        PyDCB *pydcb = (PyDCB *)self;
    PyObject *PyDCB::getattro(PyObject *self, PyObject *obname)  
    204212        return PyObject_GenericGetAttr(self, obname);
    205213}
    206214
     215#if defined(__MINGW32__)
    207216#define SET_BITFIELD_ENTRY(bitfield_name) \
     217        else if (strcmp(name, #bitfield_name)==0) { \
     218                if (!PyInt_Check(v)) { \
     219                        PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \
     220                        return -1; \
     221                } \
     222                pydcb->m_DCB. bitfield_name = PyInt_AsLong(v); \
     223                return 0; \
     224        } \
     225
     226#else
     227#define SET_BITFIELD_ENTRY(bitfield_name)           \
    208228        else if (strcmp(name, #bitfield_name)==0) { \
    209229                if (!PyInt_Check(v)) { \
    210230                        PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \
    PyObject *PyDCB::getattro(PyObject *self, PyObject *obname)  
    214234                return 0; \
    215235        } \
    216236
     237#endif
    217238int PyDCB::setattro(PyObject *self, PyObject *obname, PyObject *v)
    218239{
    219240        PyDCB *pydcb = (PyDCB *)self;
    PyCOMSTAT::~PyCOMSTAT(void)  
    367388}
    368389
    369390#undef GET_BITFIELD_ENTRY
     391#if defined(__MINGW32__)
     392#define GET_BITFIELD_ENTRY(bitfield_name) \
     393        else if (strcmp(name, #bitfield_name)==0) { \
     394                return PyInt_FromLong(pyCOMSTAT->m_COMSTAT. bitfield_name); \
     395        } \
     396
     397#else
    370398#define GET_BITFIELD_ENTRY(bitfield_name) \
    371399        else if (strcmp(name, #bitfield_name)==0) { \
    372400                return PyInt_FromLong(pyCOMSTAT->m_COMSTAT.##bitfield_name); \
    373401        } \
    374402
     403#endif
    375404PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname)
    376405{
    377406        PyCOMSTAT *pyCOMSTAT = (PyCOMSTAT *)self;
    PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname)  
    392421}
    393422
    394423#undef SET_BITFIELD_ENTRY
     424#if defined(__MINGW32__)
     425#define SET_BITFIELD_ENTRY(bitfield_name) \
     426        else if (strcmp(name, #bitfield_name)==0) { \
     427                if (!PyInt_Check(v)) { \
     428                        PyErr_Format(PyExc_TypeError, szNeedIntAttr, #bitfield_name); \
     429                        return -1; \
     430                } \
     431                pyCOMSTAT->m_COMSTAT. bitfield_name = PyInt_AsLong(v); \
     432                return 0; \
     433        } \
     434
     435#else
    395436#define SET_BITFIELD_ENTRY(bitfield_name) \
    396437        else if (strcmp(name, #bitfield_name)==0) { \
    397438                if (!PyInt_Check(v)) { \
    PyObject *PyCOMSTAT::getattro(PyObject *self, PyObject *obname)  
    402443                return 0; \
    403444        } \
    404445
     446#endif
    405447int PyCOMSTAT::setattro(PyObject *self, PyObject *obname, PyObject *v)
    406448{
    407449        PyCOMSTAT *pyCOMSTAT = (PyCOMSTAT *)self;
  • win32/src/win32gui.i

    diff --git a/win32/src/win32gui.i b/win32/src/win32gui.i
    index 94b738f..bc5e494 100644
    a b  
    3434#include "Dbt.h" // device notification
    3535#include "malloc.h"
    3636
     37#if defined(__MINGW32__)
     38#include <algorithm>
     39#endif
    3740#ifdef MS_WINCE
    3841#include "winbase.h"
    3942#define IS_INTRESOURCE(res) (((DWORD)(res) & 0xffff0000) == 0)
    typedef int UINT;  
    640643// @object TRACKMOUSEEVENT|A tuple of (dwFlags, hwndTrack, dwHoverTime)
    641644%typemap(python,in) TRACKMOUSEEVENT *INPUT(TRACKMOUSEEVENT e){
    642645        PyObject *obhwnd;
     646#if defined(__MINGW32__)
     647        e.cbSize = sizeof(e);
     648#else
    643649        e.cbSize = sizeof e;
     650#endif
    644651        if (PyTuple_Check($source)) {
    645652                if (PyArg_ParseTuple($source, "lOl", &e.dwFlags, &obhwnd, &e.dwHoverTime) == 0) {
    646653                        return PyErr_Format(PyExc_TypeError, "%s: a TRACKMOUSEEVENT must be a tuple of 3 integers", "$name");
    PyObject *PyFlashWindowEx(PyObject *self, PyObject *args)  
    18221829        PyObject *ret, *obhwnd;
    18231830        BOOL rc;
    18241831        FLASHWINFO f;
     1832#if defined(__MINGW32__)
     1833        f.cbSize = sizeof(f);
     1834#else
    18251835        f.cbSize = sizeof f;
     1836#endif
    18261837        // @pyparm <o PyHANDLE>|hwnd||Handle to a window
    18271838        // @pyparm int|dwFlags||Combination of win32con.FLASHW_* flags
    18281839        // @pyparm int|uCount||Nbr of times to flash
    static PyObject *PyExtractIconEx(PyObject *self, PyObject *args)  
    38023813    nicons_got = 1;
    38033814#endif
    38043815    // Asking for 1 always says it got 2!?
     3816#if defined(__MINGW32__)
     3817    nicons = std::min(nicons, nicons_got);
     3818#else
    38053819    nicons = min(nicons, nicons_got);
     3820#endif
    38063821    objects_large = PyList_New(nicons);
    38073822    if (!objects_large) goto done;
    38083823    objects_small = PyList_New(nicons);
    BOOL GetOpenFileName(OPENFILENAME *INPUT);  
    45964611%typemap (python, in) MENUITEMINFO *INPUT (Py_ssize_t target_size){
    45974612        if (0 != PyObject_AsReadBuffer($source, (const void **)&$target, &target_size))
    45984613                return NULL;
     4614#if defined(__MINGW32__)
     4615        if (sizeof(MENUITEMINFO) != target_size)
     4616                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof(MENUITEMINFO), target_size);
     4617#else
    45994618        if (sizeof MENUITEMINFO != target_size)
    46004619                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof MENUITEMINFO, target_size);
     4620#endif
    46014621}
    46024622
    46034623%typemap (python,in) MENUITEMINFO *BOTH(Py_ssize_t target_size) {
    46044624        if (0 != PyObject_AsWriteBuffer($source, (void **)&$target, &target_size))
    46054625                return NULL;
     4626#if defined(__MINGW32__)
     4627        if (sizeof(MENUITEMINFO) != target_size)
     4628                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof(MENUITEMINFO), target_size);
     4629#else
    46064630        if (sizeof MENUITEMINFO != target_size)
    46074631                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof MENUITEMINFO, target_size);
     4632#endif
    46084633}
    46094634
    46104635%typemap (python, in) MENUINFO *INPUT (Py_ssize_t target_size){
    46114636        if (0 != PyObject_AsReadBuffer($source, (const void **)&$target, &target_size))
    46124637                return NULL;
     4638#if defined(__MINGW32__)
     4639        if (sizeof(MENUINFO) != target_size)
     4640                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof(MENUINFO), target_size);
     4641#else
    46134642        if (sizeof MENUINFO != target_size)
    46144643                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte string/buffer (got %d bytes)", sizeof MENUINFO, target_size);
     4644#endif
    46154645}
    46164646
    46174647%typemap (python,in) MENUINFO *BOTH(Py_ssize_t target_size) {
    46184648        if (0 != PyObject_AsWriteBuffer($source, (void **)&$target, &target_size))
    46194649                return NULL;
     4650#if defined(__MINGW32__)
     4651        if (sizeof(MENUINFO) != target_size)
     4652                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof(MENUINFO), target_size);
     4653#else
    46204654        if (sizeof MENUINFO != target_size)
    46214655                return PyErr_Format(PyExc_TypeError, "Argument must be a %d-byte buffer (got %d bytes)", sizeof MENUINFO, target_size);
     4656#endif
    46224657}
    46234658
    46244659// @pyswig |InsertMenuItem|Inserts a menu item
    PyObject *PySetMenuInfo(PyObject *self, PyObject *args)  
    47504785
    47514786        if (0 != PyObject_AsReadBuffer(obInfo, (const void **)&pInfo, &cbInfo))
    47524787                return NULL;
     4788#if defined(__MINGW32__)
     4789        if (sizeof(MENUINFO) != cbInfo)
     4790                return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte string/buffer (got %d bytes)", sizeof(MENUINFO), cbInfo);
     4791#else
    47534792        if (sizeof MENUINFO != cbInfo)
    47544793                return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte string/buffer (got %d bytes)", sizeof MENUINFO, cbInfo);
     4794#endif
    47554795
    47564796        Py_BEGIN_ALLOW_THREADS
    47574797        result = (*pfnSetMenuInfo)(hmenu, pInfo);
    PyObject *PyGetMenuInfo(PyObject *self, PyObject *args)  
    47874827
    47884828        if (0 != PyObject_AsWriteBuffer(obInfo, (void **)&pInfo, &cbInfo))
    47894829                return NULL;
     4830#if defined(__MINGW32__)
     4831        if (sizeof(MENUINFO) != cbInfo)
     4832                return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte buffer (got %d bytes)", sizeof(MENUINFO), cbInfo);
     4833#else
    47904834        if (sizeof MENUINFO != cbInfo)
    47914835                return PyErr_Format(PyExc_TypeError, "Argument must be a %d byte buffer (got %d bytes)", sizeof MENUINFO, cbInfo);
     4836#endif
    47924837
    47934838        Py_BEGIN_ALLOW_THREADS
    47944839        result = (*pfnGetMenuInfo)(hmenu, pInfo);
    PyGetClassName(PyObject *self, PyObject *args)  
    60056050        if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd))
    60066051                return NULL;
    60076052        // dont bother with lock - no callback possible.
     6053#if defined(__MINGW32__)
     6054        int nchars = GetClassName(hwnd, buf, sizeof(buf)/sizeof(buf[0]));
     6055#else
    60086056        int nchars = GetClassName(hwnd, buf, sizeof buf/sizeof buf[0]);
     6057#endif
    60096058        if (nchars==0)
    60106059                return PyWin_SetAPIError("GetClassName");
    60116060        return PyWinObject_FromTCHAR(buf, nchars);
    BOOL PyParse_OPENFILENAMEW_Args(PyObject *args, PyObject *kwargs, OPENFILENAMEW  
    63706419        // lpstrFile buffer receives full path and possibly multiple file names, allocate extra space
    63716420        if (!PyWinObject_AsWCHAR(obFile, &initfile, TRUE, &initfilechars))
    63726421                goto done;
     6422#if defined(__MINGW32__)
     6423        pofn->nMaxFile=std::max(pofn->nMaxFile, initfilechars+1);
     6424#else
    63736425        pofn->nMaxFile=max(pofn->nMaxFile, initfilechars+1);
     6426#endif
    63746427        bufsize=pofn->nMaxFile*sizeof(WCHAR);
    63756428        pofn->lpstrFile=(LPWSTR)malloc(bufsize);
    63766429        if (pofn->lpstrFile==NULL){
    PyObject *PyRegisterDeviceNotification(PyObject *self, PyObject *args)  
    75067559                                "structure says it has %d bytes, but %d was provided",
    75077560                                (int)struct_bytes, (int)nbytes);
    75087561        // @pyseeapi RegisterDeviceNotification
    7509         HDEVNOTIFY not;
     7562        HDEVNOTIFY notify;
    75107563        Py_BEGIN_ALLOW_THREADS
    7511         not = RegisterDeviceNotification(handle, (void *)filter, flags);
     7564        notify = RegisterDeviceNotification(handle, (void *)filter, flags);
    75127565        Py_END_ALLOW_THREADS
    7513         if (not == NULL)
     7566        if (notify == NULL)
    75147567                return PyWin_SetAPIError("RegisterDeviceNotification");
    7515         return PyWinObject_FromHDEVNOTIFY(not);
     7568        return PyWinObject_FromHDEVNOTIFY(notify);
    75167569}
    75177570%}
    75187571%native(RegisterDeviceNotification) PyRegisterDeviceNotification;
  • win32/src/win32inet.i

    diff --git a/win32/src/win32inet.i b/win32/src/win32inet.i
    index 92d7462..16a8912 100644
    a b  
    1515%{
    1616#undef PyHANDLE // undef earlier define, so we are back to the class.
    1717#include "pywinobjects.h"
     18#if defined(__MINGW32__)
     19#include <algorithm>
     20#endif
    1821
    1922void CALLBACK PyHINTERNET_StatusChange(
    2023        HINTERNET hInternet,
    PyObject *PyInternetQueryOption(PyObject *self, PyObject *args)  
    953956                case INTERNET_OPTION_RECEIVE_TIMEOUT:   // @flag INTERNET_OPTION_RECEIVE_TIMEOUT|Int - timeout in millseconds
    954957                                                                                                // @flag INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT|Int - timeout in millseconds
    955958                case INTERNET_OPTION_CODEPAGE:          // @flag INTERNET_OPTION_CODEPAGE|Int - Codepage of host part of URL
     959#if !defined(__MINGW32__)
    956960                case INTERNET_OPTION_CODEPAGE_PATH:     // @flag INTERNET_OPTION_CODEPAGE_PATH|Int - Codepage for URL
    957961                case INTERNET_OPTION_CODEPAGE_EXTRA:    // @flag INTERNET_OPTION_CODEPAGE_EXTRA|Int - Codepage for path part of URL
     962#endif
    958963                case INTERNET_OPTION_CONNECT_RETRIES:           // @flag INTERNET_OPTION_CONNECT_RETRIES|Int - Number of time to try to reconnect to host
    959964                case INTERNET_OPTION_CONNECT_TIMEOUT:           // @flag INTERNET_OPTION_CONNECT_TIMEOUT|Int - Connection timeout in milliseconds
    960965                case INTERNET_OPTION_CONNECTED_STATE:           // @flag INTERNET_OPTION_CONNECTED_STATE|Int - Connection state, INTERNET_STATE_*
    PyObject *PyInternetQueryOption(PyObject *self, PyObject *args)  
    962967                case INTERNET_OPTION_ERROR_MASK:                // @flag INTERNET_OPTION_ERROR_MASK|Int, combination of INTERNET_ERROR_MASK_*
    963968                case INTERNET_OPTION_EXTENDED_ERROR:            // @flag INTERNET_OPTION_EXTENDED_ERROR|Int, ERROR_INTERNET_*
    964969                case INTERNET_OPTION_FROM_CACHE_TIMEOUT:                // @flag INTERNET_OPTION_FROM_CACHE_TIMEOUT|Int - Timeout in ms before cached copy is used
     970#if !defined(__MINGW32__)
    965971                case INTERNET_OPTION_IDN:               // @flag INTERNET_OPTION_IDN|Int, INTERNET_FLAG_IDN_*
     972#endif
    966973                case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:          // @flag INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER|Int
    967974                case INTERNET_OPTION_MAX_CONNS_PER_SERVER:              // @flag INTERNET_OPTION_MAX_CONNS_PER_SERVER|Int
    968975                case INTERNET_OPTION_READ_BUFFER_SIZE:          // @flag INTERNET_OPTION_READ_BUFFER_SIZE|Int
    PyObject *PyInternetQueryOption(PyObject *self, PyObject *args)  
    974981                        ret=PyLong_FromUnsignedLong(*(unsigned long *)buf);
    975982                        break;
    976983                case INTERNET_OPTION_BYPASS_EDITED_ENTRY:               // @flag INTERNET_OPTION_BYPASS_EDITED_ENTRY|Boolean
     984#if !defined(__MINGW32__)
    977985                case INTERNET_OPTION_HTTP_DECODING:             // @flag INTERNET_OPTION_HTTP_DECODING|Boolean
     986#endif
    978987                case INTERNET_OPTION_IGNORE_OFFLINE:            // @flag INTERNET_OPTION_IGNORE_OFFLINE|Boolean
    979988                        ret=PyBool_FromLong(*(BOOL *)buf);
    980989                        break;
    PyObject *PyInternetSetOption(PyObject *self, PyObject *args)  
    11571166                case INTERNET_OPTION_RECEIVE_TIMEOUT:   // @flag INTERNET_OPTION_RECEIVE_TIMEOUT|Int - timeout in millseconds
    11581167                                                                                                // @flag INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT|Int - timeout in millseconds
    11591168                case INTERNET_OPTION_CODEPAGE:          // @flag INTERNET_OPTION_CODEPAGE|Int - Codepage of host part of URL
     1169#if !defined(__MINGW32__)
    11601170                case INTERNET_OPTION_CODEPAGE_PATH:     // @flag INTERNET_OPTION_CODEPAGE_PATH|Codepage for URL
    11611171                case INTERNET_OPTION_CODEPAGE_EXTRA:    // @flag INTERNET_OPTION_CODEPAGE_EXTRA|Int - Codepage for path part of URL
     1172#endif
    11621173                case INTERNET_OPTION_CONNECT_RETRIES:           // @flag INTERNET_OPTION_CONNECT_RETRIES|Int - Number of time to try to reconnect to host
    11631174                case INTERNET_OPTION_CONNECT_TIMEOUT:           // @flag INTERNET_OPTION_CONNECT_TIMEOUT|Int - Connection timeout in milliseconds
    11641175                case INTERNET_OPTION_CONNECTED_STATE:           // @flag INTERNET_OPTION_CONNECTED_STATE|Int - Connection state, INTERNET_STATE_*
    11651176                case INTERNET_OPTION_ERROR_MASK:                // @flag INTERNET_OPTION_ERROR_MASK|Int, combination of INTERNET_ERROR_MASK_*
    11661177                case INTERNET_OPTION_FROM_CACHE_TIMEOUT:                // @flag INTERNET_OPTION_FROM_CACHE_TIMEOUT|Int - Timeout in ms before cached copy is used
     1178#if !defined(__MINGW32__)
    11671179                case INTERNET_OPTION_IDN:               // @flag INTERNET_OPTION_IDN|Int, INTERNET_FLAG_IDN_*
     1180#endif
    11681181                case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:          // @flag INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER|Int
    11691182                case INTERNET_OPTION_MAX_CONNS_PER_SERVER:              // @flag INTERNET_OPTION_MAX_CONNS_PER_SERVER|Int
    11701183                case INTERNET_OPTION_READ_BUFFER_SIZE:          // @flag INTERNET_OPTION_READ_BUFFER_SIZE|Int
    PyObject *PyInternetSetOption(PyObject *self, PyObject *args)  
    11891202                                }
    11901203                        break;
    11911204                case INTERNET_OPTION_BYPASS_EDITED_ENTRY:       // @flag INTERNET_OPTION_BYPASS_EDITED_ENTRY|Boolean
     1205#if !defined(__MINGW32__)
    11921206                case INTERNET_OPTION_HTTP_DECODING:             // @flag INTERNET_OPTION_HTTP_DECODING|Boolean
     1207#endif
    11931208                case INTERNET_OPTION_IGNORE_OFFLINE:    // @flag INTERNET_OPTION_IGNORE_OFFLINE|Boolean
    11941209                        bufsize=sizeof(BOOL);
    11951210                        buf=malloc(bufsize);
    BOOL PyWinObject_AsINTERNET_CACHE_GROUP_INFO(PyObject *ob, INTERNET_CACHE_GROUP_  
    18351850                        }
    18361851                }
    18371852        if (bsuccess && GroupName)
     1853#if defined(__MINGW32__)
     1854                _tcsncpy(GroupInfo->szGroupName, GroupName, std::min(namelen, (DWORD)GROUPNAME_MAX_LENGTH));
     1855#else
    18381856                _tcsncpy(GroupInfo->szGroupName, GroupName, min(namelen, GROUPNAME_MAX_LENGTH));
     1857#endif
    18391858        Py_DECREF(dummy_tuple);
    18401859        PyWinObject_FreeTCHAR(GroupName);
    18411860        if (OwnerStorage)
  • win32/src/win32net/win32net.h

    diff --git a/win32/src/win32net/win32net.h b/win32/src/win32net/win32net.h
    index ae7c690..c961c18 100644
    a b PyObject *PyDoGroupDelMembers(PyObject *self, PyObject *args);  
    6262
    6363#if WINVER >= 0x0500
    6464typedef NET_API_STATUS (NET_API_FUNCTION *NetValidateNamefunc)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, NETSETUP_NAME_TYPE);
    65 extern NetValidateNamefunc pfnNetValidateName;
     65extern
     66#if defined(__MINGW32__)
     67"C"
     68#endif
     69NetValidateNamefunc pfnNetValidateName;
    6670
    6771typedef NET_API_STATUS (NET_API_FUNCTION *NetGetJoinInformationfunc)(LPCWSTR, LPWSTR *, PNETSETUP_JOIN_STATUS);
    6872extern NetGetJoinInformationfunc pfnNetGetJoinInformation;
    6973
    7074typedef NET_API_STATUS (NET_API_FUNCTION *NetValidatePasswordPolicyfunc)(LPCWSTR, LPVOID, NET_VALIDATE_PASSWORD_TYPE, LPVOID, LPVOID *);
    71 extern NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy;
     75extern
     76#if defined(__MINGW32__)
     77"C"
     78#endif
     79NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy;
    7280
    7381typedef NET_API_STATUS (NET_API_FUNCTION *NetValidatePasswordPolicyFreefunc)(LPVOID *);
    74 extern NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree;
     82extern
     83#if defined(__MINGW32__)
     84"C"
     85#endif
     86NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree;
    7587
    7688#endif // WINVER
  • win32/src/win32pdhmodule.cpp

    diff --git a/win32/src/win32pdhmodule.cpp b/win32/src/win32pdhmodule.cpp
    index 94c4ed1..533dad7 100644
    a b generates Windows .hlp files.  
    1515#include "pdh.h"
    1616#include "pdhmsg.h"
    1717
     18#if defined(__MINGW32__)
     19#include <algorithm>
     20#endif
     21
    1822/*
    1923According to MSDN, Pdh calls are thread safe, although there was a bug
    2024in Win2k that might make it appear to not be.  Plus, the PyW32* macros
    PDH_STATUS __stdcall PyCounterPathCallback(DWORD_PTR dwArg)  
    10131017        return rc;
    10141018}
    10151019
     1020#if defined(__MINGW32__)
     1021#define SET_BOOL(r, i) { \
     1022        if (i<seqLen){ \
     1023                PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \
     1024                myCfg.cfg. r = PyObject_IsTrue(subItem); \
     1025        } \
     1026}
     1027#else
    10161028#define SET_BOOL(r, i) { \
    10171029        if (i<seqLen){ \
    10181030                PyObject *subItem = PyTuple_GET_ITEM(flags_tuple, i); \
    10191031                myCfg.cfg.##r = PyObject_IsTrue(subItem); \
    10201032        } \
    10211033}
     1034#endif
    10221035
    10231036// @pymethod string|win32pdh|BrowseCounters|Displays the counter browsing dialog box so that the user can select the counters to be returned to the caller.
    10241037static PyObject *PyBrowseCounters(PyObject *self, PyObject *args, PyObject *kwargs)
    static PyObject *PyBrowseCounters(PyObject *self, PyObject *args, PyObject *kwar  
    10821095        // Initialize the return buffer if starting path is passed in. (bInitializePath will also be set)
    10831096        if (!PyWinObject_AsTCHAR(obInitialPath, &InitialPath, TRUE, &cchInitialPath))
    10841097                return NULL;    // Last exit without cleanup
     1098#if defined(__MINGW32__)
     1099        myCfg.cfg.cchReturnPathLength = std::max(cchInitialPath+1, 1024UL);
     1100#else
    10851101        myCfg.cfg.cchReturnPathLength = max(cchInitialPath+1, 1024);
     1102#endif
    10861103        myCfg.cfg.szReturnPathBuffer = (TCHAR *)malloc(myCfg.cfg.cchReturnPathLength * sizeof(TCHAR));
    10871104        if (myCfg.cfg.szReturnPathBuffer == NULL){
    10881105                PyErr_NoMemory();
  • win32/src/win32service.i

    diff --git a/win32/src/win32service.i b/win32/src/win32service.i
    index 11a4a23..fab8092 100644
    a b PyObject *PyQueryServiceConfig2(PyObject *self, PyObject *args)  
    18181818#define SERVICE_CONTROL_HARDWAREPROFILECHANGE SERVICE_CONTROL_HARDWAREPROFILECHANGE
    18191819#define SERVICE_CONTROL_POWEREVENT SERVICE_CONTROL_POWEREVENT
    18201820#define SERVICE_CONTROL_SESSIONCHANGE SERVICE_CONTROL_SESSIONCHANGE
    1821 #define SERVICE_CONTROL_PRESHUTDOWN SERVICE_CONTROL_PRESHUTDOWN
    18221821
    18231822
    18241823#define SC_MANAGER_ALL_ACCESS SC_MANAGER_ALL_ACCESS
    PyObject *PyQueryServiceConfig2(PyObject *self, PyObject *args)  
    18751874#define SERVICE_ACCEPT_HARDWAREPROFILECHANGE SERVICE_ACCEPT_HARDWAREPROFILECHANGE
    18761875#define SERVICE_ACCEPT_POWEREVENT SERVICE_ACCEPT_POWEREVENT
    18771876#define SERVICE_ACCEPT_SESSIONCHANGE SERVICE_ACCEPT_SESSIONCHANGE
    1878 #define SERVICE_ACCEPT_PRESHUTDOWN SERVICE_ACCEPT_PRESHUTDOWN
    18791877
    18801878//#define SERVICE_ERROR_IGNORER_IGNORE SERVICE_ERROR_IGNORER_IGNORE
    18811879#define SERVICE_BOOT_START SERVICE_BOOT_START
  • win32/src/win32trace.cpp

    diff --git a/win32/src/win32trace.cpp b/win32/src/win32trace.cpp
    index 2237094..60e7c83 100644
    a b See - I told you the implementation was simple :-)  
    3535
    3636
    3737
     38#if defined(__MINGW32__)
     39#include <algorithm>
     40#endif
    3841
    3942const unsigned long BUFFER_SIZE = 0x20000; // Includes size integer.
    4043const TCHAR *MAP_OBJECT_NAME = _T("Global\\PythonTraceOutputMapping");
    BOOL PyTraceObject::WriteData(const char *data, unsigned len)  
    341344    Py_BEGIN_ALLOW_THREADS
    342345    const char *data_this = data;
    343346    while (len) {
     347#if defined(__MINGW32__)
     348        unsigned len_this = std::min(static_cast<unsigned long>(len), BUFFER_SIZE/2);
     349#else
    344350        unsigned len_this = min(len, BUFFER_SIZE/2);
     351#endif
    345352        BOOL ok = GetMyMutex();
    346353        if (ok) {
    347354            // must use types with identical size on win32 and win64
Note: See TracBrowser for help on using the repository browser.