pywin32-checkins Mailing List for Python for Windows Extensions (Page 131)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
| 2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
| 2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
| 2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
| 2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
| 2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
| 2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
| 2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
| 2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
| 2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
|
From: Mark H. <mha...@us...> - 2004-07-02 04:06:50
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/axscript/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29090 Modified Files: error.py Log Message: Report the line-number of the exception as being the lowest "script block" frame, rather than the very lowest in an external file. Index: error.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/axscript/client/error.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** error.py 31 May 2002 06:27:32 -0000 1.4 --- error.py 2 Jul 2004 04:06:40 -0000 1.5 *************** *** 133,138 **** if name in hide_names: break ! self.lineno = lineno ! self.linetext = line format_items.append((filename, lineno, name, line)) depth = depth + 1 --- 133,142 ---- if name in hide_names: break ! # We can report a line-number, but not a filename. Therefore, ! # we return the last line-number we find in one of our script ! # blocks. ! if filename.startswith("<Script"): ! self.lineno = lineno ! self.linetext = line format_items.append((filename, lineno, name, line)) depth = depth + 1 |
|
From: Mark H. <mha...@us...> - 2004-07-02 04:05:16
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28861 Modified Files: PyGatewayBase.cpp Log Message: Print an exception for most Python errors in gateway methods. This means that even exceptions that happen outside the user code, such as processing return values, will still be logged. Index: PyGatewayBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyGatewayBase.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyGatewayBase.cpp 5 Oct 2002 02:30:50 -0000 1.12 --- PyGatewayBase.cpp 2 Jul 2004 04:04:54 -0000 1.13 *************** *** 911,915 **** if (result==NULL) PyCom_LogNonServerError("Python error calling method %s\n", szMethodName); ! HRESULT hr = PyCom_SetCOMErrorFromPyException(GetIID()); if ( ppResult ) --- 911,915 ---- if (result==NULL) PyCom_LogNonServerError("Python error calling method %s\n", szMethodName); ! HRESULT hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, GetIID()); if ( ppResult ) |
|
From: Mark H. <mha...@us...> - 2004-07-02 02:38:56
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16226 Modified Files: pywintypes.py Log Message: Revert to using win32api to find the module - this means we do get a modal error dialog when it fails, but at least it works correctly in all cases when it should! Big problem is that on Win9x, the Windows system directory is *not* on the PATH. Index: pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pywintypes.py 4 May 2004 07:33:29 -0000 1.10 --- pywintypes.py 2 Jul 2004 02:38:45 -0000 1.11 *************** *** 46,64 **** "Module '%s' isn't in frozen sys.path %s" % (modname, sys.path) else: ! search_dirs = [sys.prefix] + \ ! os.environ.get("PATH", "").split(os.pathsep) ! for d in search_dirs: ! found = os.path.join(d, filename) ! if os.path.isfile(found): ! break ! else: ! # Eeek - can't find on the path. Try "LoadLibrary", as it ! # has slightly different semantics than a simple sys.path search ! # XXX - OK, we *don't* try LoadLibrary - if we can't find it, ! # there is an excellent change Windows can't find it, and ! # the attempt to bring in win32api *needs* Windows to find it. ! # If Windows can't find it, it displays a dialog trying to ! # import win32api, which is not what we want! ! raise ImportError, "Can not locate " + filename # Python can load the module mod = imp.load_module(modname, None, found, --- 46,74 ---- "Module '%s' isn't in frozen sys.path %s" % (modname, sys.path) else: ! # If there is a version in our Python directory, use that ! # (it may not be on the PATH, so may fail to be loaded by win32api) ! # Non-admin installs will have the system files there. ! found = None ! if os.path.isfile(os.path.join(sys.prefix, filename)): ! found = os.path.join(sys.prefix, filename) ! # Allow Windows to find it. We have tried various other tricks, ! # but in some cases, we ended up with *2* versions of the libraries ! # loaded - the one found by Windows when doing a later "import win32*", ! # and the one we found here. ! # A remaining trick would be to simulate LoadLibrary(), using the ! # registry to determine the system32 directory. However, Python ! # 2.2 doesn't have sys.getwindowsversion(), which is kinda needed ! # to determine the correct places to look. ! ! # The downside of this is that we need to use win32api, and this ! # depends on pywintypesxx.dll, which may be what we are trying to ! # find! If this fails, we get a dialog box, followed by the import ! # error. The dialog box is undesirable, but should only happen ! # when something is badly broken, and is a less harmful side-effect ! # than loading the DLL twice! ! if found is None: ! import win32api # failure here means Windows can't find it either! ! found = win32api.GetModuleFileName(win32api.LoadLibrary(filename)) ! # Python can load the module mod = imp.load_module(modname, None, found, |
|
From: Mark H. <mha...@us...> - 2004-07-02 02:37:07
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16100 Modified Files: win32file.i Log Message: Was missing FILE_ATTRIBUTE_DIRECTORY Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** win32file.i 15 Jun 2004 11:32:14 -0000 1.40 --- win32file.i 2 Jul 2004 02:36:58 -0000 1.41 *************** *** 60,63 **** --- 60,65 ---- #define FILE_ATTRIBUTE_ARCHIVE FILE_ATTRIBUTE_ARCHIVE // The file should be archived. Applications use this attribute to mark files for backup or removal. + #define FILE_ATTRIBUTE_DIRECTORY FILE_ATTRIBUTE_DIRECTORY + // The file is a directory #define FILE_ATTRIBUTE_COMPRESSED FILE_ATTRIBUTE_COMPRESSED // The file or directory is compressed. For a file, this means that all of the data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories. *************** *** 491,494 **** --- 493,497 ---- 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ + #if (PY_VERSION_HEX >= 0x02030000) // Iterators only in 2.3+ PyObject_SelfIter, /* tp_iter */ (iternextfunc)ffi_iternext, /* tp_iternext */ *************** *** 500,503 **** --- 503,507 ---- 0, /* tp_descr_get */ 0, /* tp_descr_set */ + #endif // PY_VERSION }; |
|
From: Mark H. <mha...@us...> - 2004-07-02 02:36:36
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16070 Modified Files: win32gui.i Log Message: Add listview sorting. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** win32gui.i 12 Jun 2004 08:55:50 -0000 1.43 --- win32gui.i 2 Jul 2004 02:36:28 -0000 1.44 *************** *** 1100,1103 **** --- 1100,1113 ---- %native (CallWindowProc) PyCallWindowProc; + %typemap(python,in) WPARAM { + if (!make_param($source, (long *)&$target)) + return NULL; + } + + %typemap(python,in) LPARAM { + if (!make_param($source, (long *)&$target)) + return NULL; + } + %{ static BOOL make_param(PyObject *ob, long *pl) *************** *** 2748,2751 **** --- 2758,2762 ---- // Sorting for controls %{ + #if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+ // Callbacks *************** *** 2852,2855 **** --- 2863,2880 ---- return Py_None; } + #else // PYVERSION + static PyObject *PyListView_SortItemsEx(PyObject *self, PyObject *args) + { + PyErr_SetString(PyExc_NotImplementedError, + "This requires Python 2.3 or greater"); + return NULL; + } + static PyObject *PyListView_SortItems(PyObject *self, PyObject *args) + { + PyErr_SetString(PyExc_NotImplementedError, + "This requires Python 2.3 or greater"); + return NULL; + } + #endif // PYVERSION 2.3+ %} |
|
From: Roger U. <ru...@us...> - 2004-06-30 01:51:30
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8766/win32/src Modified Files: win32process.i Log Message: PySTARTUPINFO.lpTitle was throwing a bogus error when set Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32process.i 13 May 2004 14:15:28 -0000 1.14 --- win32process.i 30 Jun 2004 01:51:21 -0000 1.15 *************** *** 218,221 **** --- 218,222 ---- pO->m_obTitle = v; Py_INCREF(v); + return 0; } else return -1; |
|
From: Roger U. <ru...@us...> - 2004-06-29 05:23:34
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25608/win32/src Modified Files: win32security.i Log Message: Return empty tuple when LsaEnumerateAccountsWithUserRight finds no results Add more access token related functions Load EnumerateSecurityPackages from security.dll on NT Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32security.i 8 Jun 2004 04:05:31 -0000 1.17 --- win32security.i 29 Jun 2004 05:23:21 -0000 1.18 *************** *** 25,28 **** --- 25,29 ---- %} + typedef long SECURITY_IMPERSONATION_LEVEL; %apply LARGE_INTEGER {LUID}; typedef LARGE_INTEGER LUID; *************** *** 104,108 **** // @comm This is a sequence (eg, list) of ((id, attributes),...) where id is a // privilege LUID as returned by <om win32security.LookupPrivilegeValue> and ! // attributes is a combination if SE_PRIVILEGE_ENABLED, SE_PRIVILEGE_ENABLED_BY_DEFAULT, // and SE_PRIVILEGE_USED_FOR_ACCESS %{ --- 105,109 ---- // @comm This is a sequence (eg, list) of ((id, attributes),...) where id is a // privilege LUID as returned by <om win32security.LookupPrivilegeValue> and ! // attributes is a combination of SE_PRIVILEGE_ENABLED, SE_PRIVILEGE_ENABLED_BY_DEFAULT, // and SE_PRIVILEGE_USED_FOR_ACCESS %{ *************** *** 124,142 **** } PyObject *PyWinObject_FromTOKEN_GROUPS(TOKEN_GROUPS *tg) { unsigned int groupInd; - PyObject *groups = PyTuple_New(tg->GroupCount); PyObject *group = NULL; PyObject *groupSID = NULL; for (groupInd = 0; groupInd < tg->GroupCount; groupInd++){ groupSID = PyWinObject_FromSID(tg->Groups[groupInd].Sid); group = Py_BuildValue("(Ol)", groupSID, tg->Groups[groupInd].Attributes ); - PyTuple_SET_ITEM(groups, groupInd, group); Py_DECREF(groupSID); } return groups; } BOOL PyWinObject_AsLSA_UNICODE_STRING(PyObject *obstr, LSA_UNICODE_STRING *plsaus, BOOL bNoneOk) { --- 125,274 ---- } + // @object PyTOKEN_GROUPS|A sequence of <o PySID_AND_ATTRIBUTES> sequences, eg [(<o PySID>,int),...] representing a TOKEN_GROUPS structure PyObject *PyWinObject_FromTOKEN_GROUPS(TOKEN_GROUPS *tg) { unsigned int groupInd; PyObject *group = NULL; PyObject *groupSID = NULL; + PyObject *groups = PyTuple_New(tg->GroupCount); + if (groups==NULL) + return NULL; for (groupInd = 0; groupInd < tg->GroupCount; groupInd++){ groupSID = PyWinObject_FromSID(tg->Groups[groupInd].Sid); group = Py_BuildValue("(Ol)", groupSID, tg->Groups[groupInd].Attributes ); Py_DECREF(groupSID); + if (group==NULL){ + Py_DECREF(groups); + groups=NULL; + break; + } + PyTuple_SET_ITEM(groups, groupInd, group); } return groups; } + // @object PySID_AND_ATTRIBUTES|A sequence containing (<o PySID>,Attributes) Representing a SID_AND_ATTRIBUTES structure + // @comm Attributes is an integer containing flags that depend on intended usage + BOOL PyWinObject_AsSID_AND_ATTRIBUTES(PyObject *obsid_attr, PSID_AND_ATTRIBUTES sid_attr) + { + static char *fmt_msg="SID_AND_ATTRIBUTES must be a tuple of (PySID,int)"; + PyObject *obsid, *obsid_attr_tuple; + BOOL bsuccess=TRUE; + obsid_attr_tuple=PySequence_Tuple(obsid_attr); + if (obsid_attr_tuple==NULL){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,fmt_msg); + bsuccess=FALSE; + } + else if (!PyArg_ParseTuple(obsid_attr_tuple,"Ol",&obsid,&sid_attr->Attributes)){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,fmt_msg); + bsuccess=FALSE; + } + else + bsuccess=PyWinObject_AsSID(obsid,&sid_attr->Sid); + Py_XDECREF(obsid_attr_tuple); + return bsuccess; + } + + BOOL PyWinObject_AsSID_AND_ATTRIBUTESArray(PyObject *obsids, PSID_AND_ATTRIBUTES *psid_attr_array, DWORD *sid_cnt) + { + PyObject *obsid_attr; + *psid_attr_array=NULL; + *sid_cnt=0; + static char *fmt_msg="Object must be a sequence of PySID_AND_ATTRIBUTES tuples, or None"; + + if (obsids==Py_None) + return TRUE; + *sid_cnt=PySequence_Length(obsids); + if (*sid_cnt==-1){ + PyErr_SetString(PyExc_TypeError,fmt_msg); + return FALSE; + } + *psid_attr_array=(SID_AND_ATTRIBUTES *)malloc((*sid_cnt)*sizeof(SID_AND_ATTRIBUTES)); + if (*psid_attr_array==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate array of %d SID_AND_ATTRIBUTES structures",sid_cnt); + return FALSE; + } + BOOL bsuccess=TRUE; + for (DWORD sid_ind=0;sid_ind<*sid_cnt;sid_ind++){ + obsid_attr=PySequence_GetItem(obsids,sid_ind); + if (obsid_attr==NULL) + bsuccess=FALSE; + else + bsuccess=PyWinObject_AsSID_AND_ATTRIBUTES(obsid_attr,&(*psid_attr_array)[sid_ind]); + Py_XDECREF(obsid_attr); + if (!bsuccess) + break; + } + if (!bsuccess){ + free(*psid_attr_array); + *psid_attr_array=NULL; + } + return bsuccess; + } + + // @object PyLUID_AND_ATTRIBUTES|A sequence containing (LUID,Attributes) representing an LUID_AND_ATTRIBUTES structure + // @comm LUID is a large integer, and attributes is an integer containing flags + BOOL PyWinObject_AsLUID_AND_ATTRIBUTES(PyObject *obluid_attr, PLUID_AND_ATTRIBUTES luid_attr) + { + static char *fmt_msg="LUID_AND_ATTRIBUTES must be a sequence of (LARGE_INTEGER,int)"; + PyObject *obluid, *obluid_attr_tuple; + BOOL bsuccess=TRUE; + obluid_attr_tuple=PySequence_Tuple(obluid_attr); + if (obluid_attr_tuple==NULL){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,fmt_msg); + bsuccess=FALSE; + } + else if (!PyArg_ParseTuple(obluid_attr_tuple,"Ol",&obluid,&luid_attr->Attributes)){ + PyErr_Clear(); + PyErr_SetString(PyExc_TypeError,fmt_msg); + bsuccess=FALSE; + } + else + bsuccess=PyWinObject_AsLARGE_INTEGER(obluid, (LARGE_INTEGER *)&luid_attr->Luid); + Py_XDECREF(obluid_attr_tuple); + return bsuccess; + } + + BOOL PyWinObject_AsLUID_AND_ATTRIBUTESArray(PyObject *obluids, PLUID_AND_ATTRIBUTES *pluid_attr_array, DWORD *luid_cnt) + { + PyObject *obluid_attr; + *pluid_attr_array=NULL; + *luid_cnt=0; + static char *fmt_msg="Object must be a sequence of PyLUID_AND_ATTRIBUTES tuples, or None"; + + if (obluids==Py_None) + return TRUE; + *luid_cnt=PySequence_Length(obluids); + if (*luid_cnt==-1){ + PyErr_SetString(PyExc_TypeError,fmt_msg); + return FALSE; + } + *pluid_attr_array=(LUID_AND_ATTRIBUTES *)malloc((*luid_cnt)*sizeof(LUID_AND_ATTRIBUTES)); + if (*pluid_attr_array==NULL){ + PyErr_Format(PyExc_MemoryError,"Unable to allocate array of %d LUID_AND_ATTRIBUTES structures",luid_cnt); + return FALSE; + } + BOOL bsuccess=TRUE; + for (DWORD luid_ind=0;luid_ind<*luid_cnt;luid_ind++){ + obluid_attr=PySequence_GetItem(obluids,luid_ind); + if (obluid_attr==NULL) + bsuccess=FALSE; + else{ + bsuccess=PyWinObject_AsLUID_AND_ATTRIBUTES(obluid_attr,&(*pluid_attr_array)[luid_ind]); + Py_DECREF(obluid_attr); + } + if (!bsuccess) + break; + } + if (!bsuccess){ + free(*pluid_attr_array); + *pluid_attr_array=NULL; + } + return bsuccess; + } + BOOL PyWinObject_AsLSA_UNICODE_STRING(PyObject *obstr, LSA_UNICODE_STRING *plsaus, BOOL bNoneOk) { *************** *** 164,251 **** BOOL PyWinObject_AsTOKEN_GROUPS(PyObject *groups, TOKEN_GROUPS **ptg) { ! BOOL ok = FALSE; ! char *errMsg = "TOKEN_GROUPS must be a sequence of (PySID,int)"; ! if (!PySequence_Check(groups)) { PyErr_SetString(PyExc_TypeError, errMsg); ! return NULL; ! } ! int groupind = 0; ! int groupcnt = PySequence_Length(groups); TOKEN_GROUPS *tg = (TOKEN_GROUPS *)malloc(sizeof(DWORD) + (sizeof(SID_AND_ATTRIBUTES) * groupcnt)); ! tg->GroupCount = groupcnt; - PyObject *group = NULL; - PyObject *sid = NULL; - PSID psid; for (groupind=0; groupind<groupcnt; groupind++){ group = PySequence_GetItem(groups, groupind); ! if (!PySequence_Check(group)){ ! PyErr_SetString(PyExc_TypeError, errMsg); ! goto done; ! } ! if (!PyArg_ParseTuple(group, "Ol", &sid, &tg->Groups[groupind].Attributes)){ ! PyErr_SetString(PyExc_TypeError, errMsg); ! goto done; ! } ! if (!PySID_Check(sid)){ ! PyErr_SetString(PyExc_TypeError, errMsg); ! goto done; ! } ! psid = ((PySID *)sid)->GetSID(); ! if (!IsValidSid(psid)){ ! PyErr_SetString(PyExc_TypeError,"Invalid Sid"); ! goto done; } ! tg->Groups[groupind].Sid = psid; } ! ok = TRUE; ! done: ! if (ok) ! *ptg = tg; ! else ! free(tg); ! return ok; } BOOL PyWinObject_AsTOKEN_PRIVILEGES(PyObject *ob, TOKEN_PRIVILEGES **ppRest, BOOL bNoneOK /*= TRUE*/) { ! BOOL ok = FALSE; ! char *errMsg = "A TOKEN_PRIVILEGES object must be a tuple of (LARGE_INTEGER, int)"; PyObject *subObj = NULL; - if (!PySequence_Check(ob)) { - PyErr_SetString(PyExc_TypeError, errMsg); - return NULL; - } int num = PySequence_Length(ob); // space for the array and the priv. count. TOKEN_PRIVILEGES *pRet = (TOKEN_PRIVILEGES *)malloc((sizeof(LUID_AND_ATTRIBUTES) * num) + sizeof(DWORD)); ! if (pRet==NULL) { ! PyErr_SetString(PyExc_MemoryError, "allocating TOKEN_PRIVILEGES"); ! return NULL; ! } pRet->PrivilegeCount = num; for (int i =0;i<num;i++) { subObj = PySequence_GetItem(ob, i); if (subObj==NULL) ! goto done; ! if (!PySequence_Check(subObj)) { ! PyErr_SetString(PyExc_TypeError, errMsg); ! goto done; } - PyObject *obLUID; - if (!PyArg_ParseTuple(subObj, "Ol", &obLUID, &pRet->Privileges[i].Attributes)) - goto done; - if (!PyWinObject_AsLARGE_INTEGER(obLUID, (LARGE_INTEGER *)&pRet->Privileges[i].Luid)) - goto done; - Py_DECREF(subObj); - subObj = NULL; - } - ok = TRUE; - done: - Py_XDECREF(subObj); if (ok) *ppRest = pRet; ! else free(pRet); return ok; } --- 296,375 ---- BOOL PyWinObject_AsTOKEN_GROUPS(PyObject *groups, TOKEN_GROUPS **ptg) { ! BOOL ok = TRUE; ! PyObject *group; ! int groupind, groupcnt; ! static char *errMsg = "TOKEN_GROUPS must be a sequence of ((PySID,int),...)"; ! ! groupcnt = PySequence_Length(groups); ! if (groupcnt==-1){ PyErr_SetString(PyExc_TypeError, errMsg); ! return FALSE; ! } TOKEN_GROUPS *tg = (TOKEN_GROUPS *)malloc(sizeof(DWORD) + (sizeof(SID_AND_ATTRIBUTES) * groupcnt)); ! if (tg==NULL){ ! PyErr_Format(PyExc_MemoryError, "Unable to allocate TOKEN_GROUPS (%d Groups)", groupcnt); ! return FALSE; ! } tg->GroupCount = groupcnt; for (groupind=0; groupind<groupcnt; groupind++){ group = PySequence_GetItem(groups, groupind); ! if (group==NULL) ! ok=FALSE; ! else{ ! ok=PyWinObject_AsSID_AND_ATTRIBUTES(group,&tg->Groups[groupind]); ! Py_DECREF(group); } ! if (!ok) ! break; } ! if (!ok){ ! free(tg); ! *ptg=NULL; ! } ! else ! *ptg = tg; ! return ok; ! } ! ! void PyWinObject_FreeTOKEN_GROUPS(TOKEN_GROUPS *ptg) ! { ! if (ptg!=NULL) ! free(ptg); } BOOL PyWinObject_AsTOKEN_PRIVILEGES(PyObject *ob, TOKEN_PRIVILEGES **ppRest, BOOL bNoneOK /*= TRUE*/) { ! BOOL ok = TRUE; ! static char *errMsg = "A TOKEN_PRIVILEGES object must be a tuple of (LARGE_INTEGER, int)"; PyObject *subObj = NULL; int num = PySequence_Length(ob); + if (num==-1){ + PyErr_SetString(PyExc_TypeError, errMsg); + return FALSE; + } // space for the array and the priv. count. TOKEN_PRIVILEGES *pRet = (TOKEN_PRIVILEGES *)malloc((sizeof(LUID_AND_ATTRIBUTES) * num) + sizeof(DWORD)); ! if (pRet==NULL){ ! PyErr_Format(PyExc_MemoryError, "Unable to allocate TOKEN_PRIVILEGES with %d LUID_AND_ATTRIBUTES", num); ! return FALSE; ! } pRet->PrivilegeCount = num; for (int i =0;i<num;i++) { subObj = PySequence_GetItem(ob, i); if (subObj==NULL) ! ok=FALSE; ! else{ ! ok=PyWinObject_AsLUID_AND_ATTRIBUTES(subObj,&pRet->Privileges[i]); ! Py_DECREF(subObj); ! } ! if (!ok) ! break; } if (ok) *ppRest = pRet; ! else{ free(pRet); + *ppRest=NULL; + } return ok; } *************** *** 256,259 **** --- 380,384 ---- } + static BOOL (WINAPI *cstss)(PSID, WCHAR **) = NULL; static BOOL (WINAPI *cssts)(LPCWSTR, PSID) = NULL; *************** *** 263,267 **** static long (WINAPI *lsaupcn)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE) = NULL; static BOOL (WINAPI *cryptenumproviders)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *) = NULL; ! BOOL CheckIfSupported(char *funcname, WCHAR *dllname, FARPROC *fp) --- 388,396 ---- static long (WINAPI *lsaupcn)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE) = NULL; static BOOL (WINAPI *cryptenumproviders)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *) = NULL; ! static BOOL (WINAPI *checktokenmembership)(HANDLE, PSID, PBOOL) = NULL; ! static BOOL (WINAPI *createrestrictedtoken)(HANDLE,DWORD,DWORD,PSID_AND_ATTRIBUTES, ! DWORD,PLUID_AND_ATTRIBUTES,DWORD,PSID_AND_ATTRIBUTES,PHANDLE) = NULL; ! static SECURITY_STATUS (WINAPI *enumeratesecuritypackages)(PULONG, PSecPkgInfoW*) = NULL; ! static SECURITY_STATUS (WINAPI *freecontextbuffer)(PVOID) = NULL; BOOL CheckIfSupported(char *funcname, WCHAR *dllname, FARPROC *fp) *************** *** 269,274 **** *fp=NULL; HMODULE hmodule = GetModuleHandle(dllname); ! if (hmodule==NULL) ! return false; *fp = GetProcAddress(hmodule, funcname); if (*fp==NULL) --- 398,406 ---- *fp=NULL; HMODULE hmodule = GetModuleHandle(dllname); ! if (hmodule==NULL){ ! hmodule = LoadLibrary(dllname); ! if (hmodule==NULL) ! return false; ! } *fp = GetProcAddress(hmodule, funcname); if (*fp==NULL) *************** *** 363,366 **** --- 495,503 ---- if (CheckIfSupported("ConvertStringSidToSidW",_T("Advapi32.dll"),&fp)) cssts= (BOOL (WINAPI *)(LPCWSTR, PSID))(fp); + if (CheckIfSupported("CheckTokenMembership", _T("Advapi32.dll"),&fp)) + checktokenmembership=(BOOL (WINAPI *)(HANDLE, PSID, PBOOL))(fp); + if (CheckIfSupported("CreateRestrictedToken", _T("Advapi32.dll"),&fp)) + createrestrictedtoken=(BOOL (WINAPI *)(HANDLE,DWORD,DWORD,PSID_AND_ATTRIBUTES, + DWORD,PLUID_AND_ATTRIBUTES,DWORD,PSID_AND_ATTRIBUTES,PHANDLE))(fp); if (CheckIfSupported("ConvertSecurityDescriptorToStringSecurityDescriptorW",_T("Advapi32.dll"),&fp)) csdtssd=(BOOL (WINAPI *)(PSECURITY_DESCRIPTOR,DWORD,SECURITY_INFORMATION, LPTSTR*,PULONG))(fp); *************** *** 373,379 **** if (CheckIfSupported("CryptEnumProvidersW", _T("Advapi32.dll"),&fp)) cryptenumproviders=(BOOL (WINAPI *)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *))(fp); %} - // @pyswig PyACL|ACL|Creates a new <o PyACL> object. // @pyparm int|bufSize|64|The size of the buffer for the ACL. --- 510,525 ---- if (CheckIfSupported("CryptEnumProvidersW", _T("Advapi32.dll"),&fp)) cryptenumproviders=(BOOL (WINAPI *)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *))(fp); + if (CheckIfSupported("EnumerateSecurityPackagesW",_T("Secur32.dll"),&fp)) + enumeratesecuritypackages=(SECURITY_STATUS (WINAPI *)(PULONG, PSecPkgInfoW*))(fp); + else + if (CheckIfSupported("EnumerateSecurityPackagesW",_T("security.dll"),&fp)) + enumeratesecuritypackages=(SECURITY_STATUS (WINAPI *)(PULONG, PSecPkgInfoW*))(fp); + if (CheckIfSupported("FreeContextBuffer",_T("Secur32.dll"),&fp)) + freecontextbuffer=(SECURITY_STATUS (WINAPI *)(PVOID))(fp); + else + if (CheckIfSupported("FreeContextBuffer",_T("security.dll"),&fp)) + freecontextbuffer=(SECURITY_STATUS (WINAPI *)(PVOID))(fp); %} // @pyswig PyACL|ACL|Creates a new <o PyACL> object. // @pyparm int|bufSize|64|The size of the buffer for the ACL. *************** *** 409,413 **** ); - // @pyswig <o PySID>, string, int|LookupAccountName|Accepts the name of a system and an account as input. It retrieves a security identifier (SID) for the account and the name of the domain on which the account was found. // @rdesc The result is a tuple of new SID object, the domain name where the account was found, and the type of account the SID is for. --- 555,558 ---- *************** *** 1031,1045 **** static PyObject *PyAdjustTokenGroups(PyObject *self, PyObject *args) { ! PyObject *obHandle=NULL; ! PyObject *obtg = NULL; PyObject *ret = NULL; HANDLE th; ! TOKEN_GROUPS *newstate; ! BOOL reset = 0; if (!PyArg_ParseTuple(args, "OiO", &obHandle, // @pyparm <o PyHANDLE>|obHandle||The handle to access token to be modified ! &reset, // @pyparm int|ResetToDefault||Sets groups to default enabled/disabled states, ! &obtg)) // @pyparm PyTOKEN_GROUPS|NewState||Groups and attributes to be set for token return NULL; if (!PyWinObject_AsHANDLE(obHandle, &th, FALSE)) --- 1176,1190 ---- static PyObject *PyAdjustTokenGroups(PyObject *self, PyObject *args) { ! PyObject *obHandle, *obtg; PyObject *ret = NULL; HANDLE th; ! TOKEN_GROUPS *newstate=NULL, *oldstate=NULL; ! BOOL ok = TRUE, reset; ! DWORD reqdbufsize=0, origgroupcnt=1, origbufsize, err; if (!PyArg_ParseTuple(args, "OiO", &obHandle, // @pyparm <o PyHANDLE>|obHandle||The handle to access token to be modified ! &reset, // @pyparm boolean|ResetToDefault||Sets groups to default enabled/disabled states, ! &obtg)) // @pyparm <o PyTOKEN_GROUPS>|NewState||Groups and attributes to be set for token return NULL; if (!PyWinObject_AsHANDLE(obHandle, &th, FALSE)) *************** *** 1047,1079 **** if (!PyWinObject_AsTOKEN_GROUPS(obtg, &newstate)) return NULL; ! ! DWORD bufsize = 0, origbufsize = 10; //pick a number out of a hat ! TOKEN_GROUPS *oldstate = (TOKEN_GROUPS *)malloc(origbufsize); ! if (oldstate==NULL) { ! PyErr_SetString(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate memory"); ! return NULL; } ! ! if (!AdjustTokenGroups(th, reset, newstate, origbufsize, oldstate, &bufsize)){ ! if (bufsize <= origbufsize){ ! PyWin_SetAPIError("AdjustTokenGroups"); ! goto done; ! } ! free (oldstate); ! oldstate = (TOKEN_GROUPS *)malloc(bufsize); ! if (oldstate==NULL) { ! PyErr_SetString(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate memory"); ! return NULL; ! } ! if (!AdjustTokenGroups(th, reset, newstate, bufsize, oldstate, &bufsize)){ ! PyWin_SetAPIError("AdjustTokenGroups"); ! goto done; } } ! ret = PyWinObject_FromTOKEN_GROUPS(oldstate); ! done: ! if (oldstate != NULL) ! free(oldstate); ! return ret; } %} --- 1192,1231 ---- if (!PyWinObject_AsTOKEN_GROUPS(obtg, &newstate)) return NULL; ! origbufsize=sizeof(DWORD) + (sizeof(SID_AND_ATTRIBUTES) * origgroupcnt); ! oldstate=(TOKEN_GROUPS *)malloc(origbufsize); ! if (oldstate==NULL){ ! PyErr_Format(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate %d SID_AND_ATTRIBUTES structs", origgroupcnt); ! ok=FALSE; } ! else{ ! oldstate->GroupCount=origgroupcnt; ! if (!AdjustTokenGroups(th, reset, newstate, origbufsize, oldstate, &reqdbufsize)){ ! err=GetLastError(); ! if (err!=ERROR_INSUFFICIENT_BUFFER){ ! PyWin_SetAPIError("AdjustTokenGroups",err); ! ok=FALSE; ! } ! else{ ! free (oldstate); ! oldstate = (TOKEN_GROUPS *)malloc(reqdbufsize); ! if (oldstate==NULL){ ! PyErr_Format(PyExc_MemoryError, "AdjustTokenGroups: unable to allocate %d bytes", reqdbufsize); ! ok=FALSE; ! } ! else{ ! if (!AdjustTokenGroups(th, reset, newstate, reqdbufsize, oldstate, &reqdbufsize)){ ! PyWin_SetAPIError("AdjustTokenGroups",GetLastError()); ! ok=FALSE; ! } ! } ! } } } ! if (ok) ! ret = PyWinObject_FromTOKEN_GROUPS(oldstate); ! if (oldstate != NULL) ! free(oldstate); ! PyWinObject_FreeTOKEN_GROUPS(newstate); ! return ret; } %} *************** *** 1937,1942 **** HANDLE hpolicy; LSA_ENUMERATION_INFORMATION *buf; ! void *buf_start; NTSTATUS err; // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm str/unicode|UserRight||Name of privilege (SE_*_NAME unicode constant) --- 2089,2095 ---- HANDLE hpolicy; LSA_ENUMERATION_INFORMATION *buf; ! void *buf_start=NULL; NTSTATUS err; + DWORD win32err; // @pyparm <o PyHANDLE>|PolicyHandle||An LSA policy handle as returned by <om win32security.LsaOpenPolicy> // @pyparm str/unicode|UserRight||Name of privilege (SE_*_NAME unicode constant) *************** *** 1948,1964 **** return NULL; err=LsaEnumerateAccountsWithUserRight(hpolicy,&lsau,&buf_start,&sid_cnt); ! if (err != STATUS_SUCCESS){ ! PyWin_SetAPIError("LsaEnumerateAccountsWithUserRight",LsaNtStatusToWinError(err)); ! goto done; } ! ! sids=PyTuple_New(sid_cnt); ! buf=(LSA_ENUMERATION_INFORMATION *)buf_start; ! for (sid_ind=0; sid_ind<sid_cnt; sid_ind++){ ! sid=PyWinObject_FromSID(buf->Sid); ! PyTuple_SetItem(sids, sid_ind, sid); ! buf++; } - done: if (buf_start) LsaFreeMemory(buf_start); --- 2101,2123 ---- return NULL; err=LsaEnumerateAccountsWithUserRight(hpolicy,&lsau,&buf_start,&sid_cnt); ! if (err == STATUS_SUCCESS){ ! sids=PyTuple_New(sid_cnt); ! if (sids!=NULL){ ! buf=(LSA_ENUMERATION_INFORMATION *)buf_start; ! for (sid_ind=0; sid_ind<sid_cnt; sid_ind++){ ! sid=PyWinObject_FromSID(buf->Sid); ! PyTuple_SetItem(sids, sid_ind, sid); ! buf++; ! } ! } } ! else{ ! win32err=LsaNtStatusToWinError(err); ! // real error code is STATUS_NO_MORE_ENTRIES, which is only defined in ntstatus.h that only comes with Driver Development Kit ! if (win32err==ERROR_NO_MORE_ITEMS) ! sids=PyTuple_New(0); ! else ! PyWin_SetAPIError("LsaEnumerateAccountsWithUserRight",win32err); } if (buf_start) LsaFreeMemory(buf_start); *************** *** 2282,2285 **** --- 2441,2446 ---- static PyObject *PyEnumerateSecurityPackages(PyObject *self, PyObject *args) { + if (enumeratesecuritypackages==NULL || freecontextbuffer==NULL) + return PyErr_Format(PyExc_NotImplementedError,"EnumerateSecurityPackages not supported by this version of Windows"); if (!PyArg_ParseTuple(args, ":EnumerateSecurityPackages")) return NULL; *************** *** 2288,2292 **** SECURITY_STATUS result; ULONG pkg_cnt, pkg_ind; ! result = EnumerateSecurityPackagesW(&pkg_cnt, &pbuf); if (result!=SEC_E_OK) goto done; --- 2449,2453 ---- SECURITY_STATUS result; ULONG pkg_cnt, pkg_ind; ! result = (*enumeratesecuritypackages)(&pkg_cnt, &pbuf); if (result!=SEC_E_OK) goto done; *************** *** 2313,2322 **** done: if (pbuf!=NULL) ! FreeContextBuffer(pbuf); return ret; } %} #define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token. --- 2474,2569 ---- done: if (pbuf!=NULL) ! (*freecontextbuffer)(pbuf); return ret; } %} + // @pyswig |AllocateLocallyUniqueId|Creates a new LUID + BOOLAPI AllocateLocallyUniqueId( + LUID *OUTPUT + ); + // @pyswig |ImpersonateSelf|Assigns an impersonation token for current security context to current process + // @pyparm int|ImpersonationLevel||A value from SECURITY_IMPERSONATION_LEVEL enum + BOOLAPI ImpersonateSelf( + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel + ); + + // @pyswig |DuplicateToken|Creates a copy of an access token with specified impersonation level + // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken>) + // @pyparm int|ImpersonationLevel||A value from SECURITY_IMPERSONATION_LEVEL enum + BOOLAPI DuplicateToken( + HANDLE ExistingTokenHandle, + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, + HANDLE *OUTPUT + ); + + // @pyswig bool|CheckTokenMembership|Checks if a SID is enabled in a token + %native(CheckTokenMembership) PyCheckTokenMembership; + %{ + static PyObject *PyCheckTokenMembership(PyObject *self, PyObject *args) + { + PyObject *ret=NULL; + HANDLE htoken; + PSID sid; + BOOL enabled; + PyObject *obsid=NULL, *obtoken=NULL; + if (checktokenmembership==NULL) + return PyErr_Format(PyExc_NotImplementedError,"CheckTokenMembership not supported by this version of Windows"); + // @pyparm <o PyHANDLE>|TokenHandle||Handle to an access token, current process token used if None + // @pyparm <o PySID>|SidToCheck||Sid to be checked for presence in token + if (!PyArg_ParseTuple(args, "OO:CheckTokenMembership",&obtoken, &obsid)) + return NULL; + if (!PyWinObject_AsHANDLE(obtoken, &htoken, TRUE)) + return NULL; + if (!PyWinObject_AsSID(obsid, &sid, FALSE)) + return NULL; + if (!(*checktokenmembership)(htoken,sid,&enabled)) + PyWin_SetAPIError("CheckTokenMembership",GetLastError()); + else + ret=PyBool_FromLong(enabled); + return ret; + } + %} + + // @pyswig <o PyHANDLE>|CreateRestrictedToken|Creates a restricted copy of an access token with reduced privs - requires win2K or higher + %native(CreateRestrictedToken) PyCreateRestrictedToken; + %{ + static PyObject *PyCreateRestrictedToken(PyObject *self, PyObject *args) + { + PyObject *obExistingTokenHandle, *ret=NULL; + PyObject *obSidsToDisable, *obSidsToRestrict, *obPrivilegesToDelete; + HANDLE ExistingTokenHandle, NewTokenHandle; + DWORD Flags,DisableSidCount=0,DeletePrivilegeCount=0,RestrictedSidCount=0; + PSID_AND_ATTRIBUTES SidsToDisable=NULL,SidsToRestrict=NULL; + PLUID_AND_ATTRIBUTES PrivilegesToDelete=NULL; + BOOL bsuccess=TRUE; + if (createrestrictedtoken==NULL) + return PyErr_Format(PyExc_NotImplementedError,"CreateRestrictedToken not supported by this version of Windows"); + if (!PyArg_ParseTuple(args,"OlOOO", + &obExistingTokenHandle, // @pyparm <o PyHANDLE>|ExistingTokenHandle||Handle to an access token (see <om win32security.LogonUser>,<om win32security.OpenProcessToken> + &Flags, // @pyparm int|Flags||Valid values are zero or a combination of DISABLE_MAX_PRIVILEGE and SANDBOX_INERT + &obSidsToDisable, // @pyparm (<o PySID_AND_ATTRIBUTES>,...)|SidsToDisable||Can be None, otherwise must be a sequence of <o PySID_AND_ATTRIBUTES> tuples (attributes must be 0) + &obPrivilegesToDelete, // @pyparm (<o PyLUID_AND_ATTRIBUTES>,...)|PrivilegesToDelete||Privilege LUIDS to remove from token (attributes are ignored), or None + &obSidsToRestrict)) // @pyparm (<o PySID_AND_ATTRIBUTES>,...)|SidsToRestrict||Can be None, otherwise must be a sequence of <o PySID_AND_ATTRIBUTES> tuples (attributes must be 0) + return NULL; + if (PyWinObject_AsHANDLE(obExistingTokenHandle, &ExistingTokenHandle, FALSE)) + if (PyWinObject_AsSID_AND_ATTRIBUTESArray(obSidsToDisable, &SidsToDisable, &DisableSidCount)) + if (PyWinObject_AsSID_AND_ATTRIBUTESArray(obSidsToRestrict, &SidsToRestrict, &RestrictedSidCount)) + if (PyWinObject_AsLUID_AND_ATTRIBUTESArray(obPrivilegesToDelete, &PrivilegesToDelete, &DeletePrivilegeCount)) + if ((*createrestrictedtoken)(ExistingTokenHandle,Flags,DisableSidCount,SidsToDisable, + DeletePrivilegeCount,PrivilegesToDelete,RestrictedSidCount,SidsToRestrict,&NewTokenHandle)) + ret=PyWinObject_FromHANDLE(NewTokenHandle); + else + PyWin_SetAPIError("CreateRestrictedToken",GetLastError()); + if (SidsToDisable!=NULL) + free(SidsToDisable); + if (PrivilegesToDelete!=NULL) + free(PrivilegesToDelete); + if (SidsToRestrict!=NULL) + free(SidsToRestrict); + return ret; + } + %} #define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token. *************** *** 2613,2614 **** --- 2860,2863 ---- #define SECPKG_CRED_OUTBOUND SECPKG_CRED_OUTBOUND #define SECPKG_CRED_BOTH SECPKG_CRED_BOTH + #define DISABLE_MAX_PRIVILEGE DISABLE_MAX_PRIVILEGE + #define SANDBOX_INERT SANDBOX_INERT |
|
From: Mark H. <mha...@us...> - 2004-06-28 03:38:18
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6797 Modified Files: PyLARGE_INTEGER.cpp Log Message: Fix stupid error I made in my last fix, and yet another problem converting 'two ints' to a 64 bit int. I've worked out how to test this now! Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyLARGE_INTEGER.cpp 12 Jun 2004 13:24:57 -0000 1.9 --- PyLARGE_INTEGER.cpp 28 Jun 2004 03:37:59 -0000 1.10 *************** *** 101,105 **** { // If it fits in a normal Python int, we return one of them. ! if (hidword==0 && ((lodword & 0x8000)==0)) return PyInt_FromLong(lodword); else { --- 101,105 ---- { // If it fits in a normal Python int, we return one of them. ! if (hidword==0 && ((lodword & 0x80000000)==0)) return PyInt_FromLong(lodword); else { *************** *** 116,126 **** if (PyInt_Check(ob)) { PyErr_Clear(); - *hiint = 0; *loint = PyInt_AsLong(ob); return !PyErr_Occurred(); } // Otherwize a long integer. __int64 newval = PyLong_AsLongLong(ob); ! if (newval==(__int64)-1) return FALSE; if (hiint) *hiint=(int)(newval>>32); --- 116,126 ---- if (PyInt_Check(ob)) { PyErr_Clear(); *loint = PyInt_AsLong(ob); + *hiint = (*(int *)loint) < 0 ? -1 : 0; return !PyErr_Occurred(); } // Otherwize a long integer. __int64 newval = PyLong_AsLongLong(ob); ! if (newval==(__int64)-1 && PyErr_Occurred()) return FALSE; if (hiint) *hiint=(int)(newval>>32); |
|
From: Mark H. <mha...@us...> - 2004-06-22 01:25:59
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19002 Modified Files: PythonCOM.h Log Message: Export our PROPVARIANT converters. Index: PythonCOM.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PythonCOM.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PythonCOM.h 30 Mar 2004 04:27:12 -0000 1.19 --- PythonCOM.h 22 Jun 2004 01:25:50 -0000 1.20 *************** *** 261,264 **** --- 261,269 ---- PYCOM_EXPORT PyObject *PyCom_PyObjectFromVariant(const VARIANT *var); + // PROPVARIANT + PYCOM_EXPORT PyObject *PyObject_FromPROPVARIANT( PROPVARIANT *pVar ); + PYCOM_EXPORT PyObject *PyObject_FromPROPVARIANTs( PROPVARIANT *pVars, ULONG cVars ); + PYCOM_EXPORT BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar); + // Other conversion helpers... PYCOM_EXPORT PyObject *PyCom_PyObjectFromSTATSTG(STATSTG *pStat); |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:55:51
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29630 Modified Files: Python and Extensions.dsw Log Message: Add new ifilter project Index: Python and Extensions.dsw =================================================================== RCS file: /cvsroot/pywin32/pywin32/Python and Extensions.dsw,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Python and Extensions.dsw 12 Jun 2004 13:40:33 -0000 1.17 --- Python and Extensions.dsw 22 Jun 2004 00:55:40 -0000 1.18 *************** *** 352,355 **** --- 352,367 ---- ############################################################################### + Project: "ifilter"=.\com\ifilter.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Project: "internet"=.\com\internet.dsp - Package Owner=<4> *************** *** 628,631 **** --- 640,655 ---- ############################################################################### + Project: "win32inet"=.\win32\win32inet.dsp - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Project: "win32lz"=.\win32\win32lz.dsp - Package Owner=<4> *************** *** 841,856 **** ############################################################################### - Project: "win32inet"=.\win32\win32inet.dsp - Package Owner=<4> - - Package=<5> - {{{ - }}} - - Package=<4> - {{{ - }}} - - ############################################################################### - Global: --- 865,868 ---- |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:54:59
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29181 Modified Files: setup_win32all.py Log Message: New win32com.ifilter module, contributed by Phil Frantz. Index: setup_win32all.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** setup_win32all.py 16 Jun 2004 00:16:06 -0000 1.21 --- setup_win32all.py 22 Jun 2004 00:54:47 -0000 1.22 *************** *** 771,775 **** WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript msdbg", pch_header = "stdafx.h", ), --- 771,775 ---- WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", ! libraries="axscript msdbg", # ad1.lib should work, but fails in debug? pch_header = "stdafx.h", ), *************** *** 786,789 **** --- 786,790 ---- WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h"), WinExt_win32com('taskscheduler', libraries='mstask'), + WinExt_win32com('ifilter', libraries='ntquery'), ] *************** *** 918,921 **** --- 919,923 ---- 'win32comext.shell', 'win32comext.mapi', + 'win32comext.ifilter', 'win32comext.internet', 'win32comext.axcontrol', *************** *** 997,1000 **** --- 999,1003 ---- 'com/win32comext/shell/demos/*.py', 'com/win32comext/taskscheduler/test/*.py', + 'com/win32comext/ifilter/demo/*.py', ]) + # And data files convert_data_files can't handle. |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:54:12
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27891/win32comext/ifilter Added Files: __init__.py ifiltercon.py Log Message: New ifilter COM extension, providing an interface to Microsoft's Index server related interfaces. Only "client" side for now (ie, the ability to call a filter), but server side should come soon! Contributed by Phil Frantz - thanks Phil! --- NEW FILE: ifiltercon.py --- # manual stuff from pywintypes import IID PSGUID_STORAGE = IID('{B725F130-47EF-101A-A5F1-02608C9EEBAC}') PSGUID_SUMMARYINFORMATION = IID('{F29F85E0-4FF9-1068-AB91-08002B27B3D9}') PSGUID_HTMLINFORMATION = IID('{D1B5D3F0-C0B3-11CF-9A92-00A0C908DBF1}') PSGUID_HTML2_INFORMATION = IID('{C82BF597-B831-11D0-B733-00AA00A1EBD2}') IFILTER_INIT_CANON_PARAGRAPHS = 1 IFILTER_INIT_HARD_LINE_BREAKS = 2 IFILTER_INIT_CANON_HYPHENS = 4 IFILTER_INIT_CANON_SPACES = 8 IFILTER_INIT_APPLY_INDEX_ATTRIBUTES = 16 IFILTER_INIT_APPLY_OTHER_ATTRIBUTES = 32 IFILTER_INIT_INDEXING_ONLY = 64 IFILTER_INIT_SEARCH_LINKS = 128 IFILTER_FLAGS_OLE_PROPERTIES = 1 CHUNK_TEXT = 0x1 CHUNK_VALUE = 0x2 CHUNK_NO_BREAK = 0 CHUNK_EOW = 1 CHUNK_EOS = 2 CHUNK_EOP = 3 CHUNK_EOC = 4 NOT_AN_ERROR = 0x00080000L FILTER_E_END_OF_CHUNKS = -2147215616 FILTER_E_NO_MORE_TEXT = -2147215615 FILTER_E_NO_MORE_VALUES = -2147215614 FILTER_E_ACCESS = -2147215613 FILTER_W_MONIKER_CLIPPED = 0x00041704 FILTER_E_NO_TEXT = -2147215611 FILTER_E_NO_VALUES = -2147215610 FILTER_E_EMBEDDING_UNAVAILABLE = -2147215609 FILTER_E_LINK_UNAVAILABLE = -2147215608 FILTER_S_LAST_TEXT = 0x00041709 FILTER_S_LAST_VALUES = 0x0004170A FILTER_E_PASSWORD = -2147215605 FILTER_E_UNKNOWNFORMAT = -2147215604 # Generated by h2py from PropIdl.h PROPSETFLAG_DEFAULT = ( 0 ) PROPSETFLAG_NONSIMPLE = ( 1 ) PROPSETFLAG_ANSI = ( 2 ) PROPSETFLAG_UNBUFFERED = ( 4 ) PROPSETFLAG_CASE_SENSITIVE = ( 8 ) PROPSET_BEHAVIOR_CASE_SENSITIVE = ( 1 ) PID_DICTIONARY = ( 0 ) PID_CODEPAGE = ( 0x1 ) PID_FIRST_USABLE = ( 0x2 ) PID_FIRST_NAME_DEFAULT = ( 0xfff ) PID_LOCALE = ( (-2147483648) ) PID_MODIFY_TIME = ( (-2147483647) ) PID_SECURITY = ( (-2147483646) ) PID_BEHAVIOR = ( (-2147483645) ) PID_ILLEGAL = ( (-1) ) PID_MIN_READONLY = ( (-2147483648) ) PID_MAX_READONLY = ( (-1073741825) ) PIDDI_THUMBNAIL = 0x00000002 PIDSI_TITLE = 0x00000002 PIDSI_SUBJECT = 0x00000003 PIDSI_AUTHOR = 0x00000004 PIDSI_KEYWORDS = 0x00000005 PIDSI_COMMENTS = 0x00000006 PIDSI_TEMPLATE = 0x00000007 PIDSI_LASTAUTHOR = 0x00000008 PIDSI_REVNUMBER = 0x00000009 PIDSI_EDITTIME = 0x0000000a PIDSI_LASTPRINTED = 0x0000000b PIDSI_CREATE_DTM = 0x0000000c PIDSI_LASTSAVE_DTM = 0x0000000d PIDSI_PAGECOUNT = 0x0000000e PIDSI_WORDCOUNT = 0x0000000f PIDSI_CHARCOUNT = 0x00000010 PIDSI_THUMBNAIL = 0x00000011 PIDSI_APPNAME = 0x00000012 PIDSI_DOC_SECURITY = 0x00000013 PIDDSI_CATEGORY = 0x00000002 PIDDSI_PRESFORMAT = 0x00000003 PIDDSI_BYTECOUNT = 0x00000004 PIDDSI_LINECOUNT = 0x00000005 PIDDSI_PARCOUNT = 0x00000006 PIDDSI_SLIDECOUNT = 0x00000007 PIDDSI_NOTECOUNT = 0x00000008 PIDDSI_HIDDENCOUNT = 0x00000009 PIDDSI_MMCLIPCOUNT = 0x0000000A PIDDSI_SCALE = 0x0000000B PIDDSI_HEADINGPAIR = 0x0000000C PIDDSI_DOCPARTS = 0x0000000D PIDDSI_MANAGER = 0x0000000E PIDDSI_COMPANY = 0x0000000F PIDDSI_LINKSDIRTY = 0x00000010 PIDMSI_EDITOR = 0x00000002 PIDMSI_SUPPLIER = 0x00000003 PIDMSI_SOURCE = 0x00000004 PIDMSI_SEQUENCE_NO = 0x00000005 PIDMSI_PROJECT = 0x00000006 PIDMSI_STATUS = 0x00000007 PIDMSI_OWNER = 0x00000008 PIDMSI_RATING = 0x00000009 PIDMSI_PRODUCTION = 0x0000000A PIDMSI_COPYRIGHT = 0x0000000B PRSPEC_INVALID = -1 PRSPEC_LPWSTR = 0 PRSPEC_PROPID = 1 CCH_MAX_PROPSTG_NAME = 31 --- NEW FILE: __init__.py --- # empty file to designate as a package. |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:54:12
|
Update of /cvsroot/pywin32/pywin32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27891 Added Files: ifilter.dsp Log Message: New ifilter COM extension, providing an interface to Microsoft's Index server related interfaces. Only "client" side for now (ie, the ability to call a filter), but server side should come soon! Contributed by Phil Frantz - thanks Phil! --- NEW FILE: ifilter.dsp --- # Microsoft Developer Studio Project File - Name="ifilter" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ifilter - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ifilter.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ifilter.mak" CFG="ifilter - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ifilter - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ifilter - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ifilter - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\ifilter\Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ifilter_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "c:\python23\include" /I "C:\Python23src\pywin32-200\com\win32com\src\include" /I "C:\Python23src\pywin32-200\win32\src" /I "c:\Python23\include" /D "NDEBUG" /D "_MBCS" /D "_USRDLL" /D "ifilter_EXPORTS" /D "WIN32" /D "_WINDOWS" /D "STRICT" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntquery.lib /nologo /dll /machine:I386 /out:"Build\ifilter.pyd" /libpath:"..\win32\build" !ELSEIF "$(CFG)" == "ifilter - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\ifilter\Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ifilter_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "c:\Python23\include" /I "C:\Python23src\pywin32-200\com\win32com\src\include" /I "C:\Python23src\pywin32-200\win32\src" /D "_DEBUG" /D "STRICT" /D "WIN32" /D "_WINDOWS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ntquery.lib /nologo /dll /debug /machine:I386 /out:"Build\ifilter_d.pyd" /pdbtype:sept /libpath:"..\win32\build" !ENDIF # Begin Target # Name "ifilter - Win32 Release" # Name "ifilter - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\win32comext\ifilter\src\PyIFilter.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\win32comext\ifilter\src\PyIFilter.h # End Source File # Begin Source File SOURCE=.\win32comext\ifilter\src\stdafx.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:54:11
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27891/win32comext/ifilter/src Added Files: PyIFilter.cpp PyIFilter.h stdafx.h Log Message: New ifilter COM extension, providing an interface to Microsoft's Index server related interfaces. Only "client" side for now (ie, the ability to call a filter), but server side should come soon! Contributed by Phil Frantz - thanks Phil! --- NEW FILE: stdafx.h --- // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // // _WIN32_DCOM screws win95 and NT :-( However, we need to define this // so we dont lose all the constants etc that come with DCOM // #define _WIN32_DCOM // PyWinTypes.h pulls in Python.h and windows.h. #include <Filter.h> #include <Filterr.h> #include <ntquery.h> #include <windows.h> #include <oleauto.h> #include <ocidl.h> // Used to be <multinfo.h> #include <Python.h> #include <PythonCOM.h> --- NEW FILE: PyIFilter.h --- // This file declares the IFilter Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyIFilter : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIFilter); static IFilter *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *Init(PyObject *self, PyObject *args); static PyObject *GetChunk(PyObject *self, PyObject *args); static PyObject *GetText(PyObject *self, PyObject *args); static PyObject *GetValue(PyObject *self, PyObject *args); static PyObject *BindRegion(PyObject *self, PyObject *args); protected: PyIFilter(IUnknown *pdisp); ~PyIFilter(); }; --- NEW FILE: PyIFilter.cpp --- // This file implements the IFilter Interface for Python. // Generated by makegw.py #include "stdafx.h" #include "PyIFilter.h" #include "PythonCOMRegister.h" // For simpler registration of IIDs etc. // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIFilter::PyIFilter(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIFilter::~PyIFilter() { } /* static */ IFilter *PyIFilter::GetI(PyObject *self) { return (IFilter *)PyIUnknown::GetI(self); } // @pymethod |PyIFilter|Init|Init an ifilter // // TODO: I don't support passing in a FULLPROPSEC array yet // PyObject *PyIFilter::Init(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; const FULLPROPSPEC * aAttributes=NULL; ULONG cAttributes=0; ULONG grfFlags=0; ULONG flags = 0; if ( !PyArg_ParseTuple(args, "l:Init", &grfFlags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIF->Init( grfFlags, cAttributes, aAttributes, &flags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIF, IID_IFilter ); return Py_BuildValue("l", flags); } // @pymethod |PyIFilter|GetChunk|Description of GetChunk. PyObject *PyIFilter::GetChunk(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetChunk") ) return NULL; HRESULT hr; STAT_CHUNK stat; PY_INTERFACE_PRECALL; hr = pIF->GetChunk( &stat ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIF, IID_IFilter ); PyObject * obProp; if (stat.attribute.psProperty.ulKind == PRSPEC_LPWSTR){ obProp = PyWinObject_FromWCHAR(stat.attribute.psProperty.lpwstr); } else { obProp = Py_BuildValue("i", stat.attribute.psProperty.propid); } PyObject * obAttr = Py_BuildValue("OO", PyWinObject_FromIID(stat.attribute.guidPropSet), obProp); return Py_BuildValue("iiiiOiii", stat.idChunk, stat.breakType, stat.flags, stat.locale, obAttr, stat.idChunkSource, stat.cwcStartSource, stat.cwcLenSource); } // @pymethod |PyIFilter|GetText|Description of GetText. PyObject *PyIFilter::GetText(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; // @pyparm <int>|nBufSize|size of text buffer to create ULONG nBufSize = 0; if ( !PyArg_ParseTuple(args, "|i:GetText", &nBufSize) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; if (nBufSize <= 0) nBufSize = 8192; // 8k default WCHAR *wBuffer = (WCHAR *)PyMem_Malloc((nBufSize+1)*sizeof(WCHAR)); if (!wBuffer){ PyErr_SetString(PyExc_MemoryError, "getting text"); return NULL; } hr = pIF->GetText( &nBufSize, wBuffer ); PY_INTERFACE_POSTCALL; PyObject *obRet = PyWinObject_FromWCHAR(wBuffer, nBufSize); PyWinObject_FreeWCHAR(wBuffer); if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIF, IID_IFilter ); return obRet; } // @pymethod |PyIFilter|GetValue|Description of GetValue. PyObject *PyIFilter::GetValue(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetValue") ) return NULL; HRESULT hr; PROPVARIANT * pPropValue = 0; PY_INTERFACE_PRECALL; hr = pIF->GetValue(&pPropValue ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ){ return PyCom_BuildPyException(hr, pIF, IID_IFilter ); } if (pPropValue){ PyObject *obRet = PyObject_FromPROPVARIANT(pPropValue); PropVariantClear(pPropValue); CoTaskMemFree(pPropValue); return obRet; } Py_INCREF(Py_None); return Py_None; } static PyObject *pyLoadIFilter(PyObject *self, PyObject *args) { HRESULT hr; IUnknown *pOb = NULL; PyObject *obPath; PyObject *ret; long lres = 0; if (!PyArg_ParseTuple(args, "O:LoadIFilter", &obPath)) return NULL; WCHAR *path; if (!PyWinObject_AsWCHAR(obPath, &path, FALSE)) goto done; Py_BEGIN_ALLOW_THREADS; hr = LoadIFilter( path , NULL , (void**)&pOb ); Py_END_ALLOW_THREADS; if (FAILED(hr)) ret = OleSetOleError(hr); else ret = PyCom_PyObjectFromIUnknown(pOb, IID_IFilter, FALSE); done: PyWinObject_FreeWCHAR(path); return ret; } static PyObject *pyBindIFilterFromStorage(PyObject *self, PyObject *args) { HRESULT hr; IUnknown *pOb = NULL; PyObject *obStg; PyObject *ret; long lres = 0; if (!PyArg_ParseTuple(args, "O:BindIFilterFromStorage", &obStg)) return NULL; IStorage *pstgDest; BOOL bPythonIsHappy = TRUE; if (!PyCom_InterfaceFromPyObject(obStg, IID_IStorage, (void **)&pstgDest, FALSE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; Py_BEGIN_ALLOW_THREADS; hr = BindIFilterFromStorage( pstgDest , NULL , (void**)&pOb ); pstgDest->Release(); Py_END_ALLOW_THREADS; if (FAILED(hr)) ret = OleSetOleError(hr); else ret = PyCom_PyObjectFromIUnknown(pOb, IID_IFilter, FALSE); return ret; } static int AddConstant(PyObject *dict, const char *key, long value) { PyObject *oval = PyInt_FromLong(value); if (!oval) { return 1; } int rc = PyDict_SetItemString(dict, (char*)key, oval); Py_DECREF(oval); return rc; } static int AddIID(PyObject *dict, const char *key, REFGUID guid) { PyObject *obiid = PyWinObject_FromIID(guid); if (!obiid) return 1; int rc = PyDict_SetItemString(dict, (char*)key, obiid); Py_DECREF(obiid); return rc; } #define ADD_CONSTANT(tok) AddConstant(dict, #tok, tok) #define ADD_IID(tok) AddIID(dict, #tok, tok) // @object PyIFilter|Description of the interface static struct PyMethodDef PyIFilter_methods[] = { { "Init", PyIFilter::Init, 1 }, // @pymeth Init|Description of Init { "GetChunk", PyIFilter::GetChunk, 1 }, // @pymeth GetChunk|Description of GetChunk { "GetText", PyIFilter::GetText, 1 }, // @pymeth GetText|returns text for the last getChunk { "GetValue", PyIFilter::GetValue, 1 }, // @pymeth GetValue|returns next property as defined by get check { NULL } }; PyComTypeObject PyIFilter::type("PyIFilter", &PyIUnknown::type, sizeof(PyIFilter), PyIFilter_methods, GET_PYCOM_CTOR(PyIFilter)); static struct PyMethodDef g_methods[] = { { "LoadIFilter", pyLoadIFilter, 1 }, // @pymeth Init|Description of Init { "BindIFilterFromStorage", pyBindIFilterFromStorage, 1 }, // @pymeth Init|Description of Init { NULL } }; static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = { PYCOM_INTERFACE_CLIENT_ONLY (Filter), }; /* Module initialisation */ extern "C" __declspec(dllexport) void initifilter() { char *modName = "ifilter"; PyObject *oModule; PyWinGlobals_Ensure(); // Create the module and add the functions oModule = Py_InitModule(modName, g_methods); if (!oModule) /* Eeek - some serious error! */ return; PyObject *dict = PyModule_GetDict(oModule); if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); // NOTE: New constants should go in ifiltercon.py // IFilter Init functions ADD_CONSTANT(IFILTER_INIT_CANON_PARAGRAPHS); ADD_CONSTANT(IFILTER_INIT_HARD_LINE_BREAKS); ADD_CONSTANT(IFILTER_INIT_CANON_HYPHENS); ADD_CONSTANT(IFILTER_INIT_CANON_SPACES); ADD_CONSTANT(IFILTER_INIT_APPLY_INDEX_ATTRIBUTES); ADD_CONSTANT(IFILTER_INIT_APPLY_OTHER_ATTRIBUTES); ADD_CONSTANT(IFILTER_INIT_INDEXING_ONLY); ADD_CONSTANT(IFILTER_INIT_SEARCH_LINKS); // IFilter return code ADD_CONSTANT(IFILTER_FLAGS_OLE_PROPERTIES); // Get Chunk Error codes ADD_CONSTANT(FILTER_E_END_OF_CHUNKS); ADD_CONSTANT(FILTER_E_EMBEDDING_UNAVAILABLE); ADD_CONSTANT(FILTER_E_LINK_UNAVAILABLE); ADD_CONSTANT(FILTER_E_PASSWORD); ADD_CONSTANT(FILTER_E_ACCESS); // Chunk Break (ret item index 1) ADD_CONSTANT(CHUNK_NO_BREAK); ADD_CONSTANT(CHUNK_EOW); ADD_CONSTANT(CHUNK_EOS); ADD_CONSTANT(CHUNK_EOP); ADD_CONSTANT(CHUNK_EOC); // Chunk Flas (ret item index 2) ADD_CONSTANT(CHUNK_TEXT); ADD_CONSTANT(CHUNK_VALUE); // Get Value error codes ADD_CONSTANT(FILTER_E_NO_MORE_VALUES); ADD_CONSTANT(FILTER_E_NO_VALUES); // Get Text error codes ADD_CONSTANT(FILTER_E_NO_TEXT); ADD_CONSTANT(FILTER_E_NO_MORE_TEXT); ADD_CONSTANT(FILTER_S_LAST_TEXT); // NOTE: New constants should go in ifiltercon.py } |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:54:11
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27891/win32comext/ifilter/demo Added Files: filterDemo.py Log Message: New ifilter COM extension, providing an interface to Microsoft's Index server related interfaces. Only "client" side for now (ie, the ability to call a filter), but server side should come soon! Contributed by Phil Frantz - thanks Phil! --- NEW FILE: filterDemo.py --- import pythoncom import pywintypes from win32com.ifilter import ifilter from win32com.ifilter.ifiltercon import * from win32com import storagecon class FileParser: # Property IDs for the Storage Property Set PIDS_BODY = 0x00000013 # property IDs for HTML Storage Property Set PIDH_DESCRIPTION = "DESCRIPTION" PIDH_HREF = "A.HREF" PIDH_IMGSRC = "IMG.SRC" # conversion map to convert ifilter properties to more user friendly names propertyToName = {PSGUID_STORAGE : {PIDS_BODY : 'body'}, PSGUID_SUMMARYINFORMATION : {PIDSI_TITLE : 'title', PIDSI_SUBJECT : 'description', PIDSI_AUTHOR : 'author', PIDSI_KEYWORDS : 'keywords', PIDSI_COMMENTS : 'comments'}, PSGUID_HTMLINFORMATION : {PIDH_DESCRIPTION : 'description'}, PSGUID_HTML2_INFORMATION : {PIDH_HREF : 'href', PIDH_IMGSRC : 'img'} } def __init__(self, verbose=False): self.f = None self.stg = None self.verbose = verbose def Close(self): self.f = None self.stg = None def Parse(self, fileName, maxErrors=10): properties = {} try: self._bind_to_filter(fileName) try: flags = self.f.Init(IFILTER_INIT_APPLY_INDEX_ATTRIBUTES | IFILTER_INIT_APPLY_OTHER_ATTRIBUTES) if flags == IFILTER_FLAGS_OLE_PROPERTIES and self.stg is not None: self._trace('filter requires to get properities via ole') self._get_properties(properties) errCnt = 0 while True: try: # each chunk returns a tuple with the following:- # idChunk = The chunk identifier. each chunk has a unique identifier # breakType = The type of break that separates the previous chunk from the current chunk. Values are:- # CHUNK_NO_BREAK=0,CHUNK_EOW=1,CHUNK_EOS= 2,CHUNK_EOP= 3,CHUNK_EOC= 4 # flags = Flags indicate whether this chunk contains a text-type or a value-type property # locale = The language and sublanguage associated with a chunk of text # attr = A tuple containing the property to be applied to the chunk. Tuple is (propertyset GUID, property ID) # Property ID can be a number or string # idChunkSource = The ID of the source of a chunk. The value of the idChunkSource member depends on the nature of the chunk # startSource = The offset from which the source text for a derived chunk starts in the source chunk # lenSource = The length in characters of the source text from which the current chunk was derived. # A zero value signifies character-by-character correspondence between the source text and the derived text. idChunk, breakType, flags, locale, attr, idChunkSource, startSource,lenSource = self.f.GetChunk() self._trace("Chunk details:", idChunk, breakType, flags, locale, attr, idChunkSource, startSource,lenSource) # attempt to map each property to a more user friendly name. If we don't know what it is just return # the set guid and property id. (note: the id can be a number or a string. propSet = self.propertyToName.get(attr[0]) if propSet: propName = propSet.get(attr[1], '%s:%s' % attr) else: propName = '%s:%s' % attr except pythoncom.com_error, e: if e[0] == FILTER_E_END_OF_CHUNKS: # we have read all the chunks break elif e[0] in [FILTER_E_EMBEDDING_UNAVAILABLE, FILTER_E_LINK_UNAVAILABLE]: # the next chunk can't be read. Also keep track of the number of times we # fail as some filters (ie. the Msoft office ones can get stuck here) errCnt += 1 if errCnt > maxErrors: raise else: continue elif e[0] == FILTER_E_ACCESS: self._trace('Access denied') raise elif e[0] == FILTER_E_PASSWORD: self._trace('Password required') raise else: # any other type of error really can't be recovered from raise # reset consecutive errors (some filters may get stuck in a lopp if embedding or link failures occurs errCnt = 0 if flags == CHUNK_TEXT: # its a text segment - get all available text for this chunk. body_chunks = properties.setdefault(propName, []) self._get_text(body_chunks) elif flags == CHUNK_VALUE: # its a data segment - get the value properties[propName] = self.f.GetValue() else: self._trace("Unknown flag returned by GetChunk:", flags) finally: self.Close() except pythoncom.com_error, e: self._trace("ERROR processing file", e) raise return properties def _bind_to_filter(self, fileName): """ See if the file is a structured storage file or a normal file and then return an ifilter interface by calling the appropriate bind/load function """ if pythoncom.StgIsStorageFile(fileName): self.stg = pythoncom.StgOpenStorage(fileName, None, storagecon.STGM_READ | storagecon.STGM_SHARE_DENY_WRITE) try: self.f = ifilter.BindIFilterFromStorage(self.stg) except pythoncom.com_error, e: if e[0] == -2147467262: # 0x80004002: # no interface, try the load interface (this happens for some MSoft files) self.f = ifilter.LoadIFilter(fileName) else: raise else: self.f = ifilter.LoadIFilter(fileName) self.stg = None def _get_text(self, body_chunks): """ Gets all the text for a particular chunk. We need to keep calling get text till all the segments for this chunk are retrieved """ while True: try: body_chunks.append(self.f.GetText()) except pythoncom.com_error, e: if e[0] in [FILTER_E_NO_MORE_TEXT, FILTER_E_NO_MORE_TEXT, FILTER_E_NO_TEXT]: break else: raise # not one of the values we were expecting def _get_properties(self, properties): """ Use OLE property sets to get base properties """ try: pss = self.stg.QueryInterface(pythoncom.IID_IPropertySetStorage ) except pythoncom.com_error, e: self._trace('No Property information could be retrieved', e) return ps = pss.Open(PSGUID_SUMMARYINFORMATION) props = (PIDSI_TITLE, PIDSI_SUBJECT, PIDSI_AUTHOR, PIDSI_KEYWORDS, PIDSI_COMMENTS) title, subject, author, keywords, comments = ps.ReadMultiple(props) if title is not None: properties['title'] = title if subject is not None: properties['description'] = subject if author is not None: properties['author'] = author if keywords is not None: properties['keywords'] = keywords if comments is not None: properties['comments'] = comments def _trace(self, *args): if self.verbose: ret = ' '.join([str(arg) for arg in args]) try: print ret except IOError: pass def _usage(): import os print "Usage: %s filename [verbose [dumpbody]]" % (os.path.basename(sys.argv[0]),) print print "Where:-" print "filename = name of the file to extract text & properties from" print "verbose = 1=debug output, 0=no debug output (default=0)" print "dumpbody = 1=print text content, 0=don't print content (default=1)" print print "e.g. to dump a word file called spam.doc go:- filterDemo.py spam.doc" print print "by default .htm, .txt, .doc, .dot, .xls, .xlt, .ppt are supported" print "you can filter .pdf's by downloading adobes ifilter component. " print "(currently found at http://download.adobe.com/pub/adobe/acrobat/win/all/ifilter50.exe)." print "ifilters for other filetypes are also available." print print "This extension is only supported on win2000 & winXP - because thats the only" print "place the ifilter stuff is supported. For more info on the API check out " print "MSDN under ifilters" if __name__ == "__main__": import sys import operator fName = '' verbose = False bDumpBody =True if len(sys.argv) < 2: _usage() sys.exit(1) try: fName = sys.argv[1] verbose = (sys.argv[2]!="0") bDumpBody = (sys.argv[3]!="0") except: pass p = FileParser(verbose) propMap = p.Parse(fName) if bDumpBody: print "Body" ch = ' '.join(propMap.get('body', [])) try: print ch except UnicodeError: print ch.encode('iso8859-1','ignore') print "Properties" for propName, propValue in propMap.items(): print propName,":", if propName == 'body': print "<%s length: %d>" % (propName, reduce(operator.add, [len(p) for p in propValue]),) elif type(propValue) == type([]): print for pv in propValue: print pv else: print propValue print |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:48:27
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25473/src Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src added to the repository |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:48:27
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25473/demo Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/ifilter/demo added to the repository |
|
From: Mark H. <mha...@us...> - 2004-06-22 00:19:22
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6769/ifilter Log Message: Directory /cvsroot/pywin32/pywin32/com/win32comext/ifilter added to the repository |
|
From: Mark H. <mha...@us...> - 2004-06-16 00:16:18
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27433 Modified Files: setup_win32all.py Log Message: win32security now needs Secur32.lib Index: setup_win32all.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** setup_win32all.py 12 Jun 2004 13:40:33 -0000 1.20 --- setup_win32all.py 16 Jun 2004 00:16:06 -0000 1.21 *************** *** 716,720 **** ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), ! ("win32security", "advapi32 user32", True), ("win32service", "advapi32 oleaut32", True, 0x0500), ("win32trace", "advapi32", False), --- 716,720 ---- ("win32process", "advapi32 user32", False, 0x0500), ("win32ras", "rasapi32 user32", False), ! ("win32security", "advapi32 user32 Secur32", True), ("win32service", "advapi32 oleaut32", True, 0x0500), ("win32trace", "advapi32", False), |
|
From: Roger U. <ru...@us...> - 2004-06-15 11:32:27
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1488/win32/src Modified Files: win32file.i Log Message: Add GetVolumePathName and combined char/unicode version of GetFullPathName Fix crash in DecryptFile Call unicode Api functions for RemoveDirectory and SetCurrentDirectory Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** win32file.i 12 Jun 2004 07:58:29 -0000 1.39 --- win32file.i 15 Jun 2004 11:32:14 -0000 1.40 *************** *** 37,41 **** #define GENERIC_EXECUTE GENERIC_EXECUTE // Specifies execute access. ! #ifndef MS_WINCE #define FILE_SHARE_DELETE FILE_SHARE_DELETE --- 37,41 ---- #define GENERIC_EXECUTE GENERIC_EXECUTE // Specifies execute access. ! #ifndef MS_WINCE #define FILE_SHARE_DELETE FILE_SHARE_DELETE *************** *** 1225,1228 **** --- 1225,1312 ---- // GetFullPathName + // @pyswig str/unicode|GetFullPathName|Returns full path for path passed in + // @comm This function takes either a plain string or a unicode string, and returns the same type + // If unicode is passed in, GetFullPathNameW is called, which supports filenames longer than MAX_PATH + %native(GetFullPathName) MyGetFullPathName; + %{ + static PyObject *MyGetFullPathName(PyObject *self, PyObject *args) + { + PyObject *ret=NULL, *obpathin; + int pathlen, retlen; + + // @pyparm str/unicode|FileName||Path on which to operate + if (!PyArg_ParseTuple(args, "O", &obpathin)) + return NULL; + WCHAR *wpathin; + if (wpathin=PyUnicode_AsUnicode(obpathin)){ + WCHAR *wpathret, *wfilepart; + pathlen=wcslen(wpathin)+1; + wpathret=(WCHAR *)malloc(pathlen*sizeof(WCHAR)); + if (wpathret==NULL){ + PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + retlen=GetFullPathNameW(wpathin, pathlen, wpathret, &wfilepart); + Py_END_ALLOW_THREADS + if (retlen>pathlen){ + pathlen=retlen; + wpathret=(WCHAR *)realloc(wpathret,pathlen*sizeof(WCHAR)); + if (wpathret==NULL){ + PyErr_SetString(PyExc_MemoryError,"GetFullPathNameW: unable to allocate unicode return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + retlen=GetFullPathNameW(wpathin, retlen, wpathret, &wfilepart); + Py_END_ALLOW_THREADS + } + if (retlen>pathlen) + PyErr_SetString(PyExc_SystemError,"GetFullPathNameW: Unexpected second increase in required buffer size"); + else + if (retlen==0) + PyWin_SetAPIError("GetFullPathNameW", GetLastError()); + else + ret=PyUnicode_FromWideChar(wpathret,retlen); + free(wpathret); + return ret; + } + + PyErr_Clear(); + char *cpathin; + if (PyString_AsStringAndSize(obpathin, &cpathin, &pathlen)!=-1){ + char *cpathret, *cfilepart; + pathlen+=1; + cpathret=(char *)malloc(pathlen); + if (cpathret==NULL){ + PyErr_SetString(PyExc_MemoryError,"GetFullPathName: unable to allocate character return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + retlen=GetFullPathName(cpathin, pathlen, cpathret, &cfilepart); + Py_END_ALLOW_THREADS + if (retlen>pathlen){ + pathlen=retlen; + cpathret=(char *)realloc(cpathret,pathlen); + if (cpathret==NULL){ + PyErr_SetString(PyExc_MemoryError,"GetFullPathName: unable to allocate character return buffer"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + retlen=GetFullPathName(cpathin, retlen, cpathret, &cfilepart); + Py_END_ALLOW_THREADS + } + if (retlen>pathlen) + PyErr_SetString(PyExc_SystemError,"GetFullPathName: Unexpected second increase in required buffer size"); + else + if (retlen==0) + PyWin_SetAPIError("GetFullPathName", GetLastError()); + else + ret=PyString_FromStringAndSize(cpathret,retlen); + free(cpathret); + } + return ret; + } + %} + #ifndef MS_WINCE *************** *** 1397,1402 **** // @pyswig |RemoveDirectory|Removes an existing directory ! BOOLAPI RemoveDirectory( ! TCHAR *lpPathName // @pyparm <o PyUnicode>|lpPathName||Name of the path to remove. ); --- 1481,1486 ---- // @pyswig |RemoveDirectory|Removes an existing directory ! %name(RemoveDirectory) BOOLAPI RemoveDirectoryW( ! WCHAR *lpPathName // @pyparm str/<o PyUnicode>|lpPathName||Name of the path to remove. ); *************** *** 1405,1410 **** #ifndef MS_WINCE // @pyswig |SetCurrentDirectory|Sets the current directory. ! BOOLAPI SetCurrentDirectory( ! TCHAR *lpPathName // @pyparm <o PyUnicode>|lpPathName||Name of the path to set current. ); #endif // MS_WINCE --- 1489,1494 ---- #ifndef MS_WINCE // @pyswig |SetCurrentDirectory|Sets the current directory. ! %name(SetCurrentDirectory) BOOLAPI SetCurrentDirectoryW( ! WCHAR *lpPathName // @pyparm str/<o PyUnicode>|lpPathName||Name of the path to set current. ); #endif // MS_WINCE *************** *** 2462,2466 **** static BOOL (WINAPI *pfnCreateHardLinkW)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES ) = NULL; static BOOL (WINAPI *pfnEncryptFile)(WCHAR *)=NULL; ! static BOOL (WINAPI *pfnDecryptFile)(WCHAR *)=NULL; static BOOL (WINAPI *pfnEncryptionDisable)(WCHAR *, BOOL)=NULL; static BOOL (WINAPI *pfnFileEncryptionStatus)(WCHAR *, LPDWORD)=NULL; --- 2546,2550 ---- static BOOL (WINAPI *pfnCreateHardLinkW)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES ) = NULL; static BOOL (WINAPI *pfnEncryptFile)(WCHAR *)=NULL; ! static BOOL (WINAPI *pfnDecryptFile)(WCHAR *, DWORD)=NULL; static BOOL (WINAPI *pfnEncryptionDisable)(WCHAR *, BOOL)=NULL; static BOOL (WINAPI *pfnFileEncryptionStatus)(WCHAR *, LPDWORD)=NULL; *************** *** 2470,2474 **** static DWORD (WINAPI *pfnRemoveUsersFromEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST)=NULL; static DWORD (WINAPI *pfnAddUsersToEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_LIST)=NULL; ! --- 2554,2558 ---- static DWORD (WINAPI *pfnRemoveUsersFromEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST)=NULL; static DWORD (WINAPI *pfnAddUsersToEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_LIST)=NULL; ! static BOOL (WINAPI *pfnGetVolumePathNameW)(WCHAR *, WCHAR *, DWORD)=NULL; *************** *** 2634,2638 **** return PyErr_Format(PyExc_NotImplementedError,"GetVolumeNameForVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O", &obmount_point)) return NULL; --- 2718,2722 ---- return PyErr_Format(PyExc_NotImplementedError,"GetVolumeNameForVolumeMountPoint not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O:GetVolumeNameForVolumeMountPoint", &obmount_point)) return NULL; *************** *** 2652,2655 **** --- 2736,2779 ---- } + // @pyswig <o PyUnicode>|GetVolumePathName|Returns volume mount point for a path + // @comm Api gives no indication of how much memory is needed, so function assumes returned path + // will not be longer that length of input path + 1. + // Use GetFullPathName first for relative paths, or GetLongPathName for 8.3 paths. + // Optional second parm can also be used to override the buffer size for returned path + static PyObject* + py_GetVolumePathName(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||File/dir for which to return volume mount point + // @pyparm int|bufsize|0|Optional parm to allocate extra space for returned string + PyObject *ret=NULL; + PyObject *obpath = NULL; + WCHAR *path=NULL, *mount_point=NULL; + DWORD pathlen, bufsize=0; + if (pfnGetVolumePathNameW==NULL) + return PyErr_Format(PyExc_NotImplementedError,"GetVolumePathName not supported by this version of Windows"); + if (!PyArg_ParseTuple(args,"O|l:GetVolumePathName", &obpath, &bufsize)) + return NULL; + if (!PyWinObject_AsWCHAR(obpath, &path, FALSE, &pathlen)) + return NULL; + + // yet another function that doesn't tell us how much memory it needs ... + if (bufsize>0) + bufsize+=1; + else + bufsize=pathlen+2; // enough to accomodate trailing null, and possibly extra backslash + mount_point=(WCHAR *)malloc(bufsize*sizeof(WCHAR)); + if (mount_point==NULL) + PyErr_SetString(PyExc_MemoryError,"GetVolumePathName: Unable to allocate return buffer"); + else + if (!(*pfnGetVolumePathNameW)(path, mount_point, bufsize)) + PyWin_SetAPIError("GetVolumePathName"); + else + ret=PyWinObject_FromWCHAR(mount_point); + if (path != NULL) + PyWinObject_FreeWCHAR(path); + if (mount_point!=NULL) + free(mount_point); + return ret; + } // @pyswig |EncryptFile|Encrypts specified file (requires Win2k or higher and NTFS) *************** *** 2680,2699 **** py_DecryptFile(PyObject *self, PyObject *args) { ! // @pyparm string/unicode|filename||File to decrypt ! PyObject *ret=NULL, *obfname=NULL; ! WCHAR *fname = NULL; if (pfnDecryptFile==NULL) return PyErr_Format(PyExc_NotImplementedError,"DecryptFile not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O", &obfname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) ! return NULL; ! if (!(*pfnDecryptFile)(fname)) ! PyWin_SetAPIError("DecryptFile"); ! else ! ret=Py_None; ! PyWinObject_FreeWCHAR(fname); ! Py_XINCREF(ret); ! return ret; } --- 2804,2824 ---- py_DecryptFile(PyObject *self, PyObject *args) { ! // @pyparm string/unicode|filename||File to decrypt ! PyObject *ret=NULL, *obfname=NULL; ! WCHAR *fname = NULL; ! DWORD reserved=0; if (pfnDecryptFile==NULL) return PyErr_Format(PyExc_NotImplementedError,"DecryptFile not supported by this version of Windows"); ! if (!PyArg_ParseTuple(args,"O:DecryptFile", &obfname)) ! return NULL; ! if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) ! return NULL; ! if (!(*pfnDecryptFile)(fname,reserved)) ! PyWin_SetAPIError("DecryptFile"); ! else ! ret=Py_None; ! PyWinObject_FreeWCHAR(fname); ! Py_XINCREF(ret); ! return ret; } *************** *** 3152,3155 **** --- 3277,3281 ---- %native (CreateHardLink) py_CreateHardLink; %native (GetVolumeNameForVolumeMountPoint) py_GetVolumeNameForVolumeMountPoint; + %native (GetVolumePathName) py_GetVolumePathName; // end of win2k volume mount functions. *************** *** 3176,3180 **** fp=GetProcAddress(hmodule,"DecryptFileW"); ! if (fp) pfnDecryptFile=(BOOL (WINAPI *)(WCHAR *))(fp); fp=GetProcAddress(hmodule,"EncryptionDisable"); --- 3302,3306 ---- fp=GetProcAddress(hmodule,"DecryptFileW"); ! if (fp) pfnDecryptFile=(BOOL (WINAPI *)(WCHAR *, DWORD))(fp); fp=GetProcAddress(hmodule,"EncryptionDisable"); *************** *** 3203,3217 **** hmodule = GetModuleHandle("kernel32.dll"); if (hmodule){ ! fp = GetProcAddress(hmodule, "GetVolumeNameForVolumeMountPointW"); ! if (fp) pfnGetVolumeNameForVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, DWORD))(fp); ! fp = GetProcAddress(hmodule, "SetVolumeMountPointW"); ! if (fp) pfnSetVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR))(fp); ! fp = GetProcAddress(hmodule, "DeleteVolumeMountPointW"); ! if (fp) pfnDeleteVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR))(fp); ! fp = GetProcAddress(hmodule, "CreateHardLinkW"); ! if (fp) pfnCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))(fp); } %} --- 3329,3346 ---- hmodule = GetModuleHandle("kernel32.dll"); if (hmodule){ ! fp = GetProcAddress(hmodule, "GetVolumeNameForVolumeMountPointW"); ! if (fp) pfnGetVolumeNameForVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, DWORD))(fp); ! fp = GetProcAddress(hmodule, "GetVolumePathNameW"); ! if (fp) pfnGetVolumePathNameW = (BOOL (WINAPI *)(WCHAR *, WCHAR *, DWORD))(fp); ! fp = GetProcAddress(hmodule, "SetVolumeMountPointW"); ! if (fp) pfnSetVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR))(fp); ! fp = GetProcAddress(hmodule, "DeleteVolumeMountPointW"); ! if (fp) pfnDeleteVolumeMountPointW = (BOOL (WINAPI *)(LPCWSTR))(fp); ! ! fp = GetProcAddress(hmodule, "CreateHardLinkW"); ! if (fp) pfnCreateHardLinkW = (BOOL (WINAPI *)(LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES))(fp); } %} |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:42:16
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14106 Modified Files: .cvsignore Log Message: Ignore the SWIG generated win32inet module Index: .cvsignore =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .cvsignore 6 Jan 2000 12:02:24 -0000 1.1 --- .cvsignore 12 Jun 2004 13:42:07 -0000 1.2 *************** *** 12,13 **** --- 12,14 ---- win32servicemodule.cpp wincerapimodule.cpp + win32inetmodule.cpp |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:40:43
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940/win32/src Added Files: win32inet.i Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. --- NEW FILE: win32inet.i --- /* File : win32inet.i */ // @doc %module win32inet // An interface to the Windows internet (wininet) API %{ #include "Windows.h" #include "WinInet.h" #undef BOOLAPI // wininet.h defines this! %} %include "typemaps.i" %include "pywin32.i" %apply HWND {long}; typedef long HWND %{ #undef PyHANDLE // undef earlier define, so we are back to the class. #include "pywinobjects.h" // @object PyHINTERNET|An object that wraps a HINTERNET handle. When the // handle object is destroyed, it is automatically closed. // See the <o PyHANDLE> object for more details. class PyHINTERNET : public PyHANDLE { public: PyHINTERNET(HANDLE hInit) : PyHANDLE(hInit) {} virtual BOOL Close(void) { if (m_handle && !InternetCloseHandle((HINTERNET)m_handle)) { m_handle = 0; // don't try again! PyWin_SetAPIError("InternetCloseHandle"); return FALSE; } m_handle = 0; return TRUE; } virtual const char *GetTypeName() {return "PyHINTERNET";} }; %} %typemap(python,ignore) HINTERNET *OUTPUT(HINTERNET temp) { $target = &temp; } %typemap(python,except) PyHINTERNET { Py_BEGIN_ALLOW_THREADS $function Py_END_ALLOW_THREADS if ($source==0 || $source==INVALID_HANDLE_VALUE) { $cleanup return PyWin_SetAPIError("$name"); } } %typemap(python,except) HINTERNET { Py_BEGIN_ALLOW_THREADS $function Py_END_ALLOW_THREADS if ($source==0 || $source==INVALID_HANDLE_VALUE) { $cleanup return PyWin_SetAPIError("$name"); } } %apply long {HINTERNET}; typedef long HINTERNET; typedef HINTERNET PyHINTERNET; %{ PyObject *PyObject_FromHINTERNET(HINTERNET hi) { return new PyHINTERNET(hi); } #define PyHINTERNET HINTERNET // Use a #define so we can undef it later if we need the true defn. %} %typemap(python,in) HINTERNET { if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) return NULL; } %typemap(python,in) PyHINTERNET { if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, FALSE)) return NULL; } %typemap(python,in) PyHINTERNET INPUT_NULLOK { if (!PyWinObject_AsHANDLE($source, (HANDLE *)&$target, TRUE)) return NULL; } %typemap(python,ignore) PyHINTERNET *OUTPUT(HINTERNET temp) { $target = &temp; } %typemap(python,out) PyHINTERNET { $target = PyObject_FromHINTERNET($source); } %typemap(python,argout) PyHINTERNET *OUTPUT { PyObject *o; o = PyObject_FromHINTERNET(*$source); if (!$target) { $target = o; } else if ($target == Py_None) { Py_DECREF(Py_None); $target = o; } else { if (!PyList_Check($target)) { PyObject *o2 = $target; $target = PyList_New(0); PyList_Append($target,o2); Py_XDECREF(o2); } PyList_Append($target,o); Py_XDECREF(o); } } // @pyswig |InternetSetCookie|Creates a cookie associated with the specified URL. BOOLAPI InternetSetCookie( TCHAR *lpszUrl, // @pyparm string|url|| TCHAR *INPUT_NULLOK, // @pyparm string|lpszCookieName|| TCHAR *lpszCookieData // @pyparm string|data|| ); %{ // @pyswig string|InternetGetCookie|Retrieves the cookie for the specified URL PyObject *PyInternetGetCookie(PyObject *self, PyObject *args) { PyObject *obUrl, *obCookieName; PyObject *ret = NULL; BOOL ok = FALSE; DWORD cb = 0; TCHAR *szUrl = NULL, *szCookieName = NULL; if (!PyArg_ParseTuple(args, "OO:InternetGetCookie", &obUrl, &obCookieName)) return NULL; if (!PyWinObject_AsTCHAR(obUrl, &szUrl)) goto done; if (!PyWinObject_AsTCHAR(obCookieName, &szCookieName, TRUE)) goto done; InternetGetCookie(szUrl, szCookieName, NULL, &cb); if (!cb) { // assume this means some other failure. PyWin_SetAPIError("InternetGetCookie"); goto done; } // cb includes the NULL - Python adds one for the null. ret = PyString_FromStringAndSize(NULL, cb-1); Py_BEGIN_ALLOW_THREADS ok = InternetGetCookie(szUrl, szCookieName, PyString_AS_STRING(ret), &cb); Py_END_ALLOW_THREADS if (!ok) { PyWin_SetAPIError("InternetGetCookie"); goto done; } done: if (!ok) { Py_XDECREF(ret); ret = NULL; } if (szUrl) PyWinObject_FreeTCHAR(szUrl); if (szCookieName) PyWinObject_FreeTCHAR(szCookieName); return ret; } %} %native (InternetGetCookie) PyInternetGetCookie; // @pyswig |InternetAttemptConnect|Attempts to make a connection to the Internet. BOOLAPI InternetAttemptConnect( DWORD reserved); // @pyparm int|reserved|| // @pyswig |InternetCheckConnection|Allows an application to check if a connection to the Internet can be established BOOLAPI InternetCheckConnection( TCHAR *lpszUrl, // @pyparm string|url|| DWORD flags, // @pyparm int|flags|| DWORD reserved); // @pyswig |InternetGoOnline|Prompts the user for permission to initiate connection to a URL. BOOLAPI InternetGoOnline( TCHAR *lpszUrl, // @pyparm string|url|| HWND hwnd, // @pyparm int|hwnd|| DWORD reserved); // @pyswig |InternetCloseHandle| // @comm It should not be necessary to call this function - all handles are // <o PyHINTERNET> objects, so can have their Close method called, and will // otherwise be automatically closed. BOOLAPI InternetCloseHandle( HINTERNET handle // @pyparm <o PyHINTERNET>|handle|| ); // @pyswig |InternetConnect|Opens an FTP, Gopher, or HTTP session for a given site. PyHINTERNET InternetConnect( HINTERNET hInternet, // <o PyHINTERNET>|hInternet||Valid HINTERNET handle returned by a previous call to <om win32inet.InternetOpen>. TCHAR *lpszServerName, // string|serverName||A string that contains the host name of an Internet // server. Alternately, the string can contain the IP number of the site, // in ASCII dotted-decimal format (for example, 11.0.1.45). int nServerPort, // int|serverPort||Number of the TCP/IP port on the server to connect to. // These flags set only the port that will be used. The service is set by // the value of dwService. This can be one of the INTERNET_DEFAULT_*_PORT // constants or INTERNET_INVALID_PORT_NUMBER, which uses the default // port for the service specified by dwService. TCHAR *INPUT_NULLOK, // @pyparm string|lpszUsername||A string that contains the name of the user // to log on. If this parameter is None, the function uses an appropriate // default, except for HTTP; a NULL parameter in HTTP causes the server // to return an error. For the FTP protocol, the default is "anonymous". TCHAR *INPUT_NULLOK, // @pyparm string|lpszPassword||Address of a null-terminated string that // contains the password to use to log on. If both lpszPassword // and lpszUsername are None, the function uses the default // "anonymous" password. In the case of FTP, the default password // is the user's e-mail name. If lpszPassword is None, but lpszUsername // is not None, the function uses a blank password. DWORD dwService, // @pyparm int|dwService||Iinteger value that contains the type of service to // access. This can be one of INTERNET_SERVICE_FTP, INTERNET_SERVICE_GOPHER, // or INTERNET_SERVICE_HTTP. DWORD dwFlags, // @pyparm int|flags||Integer value that contains the flags specific to // the service used. When the value of dwService is INTERNET_SERVICE_FTP, // INTERNET_FLAG_PASSIVE causes the application to use passive FTP semantics. DWORD context // @pyparm int|context||Must be zero. ); // @pyswig |InternetOpen|Initializes an application's use of the Microsoft® Win32® Internet functions. PyHINTERNET InternetOpen( TCHAR *lpszAgent, // @pyparm string|agent||A string that contains the name of the application // or entity calling the Internet functions. This name is used as the user // agent in the HTTP protocol. DWORD dwAccessType, // pyparm int|accessType||dwAccessType|Type of access required. This can be one // of INTERNET_OPEN_TYPE_DIRECT, INTERNET_OPEN_TYPE_PRECONFIG, // INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY or // INTERNET_OPEN_TYPE_PROXY TCHAR *INPUT_NULLOK, // @pyparm string|proxyName|| TCHAR *INPUT_NULLOK, // @pyparm string|proxyBypass|| DWORD dwFlags // @pyparm int|flags|| ); %{ // @pyswig <o PyHINTERNET>|InternetOpenUrl|Opens a resource specified by a // complete FTP, Gopher, or HTTP URL. PyObject *PyInternetOpenUrl(PyObject *self, PyObject *args) { PyObject *obURL, *obHeaders, *obH; TCHAR *szURL = NULL; TCHAR *szHeaders = NULL; DWORD headerLen = 0; HINTERNET hiret, hiin; DWORD flags; PyObject *ret = NULL; // @pyparm <o PyHINTERNET>|hInternet|| // @pyparm string|url||A string that contains the URL to begin reading. Only URLs beginning with ftp:, gopher:, http:, or https: are supported. // @pyparm string|headers||a string variable that contains the headers to be sent to the HTTP server. // @pyparm int|flags|| if (!PyArg_ParseTuple(args, "OOOi:InternetOpenUrl", &obH, &obURL, &obHeaders, &flags)) return NULL; if (!PyWinObject_AsHANDLE(obH, (HANDLE *)&hiin, FALSE)) goto done; if (!PyWinObject_AsString(obURL, &szURL, FALSE)) goto done; if (!PyWinObject_AsString(obHeaders, &szHeaders, TRUE, &headerLen)) goto done; Py_BEGIN_ALLOW_THREADS hiret = InternetOpenUrl(hiin, szURL, szHeaders, headerLen, flags, 0); Py_END_ALLOW_THREADS if (!hiret) { PyWin_SetAPIError("InternetOpenUrl"); goto done; } ret = PyObject_FromHINTERNET(hiret); done: if (szURL) PyWinObject_FreeTCHAR(szURL); if (szHeaders) PyWinObject_FreeTCHAR(szHeaders); return ret; } %} %native (InternetOpenUrl) PyInternetOpenUrl; %{ // @pyswig string|InternetCanonicalizeUrl|Canonicalizes a URL, which includes // converting unsafe characters and spaces into escape sequences. PyObject *PyInternetCanonicalizeUrl(PyObject *self, PyObject *args) { DWORD flags = 0; TCHAR *szURL = NULL; TCHAR *buf = NULL; PyObject *ret = NULL; PyObject *obURL; // @pyparm string|url||The URL to canonicalize. // @pyparm int|flags|0|integer value that contains the flags that control // canonicalization. This can be one of the following values: // @flag ICU_BROWSER_MODE|Does not encode or decode characters after "#" or "?", and does not remove trailing white space after "?". If this value is not specified, the entire URL is encoded and trailing white space is removed. // @flag ICU_DECODE|Converts all %XX sequences to characters, including escape sequences, before the URL is parsed. // @flag ICU_ENCODE_PERCENT|Encodes any percent signs encountered. By default, percent signs are not encoded. This value is available in Microsoft® Internet Explorer 5 and later versions of the Win32® Internet functions. // @flag ICU_ENCODE_SPACES_ONLY|Encodes spaces only. // @flag ICU_NO_ENCODE|Does not convert unsafe characters to escape sequences. // @flag ICU_NO_META|Does not remove meta sequences (such as "." and "..") from the URL. // If no flags are specified (dwFlags = 0), the function converts all unsafe characters and meta sequences (such as \.,\ .., and \...) to escape sequences. if (!PyArg_ParseTuple(args, "O|i:InternetCanonicalizeUrl", &obURL, &flags)) return NULL; if (!PyWinObject_AsString(obURL, &szURL, FALSE)) return NULL; DWORD cch = INTERNET_MAX_URL_LENGTH + 1; buf = (TCHAR *)malloc(cch * sizeof(TCHAR)); if (!buf) { PyErr_NoMemory(); goto done; } if (!InternetCanonicalizeUrl(szURL, buf, &cch, flags)) { if (GetLastError()!= ERROR_INSUFFICIENT_BUFFER) { PyWin_SetAPIError("InternetCanonicalizeUrl"); goto done; } // size includes NULL buf = (TCHAR *)realloc(buf, cch * sizeof(TCHAR)); if (!buf) { PyErr_NoMemory(); goto done; } if (!InternetCanonicalizeUrl(szURL, buf, &cch, flags)) { PyWin_SetAPIError("InternetCanonicalizeUrl"); goto done; } } ret = PyWinObject_FromTCHAR(buf); done: if (buf) free(buf); if (szURL) PyWinObject_FreeTCHAR(szURL); return ret; } %} %native (InternetCanonicalizeUrl) PyInternetCanonicalizeUrl; %{ // @pyswig int, string|InternetGetLastResponseInfo|Retrieves the last Win32® Internet function error description or server response on the thread calling this function. PyObject *PyInternetGetLastResponseInfo(PyObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":InternetGetLastResponseInfo")) return NULL; DWORD err; DWORD cch = 0; TCHAR *buf = NULL; InternetGetLastResponseInfo(&err, NULL, &cch); if (!cch) { // assume this means some other failure. PyWin_SetAPIError("InternetGetLastResponseInfo"); return NULL; } cch += 1; // size does NOT include NULL buf = (TCHAR *)malloc(cch * sizeof(TCHAR)); if (!buf) { PyErr_NoMemory(); return NULL; } if (!InternetGetLastResponseInfo(&err, buf, &cch)) { PyWin_SetAPIError("InternetGetLastResponseInfo"); free(buf); return NULL; } PyObject *obMsg = PyWinObject_FromTCHAR(buf); free(buf); return Py_BuildValue("iN", err, obMsg); } %} %native (InternetGetLastResponseInfo) PyInternetGetLastResponseInfo; %{ // @pyswig string|InternetReadFile|Reads data from a handle opened by the // <om win32inet.InternetOpenUrl>, <om win32inet.FtpOpenFile>, // <om win32inet.GopherOpenFile>, or <om win32inet.HttpOpenRequest> function. PyObject *PyInternetReadFile(PyObject *self, PyObject *args) { PyObject *ret = NULL; PyObject *obH; DWORD size; DWORD read = 0; TCHAR *buf = NULL; HINTERNET hiin; BOOL ok; // @pyparm <o PyHINTERNET>|hInternet|| // @pyparm int|size||Number of bytes to read. if (!PyArg_ParseTuple(args, "Oi:InternetReadFile", &obH, &size)) return NULL; // todo - allow buffer of size, like win32file - but who really cares for // this? No asynch IO, so only advantage is less heap thrashing. if (size==0) return PyErr_Format(PyExc_ValueError, "Can't read zero bytes"); buf = (TCHAR *)malloc(size); if (!buf) { PyErr_NoMemory(); return NULL; } if (!PyWinObject_AsHANDLE(obH, (HANDLE *)&hiin, FALSE)) goto done; Py_BEGIN_ALLOW_THREADS ok = InternetReadFile(hiin, buf, size, &read); Py_END_ALLOW_THREADS if (!ok) { PyWin_SetAPIError("InternetReadFile"); goto done; } ret = PyString_FromStringAndSize(buf, read); // @rdesc The result will be a string of zero bytes when the end is reached. done: if (buf) free(buf); return ret; } %} %native (InternetReadFile) PyInternetReadFile; // @pyswig <o PyINTERNET>|FtpOpenFile|Initiates access to a remote file on an FTP server for reading or writing. HINTERNET FtpOpenFile( HINTERNET hConnect, // @pyparm <o PyHINTERNET>|hConnect||Valid HINTERNET handle to an FTP session. TCHAR *lpszFileName, // @pyparm string|filename||The name of the file to access on the remote system. DWORD dwAccess, // @pyparm int|access||Integer value that determines how the file will be accessed. This can be GENERIC_READ or GENERIC_WRITE, but not both. DWORD dwFlags, // @pyparm int|flags||Integer value that contains the conditions under which the // transfers occur. The application should select one transfer type and // any of the flags that indicate how the caching of the file will be // controlled. The transfer type can be one of the FTP_TRANSFER_TYPE* values DWORD dwContext // @pyparm int|context||Most be zero ); // @pyswig <o PyHINTERNET>|FtpCommand|Allows an application to send commands directly to an FTP server. BOOLAPI FtpCommand( HINTERNET hConnect, // @pyparm <o PyHINTERNET>|hConnect||Valid HINTERNET handle to an FTP session. BOOL fExpectResponse, // @pyparm bool|fExpectResponse||Boolean value that indicates whether or not // the application expects a response from the FTP server. // This must be set to True if a response is expected, or False otherwise. DWORD dwFlags, // @pyparm int|flags||Unsigned long integer value that contains the flags that // control this function. This can be set to either FTP_TRANSFER_TYPE_ASCII or // FTP_TRANSFER_TYPE_BINARY TCHAR *lpszCommand, // @pyparm string|command||The command to send to the FTP server. DWORD dwContext,// @pyparm int|context||Must be zero. PyHINTERNET *OUTPUT ); %init %{ PyDict_SetItemString(d, "error", PyWinExc_ApiError); HMODULE hmod = GetModuleHandle("wininet.dll"); assert(hmod); PyWin_RegisterErrorMessageModule(INTERNET_ERROR_BASE, INTERNET_ERROR_LAST, hmod); %} |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:40:43
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940/win32/Lib Added Files: win32inetcon.py Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. --- NEW FILE: win32inetcon.py --- # Generated by h2py from \mssdk\include\WinInet.h # Included from pshpack8.h # Included from pshpack4.h INTERNET_INVALID_PORT_NUMBER = 0 INTERNET_DEFAULT_FTP_PORT = 21 INTERNET_DEFAULT_GOPHER_PORT = 70 INTERNET_DEFAULT_HTTP_PORT = 80 INTERNET_DEFAULT_HTTPS_PORT = 443 INTERNET_DEFAULT_SOCKS_PORT = 1080 INTERNET_MAX_HOST_NAME_LENGTH = 256 INTERNET_MAX_USER_NAME_LENGTH = 128 INTERNET_MAX_PASSWORD_LENGTH = 128 INTERNET_MAX_PORT_NUMBER_LENGTH = 5 INTERNET_MAX_PORT_NUMBER_VALUE = 65535 INTERNET_MAX_PATH_LENGTH = 2048 INTERNET_MAX_SCHEME_LENGTH = 32 INTERNET_KEEP_ALIVE_ENABLED = 1 INTERNET_KEEP_ALIVE_DISABLED = 0 INTERNET_REQFLAG_FROM_CACHE = 0x00000001 INTERNET_REQFLAG_ASYNC = 0x00000002 INTERNET_REQFLAG_VIA_PROXY = 0x00000004 INTERNET_REQFLAG_NO_HEADERS = 0x00000008 INTERNET_REQFLAG_PASSIVE = 0x00000010 INTERNET_REQFLAG_CACHE_WRITE_DISABLED = 0x00000040 INTERNET_REQFLAG_NET_TIMEOUT = 0x00000080 INTERNET_FLAG_RELOAD = (-2147483648) INTERNET_FLAG_RAW_DATA = 0x40000000 INTERNET_FLAG_EXISTING_CONNECT = 0x20000000 INTERNET_FLAG_ASYNC = 0x10000000 INTERNET_FLAG_PASSIVE = 0x08000000 INTERNET_FLAG_NO_CACHE_WRITE = 0x04000000 INTERNET_FLAG_DONT_CACHE = INTERNET_FLAG_NO_CACHE_WRITE INTERNET_FLAG_MAKE_PERSISTENT = 0x02000000 INTERNET_FLAG_FROM_CACHE = 0x01000000 INTERNET_FLAG_OFFLINE = INTERNET_FLAG_FROM_CACHE INTERNET_FLAG_SECURE = 0x00800000 INTERNET_FLAG_KEEP_CONNECTION = 0x00400000 INTERNET_FLAG_NO_AUTO_REDIRECT = 0x00200000 INTERNET_FLAG_READ_PREFETCH = 0x00100000 INTERNET_FLAG_NO_COOKIES = 0x00080000 INTERNET_FLAG_NO_AUTH = 0x00040000 INTERNET_FLAG_RESTRICTED_ZONE = 0x00020000 INTERNET_FLAG_CACHE_IF_NET_FAIL = 0x00010000 INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP = 0x00008000 INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS = 0x00004000 INTERNET_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000 INTERNET_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000 INTERNET_FLAG_RESYNCHRONIZE = 0x00000800 INTERNET_FLAG_HYPERLINK = 0x00000400 INTERNET_FLAG_NO_UI = 0x00000200 INTERNET_FLAG_PRAGMA_NOCACHE = 0x00000100 INTERNET_FLAG_CACHE_ASYNC = 0x00000080 INTERNET_FLAG_FORMS_SUBMIT = 0x00000040 INTERNET_FLAG_FWD_BACK = 0x00000020 INTERNET_FLAG_NEED_FILE = 0x00000010 INTERNET_FLAG_MUST_CACHE_REQUEST = INTERNET_FLAG_NEED_FILE SECURITY_INTERNET_MASK = (INTERNET_FLAG_IGNORE_CERT_CN_INVALID | \ INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | \ INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | \ INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP ) INTERNET_ERROR_MASK_INSERT_CDROM = 0x1 INTERNET_ERROR_MASK_COMBINED_SEC_CERT = 0x2 INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG = 0X4 INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY = 0x8 WININET_API_FLAG_ASYNC = 0x00000001 WININET_API_FLAG_SYNC = 0x00000004 WININET_API_FLAG_USE_CONTEXT = 0x00000008 INTERNET_NO_CALLBACK = 0 IDSI_FLAG_KEEP_ALIVE = 0x00000001 IDSI_FLAG_SECURE = 0x00000002 IDSI_FLAG_PROXY = 0x00000004 IDSI_FLAG_TUNNEL = 0x00000008 INTERNET_PER_CONN_FLAGS = 1 INTERNET_PER_CONN_PROXY_SERVER = 2 INTERNET_PER_CONN_PROXY_BYPASS = 3 INTERNET_PER_CONN_AUTOCONFIG_URL = 4 INTERNET_PER_CONN_AUTODISCOVERY_FLAGS = 5 INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL = 6 INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS = 7 INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME = 8 INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL = 9 PROXY_TYPE_DIRECT = 0x00000001 PROXY_TYPE_PROXY = 0x00000002 PROXY_TYPE_AUTO_PROXY_URL = 0x00000004 PROXY_TYPE_AUTO_DETECT = 0x00000008 AUTO_PROXY_FLAG_USER_SET = 0x00000001 AUTO_PROXY_FLAG_ALWAYS_DETECT = 0x00000002 AUTO_PROXY_FLAG_DETECTION_RUN = 0x00000004 AUTO_PROXY_FLAG_MIGRATED = 0x00000008 AUTO_PROXY_FLAG_DONT_CACHE_PROXY_RESULT = 0x00000010 AUTO_PROXY_FLAG_CACHE_INIT_RUN = 0x00000020 AUTO_PROXY_FLAG_DETECTION_SUSPECT = 0x00000040 ISO_FORCE_DISCONNECTED = 0x00000001 INTERNET_RFC1123_FORMAT = 0 INTERNET_RFC1123_BUFSIZE = 30 ICU_ESCAPE = (-2147483648) ICU_USERNAME = 0x40000000 ICU_NO_ENCODE = 0x20000000 ICU_DECODE = 0x10000000 ICU_NO_META = 0x08000000 ICU_ENCODE_SPACES_ONLY = 0x04000000 ICU_BROWSER_MODE = 0x02000000 ICU_ENCODE_PERCENT = 0x00001000 INTERNET_OPEN_TYPE_PRECONFIG = 0 INTERNET_OPEN_TYPE_DIRECT = 1 INTERNET_OPEN_TYPE_PROXY = 3 INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 PRE_CONFIG_INTERNET_ACCESS = INTERNET_OPEN_TYPE_PRECONFIG LOCAL_INTERNET_ACCESS = INTERNET_OPEN_TYPE_DIRECT CERN_PROXY_INTERNET_ACCESS = INTERNET_OPEN_TYPE_PROXY INTERNET_SERVICE_FTP = 1 INTERNET_SERVICE_GOPHER = 2 INTERNET_SERVICE_HTTP = 3 IRF_ASYNC = WININET_API_FLAG_ASYNC IRF_SYNC = WININET_API_FLAG_SYNC IRF_USE_CONTEXT = WININET_API_FLAG_USE_CONTEXT IRF_NO_WAIT = 0x00000008 ISO_GLOBAL = 0x00000001 ISO_REGISTRY = 0x00000002 ISO_VALID_FLAGS = (ISO_GLOBAL | ISO_REGISTRY) INTERNET_OPTION_CALLBACK = 1 INTERNET_OPTION_CONNECT_TIMEOUT = 2 INTERNET_OPTION_CONNECT_RETRIES = 3 INTERNET_OPTION_CONNECT_BACKOFF = 4 INTERNET_OPTION_SEND_TIMEOUT = 5 INTERNET_OPTION_CONTROL_SEND_TIMEOUT = INTERNET_OPTION_SEND_TIMEOUT INTERNET_OPTION_RECEIVE_TIMEOUT = 6 INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT = INTERNET_OPTION_RECEIVE_TIMEOUT INTERNET_OPTION_DATA_SEND_TIMEOUT = 7 INTERNET_OPTION_DATA_RECEIVE_TIMEOUT = 8 INTERNET_OPTION_HANDLE_TYPE = 9 INTERNET_OPTION_LISTEN_TIMEOUT = 11 INTERNET_OPTION_READ_BUFFER_SIZE = 12 INTERNET_OPTION_WRITE_BUFFER_SIZE = 13 INTERNET_OPTION_ASYNC_ID = 15 INTERNET_OPTION_ASYNC_PRIORITY = 16 INTERNET_OPTION_PARENT_HANDLE = 21 INTERNET_OPTION_KEEP_CONNECTION = 22 INTERNET_OPTION_REQUEST_FLAGS = 23 INTERNET_OPTION_EXTENDED_ERROR = 24 INTERNET_OPTION_OFFLINE_MODE = 26 INTERNET_OPTION_CACHE_STREAM_HANDLE = 27 INTERNET_OPTION_USERNAME = 28 INTERNET_OPTION_PASSWORD = 29 INTERNET_OPTION_ASYNC = 30 INTERNET_OPTION_SECURITY_FLAGS = 31 INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT = 32 INTERNET_OPTION_DATAFILE_NAME = 33 INTERNET_OPTION_URL = 34 INTERNET_OPTION_SECURITY_CERTIFICATE = 35 INTERNET_OPTION_SECURITY_KEY_BITNESS = 36 INTERNET_OPTION_REFRESH = 37 INTERNET_OPTION_PROXY = 38 INTERNET_OPTION_SETTINGS_CHANGED = 39 INTERNET_OPTION_VERSION = 40 INTERNET_OPTION_USER_AGENT = 41 INTERNET_OPTION_END_BROWSER_SESSION = 42 INTERNET_OPTION_PROXY_USERNAME = 43 INTERNET_OPTION_PROXY_PASSWORD = 44 INTERNET_OPTION_CONTEXT_VALUE = 45 INTERNET_OPTION_CONNECT_LIMIT = 46 INTERNET_OPTION_SECURITY_SELECT_CLIENT_CERT = 47 INTERNET_OPTION_POLICY = 48 INTERNET_OPTION_DISCONNECTED_TIMEOUT = 49 INTERNET_OPTION_CONNECTED_STATE = 50 INTERNET_OPTION_IDLE_STATE = 51 INTERNET_OPTION_OFFLINE_SEMANTICS = 52 INTERNET_OPTION_SECONDARY_CACHE_KEY = 53 INTERNET_OPTION_CALLBACK_FILTER = 54 INTERNET_OPTION_CONNECT_TIME = 55 INTERNET_OPTION_SEND_THROUGHPUT = 56 INTERNET_OPTION_RECEIVE_THROUGHPUT = 57 INTERNET_OPTION_REQUEST_PRIORITY = 58 INTERNET_OPTION_HTTP_VERSION = 59 INTERNET_OPTION_RESET_URLCACHE_SESSION = 60 INTERNET_OPTION_ERROR_MASK = 62 INTERNET_OPTION_FROM_CACHE_TIMEOUT = 63 INTERNET_OPTION_BYPASS_EDITED_ENTRY = 64 INTERNET_OPTION_DIAGNOSTIC_SOCKET_INFO = 67 INTERNET_OPTION_CODEPAGE = 68 INTERNET_OPTION_CACHE_TIMESTAMPS = 69 INTERNET_OPTION_DISABLE_AUTODIAL = 70 INTERNET_OPTION_MAX_CONNS_PER_SERVER = 73 INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER = 74 INTERNET_OPTION_PER_CONNECTION_OPTION = 75 INTERNET_OPTION_DIGEST_AUTH_UNLOAD = 76 INTERNET_OPTION_IGNORE_OFFLINE = 77 INTERNET_OPTION_IDENTITY = 78 INTERNET_OPTION_REMOVE_IDENTITY = 79 INTERNET_OPTION_ALTER_IDENTITY = 80 INTERNET_OPTION_SUPPRESS_BEHAVIOR = 81 INTERNET_OPTION_AUTODIAL_MODE = 82 INTERNET_OPTION_AUTODIAL_CONNECTION = 83 INTERNET_OPTION_CLIENT_CERT_CONTEXT = 84 INTERNET_OPTION_AUTH_FLAGS = 85 INTERNET_OPTION_COOKIES_3RD_PARTY = 86 INTERNET_OPTION_DISABLE_PASSPORT_AUTH = 87 INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY = 88 INTERNET_OPTION_EXEMPT_CONNECTION_LIMIT = 89 INTERNET_OPTION_ENABLE_PASSPORT_AUTH = 90 INTERNET_OPTION_HIBERNATE_INACTIVE_WORKER_THREADS = 91 INTERNET_OPTION_ACTIVATE_WORKER_THREADS = 92 INTERNET_OPTION_RESTORE_WORKER_THREAD_DEFAULTS = 93 INTERNET_OPTION_SOCKET_SEND_BUFFER_LENGTH = 94 INTERNET_OPTION_PROXY_SETTINGS_CHANGED = 95 INTERNET_FIRST_OPTION = INTERNET_OPTION_CALLBACK INTERNET_LAST_OPTION = INTERNET_OPTION_PROXY_SETTINGS_CHANGED INTERNET_PRIORITY_FOREGROUND = 1000 INTERNET_HANDLE_TYPE_INTERNET = 1 INTERNET_HANDLE_TYPE_CONNECT_FTP = 2 INTERNET_HANDLE_TYPE_CONNECT_GOPHER = 3 INTERNET_HANDLE_TYPE_CONNECT_HTTP = 4 INTERNET_HANDLE_TYPE_FTP_FIND = 5 INTERNET_HANDLE_TYPE_FTP_FIND_HTML = 6 INTERNET_HANDLE_TYPE_FTP_FILE = 7 INTERNET_HANDLE_TYPE_FTP_FILE_HTML = 8 INTERNET_HANDLE_TYPE_GOPHER_FIND = 9 INTERNET_HANDLE_TYPE_GOPHER_FIND_HTML = 10 INTERNET_HANDLE_TYPE_GOPHER_FILE = 11 INTERNET_HANDLE_TYPE_GOPHER_FILE_HTML = 12 INTERNET_HANDLE_TYPE_HTTP_REQUEST = 13 INTERNET_HANDLE_TYPE_FILE_REQUEST = 14 AUTH_FLAG_DISABLE_NEGOTIATE = 0x00000001 AUTH_FLAG_ENABLE_NEGOTIATE = 0x00000002 SECURITY_FLAG_SECURE = 0x00000001 SECURITY_FLAG_STRENGTH_WEAK = 0x10000000 SECURITY_FLAG_STRENGTH_MEDIUM = 0x40000000 SECURITY_FLAG_STRENGTH_STRONG = 0x20000000 SECURITY_FLAG_UNKNOWNBIT = (-2147483648) SECURITY_FLAG_FORTEZZA = 0x08000000 SECURITY_FLAG_NORMALBITNESS = SECURITY_FLAG_STRENGTH_WEAK SECURITY_FLAG_SSL = 0x00000002 SECURITY_FLAG_SSL3 = 0x00000004 SECURITY_FLAG_PCT = 0x00000008 SECURITY_FLAG_PCT4 = 0x00000010 SECURITY_FLAG_IETFSSL4 = 0x00000020 SECURITY_FLAG_40BIT = SECURITY_FLAG_STRENGTH_WEAK SECURITY_FLAG_128BIT = SECURITY_FLAG_STRENGTH_STRONG SECURITY_FLAG_56BIT = SECURITY_FLAG_STRENGTH_MEDIUM SECURITY_FLAG_IGNORE_REVOCATION = 0x00000080 SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100 SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200 SECURITY_FLAG_IGNORE_CERT_CN_INVALID = INTERNET_FLAG_IGNORE_CERT_CN_INVALID SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = INTERNET_FLAG_IGNORE_CERT_DATE_INVALID SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTPS = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS SECURITY_FLAG_IGNORE_REDIRECT_TO_HTTP = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP SECURITY_SET_MASK = (SECURITY_FLAG_IGNORE_REVOCATION |\ SECURITY_FLAG_IGNORE_UNKNOWN_CA |\ SECURITY_FLAG_IGNORE_CERT_CN_INVALID |\ SECURITY_FLAG_IGNORE_CERT_DATE_INVALID |\ SECURITY_FLAG_IGNORE_WRONG_USAGE) AUTODIAL_MODE_NEVER = 1 AUTODIAL_MODE_ALWAYS = 2 AUTODIAL_MODE_NO_NETWORK_PRESENT = 4 INTERNET_STATUS_RESOLVING_NAME = 10 INTERNET_STATUS_NAME_RESOLVED = 11 INTERNET_STATUS_CONNECTING_TO_SERVER = 20 INTERNET_STATUS_CONNECTED_TO_SERVER = 21 INTERNET_STATUS_SENDING_REQUEST = 30 INTERNET_STATUS_REQUEST_SENT = 31 INTERNET_STATUS_RECEIVING_RESPONSE = 40 INTERNET_STATUS_RESPONSE_RECEIVED = 41 INTERNET_STATUS_CTL_RESPONSE_RECEIVED = 42 INTERNET_STATUS_PREFETCH = 43 INTERNET_STATUS_CLOSING_CONNECTION = 50 INTERNET_STATUS_CONNECTION_CLOSED = 51 INTERNET_STATUS_HANDLE_CREATED = 60 INTERNET_STATUS_HANDLE_CLOSING = 70 INTERNET_STATUS_DETECTING_PROXY = 80 INTERNET_STATUS_REQUEST_COMPLETE = 100 INTERNET_STATUS_REDIRECT = 110 INTERNET_STATUS_INTERMEDIATE_RESPONSE = 120 INTERNET_STATUS_USER_INPUT_REQUIRED = 140 INTERNET_STATUS_STATE_CHANGE = 200 INTERNET_STATUS_COOKIE_SENT = 320 INTERNET_STATUS_COOKIE_RECEIVED = 321 INTERNET_STATUS_PRIVACY_IMPACTED = 324 INTERNET_STATUS_P3P_HEADER = 325 INTERNET_STATUS_P3P_POLICYREF = 326 INTERNET_STATUS_COOKIE_HISTORY = 327 INTERNET_STATE_CONNECTED = 0x00000001 INTERNET_STATE_DISCONNECTED = 0x00000002 INTERNET_STATE_DISCONNECTED_BY_USER = 0x00000010 INTERNET_STATE_IDLE = 0x00000100 INTERNET_STATE_BUSY = 0x00000200 FTP_TRANSFER_TYPE_UNKNOWN = 0x00000000 FTP_TRANSFER_TYPE_ASCII = 0x00000001 FTP_TRANSFER_TYPE_BINARY = 0x00000002 FTP_TRANSFER_TYPE_MASK = (FTP_TRANSFER_TYPE_ASCII | FTP_TRANSFER_TYPE_BINARY) MAX_GOPHER_DISPLAY_TEXT = 128 MAX_GOPHER_SELECTOR_TEXT = 256 MAX_GOPHER_HOST_NAME = INTERNET_MAX_HOST_NAME_LENGTH MAX_GOPHER_LOCATOR_LENGTH = (1 \ + MAX_GOPHER_DISPLAY_TEXT \ + 1 \ + MAX_GOPHER_SELECTOR_TEXT \ + 1 \ + MAX_GOPHER_HOST_NAME \ + 1 \ + INTERNET_MAX_PORT_NUMBER_LENGTH \ + 1 \ + 1 \ + 2 \ ) GOPHER_TYPE_TEXT_FILE = 0x00000001 GOPHER_TYPE_DIRECTORY = 0x00000002 GOPHER_TYPE_CSO = 0x00000004 GOPHER_TYPE_ERROR = 0x00000008 GOPHER_TYPE_MAC_BINHEX = 0x00000010 GOPHER_TYPE_DOS_ARCHIVE = 0x00000020 GOPHER_TYPE_UNIX_UUENCODED = 0x00000040 GOPHER_TYPE_INDEX_SERVER = 0x00000080 GOPHER_TYPE_TELNET = 0x00000100 GOPHER_TYPE_BINARY = 0x00000200 GOPHER_TYPE_REDUNDANT = 0x00000400 GOPHER_TYPE_TN3270 = 0x00000800 GOPHER_TYPE_GIF = 0x00001000 GOPHER_TYPE_IMAGE = 0x00002000 GOPHER_TYPE_BITMAP = 0x00004000 GOPHER_TYPE_MOVIE = 0x00008000 GOPHER_TYPE_SOUND = 0x00010000 GOPHER_TYPE_HTML = 0x00020000 GOPHER_TYPE_PDF = 0x00040000 GOPHER_TYPE_CALENDAR = 0x00080000 GOPHER_TYPE_INLINE = 0x00100000 GOPHER_TYPE_UNKNOWN = 0x20000000 GOPHER_TYPE_ASK = 0x40000000 GOPHER_TYPE_GOPHER_PLUS = (-2147483648) GOPHER_TYPE_FILE_MASK = (GOPHER_TYPE_TEXT_FILE \ | GOPHER_TYPE_MAC_BINHEX \ | GOPHER_TYPE_DOS_ARCHIVE \ | GOPHER_TYPE_UNIX_UUENCODED \ | GOPHER_TYPE_BINARY \ | GOPHER_TYPE_GIF \ | GOPHER_TYPE_IMAGE \ | GOPHER_TYPE_BITMAP \ | GOPHER_TYPE_MOVIE \ | GOPHER_TYPE_SOUND \ | GOPHER_TYPE_HTML \ | GOPHER_TYPE_PDF \ | GOPHER_TYPE_CALENDAR \ | GOPHER_TYPE_INLINE \ ) MAX_GOPHER_CATEGORY_NAME = 128 MAX_GOPHER_ATTRIBUTE_NAME = 128 MIN_GOPHER_ATTRIBUTE_LENGTH = 256 GOPHER_ATTRIBUTE_ID_BASE = (-1412641792) GOPHER_CATEGORY_ID_ALL = (GOPHER_ATTRIBUTE_ID_BASE + 1) GOPHER_CATEGORY_ID_INFO = (GOPHER_ATTRIBUTE_ID_BASE + 2) GOPHER_CATEGORY_ID_ADMIN = (GOPHER_ATTRIBUTE_ID_BASE + 3) GOPHER_CATEGORY_ID_VIEWS = (GOPHER_ATTRIBUTE_ID_BASE + 4) GOPHER_CATEGORY_ID_ABSTRACT = (GOPHER_ATTRIBUTE_ID_BASE + 5) GOPHER_CATEGORY_ID_VERONICA = (GOPHER_ATTRIBUTE_ID_BASE + 6) GOPHER_CATEGORY_ID_ASK = (GOPHER_ATTRIBUTE_ID_BASE + 7) GOPHER_CATEGORY_ID_UNKNOWN = (GOPHER_ATTRIBUTE_ID_BASE + 8) GOPHER_ATTRIBUTE_ID_ALL = (GOPHER_ATTRIBUTE_ID_BASE + 9) GOPHER_ATTRIBUTE_ID_ADMIN = (GOPHER_ATTRIBUTE_ID_BASE + 10) GOPHER_ATTRIBUTE_ID_MOD_DATE = (GOPHER_ATTRIBUTE_ID_BASE + 11) GOPHER_ATTRIBUTE_ID_TTL = (GOPHER_ATTRIBUTE_ID_BASE + 12) GOPHER_ATTRIBUTE_ID_SCORE = (GOPHER_ATTRIBUTE_ID_BASE + 13) GOPHER_ATTRIBUTE_ID_RANGE = (GOPHER_ATTRIBUTE_ID_BASE + 14) GOPHER_ATTRIBUTE_ID_SITE = (GOPHER_ATTRIBUTE_ID_BASE + 15) GOPHER_ATTRIBUTE_ID_ORG = (GOPHER_ATTRIBUTE_ID_BASE + 16) GOPHER_ATTRIBUTE_ID_LOCATION = (GOPHER_ATTRIBUTE_ID_BASE + 17) GOPHER_ATTRIBUTE_ID_GEOG = (GOPHER_ATTRIBUTE_ID_BASE + 18) GOPHER_ATTRIBUTE_ID_TIMEZONE = (GOPHER_ATTRIBUTE_ID_BASE + 19) GOPHER_ATTRIBUTE_ID_PROVIDER = (GOPHER_ATTRIBUTE_ID_BASE + 20) GOPHER_ATTRIBUTE_ID_VERSION = (GOPHER_ATTRIBUTE_ID_BASE + 21) GOPHER_ATTRIBUTE_ID_ABSTRACT = (GOPHER_ATTRIBUTE_ID_BASE + 22) GOPHER_ATTRIBUTE_ID_VIEW = (GOPHER_ATTRIBUTE_ID_BASE + 23) GOPHER_ATTRIBUTE_ID_TREEWALK = (GOPHER_ATTRIBUTE_ID_BASE + 24) GOPHER_ATTRIBUTE_ID_UNKNOWN = (GOPHER_ATTRIBUTE_ID_BASE + 25) HTTP_MAJOR_VERSION = 1 HTTP_MINOR_VERSION = 0 HTTP_VERSIONA = "HTTP/1.0" HTTP_VERSION = HTTP_VERSIONA HTTP_QUERY_MIME_VERSION = 0 HTTP_QUERY_CONTENT_TYPE = 1 HTTP_QUERY_CONTENT_TRANSFER_ENCODING = 2 HTTP_QUERY_CONTENT_ID = 3 HTTP_QUERY_CONTENT_DESCRIPTION = 4 HTTP_QUERY_CONTENT_LENGTH = 5 HTTP_QUERY_CONTENT_LANGUAGE = 6 HTTP_QUERY_ALLOW = 7 HTTP_QUERY_PUBLIC = 8 HTTP_QUERY_DATE = 9 HTTP_QUERY_EXPIRES = 10 HTTP_QUERY_LAST_MODIFIED = 11 HTTP_QUERY_MESSAGE_ID = 12 HTTP_QUERY_URI = 13 HTTP_QUERY_DERIVED_FROM = 14 HTTP_QUERY_COST = 15 HTTP_QUERY_LINK = 16 HTTP_QUERY_PRAGMA = 17 HTTP_QUERY_VERSION = 18 HTTP_QUERY_STATUS_CODE = 19 HTTP_QUERY_STATUS_TEXT = 20 HTTP_QUERY_RAW_HEADERS = 21 HTTP_QUERY_RAW_HEADERS_CRLF = 22 HTTP_QUERY_CONNECTION = 23 HTTP_QUERY_ACCEPT = 24 HTTP_QUERY_ACCEPT_CHARSET = 25 HTTP_QUERY_ACCEPT_ENCODING = 26 HTTP_QUERY_ACCEPT_LANGUAGE = 27 HTTP_QUERY_AUTHORIZATION = 28 HTTP_QUERY_CONTENT_ENCODING = 29 HTTP_QUERY_FORWARDED = 30 HTTP_QUERY_FROM = 31 HTTP_QUERY_IF_MODIFIED_SINCE = 32 HTTP_QUERY_LOCATION = 33 HTTP_QUERY_ORIG_URI = 34 HTTP_QUERY_REFERER = 35 HTTP_QUERY_RETRY_AFTER = 36 HTTP_QUERY_SERVER = 37 HTTP_QUERY_TITLE = 38 HTTP_QUERY_USER_AGENT = 39 HTTP_QUERY_WWW_AUTHENTICATE = 40 HTTP_QUERY_PROXY_AUTHENTICATE = 41 HTTP_QUERY_ACCEPT_RANGES = 42 HTTP_QUERY_SET_COOKIE = 43 HTTP_QUERY_COOKIE = 44 HTTP_QUERY_REQUEST_METHOD = 45 HTTP_QUERY_REFRESH = 46 HTTP_QUERY_CONTENT_DISPOSITION = 47 HTTP_QUERY_AGE = 48 HTTP_QUERY_CACHE_CONTROL = 49 HTTP_QUERY_CONTENT_BASE = 50 HTTP_QUERY_CONTENT_LOCATION = 51 HTTP_QUERY_CONTENT_MD5 = 52 HTTP_QUERY_CONTENT_RANGE = 53 HTTP_QUERY_ETAG = 54 HTTP_QUERY_HOST = 55 HTTP_QUERY_IF_MATCH = 56 HTTP_QUERY_IF_NONE_MATCH = 57 HTTP_QUERY_IF_RANGE = 58 HTTP_QUERY_IF_UNMODIFIED_SINCE = 59 HTTP_QUERY_MAX_FORWARDS = 60 HTTP_QUERY_PROXY_AUTHORIZATION = 61 HTTP_QUERY_RANGE = 62 HTTP_QUERY_TRANSFER_ENCODING = 63 HTTP_QUERY_UPGRADE = 64 HTTP_QUERY_VARY = 65 HTTP_QUERY_VIA = 66 HTTP_QUERY_WARNING = 67 HTTP_QUERY_EXPECT = 68 HTTP_QUERY_PROXY_CONNECTION = 69 HTTP_QUERY_UNLESS_MODIFIED_SINCE = 70 HTTP_QUERY_ECHO_REQUEST = 71 HTTP_QUERY_ECHO_REPLY = 72 HTTP_QUERY_ECHO_HEADERS = 73 HTTP_QUERY_ECHO_HEADERS_CRLF = 74 HTTP_QUERY_PROXY_SUPPORT = 75 HTTP_QUERY_AUTHENTICATION_INFO = 76 HTTP_QUERY_PASSPORT_URLS = 77 HTTP_QUERY_PASSPORT_CONFIG = 78 HTTP_QUERY_MAX = 78 HTTP_QUERY_CUSTOM = 65535 HTTP_QUERY_FLAG_REQUEST_HEADERS = (-2147483648) HTTP_QUERY_FLAG_SYSTEMTIME = 0x40000000 HTTP_QUERY_FLAG_NUMBER = 0x20000000 HTTP_QUERY_FLAG_COALESCE = 0x10000000 HTTP_QUERY_MODIFIER_FLAGS_MASK = (HTTP_QUERY_FLAG_REQUEST_HEADERS \ | HTTP_QUERY_FLAG_SYSTEMTIME \ | HTTP_QUERY_FLAG_NUMBER \ | HTTP_QUERY_FLAG_COALESCE \ ) HTTP_QUERY_HEADER_MASK = (~HTTP_QUERY_MODIFIER_FLAGS_MASK) HTTP_STATUS_CONTINUE = 100 HTTP_STATUS_SWITCH_PROTOCOLS = 101 HTTP_STATUS_OK = 200 HTTP_STATUS_CREATED = 201 HTTP_STATUS_ACCEPTED = 202 HTTP_STATUS_PARTIAL = 203 HTTP_STATUS_NO_CONTENT = 204 HTTP_STATUS_RESET_CONTENT = 205 HTTP_STATUS_PARTIAL_CONTENT = 206 HTTP_STATUS_AMBIGUOUS = 300 HTTP_STATUS_MOVED = 301 HTTP_STATUS_REDIRECT = 302 HTTP_STATUS_REDIRECT_METHOD = 303 HTTP_STATUS_NOT_MODIFIED = 304 HTTP_STATUS_USE_PROXY = 305 HTTP_STATUS_REDIRECT_KEEP_VERB = 307 HTTP_STATUS_BAD_REQUEST = 400 HTTP_STATUS_DENIED = 401 HTTP_STATUS_PAYMENT_REQ = 402 HTTP_STATUS_FORBIDDEN = 403 HTTP_STATUS_NOT_FOUND = 404 HTTP_STATUS_BAD_METHOD = 405 HTTP_STATUS_NONE_ACCEPTABLE = 406 HTTP_STATUS_PROXY_AUTH_REQ = 407 HTTP_STATUS_REQUEST_TIMEOUT = 408 HTTP_STATUS_CONFLICT = 409 HTTP_STATUS_GONE = 410 HTTP_STATUS_LENGTH_REQUIRED = 411 HTTP_STATUS_PRECOND_FAILED = 412 HTTP_STATUS_REQUEST_TOO_LARGE = 413 HTTP_STATUS_URI_TOO_LONG = 414 HTTP_STATUS_UNSUPPORTED_MEDIA = 415 HTTP_STATUS_RETRY_WITH = 449 HTTP_STATUS_SERVER_ERROR = 500 HTTP_STATUS_NOT_SUPPORTED = 501 HTTP_STATUS_BAD_GATEWAY = 502 HTTP_STATUS_SERVICE_UNAVAIL = 503 HTTP_STATUS_GATEWAY_TIMEOUT = 504 HTTP_STATUS_VERSION_NOT_SUP = 505 HTTP_STATUS_FIRST = HTTP_STATUS_CONTINUE HTTP_STATUS_LAST = HTTP_STATUS_VERSION_NOT_SUP HTTP_ADDREQ_INDEX_MASK = 0x0000FFFF HTTP_ADDREQ_FLAGS_MASK = (-65536) HTTP_ADDREQ_FLAG_ADD_IF_NEW = 0x10000000 HTTP_ADDREQ_FLAG_ADD = 0x20000000 HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA = 0x40000000 HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON = 0x01000000 HTTP_ADDREQ_FLAG_COALESCE = HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA HTTP_ADDREQ_FLAG_REPLACE = (-2147483648) HSR_ASYNC = WININET_API_FLAG_ASYNC HSR_SYNC = WININET_API_FLAG_SYNC HSR_USE_CONTEXT = WININET_API_FLAG_USE_CONTEXT HSR_INITIATE = 0x00000008 HSR_DOWNLOAD = 0x00000010 HSR_CHUNKED = 0x00000020 INTERNET_COOKIE_IS_SECURE = 0x01 INTERNET_COOKIE_IS_SESSION = 0x02 INTERNET_COOKIE_THIRD_PARTY = 0x10 INTERNET_COOKIE_PROMPT_REQUIRED = 0x20 INTERNET_COOKIE_EVALUATE_P3P = 0x40 INTERNET_COOKIE_APPLY_P3P = 0x80 INTERNET_COOKIE_P3P_ENABLED = 0x100 INTERNET_COOKIE_IS_RESTRICTED = 0x200 INTERNET_COOKIE_IE6 = 0x400 INTERNET_COOKIE_IS_LEGACY = 0x800 FLAG_ICC_FORCE_CONNECTION = 0x00000001 FLAGS_ERROR_UI_FILTER_FOR_ERRORS = 0x01 FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS = 0x02 FLAGS_ERROR_UI_FLAGS_GENERATE_DATA = 0x04 FLAGS_ERROR_UI_FLAGS_NO_UI = 0x08 FLAGS_ERROR_UI_SERIALIZE_DIALOGS = 0x10 INTERNET_ERROR_BASE = 12000 ERROR_INTERNET_OUT_OF_HANDLES = (INTERNET_ERROR_BASE + 1) ERROR_INTERNET_TIMEOUT = (INTERNET_ERROR_BASE + 2) ERROR_INTERNET_EXTENDED_ERROR = (INTERNET_ERROR_BASE + 3) ERROR_INTERNET_INTERNAL_ERROR = (INTERNET_ERROR_BASE + 4) ERROR_INTERNET_INVALID_URL = (INTERNET_ERROR_BASE + 5) ERROR_INTERNET_UNRECOGNIZED_SCHEME = (INTERNET_ERROR_BASE + 6) ERROR_INTERNET_NAME_NOT_RESOLVED = (INTERNET_ERROR_BASE + 7) ERROR_INTERNET_PROTOCOL_NOT_FOUND = (INTERNET_ERROR_BASE + 8) ERROR_INTERNET_INVALID_OPTION = (INTERNET_ERROR_BASE + 9) ERROR_INTERNET_BAD_OPTION_LENGTH = (INTERNET_ERROR_BASE + 10) ERROR_INTERNET_OPTION_NOT_SETTABLE = (INTERNET_ERROR_BASE + 11) ERROR_INTERNET_SHUTDOWN = (INTERNET_ERROR_BASE + 12) ERROR_INTERNET_INCORRECT_USER_NAME = (INTERNET_ERROR_BASE + 13) ERROR_INTERNET_INCORRECT_PASSWORD = (INTERNET_ERROR_BASE + 14) ERROR_INTERNET_LOGIN_FAILURE = (INTERNET_ERROR_BASE + 15) ERROR_INTERNET_INVALID_OPERATION = (INTERNET_ERROR_BASE + 16) ERROR_INTERNET_OPERATION_CANCELLED = (INTERNET_ERROR_BASE + 17) ERROR_INTERNET_INCORRECT_HANDLE_TYPE = (INTERNET_ERROR_BASE + 18) ERROR_INTERNET_INCORRECT_HANDLE_STATE = (INTERNET_ERROR_BASE + 19) ERROR_INTERNET_NOT_PROXY_REQUEST = (INTERNET_ERROR_BASE + 20) ERROR_INTERNET_REGISTRY_VALUE_NOT_FOUND = (INTERNET_ERROR_BASE + 21) ERROR_INTERNET_BAD_REGISTRY_PARAMETER = (INTERNET_ERROR_BASE + 22) ERROR_INTERNET_NO_DIRECT_ACCESS = (INTERNET_ERROR_BASE + 23) ERROR_INTERNET_NO_CONTEXT = (INTERNET_ERROR_BASE + 24) ERROR_INTERNET_NO_CALLBACK = (INTERNET_ERROR_BASE + 25) ERROR_INTERNET_REQUEST_PENDING = (INTERNET_ERROR_BASE + 26) ERROR_INTERNET_INCORRECT_FORMAT = (INTERNET_ERROR_BASE + 27) ERROR_INTERNET_ITEM_NOT_FOUND = (INTERNET_ERROR_BASE + 28) ERROR_INTERNET_CANNOT_CONNECT = (INTERNET_ERROR_BASE + 29) ERROR_INTERNET_CONNECTION_ABORTED = (INTERNET_ERROR_BASE + 30) ERROR_INTERNET_CONNECTION_RESET = (INTERNET_ERROR_BASE + 31) ERROR_INTERNET_FORCE_RETRY = (INTERNET_ERROR_BASE + 32) ERROR_INTERNET_INVALID_PROXY_REQUEST = (INTERNET_ERROR_BASE + 33) ERROR_INTERNET_NEED_UI = (INTERNET_ERROR_BASE + 34) ERROR_INTERNET_HANDLE_EXISTS = (INTERNET_ERROR_BASE + 36) ERROR_INTERNET_SEC_CERT_DATE_INVALID = (INTERNET_ERROR_BASE + 37) ERROR_INTERNET_SEC_CERT_CN_INVALID = (INTERNET_ERROR_BASE + 38) ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR = (INTERNET_ERROR_BASE + 39) ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR = (INTERNET_ERROR_BASE + 40) ERROR_INTERNET_MIXED_SECURITY = (INTERNET_ERROR_BASE + 41) ERROR_INTERNET_CHG_POST_IS_NON_SECURE = (INTERNET_ERROR_BASE + 42) ERROR_INTERNET_POST_IS_NON_SECURE = (INTERNET_ERROR_BASE + 43) ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED = (INTERNET_ERROR_BASE + 44) ERROR_INTERNET_INVALID_CA = (INTERNET_ERROR_BASE + 45) ERROR_INTERNET_CLIENT_AUTH_NOT_SETUP = (INTERNET_ERROR_BASE + 46) ERROR_INTERNET_ASYNC_THREAD_FAILED = (INTERNET_ERROR_BASE + 47) ERROR_INTERNET_REDIRECT_SCHEME_CHANGE = (INTERNET_ERROR_BASE + 48) ERROR_INTERNET_DIALOG_PENDING = (INTERNET_ERROR_BASE + 49) ERROR_INTERNET_RETRY_DIALOG = (INTERNET_ERROR_BASE + 50) ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR = (INTERNET_ERROR_BASE + 52) ERROR_INTERNET_INSERT_CDROM = (INTERNET_ERROR_BASE + 53) ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED = (INTERNET_ERROR_BASE + 54) ERROR_INTERNET_SEC_CERT_ERRORS = (INTERNET_ERROR_BASE + 55) ERROR_INTERNET_SEC_CERT_NO_REV = (INTERNET_ERROR_BASE + 56) ERROR_INTERNET_SEC_CERT_REV_FAILED = (INTERNET_ERROR_BASE + 57) ERROR_FTP_TRANSFER_IN_PROGRESS = (INTERNET_ERROR_BASE + 110) ERROR_FTP_DROPPED = (INTERNET_ERROR_BASE + 111) ERROR_FTP_NO_PASSIVE_MODE = (INTERNET_ERROR_BASE + 112) ERROR_GOPHER_PROTOCOL_ERROR = (INTERNET_ERROR_BASE + 130) ERROR_GOPHER_NOT_FILE = (INTERNET_ERROR_BASE + 131) ERROR_GOPHER_DATA_ERROR = (INTERNET_ERROR_BASE + 132) ERROR_GOPHER_END_OF_DATA = (INTERNET_ERROR_BASE + 133) ERROR_GOPHER_INVALID_LOCATOR = (INTERNET_ERROR_BASE + 134) ERROR_GOPHER_INCORRECT_LOCATOR_TYPE = (INTERNET_ERROR_BASE + 135) ERROR_GOPHER_NOT_GOPHER_PLUS = (INTERNET_ERROR_BASE + 136) ERROR_GOPHER_ATTRIBUTE_NOT_FOUND = (INTERNET_ERROR_BASE + 137) ERROR_GOPHER_UNKNOWN_LOCATOR = (INTERNET_ERROR_BASE + 138) ERROR_HTTP_HEADER_NOT_FOUND = (INTERNET_ERROR_BASE + 150) ERROR_HTTP_DOWNLEVEL_SERVER = (INTERNET_ERROR_BASE + 151) ERROR_HTTP_INVALID_SERVER_RESPONSE = (INTERNET_ERROR_BASE + 152) ERROR_HTTP_INVALID_HEADER = (INTERNET_ERROR_BASE + 153) ERROR_HTTP_INVALID_QUERY_REQUEST = (INTERNET_ERROR_BASE + 154) ERROR_HTTP_HEADER_ALREADY_EXISTS = (INTERNET_ERROR_BASE + 155) ERROR_HTTP_REDIRECT_FAILED = (INTERNET_ERROR_BASE + 156) ERROR_HTTP_NOT_REDIRECTED = (INTERNET_ERROR_BASE + 160) ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION = (INTERNET_ERROR_BASE + 161) ERROR_HTTP_COOKIE_DECLINED = (INTERNET_ERROR_BASE + 162) ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION = (INTERNET_ERROR_BASE + 168) ERROR_INTERNET_SECURITY_CHANNEL_ERROR = (INTERNET_ERROR_BASE + 157) ERROR_INTERNET_UNABLE_TO_CACHE_FILE = (INTERNET_ERROR_BASE + 158) ERROR_INTERNET_TCPIP_NOT_INSTALLED = (INTERNET_ERROR_BASE + 159) ERROR_INTERNET_DISCONNECTED = (INTERNET_ERROR_BASE + 163) ERROR_INTERNET_SERVER_UNREACHABLE = (INTERNET_ERROR_BASE + 164) ERROR_INTERNET_PROXY_SERVER_UNREACHABLE = (INTERNET_ERROR_BASE + 165) ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT = (INTERNET_ERROR_BASE + 166) ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT = (INTERNET_ERROR_BASE + 167) ERROR_INTERNET_SEC_INVALID_CERT = (INTERNET_ERROR_BASE + 169) ERROR_INTERNET_SEC_CERT_REVOKED = (INTERNET_ERROR_BASE + 170) ERROR_INTERNET_FAILED_DUETOSECURITYCHECK = (INTERNET_ERROR_BASE + 171) ERROR_INTERNET_NOT_INITIALIZED = (INTERNET_ERROR_BASE + 172) ERROR_INTERNET_NEED_MSN_SSPI_PKG = (INTERNET_ERROR_BASE + 173) ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY = (INTERNET_ERROR_BASE + 174) INTERNET_ERROR_LAST = ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY NORMAL_CACHE_ENTRY = 0x00000001 STICKY_CACHE_ENTRY = 0x00000004 EDITED_CACHE_ENTRY = 0x00000008 TRACK_OFFLINE_CACHE_ENTRY = 0x00000010 TRACK_ONLINE_CACHE_ENTRY = 0x00000020 SPARSE_CACHE_ENTRY = 0x00010000 COOKIE_CACHE_ENTRY = 0x00100000 URLHISTORY_CACHE_ENTRY = 0x00200000 URLCACHE_FIND_DEFAULT_FILTER = NORMAL_CACHE_ENTRY \ | COOKIE_CACHE_ENTRY \ | URLHISTORY_CACHE_ENTRY \ | TRACK_OFFLINE_CACHE_ENTRY \ | TRACK_ONLINE_CACHE_ENTRY \ | STICKY_CACHE_ENTRY CACHEGROUP_ATTRIBUTE_GET_ALL = (-1) CACHEGROUP_ATTRIBUTE_BASIC = 0x00000001 CACHEGROUP_ATTRIBUTE_FLAG = 0x00000002 CACHEGROUP_ATTRIBUTE_TYPE = 0x00000004 CACHEGROUP_ATTRIBUTE_QUOTA = 0x00000008 CACHEGROUP_ATTRIBUTE_GROUPNAME = 0x00000010 CACHEGROUP_ATTRIBUTE_STORAGE = 0x00000020 CACHEGROUP_FLAG_NONPURGEABLE = 0x00000001 CACHEGROUP_FLAG_GIDONLY = 0x00000004 CACHEGROUP_FLAG_FLUSHURL_ONDELETE = 0x00000002 CACHEGROUP_SEARCH_ALL = 0x00000000 CACHEGROUP_SEARCH_BYURL = 0x00000001 CACHEGROUP_TYPE_INVALID = 0x00000001 CACHEGROUP_READWRITE_MASK = \ CACHEGROUP_ATTRIBUTE_TYPE \ | CACHEGROUP_ATTRIBUTE_QUOTA \ | CACHEGROUP_ATTRIBUTE_GROUPNAME \ | CACHEGROUP_ATTRIBUTE_STORAGE GROUPNAME_MAX_LENGTH = 120 GROUP_OWNER_STORAGE_SIZE = 4 CACHE_ENTRY_ATTRIBUTE_FC = 0x00000004 CACHE_ENTRY_HITRATE_FC = 0x00000010 CACHE_ENTRY_MODTIME_FC = 0x00000040 CACHE_ENTRY_EXPTIME_FC = 0x00000080 CACHE_ENTRY_ACCTIME_FC = 0x00000100 CACHE_ENTRY_SYNCTIME_FC = 0x00000200 CACHE_ENTRY_HEADERINFO_FC = 0x00000400 CACHE_ENTRY_EXEMPT_DELTA_FC = 0x00000800 INTERNET_CACHE_GROUP_ADD = 0 INTERNET_CACHE_GROUP_REMOVE = 1 INTERNET_DIAL_FORCE_PROMPT = 0x2000 INTERNET_DIAL_SHOW_OFFLINE = 0x4000 INTERNET_DIAL_UNATTENDED = 0x8000 INTERENT_GOONLINE_REFRESH = 0x00000001 INTERENT_GOONLINE_MASK = 0x00000001 INTERNET_AUTODIAL_FORCE_ONLINE = 1 INTERNET_AUTODIAL_FORCE_UNATTENDED = 2 INTERNET_AUTODIAL_FAILIFSECURITYCHECK = 4 INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT = 8 INTERNET_AUTODIAL_FLAGS_MASK = (INTERNET_AUTODIAL_FORCE_ONLINE | INTERNET_AUTODIAL_FORCE_UNATTENDED | INTERNET_AUTODIAL_FAILIFSECURITYCHECK | INTERNET_AUTODIAL_OVERRIDE_NET_PRESENT) PROXY_AUTO_DETECT_TYPE_DHCP = 1 PROXY_AUTO_DETECT_TYPE_DNS_A = 2 INTERNET_CONNECTION_MODEM = 0x01 INTERNET_CONNECTION_LAN = 0x02 INTERNET_CONNECTION_PROXY = 0x04 INTERNET_CONNECTION_MODEM_BUSY = 0x08 INTERNET_RAS_INSTALLED = 0x10 INTERNET_CONNECTION_OFFLINE = 0x20 INTERNET_CONNECTION_CONFIGURED = 0x40 INTERNET_CUSTOMDIAL_CONNECT = 0 INTERNET_CUSTOMDIAL_UNATTENDED = 1 INTERNET_CUSTOMDIAL_DISCONNECT = 2 INTERNET_CUSTOMDIAL_SHOWOFFLINE = 4 INTERNET_CUSTOMDIAL_SAFE_FOR_UNATTENDED = 1 INTERNET_CUSTOMDIAL_WILL_SUPPLY_STATE = 2 INTERNET_CUSTOMDIAL_CAN_HANGUP = 4 INTERNET_DIALSTATE_DISCONNECTED = 1 INTERNET_IDENTITY_FLAG_PRIVATE_CACHE = 0x01 INTERNET_IDENTITY_FLAG_SHARED_CACHE = 0x02 INTERNET_IDENTITY_FLAG_CLEAR_DATA = 0x04 INTERNET_IDENTITY_FLAG_CLEAR_COOKIES = 0x08 INTERNET_IDENTITY_FLAG_CLEAR_HISTORY = 0x10 INTERNET_IDENTITY_FLAG_CLEAR_CONTENT = 0x20 INTERNET_SUPPRESS_RESET_ALL = 0x00 INTERNET_SUPPRESS_COOKIE_POLICY = 0x01 INTERNET_SUPPRESS_COOKIE_POLICY_RESET = 0x02 PRIVACY_TEMPLATE_NO_COOKIES = 0 PRIVACY_TEMPLATE_HIGH = 1 PRIVACY_TEMPLATE_MEDIUM_HIGH = 2 PRIVACY_TEMPLATE_MEDIUM = 3 PRIVACY_TEMPLATE_MEDIUM_LOW = 4 PRIVACY_TEMPLATE_LOW = 5 PRIVACY_TEMPLATE_CUSTOM = 100 PRIVACY_TEMPLATE_ADVANCED = 101 PRIVACY_TEMPLATE_MAX = PRIVACY_TEMPLATE_LOW PRIVACY_TYPE_FIRST_PARTY = 0 PRIVACY_TYPE_THIRD_PARTY = 1 # Included from poppack.h |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:40:43
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940/win32/test Added Files: test_win32inet.py Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. --- NEW FILE: test_win32inet.py --- from win32inet import * from win32inetcon import * import unittest class CookieTests(unittest.TestCase): def testCookies(self): data = "TestData=Test" InternetSetCookie("http://www.python.org", None, data) got = InternetGetCookie("http://www.python.org", None) self.assertEqual(got, data) class UrlTests(unittest.TestCase): def testSimpleCanonicalize(self): ret = InternetCanonicalizeUrl("foo bar") self.assertEqual(ret, "foo%20bar") def testLongCanonicalize(self): # a 4k URL causes the underlying API to request a bigger buffer" big = "x" * 2048 ret = InternetCanonicalizeUrl(big + " " + big) self.assertEqual(ret, big + "%20" + big) class TestNetwork(unittest.TestCase): def setUp(self): self.hi = InternetOpen("test", INTERNET_OPEN_TYPE_DIRECT, None, None, 0) def tearDown(self): self.hi.Close() def testPythonDotOrg(self): hdl = InternetOpenUrl(self.hi, "http://www.python.org", None, INTERNET_FLAG_EXISTING_CONNECT) chunks = [] while 1: chunk = InternetReadFile(hdl, 1024) if not chunk: break chunks.append(chunk) data = ''.join(chunks) assert data.find("Python")>0, repr(data) # This must appear somewhere on the main page! def testFtpCommand(self): hcon = InternetConnect(self.hi, "ftp.python.org", INTERNET_INVALID_PORT_NUMBER, None, None, # username/password INTERNET_SERVICE_FTP, 0, 0) try: try: hftp = FtpCommand(hcon, True, FTP_TRANSFER_TYPE_ASCII, 'NLST', 0) except error: print "Error info is", InternetGetLastResponseInfo() InternetReadFile(hftp, 2048) hftp.Close() finally: hcon.Close() if __name__=='__main__': unittest.main() |
|
From: Mark H. <mha...@us...> - 2004-06-12 13:40:42
|
Update of /cvsroot/pywin32/pywin32/win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11940/win32 Added Files: win32inet.dsp Log Message: New win32inet and win32inetcon modules - extensions to the wininet "Internet" APIs. --- NEW FILE: win32inet.dsp --- # Microsoft Developer Studio Project File - Name="win32inet" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=win32inet - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "win32inet.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "win32inet.mak" CFG="win32inet - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "win32inet - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "win32inet - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "win32inet - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\win32inet\Release" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "win32inet_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "win32inet_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" # ADD RSC /l 0xc09 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "win32inet - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Build" # PROP Intermediate_Dir "Build\Temp\win32inet\Release" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "win32inet_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "win32inet_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "_DEBUG" # ADD RSC /l 0xc09 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "win32inet - Win32 Release" # Name "win32inet - Win32 Debug" # Begin Source File SOURCE=.\src\win32inet.i !IF "$(CFG)" == "win32inet - Win32 Release" # Begin Custom Build - Invoking SWIG... InputDir=.\src InputPath=.\src\win32inet.i InputName=win32inet "$(InputDir)\$(InputName)module_win32.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ..\swig.bat $(InputDir) -python -dnone -c++ -o $(InputName)module_win32.cpp $(InputName).i # End Custom Build !ELSEIF "$(CFG)" == "win32inet - Win32 Debug" # Begin Custom Build - Invoking SWIG... InputDir=.\src InputPath=.\src\win32inet.i InputName=win32inet "$(InputDir)\$(InputName)module_win32.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" ..\swig.bat $(InputDir) -python -dnone -c++ -o $(InputName)module_win32.cpp $(InputName).i # End Custom Build !ENDIF # End Source File # Begin Source File SOURCE=.\src\win32inetmodule.cpp # End Source File # End Target # End Project |