Update of /cvsroot/pywin32/pywin32/win32/src/win32print
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29969/win32/src/win32print
Modified Files:
win32print.cpp
Log Message:
Change EnumPrintProcessors to unicode
Index: win32print.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** win32print.cpp 13 Feb 2005 22:42:41 -0000 1.18
--- win32print.cpp 14 Feb 2005 15:06:52 -0000 1.19
***************
*** 1087,1122 ****
}
! // @pymethod (string,...)|win32print|EnumPrintProcessors|List printer processors for specified server and environment
static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args)
{
! PRINTPROCESSOR_INFO_1 *info=NULL; // currently only level that exists
LPBYTE buf=NULL;
! char *servername=NULL, *environment=NULL;
DWORD level=1, bufsize=0, bytes_needed, return_cnt;
! PyObject *ret, *tuple_item;
! // @pyparm string|Server|None|Name of print server, use None for local machine
! // @pyparm string|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment
! if (!PyArg_ParseTuple(args,"|zz:EnumPrintProcessors", &servername, &environment))
return NULL;
!
! EnumPrintProcessors(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt);
if (bytes_needed==0){
PyWin_SetAPIError("EnumPrintProcessors");
! return NULL;
}
buf=(LPBYTE)malloc(bytes_needed);
if (buf==NULL){
PyErr_Format(PyExc_MemoryError,"EnumPrintProcessors: unable to allocate buffer of size %d", bytes_needed);
! return NULL;
}
bufsize=bytes_needed;
! if (!EnumPrintProcessors(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt))
PyWin_SetAPIError("EnumPrintProcessors");
else{
ret=PyTuple_New(return_cnt);
if (ret!=NULL){
! info=(PRINTPROCESSOR_INFO_1 *)buf;
for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){
! tuple_item=PyString_FromString(info->pName);
if (tuple_item==NULL){
Py_DECREF(ret);
--- 1087,1129 ----
}
! // @pymethod (<o PyUnicode>,...)|win32print|EnumPrintProcessors|List printer processors for specified server and environment
static PyObject *PyEnumPrintProcessors(PyObject *self, PyObject *args)
{
! PRINTPROCESSOR_INFO_1W *info=NULL; // currently only level that exists
LPBYTE buf=NULL;
! WCHAR *servername=NULL, *environment=NULL;
! PyObject *observername=Py_None, *obenvironment=Py_None;
DWORD level=1, bufsize=0, bytes_needed, return_cnt;
! PyObject *ret=NULL, *tuple_item;
! // @pyparm string/<o PyUnicode>|Server|None|Name of print server, use None for local machine
! // @pyparm string/<o PyUnicode>|Environment|None|Environment - eg 'Windows NT x86' - use None for current client environment
! if (!PyArg_ParseTuple(args,"|OO:EnumPrintProcessors", &observername, &obenvironment))
return NULL;
! if (!PyWinObject_AsWCHAR(observername, &servername, TRUE))
! goto done;
! if (!PyWinObject_AsWCHAR(obenvironment, &environment, TRUE))
! goto done;
! if (EnumPrintProcessorsW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt)){
! ret=PyTuple_New(0);
! goto done;
! }
if (bytes_needed==0){
PyWin_SetAPIError("EnumPrintProcessors");
! goto done;
}
buf=(LPBYTE)malloc(bytes_needed);
if (buf==NULL){
PyErr_Format(PyExc_MemoryError,"EnumPrintProcessors: unable to allocate buffer of size %d", bytes_needed);
! goto done;
}
bufsize=bytes_needed;
! if (!EnumPrintProcessorsW(servername, environment, level, buf, bufsize, &bytes_needed, &return_cnt))
PyWin_SetAPIError("EnumPrintProcessors");
else{
ret=PyTuple_New(return_cnt);
if (ret!=NULL){
! info=(PRINTPROCESSOR_INFO_1W *)buf;
for (DWORD buf_ind=0; buf_ind<return_cnt; buf_ind++){
! tuple_item=PyWinObject_FromWCHAR(info->pName);
if (tuple_item==NULL){
Py_DECREF(ret);
***************
*** 1129,1133 ****
}
}
! free(buf);
return ret;
}
--- 1136,1146 ----
}
}
! done:
! if (buf!=NULL)
! free(buf);
! if (servername!=NULL)
! PyWinObject_FreeWCHAR(servername);
! if (environment!=NULL)
! PyWinObject_FreeWCHAR(environment);
return ret;
}
|