[pywin32-checkins] pywin32/win32/src PyWinTypes.h, 1.30, 1.31 PyWinTypesmodule.cpp, 1.22, 1.23 win3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2006-12-27 04:41:16
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14936/win32/src Modified Files: PyWinTypes.h PyWinTypesmodule.cpp win32credmodule.cpp Log Message: Move PyWinObject_AsDWORDArray into pywintypes so it can be used in win32gui Index: win32credmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32credmodule.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32credmodule.cpp 26 Dec 2006 03:02:03 -0000 1.3 --- win32credmodule.cpp 27 Dec 2006 04:41:15 -0000 1.4 *************** *** 246,290 **** } - BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk=TRUE) - { - BOOL ret=TRUE; - DWORD bufsize, tuple_index; - PyObject *dwords_tuple=NULL, *tuple_item; - *pdwords=NULL; - *item_cnt=0; - if (obdwords==Py_None){ - if (bNoneOk) - return TRUE; - PyErr_SetString(PyExc_ValueError,"Sequence of dwords cannot be None"); - return FALSE; - } - if ((dwords_tuple=PySequence_Tuple(obdwords))==NULL) - return FALSE; // last exit without cleaning up - *item_cnt=PyTuple_Size(dwords_tuple); - bufsize=*item_cnt * sizeof(DWORD); - *pdwords=(DWORD *)malloc(bufsize); - if (*pdwords==NULL){ - PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); - ret=FALSE; - } - else - for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ - tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); - (*pdwords)[tuple_index]=PyInt_AsLong(tuple_item); - if (((*pdwords)[tuple_index]==-1) && PyErr_Occurred()){ - ret=FALSE; - break; - } - } - if (!ret) - if (*pdwords!=NULL){ - free(*pdwords); - *pdwords=NULL; - *item_cnt=0; - } - Py_XDECREF(dwords_tuple); - return ret; - } - void PyWinObject_FreeCREDENTIAL_TARGET_INFORMATION(PCREDENTIAL_TARGET_INFORMATION targetinfo) { --- 246,249 ---- Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PyWinTypesmodule.cpp 11 Jul 2006 11:30:08 -0000 1.22 --- PyWinTypesmodule.cpp 27 Dec 2006 04:41:14 -0000 1.23 *************** *** 474,477 **** --- 474,519 ---- } + // Alocates and populates an array of DWORDS from a sequence of Python ints + BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk) + { + BOOL ret=TRUE; + DWORD bufsize, tuple_index; + PyObject *dwords_tuple=NULL, *tuple_item; + *pdwords=NULL; + *item_cnt=0; + if (obdwords==Py_None){ + if (bNoneOk) + return TRUE; + PyErr_SetString(PyExc_ValueError,"Sequence of dwords cannot be None"); + return FALSE; + } + if ((dwords_tuple=PySequence_Tuple(obdwords))==NULL) + return FALSE; // last exit without cleaning up + *item_cnt=PyTuple_Size(dwords_tuple); + bufsize=*item_cnt * sizeof(DWORD); + *pdwords=(DWORD *)malloc(bufsize); + if (*pdwords==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + ret=FALSE; + } + else + for (tuple_index=0; tuple_index<*item_cnt; tuple_index++){ + tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); + (*pdwords)[tuple_index]=PyInt_AsLong(tuple_item); + if (((*pdwords)[tuple_index]==-1) && PyErr_Occurred()){ + ret=FALSE; + break; + } + } + if (!ret) + if (*pdwords!=NULL){ + free(*pdwords); + *pdwords=NULL; + *item_cnt=0; + } + Py_XDECREF(dwords_tuple); + return ret; + } + /* List of functions exported by this module */ // @module pywintypes|A module which supports common Windows types. Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PyWinTypes.h 3 Aug 2006 02:46:30 -0000 1.30 --- PyWinTypes.h 27 Dec 2006 04:41:14 -0000 1.31 *************** *** 323,326 **** --- 323,329 ---- PYWINTYPES_EXPORT PyObject *PyWinObject_FromIO_COUNTERS(PIO_COUNTERS pioc); + // Make an array of DWORD's from a sequence of Python ints + PYWINTYPES_EXPORT BOOL PyWinObject_AsDWORDArray(PyObject *obdwords, DWORD **pdwords, DWORD *item_cnt, BOOL bNoneOk=TRUE); + /* ** SECURITY_ATTRIBUTES support *************** *** 359,362 **** --- 362,368 ---- PYWINTYPES_EXPORT PyObject *PyWinObject_FromSECURITY_DESCRIPTOR(PSECURITY_DESCRIPTOR psd); + PYWINTYPES_EXPORT BOOL _MakeAbsoluteSD(PSECURITY_DESCRIPTOR psd_relative, PSECURITY_DESCRIPTOR *ppsd_absolute); + PYWINTYPES_EXPORT void FreeAbsoluteSD(PSECURITY_DESCRIPTOR psd); + /* ** SID support |