diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index 3572084775f..dcc972e7011 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -28,7 +28,6 @@ #include "psdrv.h" #include "wine/debug.h" #include "winspool.h" -#include "heap.h" WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -434,22 +433,38 @@ INT PSDRV_StartDocA( PSDRV_PDEVICE *physDev, const DOCINFOA *doc ) INT PSDRV_StartDoc( PSDRV_PDEVICE *physDev, const DOCINFOW *doc ) { DOCINFOA docA; - INT ret; + INT ret, len; + LPSTR docname = NULL, output = NULL, datatype = NULL; docA.cbSize = doc->cbSize; - docA.lpszDocName = doc->lpszDocName ? - HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDocName ) : NULL; - docA.lpszOutput = doc->lpszOutput ? - HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszOutput ) : NULL; - docA.lpszDatatype = doc->lpszDatatype ? - HEAP_strdupWtoA( GetProcessHeap(), 0, doc->lpszDatatype ) : NULL; + if (doc->lpszDocName) + { + len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, NULL, 0, NULL, NULL ); + if ((docname = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, doc->lpszDocName, -1, docname, len, NULL, NULL ); + } + if (doc->lpszOutput) + { + len = WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, NULL, 0, NULL, NULL ); + if ((output = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, doc->lpszOutput, -1, output, len, NULL, NULL ); + } + if (doc->lpszDatatype) + { + len = WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, NULL, 0, NULL, NULL ); + if ((datatype = HeapAlloc( GetProcessHeap(), 0, len ))) + WideCharToMultiByte( CP_ACP, 0, doc->lpszDatatype, -1, datatype, len, NULL, NULL ); + } + docA.lpszDocName = docname; + docA.lpszOutput = output; + docA.lpszDatatype = datatype; docA.fwType = doc->fwType; ret = PSDRV_StartDocA(physDev, &docA); - HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDocName ); - HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszOutput ); - HeapFree( GetProcessHeap(), 0, (LPSTR)docA.lpszDatatype ); + HeapFree( GetProcessHeap(), 0, docname ); + HeapFree( GetProcessHeap(), 0, output ); + HeapFree( GetProcessHeap(), 0, datatype ); return ret; } diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 0868e2277c9..8ec88b5af2c 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -22,6 +22,7 @@ #include "config.h" #include "wine/port.h" +#include #include #ifdef HAVE_UNISTD_H # include @@ -33,13 +34,14 @@ #define NONAMELESSUNION #define NONAMELESSSTRUCT -#include "wine/debug.h" +#include "windef.h" +#include "winbase.h" #include "winerror.h" #include "wownt32.h" -#include "heap.h" #include "winreg.h" #include "psdrv.h" #include "winspool.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -353,7 +355,9 @@ BOOL PSDRV_CreateDC( HDC hdc, PSDRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR devi physDev->logPixelsY = physDev->pi->ppd->DefaultResolution; if (output) { - physDev->job.output = HEAP_strdupWtoA( PSDRV_Heap, 0, output ); + INT len = WideCharToMultiByte( CP_ACP, 0, output, -1, NULL, 0, NULL, NULL ); + if ((physDev->job.output = HeapAlloc( PSDRV_Heap, 0, len ))) + WideCharToMultiByte( CP_ACP, 0, output, -1, physDev->job.output, len, NULL, NULL ); } else physDev->job.output = NULL; physDev->job.hJob = 0; diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c index 87592574524..38e4dc8d52f 100644 --- a/dlls/winspool.drv/info.c +++ b/dlls/winspool.drv/info.c @@ -58,7 +58,6 @@ #include "wine/unicode.h" #include "wine/debug.h" #include "wine/list.h" -#include "heap.h" #include "winnls.h" #include "ddk/winsplp.h" @@ -332,6 +331,18 @@ static LPWSTR strdupW(LPCWSTR p) return ret; } +static LPSTR strdupWtoA( LPCWSTR str ) +{ + LPSTR ret; + INT len; + + if (!str) return NULL; + len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); + ret = HeapAlloc( GetProcessHeap(), 0, len ); + if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); + return ret; +} + /* Returns the number of bytes in an ansi \0\0 terminated string (multi_sz). The result includes all \0s (specifically the last two). */ static int multi_sz_lenA(const char *str) @@ -1589,8 +1600,8 @@ INT WINAPI DeviceCapabilitiesW(LPCWSTR pDevice, LPCWSTR pPort, const DEVMODEW *pDevMode) { LPDEVMODEA dmA = DEVMODEdupWtoA(GetProcessHeap(), pDevMode); - LPSTR pDeviceA = HEAP_strdupWtoA(GetProcessHeap(),0,pDevice); - LPSTR pPortA = HEAP_strdupWtoA(GetProcessHeap(),0,pPort); + LPSTR pDeviceA = strdupWtoA(pDevice); + LPSTR pPortA = strdupWtoA(pPort); INT ret; if(pOutput && (fwCapability == DC_BINNAMES || @@ -1653,7 +1664,7 @@ LONG WINAPI DocumentPropertiesA(HWND hWnd,HANDLE hPrinter, SetLastError(ERROR_INVALID_HANDLE); return -1; } - lpName = HEAP_strdupWtoA(GetProcessHeap(),0,lpNameW); + lpName = strdupWtoA(lpNameW); } if (!GDI_CallExtDeviceMode16) @@ -1685,7 +1696,7 @@ LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPDEVMODEW pDevModeInput, DWORD fMode) { - LPSTR pDeviceNameA = HEAP_strdupWtoA(GetProcessHeap(),0,pDeviceName); + LPSTR pDeviceNameA = strdupWtoA(pDeviceName); LPDEVMODEA pDevModeInputA = DEVMODEdupWtoA(GetProcessHeap(),pDevModeInput); LPDEVMODEA pDevModeOutputA = NULL; LONG ret; @@ -3228,7 +3239,7 @@ static BOOL WINSPOOL_GetStringFromReg(HKEY hkey, LPCWSTR ValueName, LPBYTE ptr, if(unicode) ret = RegQueryValueExW(hkey, ValueName, 0, &type, ptr, &sz); else { - LPSTR ValueNameA = HEAP_strdupWtoA(GetProcessHeap(),0,ValueName); + LPSTR ValueNameA = strdupWtoA(ValueName); ret = RegQueryValueExA(hkey, ValueNameA, 0, &type, ptr, &sz); HeapFree(GetProcessHeap(),0,ValueNameA); } diff --git a/include/heap.h b/include/heap.h deleted file mode 100644 index b0432f70ac1..00000000000 --- a/include/heap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Win32 heap definitions - * - * Copyright 1996 Alexandre Julliard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __WINE_HEAP_H -#define __WINE_HEAP_H - -#include -#include - -#include -#include -#include - -/* strdup macros */ -/* DO NOT USE IT!! it will go away soon */ - -inline static LPSTR HEAP_strdupWtoA( HANDLE heap, DWORD flags, LPCWSTR str ) -{ - LPSTR ret; - INT len; - - if (!str) return NULL; - len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); - ret = HeapAlloc( heap, flags, len ); - if(ret) WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); - return ret; -} - -#endif /* __WINE_HEAP_H */