Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1:/tmp/cvs-serv26261
Modified Files:
PythonService.cpp win32evtlog.i win32service.i
Log Message:
Don't use BSTR when we mean WCHAR/TCHAR
Index: PythonService.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** PythonService.cpp 8 Nov 2003 00:56:36 -0000 1.10
--- PythonService.cpp 8 Nov 2003 12:34:45 -0000 1.11
***************
*** 142,147 ****
static PyObject *DoLogMessage(WORD errorType, PyObject *obMsg)
{
! BSTR msg;
! if (!PyWinObject_AsBstr(obMsg, &msg))
return NULL;
DWORD errorCode = errorType==EVENTLOG_ERROR_TYPE ? PYS_E_GENERIC_ERROR : PYS_E_GENERIC_WARNING;
--- 142,147 ----
static PyObject *DoLogMessage(WORD errorType, PyObject *obMsg)
{
! WCHAR *msg;
! if (!PyWinObject_AsWCHAR(obMsg, &msg))
return NULL;
DWORD errorCode = errorType==EVENTLOG_ERROR_TYPE ? PYS_E_GENERIC_ERROR : PYS_E_GENERIC_WARNING;
***************
*** 150,154 ****
Py_BEGIN_ALLOW_THREADS
ok = ReportError(errorCode, inserts, errorType);
! SysFreeString(msg);
Py_END_ALLOW_THREADS
if (!ok)
--- 150,154 ----
Py_BEGIN_ALLOW_THREADS
ok = ReportError(errorCode, inserts, errorType);
! PyWinObject_FreeWCHAR(msg);
Py_END_ALLOW_THREADS
if (!ok)
***************
*** 184,188 ****
goto cleanup;
}
! memset(pStrings, 0, sizeof(BSTR *)*(numStrings+1)); // this also terminates array!
for (int i=0;i<numStrings;i++) {
PyObject *obString = PySequence_GetItem(obStrings, i);
--- 184,188 ----
goto cleanup;
}
! memset(pStrings, 0, sizeof(TCHAR *)*(numStrings+1)); // this also terminates array!
for (int i=0;i<numStrings;i++) {
PyObject *obString = PySequence_GetItem(obStrings, i);
***************
*** 260,270 ****
return NULL;
}
! BSTR bstrName;
! if (!PyWinObject_AsBstr(nameOb, &bstrName))
return NULL;
! PY_SERVICE_TABLE_ENTRY *pe = FindPythonServiceEntry(bstrName);
if (pe==NULL) {
PyErr_SetString(PyExc_ValueError, "The service name is not hosted by this process");
! SysFreeString(bstrName);
return NULL;
}
--- 260,270 ----
return NULL;
}
! WCHAR *szName;
! if (!PyWinObject_AsWCHAR(nameOb, &szName))
return NULL;
! PY_SERVICE_TABLE_ENTRY *pe = FindPythonServiceEntry(szName);
if (pe==NULL) {
PyErr_SetString(PyExc_ValueError, "The service name is not hosted by this process");
! PyWinObject_FreeWCHAR(szName);
return NULL;
}
***************
*** 276,281 ****
return Py_None;
}
! pe->sshStatusHandle = RegisterServiceCtrlHandlerEx(bstrName, service_ctrl_ex, pe);
! SysFreeString(bstrName);
PyObject *rc;
if (pe->sshStatusHandle==0) {
--- 276,281 ----
return Py_None;
}
! pe->sshStatusHandle = RegisterServiceCtrlHandlerEx(szName, service_ctrl_ex, pe);
! PyWinObject_FreeWCHAR(szName);
PyObject *rc;
if (pe->sshStatusHandle==0) {
Index: win32evtlog.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32evtlog.i,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** win32evtlog.i 2 Mar 2000 11:03:38 -0000 1.4
--- win32evtlog.i 8 Nov 2003 12:34:45 -0000 1.5
***************
*** 257,261 ****
goto cleanup;
}
! memset(pStrings, 0, sizeof(BSTR *)*numStrings);
for (i=0;i<numStrings;i++) {
PyObject *obString = PySequence_GetItem(obStrings, i);
--- 257,261 ----
goto cleanup;
}
! memset(pStrings, 0, sizeof(WCHAR *)*numStrings);
for (i=0;i<numStrings;i++) {
PyObject *obString = PySequence_GetItem(obStrings, i);
***************
*** 263,267 ****
goto cleanup;
}
! BOOL ok = PyWinObject_AsBstr(obString, pStrings+i);
Py_XDECREF(obString);
if (!ok)
--- 263,267 ----
goto cleanup;
}
! BOOL ok = PyWinObject_AsWCHAR(obString, pStrings+i);
Py_XDECREF(obString);
if (!ok)
***************
*** 295,299 ****
if (pStrings) {
for (i=0;i<numStrings;i++)
! SysFreeString(pStrings[i]);
delete [] pStrings;
}
--- 295,299 ----
if (pStrings) {
for (i=0;i<numStrings;i++)
! PyWinObject_FreeWCHAR(pStrings[i]);
delete [] pStrings;
}
***************
*** 373,378 ****
// @pyswig int|OpenEventLog|Opens an event log.
%name (OpenEventLog) HANDLE OpenEventLogW (
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|serverName||The server name, or None
! %val PyWin_AutoFreeBstr &inWideString // @pyparm <o PyUnicode>|sourceName||specifies the name of the source that the returned handle will reference. The source name must be a subkey of a logfile entry under the EventLog key in the registry.
);
--- 373,378 ----
// @pyswig int|OpenEventLog|Opens an event log.
%name (OpenEventLog) HANDLE OpenEventLogW (
! WCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|serverName||The server name, or None
! WCHAR *sourceName // @pyparm <o PyUnicode>|sourceName||specifies the name of the source that the returned handle will reference. The source name must be a subkey of a logfile entry under the EventLog key in the registry.
);
***************
*** 380,385 ****
%name (RegisterEventSource) HANDLE
RegisterEventSourceW (
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|serverName||The server name, or None
! %val PyWin_AutoFreeBstr &inWideString // @pyparm <o PyUnicode>|sourceName||The source name
);
--- 380,385 ----
%name (RegisterEventSource) HANDLE
RegisterEventSourceW (
! WCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|serverName||The server name, or None
! WCHAR *sourceName // @pyparm <o PyUnicode>|sourceName||The source name
);
***************
*** 387,392 ****
// @pyswig int|OpenBackupEventLog|Opens a previously saved event log.
%name (OpenBackupEventLog) HANDLE OpenBackupEventLogW (
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|serverName||The server name, or None
! %val PyWin_AutoFreeBstr &inWideString // @pyparm <o PyUnicode>|fileName||The filename to open
);
--- 387,392 ----
// @pyswig int|OpenBackupEventLog|Opens a previously saved event log.
%name (OpenBackupEventLog) HANDLE OpenBackupEventLogW (
! WCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|serverName||The server name, or None
! WCHAR *fileName // @pyparm <o PyUnicode>|fileName||The filename to open
);
Index: win32service.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** win32service.i 30 Jul 2002 22:50:14 -0000 1.3
--- win32service.i 8 Nov 2003 12:34:45 -0000 1.4
***************
*** 45,57 ****
PyObject *obString = PySequence_GetItem(obDeps, i);
BSTR pStr;
! if (!PyWinObject_AsBstr(obString, &pStr)) {
Py_DECREF(obString);
goto cleanup;
}
! int len = SysStringLen(pStr);
_tcsncpy(p, pStr, len);
p += len;
*p++ = L'\0';
! SysFreeString(pStr);
Py_DECREF(obString);
}
--- 45,57 ----
PyObject *obString = PySequence_GetItem(obDeps, i);
BSTR pStr;
! if (!PyWinObject_AsTCHAR(obString, &pStr)) {
Py_DECREF(obString);
goto cleanup;
}
! int len = _tcslen(pStr);
_tcsncpy(p, pStr, len);
p += len;
*p++ = L'\0';
! PyWinObject_FreeTCHAR(pStr);
Py_DECREF(obString);
}
***************
*** 171,175 ****
}
pArgs[i] = NULL;
! PyWinObject_AsBstr(obString, pArgs+i);
Py_DECREF(obString);
}
--- 171,175 ----
}
pArgs[i] = NULL;
! PyWinObject_AsTCHAR(obString, pArgs+i);
Py_DECREF(obString);
}
***************
*** 182,186 ****
rc = PyWin_SetAPIError("StartService");
for (DWORD i=0;i<numStrings;i++)
! SysFreeString(pArgs[i]);
delete [] pArgs;
return rc;
--- 182,186 ----
rc = PyWin_SetAPIError("StartService");
for (DWORD i=0;i<numStrings;i++)
! PyWinObject_FreeTCHAR(pArgs[i]);
delete [] pArgs;
return rc;
***************
*** 432,442 ****
SC_HANDLE OpenService(
SC_HANDLE hSCManager, // @pyparm int|scHandle||Handle to the Service Control Mananger
! %val PyWin_AutoFreeBstr &inWideString, // @pyparm <o PyUnicode>|name||The name of the service to open.
unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired.
// @pyswig int|OpenSCManager|Returns a handle to the service control manager
SC_HANDLE OpenSCManager(
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|machineName||The name of the computer, or None
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|dbName||The name of the service database, or None
unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired.
--- 432,442 ----
SC_HANDLE OpenService(
SC_HANDLE hSCManager, // @pyparm int|scHandle||Handle to the Service Control Mananger
! TCHAR *name, // @pyparm <o PyUnicode>|name||The name of the service to open.
unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired.
// @pyswig int|OpenSCManager|Returns a handle to the service control manager
SC_HANDLE OpenSCManager(
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|machineName||The name of the computer, or None
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|dbName||The name of the service database, or None
unsigned long desiredAccess); // @pyparm int|desiredAccess||The access desired.
***************
*** 467,482 ****
%name (CreateService) PyObject * MyCreateService(
SC_HANDLE hSCManager, // @pyparm int|scHandle||handle to service control manager database
! %val PyWin_AutoFreeBstr &inWideString, // @pyparm <o PyUnicode>|name||Name of service
! %val PyWin_AutoFreeBstr &inWideString, // @pyparm <o PyUnicode>|displayName||Display name
DWORD dwDesiredAccess, // @pyparm int|desiredAccess||type of access to service
DWORD dwServiceType, // @pyparm int|serviceType||type of service
DWORD dwStartType, // @pyparm int|startType||When/how to start service
DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start
! %val PyWin_AutoFreeBstr &inWideString, // @pyparm <o PyUnicode>|binaryFile||name of binary file
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|loadOrderGroup||name of load ordering group , or None
BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is a tuple of (handle, tag), otherwise just handle.
PyObject *pyobject, // @pyparm [<o PyUnicode>,...]|serviceDeps||sequence of dependency names
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|acctName||account name of service, or None
! %val PyWin_AutoFreeBstr &inNullWideString // @pyparm <o PyUnicode>|password||password for service account , or None
);
--- 467,482 ----
%name (CreateService) PyObject * MyCreateService(
SC_HANDLE hSCManager, // @pyparm int|scHandle||handle to service control manager database
! TCHAR *name, // @pyparm <o PyUnicode>|name||Name of service
! TCHAR *displayName, // @pyparm <o PyUnicode>|displayName||Display name
DWORD dwDesiredAccess, // @pyparm int|desiredAccess||type of access to service
DWORD dwServiceType, // @pyparm int|serviceType||type of service
DWORD dwStartType, // @pyparm int|startType||When/how to start service
DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start
! TCHAR *binaryFile, // @pyparm <o PyUnicode>|binaryFile||name of binary file
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|loadOrderGroup||name of load ordering group , or None
BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is a tuple of (handle, tag), otherwise just handle.
PyObject *pyobject, // @pyparm [<o PyUnicode>,...]|serviceDeps||sequence of dependency names
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|acctName||account name of service, or None
! TCHAR *INPUT_NULLOK // @pyparm <o PyUnicode>|password||password for service account , or None
);
***************
*** 487,497 ****
DWORD dwStartType, // @pyparm int|startType||When/how to start service, or SERVICE_NO_CHANGE
DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start, or SERVICE_NO_CHANGE
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|binaryFile||name of binary file, or None
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|loadOrderGroup||name of load ordering group , or None
BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is the tag, else None.
PyObject *pyobject, // @pyparm [<o PyUnicode>,...]|serviceDeps||sequence of dependency names
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|acctName||account name of service, or None
! %val PyWin_AutoFreeBstr &inNullWideString, // @pyparm <o PyUnicode>|password||password for service account , or None
! %val PyWin_AutoFreeBstr &inNullWideString // @pyparm <o PyUnicode>|displayName||Display name
);
--- 487,497 ----
DWORD dwStartType, // @pyparm int|startType||When/how to start service, or SERVICE_NO_CHANGE
DWORD dwErrorControl, // @pyparm int|errorControl||severity if service fails to start, or SERVICE_NO_CHANGE
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|binaryFile||name of binary file, or None
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|loadOrderGroup||name of load ordering group , or None
BOOL bFetchTag, // @pyparm int|bFetchTag||Should the tag be fetched and returned? If TRUE, the result is the tag, else None.
PyObject *pyobject, // @pyparm [<o PyUnicode>,...]|serviceDeps||sequence of dependency names
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|acctName||account name of service, or None
! TCHAR *INPUT_NULLOK, // @pyparm <o PyUnicode>|password||password for service account , or None
! TCHAR *INPUT_NULLOK // @pyparm <o PyUnicode>|displayName||Display name
);
|