Wine-Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 17 participants
- 84524 discussions
[PATCH 1/2] gdi32: Avoid integer overflow in the obj map compare fn.
by Francisco Casas Oct. 27, 2021
by Francisco Casas Oct. 27, 2021
Oct. 27, 2021
Signed-off-by: Francisco Casas <fcasas(a)codeweavers.com>
---
dlls/gdi32/objects.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index 4b390aa0160..196cea9ba92 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -178,7 +178,11 @@ DWORD WINAPI GetObjectType( HGDIOBJ handle )
static int obj_map_cmp( const void *key, const struct wine_rb_entry *entry )
{
struct obj_map_entry *obj_entry = WINE_RB_ENTRY_VALUE( entry, struct obj_map_entry, entry );
- return HandleToLong( key ) - HandleToLong( obj_entry->obj );
+ UINT_PTR a = (UINT_PTR)key;
+ UINT_PTR b = (UINT_PTR)obj_entry->obj;
+ if (a > b) return 1;
+ if (a < b) return -1;
+ return 0;
};
struct wine_rb_tree obj_map = { obj_map_cmp };
--
2.25.1
2
1
Oct. 27, 2021
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
dlls/dinput/device.c | 150 ++++++++++++++++++++-----------------------
1 file changed, 69 insertions(+), 81 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 705aec2baca..679f907f2de 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -929,17 +929,18 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire( IDirectInputDevice8W *
* IDirectInputDeviceA
*/
-static HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat( IDirectInputDevice8W *iface, LPCDIDATAFORMAT df )
+static HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat( IDirectInputDevice8W *iface, const DIDATAFORMAT *format )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT res = DI_OK;
- if (!df) return E_POINTER;
- TRACE("(%p) %p\n", This, df);
- _dump_DIDATAFORMAT(df);
+ TRACE( "iface %p, format %p.\n", iface, format );
- if (df->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM;
- if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) return DIERR_INVALIDPARAM;
+ if (!format) return E_POINTER;
+ _dump_DIDATAFORMAT( format );
+
+ if (format->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM;
+ if (format->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) return DIERR_INVALIDPARAM;
if (This->acquired) return DIERR_ACQUIRED;
EnterCriticalSection(&This->crit);
@@ -949,7 +950,7 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat( IDirectInputDevice
This->num_actions = 0;
release_DataFormat(&This->data_format);
- res = create_DataFormat(df, &This->data_format);
+ res = create_DataFormat( format, &This->data_format );
LeaveCriticalSection(&This->crit);
return res;
@@ -961,32 +962,31 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_SetDataFormat( IDirectInputDevice
* Set cooperative level and the source window for the events.
*/
static HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel( IDirectInputDevice8W *iface,
- HWND hwnd, DWORD dwflags )
+ HWND hwnd, DWORD flags )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT hr;
- TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags);
- _dump_cooperativelevel_DI(dwflags);
+ TRACE( "iface %p, hwnd %p, flags %#x.\n", iface, hwnd, flags );
+
+ _dump_cooperativelevel_DI( flags );
- if ((dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == 0 ||
- (dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE) ||
- (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == 0 ||
- (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == (DISCL_FOREGROUND | DISCL_BACKGROUND))
+ if ((flags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == 0 ||
+ (flags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE) ||
+ (flags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == 0 ||
+ (flags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == (DISCL_FOREGROUND | DISCL_BACKGROUND))
return DIERR_INVALIDPARAM;
if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
- if (!hwnd && dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
- hwnd = GetDesktopWindow();
+ if (!hwnd && flags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND)) hwnd = GetDesktopWindow();
if (!IsWindow(hwnd)) return E_HANDLE;
/* For security reasons native does not allow exclusive background level
for mouse and keyboard only */
- if (dwflags & DISCL_EXCLUSIVE && dwflags & DISCL_BACKGROUND &&
- (IsEqualGUID(&This->guid, &GUID_SysMouse) ||
- IsEqualGUID(&This->guid, &GUID_SysKeyboard)))
+ if (flags & DISCL_EXCLUSIVE && flags & DISCL_BACKGROUND &&
+ (IsEqualGUID( &This->guid, &GUID_SysMouse ) || IsEqualGUID( &This->guid, &GUID_SysKeyboard )))
return DIERR_UNSUPPORTED;
/* Store the window which asks for the mouse */
@@ -995,7 +995,7 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_SetCooperativeLevel( IDirectInput
else
{
This->win = hwnd;
- This->dwCoopLevel = dwflags;
+ This->dwCoopLevel = flags;
hr = DI_OK;
}
LeaveCriticalSection(&This->crit);
@@ -1029,7 +1029,7 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_SetEventNotification( IDirectInpu
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- TRACE("(%p) %p\n", This, event);
+ TRACE( "iface %p, event %p.\n", iface, event );
EnterCriticalSection(&This->crit);
This->hEvent = event;
@@ -1100,34 +1100,34 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_GetCapabilities( IDirectInputDevi
}
static HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface( IDirectInputDevice8W *iface,
- REFIID riid, LPVOID *ppobj )
+ const GUID *iid, void **out )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppobj);
+ TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
- if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8A, riid))
+ if (IsEqualGUID( &IID_IDirectInputDeviceA, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice2A, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice7A, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice8A, iid ))
{
IDirectInputDevice2_AddRef(iface);
- *ppobj = IDirectInputDevice8A_from_impl(This);
+ *out = IDirectInputDevice8A_from_impl( This );
return DI_OK;
}
- if (IsEqualGUID(&IID_IUnknown, riid) ||
- IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
- IsEqualGUID(&IID_IDirectInputDevice8W, riid))
+ if (IsEqualGUID( &IID_IUnknown, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDeviceW, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice2W, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice7W, iid ) ||
+ IsEqualGUID( &IID_IDirectInputDevice8W, iid ))
{
IDirectInputDevice2_AddRef(iface);
- *ppobj = IDirectInputDevice8W_from_impl(This);
+ *out = IDirectInputDevice8W_from_impl( This );
return DI_OK;
}
- WARN("Unsupported interface!\n");
+ WARN( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
return E_NOINTERFACE;
}
@@ -1564,18 +1564,16 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceState( IDirectInputDevic
return hr;
}
-static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData( IDirectInputDevice8W *iface,
- DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
- LPDWORD entries, DWORD flags )
+static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData( IDirectInputDevice8W *iface, DWORD size,
+ DIDEVICEOBJECTDATA *data, DWORD *count, DWORD flags )
{
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
HRESULT ret = DI_OK;
int len;
- TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
- This, dod, entries, entries ? *entries : 0, dodsize, flags);
+ TRACE( "iface %p, size %u, data %p, count %p, flags %#x.\n", iface, size, data, count, flags );
- if (This->dinput->dwVersion == 0x0800 || dodsize == sizeof(DIDEVICEOBJECTDATA_DX3))
+ if (This->dinput->dwVersion == 0x0800 || size == sizeof(DIDEVICEOBJECTDATA_DX3))
{
if (!This->queue_len) return DIERR_NOTBUFFERED;
if (!This->acquired) return DIERR_NOTACQUIRED;
@@ -1583,8 +1581,7 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData( IDirectInputDevice
if (!This->queue_len)
return DI_OK;
- if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
- return DIERR_INVALIDPARAM;
+ if (size < sizeof(DIDEVICEOBJECTDATA_DX3)) return DIERR_INVALIDPARAM;
IDirectInputDevice2_Poll(iface);
EnterCriticalSection(&This->crit);
@@ -1592,18 +1589,18 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData( IDirectInputDevice
len = This->queue_head - This->queue_tail;
if (len < 0) len += This->queue_len;
- if ((*entries != INFINITE) && (len > *entries)) len = *entries;
+ if ((*count != INFINITE) && (len > *count)) len = *count;
- if (dod)
+ if (data)
{
int i;
for (i = 0; i < len; i++)
{
int n = (This->queue_tail + i) % This->queue_len;
- memcpy((char *)dod + dodsize * i, This->data_queue + n, dodsize);
+ memcpy( (char *)data + size * i, This->data_queue + n, size );
}
}
- *entries = len;
+ *count = len;
if (This->overflow && This->dinput->dwVersion == 0x0800)
ret = DI_BUFFEROVERFLOW;
@@ -1617,24 +1614,21 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData( IDirectInputDevice
LeaveCriticalSection(&This->crit);
- TRACE("Returning %d events queued\n", *entries);
+ TRACE( "Returning %d events queued\n", *count );
return ret;
}
-static HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel( IDirectInputDevice8W *iface,
- HWND hwndOwner, DWORD dwFlags )
+static HRESULT WINAPI IDirectInputDevice2WImpl_RunControlPanel( IDirectInputDevice8W *iface, HWND hwnd, DWORD flags )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("%p)->(%p,0x%08x): stub!\n", This, hwndOwner, dwFlags);
-
+ FIXME( "iface %p, hwnd %p, flags %#x stub!\n", iface, hwnd, flags );
return DI_OK;
}
-static HRESULT WINAPI IDirectInputDevice2WImpl_Initialize( IDirectInputDevice8W *iface, HINSTANCE hinst,
- DWORD dwVersion, REFGUID rguid )
+static HRESULT WINAPI IDirectInputDevice2WImpl_Initialize( IDirectInputDevice8W *iface, HINSTANCE instance,
+ DWORD version, const GUID *guid )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(%p,%d,%s): stub!\n", This, hinst, dwVersion, debugstr_guid(rguid));
+ FIXME( "iface %p, instance %p, version %#x, guid %s stub!\n", iface, instance, version,
+ debugstr_guid( guid ) );
return DI_OK;
}
@@ -1809,10 +1803,9 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_EnumCreatedEffectObjects( IDirect
return impl->vtbl->enum_created_effect_objects( iface, callback, context, flags );
}
-static HRESULT WINAPI IDirectInputDevice2WImpl_Escape( IDirectInputDevice8W *iface, LPDIEFFESCAPE lpDIEEsc )
+static HRESULT WINAPI IDirectInputDevice2WImpl_Escape( IDirectInputDevice8W *iface, DIEFFESCAPE *escape )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(%p): stub!\n", This, lpDIEEsc);
+ FIXME( "iface %p, escape %p stub!\n", iface, escape );
return DI_OK;
}
@@ -1830,33 +1823,30 @@ static HRESULT WINAPI IDirectInputDevice2WImpl_Poll( IDirectInputDevice8W *iface
return DI_OK;
}
-static HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData( IDirectInputDevice8W *iface, DWORD cbObjectData,
- LPCDIDEVICEOBJECTDATA rgdod,
- LPDWORD pdwInOut, DWORD dwFlags )
+static HRESULT WINAPI IDirectInputDevice2WImpl_SendDeviceData( IDirectInputDevice8W *iface, DWORD size,
+ const DIDEVICEOBJECTDATA *data,
+ DWORD *count, DWORD flags )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(0x%08x,%p,%p,0x%08x): stub!\n", This, cbObjectData, rgdod, pdwInOut, dwFlags);
-
+ FIXME( "iface %p, size %u, data %p, count %p, flags %#x stub!\n", iface, size, data, count, flags );
return DI_OK;
}
-static HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile( IDirectInputDevice8W *iface, LPCWSTR lpszFileName,
- LPDIENUMEFFECTSINFILECALLBACK pec,
- LPVOID pvRef, DWORD dwFlags )
+static HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile( IDirectInputDevice8W *iface,
+ const WCHAR *filename,
+ LPDIENUMEFFECTSINFILECALLBACK callback,
+ void *context, DWORD flags )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", This, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
-
+ FIXME( "iface %p, filename %s, callback %p, context %p, flags %#x stub!\n", iface,
+ debugstr_w(filename), callback, context, flags );
return DI_OK;
}
static HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile( IDirectInputDevice8W *iface,
- LPCWSTR lpszFileName, DWORD dwEntries,
- LPDIFILEEFFECT rgDiFileEft, DWORD dwFlags )
+ const WCHAR *filename, DWORD count,
+ DIFILEEFFECT *effects, DWORD flags )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", This, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
-
+ FIXME( "iface %p, filename %s, count %u, effects %p, flags %#x stub!\n", iface,
+ debugstr_w(filename), count, effects, flags );
return DI_OK;
}
@@ -2072,11 +2062,9 @@ static HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap( IDirectInputDevice8
}
static HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo( IDirectInputDevice8W *iface,
- LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader )
+ DIDEVICEIMAGEINFOHEADERW *header )
{
- IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
- FIXME("(%p)->(%p): stub !\n", This, lpdiDevImageInfoHeader);
-
+ FIXME( "iface %p, header %p stub!\n", iface, header );
return DI_OK;
}
--
2.33.0
1
3
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winspool.drv/info.c | 424 +++++++++++++++++----------------------
1 file changed, 189 insertions(+), 235 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 9bc5c5e7a8c..1748a092d8e 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -126,76 +126,7 @@ static opened_printer_t **printer_handles;
static UINT nb_printer_handles;
static LONG next_job_id = 1;
-static WCHAR envname_win40W[] = {'W','i','n','d','o','w','s',' ','4','.','0',0};
-static const WCHAR envname_x64W[] = {'W','i','n','d','o','w','s',' ','x','6','4',0};
-static WCHAR envname_x86W[] = {'W','i','n','d','o','w','s',' ','N','T',' ','x','8','6',0};
-static const WCHAR envname_armW[] = {'W','i','n','d','o','w','s',' ','A','R','M',0};
-static const WCHAR envname_arm64W[] = {'W','i','n','d','o','w','s',' ','A','R','M','6','4',0};
-static const WCHAR subdir_win40W[] = {'w','i','n','4','0',0};
-static const WCHAR subdir_x64W[] = {'x','6','4',0};
-static const WCHAR subdir_x86W[] = {'w','3','2','x','8','6',0};
-static const WCHAR subdir_armW[] = {'a','r','m',0};
-static const WCHAR subdir_arm64W[] = {'a','r','m','6','4',0};
-static const WCHAR Version0_RegPathW[] = {'\\','V','e','r','s','i','o','n','-','0',0};
-static const WCHAR Version0_SubdirW[] = {'\\','0',0};
-static const WCHAR Version3_RegPathW[] = {'\\','V','e','r','s','i','o','n','-','3',0};
-static const WCHAR Version3_SubdirW[] = {'\\','3',0};
-
-static const WCHAR AttributesW[] = {'A','t','t','r','i','b','u','t','e','s',0};
-static const WCHAR backslashW[] = {'\\',0};
-static const WCHAR Configuration_FileW[] = {'C','o','n','f','i','g','u','r','a','t',
- 'i','o','n',' ','F','i','l','e',0};
-static const WCHAR DatatypeW[] = {'D','a','t','a','t','y','p','e',0};
-static const WCHAR Data_FileW[] = {'D','a','t','a',' ','F','i','l','e',0};
-static const WCHAR Default_DevModeW[] = {'D','e','f','a','u','l','t',' ','D','e','v','M','o','d','e',0};
-static const WCHAR Default_PriorityW[] = {'D','e','f','a','u','l','t',' ','P','r','i','o','r','i','t','y',0};
-static const WCHAR Dependent_FilesW[] = {'D','e','p','e','n','d','e','n','t',' ','F','i','l','e','s',0};
-static const WCHAR DescriptionW[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
-static const WCHAR dnsTimeoutW[] = {'d','n','s','T','i','m','e','o','u','t',0};
-static const WCHAR DriverW[] = {'D','r','i','v','e','r',0};
-static const WCHAR HardwareIDW[] = {'H','a','r','d','w','a','r','e','I','D',0};
-static const WCHAR Help_FileW[] = {'H','e','l','p',' ','F','i','l','e',0};
-static const WCHAR LocationW[] = {'L','o','c','a','t','i','o','n',0};
-static const WCHAR ManufacturerW[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
-static const WCHAR MonitorW[] = {'M','o','n','i','t','o','r',0};
-static const WCHAR NameW[] = {'N','a','m','e',0};
-static const WCHAR ObjectGUIDW[] = {'O','b','j','e','c','t','G','U','I','D',0};
-static const WCHAR OEM_UrlW[] = {'O','E','M',' ','U','r','l',0};
-static const WCHAR ParametersW[] = {'P','a','r','a','m','e','t','e','r','s',0};
-static const WCHAR PortW[] = {'P','o','r','t',0};
-static const WCHAR Previous_NamesW[] = {'P','r','e','v','i','o','u','s',' ','N','a','m','e','s',0};
-static const WCHAR Print_ProcessorW[] = {'P','r','i','n','t',' ','P','r','o','c','e','s','s','o','r',0};
-static const WCHAR Printer_DriverW[] = {'P','r','i','n','t','e','r',' ','D','r','i','v','e','r',0};
-static const WCHAR PrinterDriverDataW[] = {'P','r','i','n','t','e','r','D','r','i','v','e','r','D','a','t','a',0};
-static const WCHAR PriorityW[] = {'P','r','i','o','r','i','t','y',0};
-static const WCHAR ProviderW[] = {'P','r','o','v','i','d','e','r',0};
-static const WCHAR Separator_FileW[] = {'S','e','p','a','r','a','t','o','r',' ','F','i','l','e',0};
-static const WCHAR Share_NameW[] = {'S','h','a','r','e',' ','N','a','m','e',0};
-static const WCHAR StartTimeW[] = {'S','t','a','r','t','T','i','m','e',0};
-static const WCHAR StatusW[] = {'S','t','a','t','u','s',0};
-static const WCHAR txTimeoutW[] = {'t','x','T','i','m','e','o','u','t',0};
-static const WCHAR UntilTimeW[] = {'U','n','t','i','l','T','i','m','e',0};
-static WCHAR WinPrintW[] = {'W','i','n','P','r','i','n','t',0};
-static const WCHAR deviceW[] = {'d','e','v','i','c','e',0};
-static const WCHAR windowsW[] = {'w','i','n','d','o','w','s',0};
-static WCHAR rawW[] = {'R','A','W',0};
-static WCHAR driver_9x[] = {'w','i','n','e','p','s','1','6','.','d','r','v',0};
-static WCHAR driver_nt[] = {'w','i','n','e','p','s','.','d','r','v',0};
-static const WCHAR timeout_15_45[] = {',','1','5',',','4','5',0};
-static const WCHAR commaW[] = {',',0};
-static WCHAR emptyStringW[] = {0};
-
-static const WCHAR May_Delete_Value[] = {'W','i','n','e','M','a','y','D','e','l','e','t','e','M','e',0};
-
-static const WCHAR CUPS_Port[] = {'C','U','P','S',':',0};
-static const WCHAR FILE_Port[] = {'F','I','L','E',':',0};
-static const WCHAR LPR_Port[] = {'L','P','R',':',0};
-
-static const WCHAR default_doc_title[] = {'L','o','c','a','l',' ','D','o','w','n','l','e','v','e','l',' ',
- 'D','o','c','u','m','e','n','t',0};
-
-static const WCHAR PPD_Overrides[] = {'P','P','D',' ','O','v','e','r','r','i','d','e','s',0};
-static const WCHAR DefaultPageSize[] = {'D','e','f','a','u','l','t','P','a','g','e','S','i','z','e',0};
+static const WCHAR * const May_Delete_Value = L"WineMayDeleteMe";
static const DWORD di_sizeof[] = {0, sizeof(DRIVER_INFO_1W), sizeof(DRIVER_INFO_2W),
sizeof(DRIVER_INFO_3W), sizeof(DRIVER_INFO_4W),
@@ -209,13 +140,13 @@ static const DWORD pi_sizeof[] = {0, sizeof(PRINTER_INFO_1W), sizeof(PRINTER_INF
sizeof(PRINTER_INFO_7W), sizeof(PRINTER_INFO_8W),
sizeof(PRINTER_INFO_9W)};
-static const printenv_t env_x64 = {envname_x64W, subdir_x64W, 3, Version3_RegPathW, Version3_SubdirW};
-static const printenv_t env_x86 = {envname_x86W, subdir_x86W, 3, Version3_RegPathW, Version3_SubdirW};
-static const printenv_t env_arm = {envname_armW, subdir_armW, 3, Version3_RegPathW, Version3_SubdirW};
-static const printenv_t env_arm64 = {envname_arm64W, subdir_arm64W, 3, Version3_RegPathW, Version3_SubdirW};
-static const printenv_t env_win40 = {envname_win40W, subdir_win40W, 0, Version0_RegPathW, Version0_SubdirW};
+static const printenv_t env_x64 = { L"Windows x64", L"x64", 3, L"\\Version-3", L"\\3" };
+static const printenv_t env_x86 = { L"Windows NT x86", L"w32x86", 3, L"\\Version-3", L"\\3" };
+static const printenv_t env_arm = { L"Windows ARM", L"arm", 3, L"\\Version-3", L"\\3" };
+static const printenv_t env_arm64 = { L"Windows ARM64", L"arm64", 3, L"\\Version-3", L"\\3" };
+static const printenv_t env_win40 = { L"Windows 4.0", L"win40", 0, L"\\Version-0", L"\\0" };
-static const printenv_t * const all_printenv[] = {&env_x86, &env_x64, &env_arm, &env_arm64, &env_win40};
+static const printenv_t * const all_printenv[] = { &env_x86, &env_x64, &env_arm, &env_arm64, &env_win40 };
#ifdef __i386__
#define env_arch env_x86
@@ -504,8 +435,8 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
driver[len++] = '3';
driver[len++] = '\\';
size = sizeof(driver) - len * sizeof(WCHAR);
- res = RegQueryValueExW(device_key, Configuration_FileW, NULL, &type,
- (BYTE *)(driver + len), &size);
+ res = RegQueryValueExW( device_key, L"Configuration File", NULL, &type,
+ (BYTE *)(driver + len), &size );
RegCloseKey(device_key);
if (res || type != REG_SZ) {
WARN("no configuration file: %u\n", res);
@@ -675,13 +606,11 @@ static DWORD WINSPOOL_GetOpenedPrinterRegKey(HANDLE hPrinter, HKEY *phkey)
static BOOL get_internal_fallback_ppd( const WCHAR *ppd )
{
- static const WCHAR typeW[] = {'P','P','D','F','I','L','E',0};
-
char *ptr, *end;
DWORD size, written;
HANDLE file;
BOOL ret;
- HRSRC res = FindResourceW( WINSPOOL_hInstance, MAKEINTRESOURCEW(1), typeW );
+ HRSRC res = FindResourceW( WINSPOOL_hInstance, MAKEINTRESOURCEW(1), L"PPDFILE" );
if (!res || !(ptr = LoadResource( WINSPOOL_hInstance, res ))) return FALSE;
size = SizeofResource( WINSPOOL_hInstance, res );
@@ -698,8 +627,8 @@ static BOOL get_internal_fallback_ppd( const WCHAR *ppd )
static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
{
- static const WCHAR dot_ppd[] = {'.','p','p','d',0};
- static const WCHAR invalid_chars[] = {'*','?','<','>','|','"','/','\\',0};
+ static const WCHAR dot_ppd[] = L".ppd";
+ static const WCHAR invalid_chars[] = L"*?<>|\"/\\";
int dir_len = wcslen( dir ), file_len = wcslen( file_name );
int len = (dir_len + file_len + ARRAY_SIZE( dot_ppd )) * sizeof(WCHAR);
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len ), *p;
@@ -723,6 +652,7 @@ static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir )
DRIVER_INFO_3W di3;
unsigned int i;
BOOL res = FALSE;
+ WCHAR raw[] = L"RAW", driver_nt[] = L"wineps.drv";
if (!ppd) return FALSE;
RtlInitUnicodeString( &nt_ppd, NULL );
@@ -739,13 +669,14 @@ static BOOL add_printer_driver( const WCHAR *name, const WCHAR *ppd_dir )
di3.pDriverPath = driver_nt;
di3.pDataFile = ppd;
di3.pConfigFile = driver_nt;
- di3.pDefaultDataType = rawW;
+ di3.pDefaultDataType = raw;
for (i = 0; i < ARRAY_SIZE(all_printenv); i++)
{
di3.pEnvironment = (WCHAR *)all_printenv[i]->envname;
- if (all_printenv[i]->envname == envname_win40W)
+ if (all_printenv[i]->driverversion == 0)
{
+ WCHAR driver_9x[] = L"wineps16.drv";
/* We use wineps16.drv as driver for 16 bit */
di3.pDriverPath = driver_9x;
di3.pConfigFile = driver_9x;
@@ -772,7 +703,7 @@ end:
static WCHAR *get_ppd_dir( void )
{
- static const WCHAR wine_ppds[] = {'w','i','n','e','_','p','p','d','s','\\',0};
+ static const WCHAR wine_ppds[] = L"wine_ppds\\";
DWORD len;
WCHAR *dir, tmp_path[MAX_PATH];
BOOL res;
@@ -802,6 +733,7 @@ static BOOL init_unix_printers( void )
HANDLE added_printer;
PRINTER_INFO_2W pi2;
NTSTATUS status;
+ WCHAR raw[] = L"RAW", winprint[] = L"WinPrint", empty[] = L"";
int i;
if (create_printers_reg_key( system_printers_key, &printers_key ))
@@ -828,13 +760,13 @@ static BOOL init_unix_printers( void )
if (RegOpenKeyW( printers_key, printer->name, &printer_key ) == ERROR_SUCCESS)
{
- DWORD status = get_dword_from_reg( printer_key, StatusW );
+ DWORD status = get_dword_from_reg( printer_key, L"Status" );
/* Printer already in registry, delete the tag added in WINSPOOL_LoadSystemPrinters
and continue */
TRACE("Printer already exists\n");
RegDeleteValueW( printer_key, May_Delete_Value );
/* flag that the PPD file should be checked for an update */
- set_reg_DWORD( printer_key, StatusW, status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
+ set_reg_DWORD( printer_key, L"Status", status | PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
RegCloseKey( printer_key );
}
else
@@ -842,21 +774,21 @@ static BOOL init_unix_printers( void )
if (!ppd_dir && !(ppd_dir = get_ppd_dir())) break;
if (!add_printer_driver( printer->name, ppd_dir )) continue;
- port = heap_alloc( sizeof(CUPS_Port) + wcslen( printer->name ) * sizeof(WCHAR) );
- wcscpy( port, CUPS_Port );
+ port = heap_alloc( sizeof(L"CUPS:") + wcslen( printer->name ) * sizeof(WCHAR) );
+ wcscpy( port, L"CUPS:" );
wcscat( port, printer->name );
memset( &pi2, 0, sizeof(PRINTER_INFO_2W) );
pi2.pPrinterName = printer->name;
- pi2.pDatatype = rawW;
- pi2.pPrintProcessor = WinPrintW;
+ pi2.pDatatype = raw;
+ pi2.pPrintProcessor = winprint;
pi2.pDriverName = printer->name;
pi2.pComment = printer->comment;
pi2.pLocation = printer->location;
pi2.pPortName = port;
- pi2.pParameters = emptyStringW;
- pi2.pShareName = emptyStringW;
- pi2.pSepFile = emptyStringW;
+ pi2.pParameters = empty;
+ pi2.pShareName = empty;
+ pi2.pSepFile = empty;
added_printer = AddPrinterW( NULL, 2, (BYTE *)&pi2 );
if (added_printer) ClosePrinter( added_printer );
@@ -896,7 +828,7 @@ static void set_ppd_overrides( HANDLE printer )
params.name = heap_alloc( params.name_size );
if (!params.name) break;
}
- if (!status) SetPrinterDataExW( printer, PPD_Overrides, DefaultPageSize, REG_SZ, (BYTE*)params.name, params.name_size );
+ if (!status) SetPrinterDataExW( printer, L"PPD Overrides", L"DefaultPageSize", REG_SZ, (BYTE*)params.name, params.name_size );
if (params.name != buffer) heap_free( params.name );
}
@@ -1163,8 +1095,8 @@ static void old_printer_check( BOOL delete_phase )
{
if (!pi[i].pPortName) continue;
- if (wcsncmp( pi[i].pPortName, CUPS_Port, wcslen( CUPS_Port ) ) &&
- wcsncmp( pi[i].pPortName, LPR_Port, wcslen( LPR_Port ) ))
+ if (wcsncmp( pi[i].pPortName, L"CUPS:", ARRAY_SIZE(L"CUPS:") - 1 ) &&
+ wcsncmp( pi[i].pPortName, L"LPR:", ARRAY_SIZE(L"LPR:") - 1 ))
continue;
if (open_printer_reg_key( pi[i].pPrinterName, &key )) continue;
@@ -1195,8 +1127,6 @@ static void old_printer_check( BOOL delete_phase )
HeapFree(GetProcessHeap(), 0, pi);
}
-static const WCHAR winspool_mutex_name[] = {'_','_','W','I','N','E','_','W','I','N','S','P','O','O','L','_',
- 'M','U','T','E','X','_','_','\0'};
static HANDLE init_mutex;
void WINSPOOL_LoadSystemPrinters(void)
@@ -1206,7 +1136,7 @@ void WINSPOOL_LoadSystemPrinters(void)
WCHAR PrinterName[256];
/* FIXME: The init code should be moved to spoolsv.exe */
- init_mutex = CreateMutexW( NULL, TRUE, winspool_mutex_name );
+ init_mutex = CreateMutexW( NULL, TRUE, L"__WINE_WINSPOOL_MUTEX__" );
if (!init_mutex)
{
ERR( "Failed to create mutex\n" );
@@ -1230,8 +1160,8 @@ void WINSPOOL_LoadSystemPrinters(void)
if (!RegEnumKeyW( printers_key, i, PrinterName, ARRAY_SIZE(PrinterName) ))
if (!RegOpenKeyW( printers_key, PrinterName, &printer_key ))
{
- if (RegQueryValueExW( printer_key, NameW, 0, 0, 0, &needed ) == ERROR_FILE_NOT_FOUND)
- set_reg_szW( printer_key, NameW, PrinterName );
+ if (RegQueryValueExW( printer_key, L"Name", 0, 0, 0, &needed ) == ERROR_FILE_NOT_FOUND)
+ set_reg_szW( printer_key, L"Name", PrinterName );
RegCloseKey( printer_key );
}
RegCloseKey( printers_key );
@@ -2135,8 +2065,8 @@ BOOL WINAPI OpenPrinterW(LPWSTR lpPrinterName,HANDLE *phPrinter, LPPRINTER_DEFAU
DWORD status;
RegQueryValueExW( key, May_Delete_Value, NULL, &type, (LPBYTE)&deleting, &size );
WaitForSingleObject( init_mutex, INFINITE );
- status = get_dword_from_reg( key, StatusW );
- set_reg_DWORD( key, StatusW, status & ~PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
+ status = get_dword_from_reg( key, L"Status" );
+ set_reg_DWORD( key, L"Status", status & ~PRINTER_STATUS_DRIVER_UPDATE_NEEDED );
ReleaseMutex( init_mutex );
if (!deleting && (status & PRINTER_STATUS_DRIVER_UPDATE_NEEDED))
update_driver( *phPrinter );
@@ -2502,8 +2432,7 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
opened_printer_t *printer;
job_t *job;
BOOL ret = FALSE;
- static const WCHAR spool_path[] = {'s','p','o','o','l','\\','P','R','I','N','T','E','R','S','\\',0};
- static const WCHAR fmtW[] = {'%','s','%','0','5','d','.','S','P','L',0};
+ static const WCHAR spool_path[] = L"spool\\PRINTERS\\";
WCHAR path[MAX_PATH], filename[MAX_PATH];
DWORD len;
ADDJOB_INFO_1W *addjob;
@@ -2534,14 +2463,14 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
if(path[len - 1] != '\\')
path[len++] = '\\';
memcpy( path + len, spool_path, sizeof(spool_path) );
- swprintf( filename, ARRAY_SIZE(filename), fmtW, path, job->job_id );
+ swprintf( filename, ARRAY_SIZE(filename), L"%s%05d.SPL", path, job->job_id );
len = wcslen( filename );
job->filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
memcpy(job->filename, filename, (len + 1) * sizeof(WCHAR));
job->portname = NULL;
- job->document_title = strdupW(default_doc_title);
- job->printer_name = strdupW(printer->name);
+ job->document_title = strdupW( L"Local Downlevel Document" );
+ job->printer_name = strdupW( printer->name );
job->devmode = dup_devmode( printer->devmode );
list_add_tail(&printer->queue->jobs, &job->entry);
@@ -2680,11 +2609,10 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
TRACE("(%p) %s\n", pi, debugstr_w(pi->pPrinterName));
/* FIXME: the driver must change to "winspool" */
- devline = HeapAlloc(GetProcessHeap(), 0, sizeof(driver_nt) + portlen + sizeof(timeout_15_45));
+ devline = HeapAlloc( GetProcessHeap(), 0, sizeof(L"wineps.drv") + portlen + sizeof(L",15,45") );
if (devline)
{
- wcscpy( devline, driver_nt );
- wcscat( devline, commaW );
+ wcscpy( devline, L"wineps.drv," );
wcscat( devline, pi->pPortName );
TRACE("using %s\n", debugstr_w(devline));
@@ -2695,7 +2623,7 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
RegCloseKey( key );
}
- wcscat( devline, timeout_15_45 );
+ wcscat( devline, L",15,45" );
if (!create_printers_reg_key( user_ports_key, &key ))
{
RegSetValueExW( key, pi->pPrinterName, 0, REG_SZ, (BYTE *)devline,
@@ -2714,7 +2642,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
PRINTER_INFO_2W *pi = (PRINTER_INFO_2W *) pPrinter;
LPDEVMODEW dm;
HANDLE retval;
- HKEY hkeyPrinter, printers_key, hkeyDriver, hkeyDrivers;
+ HKEY printer_key, printers_key, hkeyDriver, hkeyDrivers;
LONG size;
TRACE("(%s,%d,%p)\n", debugstr_w(pName), Level, pPrinter);
@@ -2738,15 +2666,16 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
ERR("Can't create Printers key\n");
return 0;
}
- if (!RegOpenKeyW( printers_key, pi->pPrinterName, &hkeyPrinter ))
+ if (!RegOpenKeyW( printers_key, pi->pPrinterName, &printer_key ))
{
- if (!RegQueryValueW(hkeyPrinter, AttributesW, NULL, NULL)) {
+ if (!RegQueryValueW( printer_key, L"Attributes", NULL, NULL ))
+ {
SetLastError(ERROR_PRINTER_ALREADY_EXISTS);
- RegCloseKey(hkeyPrinter);
+ RegCloseKey( printer_key );
RegCloseKey( printers_key );
return 0;
}
- RegCloseKey(hkeyPrinter);
+ RegCloseKey( printer_key );
}
hkeyDrivers = WINSPOOL_OpenDriverReg(NULL);
if(!hkeyDrivers) {
@@ -2765,7 +2694,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
RegCloseKey(hkeyDriver);
RegCloseKey(hkeyDrivers);
- if(wcsicmp( pi->pPrintProcessor, WinPrintW ))
+ if (wcsicmp( pi->pPrintProcessor, L"WinPrint" ))
{
FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor));
SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR);
@@ -2773,7 +2702,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
return 0;
}
- if (RegCreateKeyW( printers_key, pi->pPrinterName, &hkeyPrinter ))
+ if (RegCreateKeyW( printers_key, pi->pPrinterName, &printer_key ))
{
FIXME("Can't create printer %s\n", debugstr_w(pi->pPrinterName));
SetLastError(ERROR_INVALID_PRINTER_NAME);
@@ -2783,24 +2712,24 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
set_devices_and_printerports(pi);
- set_reg_DWORD(hkeyPrinter, AttributesW, pi->Attributes);
- set_reg_szW(hkeyPrinter, DatatypeW, pi->pDatatype);
- set_reg_DWORD(hkeyPrinter, Default_PriorityW, pi->DefaultPriority);
- set_reg_szW(hkeyPrinter, DescriptionW, pi->pComment);
- set_reg_DWORD(hkeyPrinter, dnsTimeoutW, 0);
- set_reg_szW(hkeyPrinter, LocationW, pi->pLocation);
- set_reg_szW(hkeyPrinter, NameW, pi->pPrinterName);
- set_reg_szW(hkeyPrinter, ParametersW, pi->pParameters);
- set_reg_szW(hkeyPrinter, PortW, pi->pPortName);
- set_reg_szW(hkeyPrinter, Print_ProcessorW, pi->pPrintProcessor);
- set_reg_szW(hkeyPrinter, Printer_DriverW, pi->pDriverName);
- set_reg_DWORD(hkeyPrinter, PriorityW, pi->Priority);
- set_reg_szW(hkeyPrinter, Separator_FileW, pi->pSepFile);
- set_reg_szW(hkeyPrinter, Share_NameW, pi->pShareName);
- set_reg_DWORD(hkeyPrinter, StartTimeW, pi->StartTime);
- set_reg_DWORD(hkeyPrinter, StatusW, pi->Status);
- set_reg_DWORD(hkeyPrinter, txTimeoutW, 0);
- set_reg_DWORD(hkeyPrinter, UntilTimeW, pi->UntilTime);
+ set_reg_DWORD( printer_key, L"Attributes", pi->Attributes );
+ set_reg_szW( printer_key, L"Datatype", pi->pDatatype );
+ set_reg_DWORD( printer_key, L"Default Priority", pi->DefaultPriority );
+ set_reg_szW( printer_key, L"Description", pi->pComment );
+ set_reg_DWORD( printer_key, L"dnsTimeout", 0 );
+ set_reg_szW( printer_key, L"Location", pi->pLocation );
+ set_reg_szW( printer_key, L"Name", pi->pPrinterName );
+ set_reg_szW( printer_key, L"Parameters", pi->pParameters );
+ set_reg_szW( printer_key, L"Port", pi->pPortName );
+ set_reg_szW( printer_key, L"Print Processor", pi->pPrintProcessor );
+ set_reg_szW( printer_key, L"Printer Driver", pi->pDriverName );
+ set_reg_DWORD( printer_key, L"Priority", pi->Priority );
+ set_reg_szW( printer_key, L"Separator File", pi->pSepFile );
+ set_reg_szW( printer_key, L"Share Name", pi->pShareName );
+ set_reg_DWORD( printer_key, L"StartTime", pi->StartTime );
+ set_reg_DWORD( printer_key, L"Status", pi->Status );
+ set_reg_DWORD( printer_key, L"txTimeout", 0 );
+ set_reg_DWORD( printer_key, L"UntilTime", pi->UntilTime );
size = DocumentPropertiesW(0, 0, pi->pPrinterName, NULL, NULL, 0);
@@ -2829,10 +2758,10 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
}
}
- set_reg_devmode( hkeyPrinter, Default_DevModeW, dm );
+ set_reg_devmode( printer_key, L"Default DevMode", dm );
if (!pi->pDevMode) HeapFree( GetProcessHeap(), 0, dm );
- RegCloseKey(hkeyPrinter);
+ RegCloseKey( printer_key );
RegCloseKey( printers_key );
if(!OpenPrinterW(pi->pPrinterName, &retval, NULL)) {
ERR("OpenPrinter failing\n");
@@ -2991,7 +2920,7 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
{
if (!create_printers_reg_key( user_default_key, &key ))
{
- RegDeleteValueW( key, deviceW );
+ RegDeleteValueW( key, L"device" );
RegCloseKey( key );
}
SetDefaultPrinterW( NULL );
@@ -3023,33 +2952,33 @@ BOOL WINAPI SetPrinterA( HANDLE printer, DWORD level, LPBYTE data, DWORD command
static void set_printer_2( HKEY key, const PRINTER_INFO_2W *pi )
{
- set_reg_szW( key, NameW, pi->pPrinterName );
- set_reg_szW( key, Share_NameW, pi->pShareName );
- set_reg_szW( key, PortW, pi->pPortName );
- set_reg_szW( key, Printer_DriverW, pi->pDriverName );
- set_reg_szW( key, DescriptionW, pi->pComment );
- set_reg_szW( key, LocationW, pi->pLocation );
+ set_reg_szW( key, L"Name", pi->pPrinterName );
+ set_reg_szW( key, L"Share Name", pi->pShareName );
+ set_reg_szW( key, L"Port", pi->pPortName );
+ set_reg_szW( key, L"Printer Driver", pi->pDriverName );
+ set_reg_szW( key, L"Description", pi->pComment );
+ set_reg_szW( key, L"Location", pi->pLocation );
if (pi->pDevMode)
- set_reg_devmode( key, Default_DevModeW, pi->pDevMode );
+ set_reg_devmode( key, L"Default DevMode", pi->pDevMode );
- set_reg_szW( key, Separator_FileW, pi->pSepFile );
- set_reg_szW( key, Print_ProcessorW, pi->pPrintProcessor );
- set_reg_szW( key, DatatypeW, pi->pDatatype );
- set_reg_szW( key, ParametersW, pi->pParameters );
+ set_reg_szW( key, L"Separator File", pi->pSepFile );
+ set_reg_szW( key, L"Print Processor", pi->pPrintProcessor );
+ set_reg_szW( key, L"Datatype", pi->pDatatype );
+ set_reg_szW( key, L"Parameters", pi->pParameters );
- set_reg_DWORD( key, AttributesW, pi->Attributes );
- set_reg_DWORD( key, PriorityW, pi->Priority );
- set_reg_DWORD( key, Default_PriorityW, pi->DefaultPriority );
- set_reg_DWORD( key, StartTimeW, pi->StartTime );
- set_reg_DWORD( key, UntilTimeW, pi->UntilTime );
+ set_reg_DWORD( key, L"Attributes", pi->Attributes );
+ set_reg_DWORD( key, L"Priority", pi->Priority );
+ set_reg_DWORD( key, L"Default Priority", pi->DefaultPriority );
+ set_reg_DWORD( key, L"StartTime", pi->StartTime );
+ set_reg_DWORD( key, L"UntilTime", pi->UntilTime );
}
static BOOL set_printer_9( HKEY key, const PRINTER_INFO_9W *pi )
{
if (!pi->pDevMode) return FALSE;
- set_reg_devmode( key, Default_DevModeW, pi->pDevMode );
+ set_reg_devmode( key, L"Default DevMode", pi->pDevMode );
return TRUE;
}
@@ -3627,8 +3556,6 @@ static BOOL WINSPOOL_GetStringFromReg(HKEY hkey, LPCWSTR ValueName, LPBYTE ptr,
*/
static void WINSPOOL_GetDefaultDevMode(LPBYTE ptr, DWORD buflen, DWORD *needed)
{
- static const WCHAR winepsW[] = { 'w','i','n','e','p','s','.','d','r','v',0 };
-
if (buflen >= sizeof(DEVMODEW))
{
DEVMODEW *dm = (DEVMODEW *)ptr;
@@ -3636,7 +3563,7 @@ static void WINSPOOL_GetDefaultDevMode(LPBYTE ptr, DWORD buflen, DWORD *needed)
/* the driver will update registry with real values */
memset(dm, 0, sizeof(*dm));
dm->dmSize = sizeof(*dm);
- wcscpy( dm->dmDeviceName, winepsW );
+ wcscpy( dm->dmDeviceName, L"wineps.drv" );
}
*needed = sizeof(DEVMODEW);
}
@@ -3689,7 +3616,8 @@ static BOOL WINSPOOL_GetPrinter_1(HKEY hkeyPrinter, PRINTER_INFO_1W *pi1,
*pcbNeeded = 0;
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Name", ptr, left, &size ))
+ {
if(space && size <= left) {
pi1->pName = (LPWSTR)ptr;
ptr += size;
@@ -3700,7 +3628,8 @@ static BOOL WINSPOOL_GetPrinter_1(HKEY hkeyPrinter, PRINTER_INFO_1W *pi1,
}
/* FIXME: pDescription should be something like "Name,Driver_Name,". */
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Name", ptr, left, &size ))
+ {
if(space && size <= left) {
pi1->pDescription = (LPWSTR)ptr;
ptr += size;
@@ -3710,7 +3639,8 @@ static BOOL WINSPOOL_GetPrinter_1(HKEY hkeyPrinter, PRINTER_INFO_1W *pi1,
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, DescriptionW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Description", ptr, left, &size ))
+ {
if(space && size <= left) {
pi1->pComment = (LPWSTR)ptr;
ptr += size;
@@ -3741,7 +3671,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
*pcbNeeded = 0;
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Name", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pPrinterName = (LPWSTR)ptr;
ptr += size;
@@ -3750,7 +3681,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, Share_NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Share Name", ptr, left, &size))
+ {
if(space && size <= left) {
pi2->pShareName = (LPWSTR)ptr;
ptr += size;
@@ -3759,7 +3691,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, PortW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Port", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pPortName = (LPWSTR)ptr;
ptr += size;
@@ -3768,7 +3701,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, Printer_DriverW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Printer Driver", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pDriverName = (LPWSTR)ptr;
ptr += size;
@@ -3777,7 +3711,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, DescriptionW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Description", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pComment = (LPWSTR)ptr;
ptr += size;
@@ -3786,7 +3721,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, LocationW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Location", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pLocation = (LPWSTR)ptr;
ptr += size;
@@ -3795,7 +3731,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetDevModeFromReg(hkeyPrinter, Default_DevModeW, ptr, left, &size)) {
+ if (WINSPOOL_GetDevModeFromReg( hkeyPrinter, L"Default DevMode", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pDevMode = (LPDEVMODEW)ptr;
ptr += size;
@@ -3815,7 +3752,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, Separator_FileW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Separator File", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pSepFile = (LPWSTR)ptr;
ptr += size;
@@ -3824,7 +3762,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, Print_ProcessorW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Print Processor", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pPrintProcessor = (LPWSTR)ptr;
ptr += size;
@@ -3833,7 +3772,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, DatatypeW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Datatype", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pDatatype = (LPWSTR)ptr;
ptr += size;
@@ -3842,7 +3782,8 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, ParametersW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Parameters", ptr, left, &size ))
+ {
if(space && size <= left) {
pi2->pParameters = (LPWSTR)ptr;
ptr += size;
@@ -3851,12 +3792,13 @@ static BOOL WINSPOOL_GetPrinter_2(HKEY hkeyPrinter, PRINTER_INFO_2W *pi2,
space = FALSE;
*pcbNeeded += size;
}
- if(pi2) {
- pi2->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
- pi2->Priority = get_dword_from_reg( hkeyPrinter, PriorityW );
- pi2->DefaultPriority = get_dword_from_reg( hkeyPrinter, Default_PriorityW );
- pi2->StartTime = get_dword_from_reg( hkeyPrinter, StartTimeW );
- pi2->UntilTime = get_dword_from_reg( hkeyPrinter, UntilTimeW );
+ if (pi2)
+ {
+ pi2->Attributes = get_dword_from_reg( hkeyPrinter, L"Attributes" );
+ pi2->Priority = get_dword_from_reg( hkeyPrinter, L"Priority" );
+ pi2->DefaultPriority = get_dword_from_reg( hkeyPrinter, L"Default Priority" );
+ pi2->StartTime = get_dword_from_reg( hkeyPrinter, L"StartTime" );
+ pi2->UntilTime = get_dword_from_reg( hkeyPrinter, L"UntilTime" );
}
if(!space && pi2) /* zero out pi2 if we can't completely fill buf */
@@ -3879,7 +3821,8 @@ static BOOL WINSPOOL_GetPrinter_4(HKEY hkeyPrinter, PRINTER_INFO_4W *pi4,
*pcbNeeded = 0;
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Name", ptr, left, &size ))
+ {
if(space && size <= left) {
pi4->pPrinterName = (LPWSTR)ptr;
ptr += size;
@@ -3889,7 +3832,7 @@ static BOOL WINSPOOL_GetPrinter_4(HKEY hkeyPrinter, PRINTER_INFO_4W *pi4,
*pcbNeeded += size;
}
if(pi4) {
- pi4->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
+ pi4->Attributes = get_dword_from_reg( hkeyPrinter, L"Attributes" );
}
if(!space && pi4) /* zero out pi4 if we can't completely fill buf */
@@ -3912,7 +3855,8 @@ static BOOL WINSPOOL_GetPrinter_5(HKEY hkeyPrinter, PRINTER_INFO_5W *pi5,
*pcbNeeded = 0;
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, NameW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Name", ptr, left, &size ))
+ {
if(space && size <= left) {
pi5->pPrinterName = (LPWSTR)ptr;
ptr += size;
@@ -3921,7 +3865,8 @@ static BOOL WINSPOOL_GetPrinter_5(HKEY hkeyPrinter, PRINTER_INFO_5W *pi5,
space = FALSE;
*pcbNeeded += size;
}
- if(WINSPOOL_GetStringFromReg(hkeyPrinter, PortW, ptr, left, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyPrinter, L"Port", ptr, left, &size ))
+ {
if(space && size <= left) {
pi5->pPortName = (LPWSTR)ptr;
ptr += size;
@@ -3931,9 +3876,9 @@ static BOOL WINSPOOL_GetPrinter_5(HKEY hkeyPrinter, PRINTER_INFO_5W *pi5,
*pcbNeeded += size;
}
if(pi5) {
- pi5->Attributes = get_dword_from_reg( hkeyPrinter, AttributesW );
- pi5->DeviceNotSelectedTimeout = get_dword_from_reg( hkeyPrinter, dnsTimeoutW );
- pi5->TransmissionRetryTimeout = get_dword_from_reg( hkeyPrinter, txTimeoutW );
+ pi5->Attributes = get_dword_from_reg( hkeyPrinter, L"Attributes" );
+ pi5->DeviceNotSelectedTimeout = get_dword_from_reg( hkeyPrinter, L"dnsTimeout" );
+ pi5->TransmissionRetryTimeout = get_dword_from_reg( hkeyPrinter, L"txTimeout" );
}
if(!space && pi5) /* zero out pi5 if we can't completely fill buf */
@@ -3956,7 +3901,7 @@ static BOOL WINSPOOL_GetPrinter_7(HKEY hkeyPrinter, PRINTER_INFO_7W *pi7, LPBYTE
*pcbNeeded = 0;
- if (! WINSPOOL_GetStringFromReg(hkeyPrinter, ObjectGUIDW, ptr, left, &size))
+ if (!WINSPOOL_GetStringFromReg( hkeyPrinter, L"ObjectGUID", ptr, left, &size ))
{
ptr = NULL;
size = sizeof(pi7->pszObjectGUID);
@@ -3992,7 +3937,8 @@ static BOOL WINSPOOL_GetPrinter_9(HKEY hkeyPrinter, PRINTER_INFO_9W *pi9, LPBYTE
*pcbNeeded = 0;
- if(WINSPOOL_GetDevModeFromReg(hkeyPrinter, Default_DevModeW, buf, cbBuf, &size)) {
+ if (WINSPOOL_GetDevModeFromReg( hkeyPrinter, L"Default DevMode", buf, cbBuf, &size ))
+ {
if(space && size <= cbBuf) {
pi9->pDevMode = (LPDEVMODEW)buf;
} else
@@ -4118,7 +4064,7 @@ BOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter,
size = sizeof(PRINTER_INFO_6);
if (size <= cbBuf) {
/* FIXME: We do not update the status yet */
- pi6->dwStatus = get_dword_from_reg( hkeyPrinter, StatusW );
+ pi6->dwStatus = get_dword_from_reg( hkeyPrinter, L"Status" );
ret = TRUE;
} else {
ret = FALSE;
@@ -4507,14 +4453,14 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
}
- /* Reserve Space for the largest subdir and a Backslash*/
- size = sizeof(driverdir) - sizeof(Version3_SubdirW) - sizeof(WCHAR);
+ /* Reserve Space for "\\3\\" + \0 */
+ size = sizeof(driverdir) - 4 * sizeof(WCHAR);
if (!GetPrinterDriverDirectoryW(NULL, (LPWSTR) env->envname, 1, (LPBYTE) driverdir, size, &size)) {
/* Should never Fail */
return FALSE;
}
wcscat( driverdir, env->versionsubdir );
- wcscat( driverdir, backslashW );
+ wcscat( driverdir, L"\\" );
/* dirlen must not include the terminating zero */
dirlen = wcslen( driverdir ) * sizeof(WCHAR);
@@ -4537,30 +4483,33 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
/* .pDriverPath is the Graphics rendering engine.
The full Path is required to avoid a crash in some apps */
- if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, DriverW, strPtr, 0, &size)) {
+ if (get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Driver", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- get_filename_from_reg(hkeyDriver, driverdir, dirlen, DriverW, strPtr, size, &tmp);
+ get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Driver", strPtr, size, &tmp );
if (di) di->pDriverPath = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
}
/* .pDataFile: For postscript-drivers, this is the ppd-file */
- if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Data_FileW, strPtr, 0, &size)) {
+ if (get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Data File", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- get_filename_from_reg(hkeyDriver, driverdir, dirlen, Data_FileW, strPtr, size, &size);
+ get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Data File", strPtr, size, &size );
if (di) di->pDataFile = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pConfigFile is the Driver user Interface */
- if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Configuration_FileW, strPtr, 0, &size)) {
+ if (get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Configuration File", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- get_filename_from_reg(hkeyDriver, driverdir, dirlen, Configuration_FileW, strPtr, size, &size);
+ get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Configuration File", strPtr, size, &size );
if (di) di->pConfigFile = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
@@ -4579,20 +4528,22 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
}
/* .pHelpFile */
- if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Help_FileW, strPtr, 0, &size)) {
+ if (get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Help File", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- get_filename_from_reg(hkeyDriver, driverdir, dirlen, Help_FileW, strPtr, size, &size);
+ get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Help File", strPtr, size, &size );
if (di) di->pHelpFile = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pDependentFiles */
- if (get_filename_from_reg(hkeyDriver, driverdir, dirlen, Dependent_FilesW, strPtr, 0, &size)) {
+ if (get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Dependent Files", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- get_filename_from_reg(hkeyDriver, driverdir, dirlen, Dependent_FilesW, strPtr, size, &size);
+ get_filename_from_reg( hkeyDriver, driverdir, dirlen, L"Dependent Files", strPtr, size, &size );
if (di) di->pDependentFiles = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
@@ -4608,20 +4559,22 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
}
/* .pMonitorName is the optional Language Monitor */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, MonitorW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"Monitor", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, MonitorW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"Monitor", strPtr, size, &size );
if (di) di->pMonitorName = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pDefaultDataType */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, DatatypeW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"Datatype", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, DatatypeW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"Datatype", strPtr, size, &size );
if (di) di->pDefaultDataType = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
@@ -4634,10 +4587,11 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
}
/* .pszzPreviousNames */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, Previous_NamesW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"Previous Names", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, Previous_NamesW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"Previous Names", strPtr, size, &size );
if (di) di->pszzPreviousNames = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
@@ -4653,40 +4607,44 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
TRACE("%s: DriverDate + DriverVersion not supported\n", debugstr_w(DriverName));
/* .pszMfgName */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, ManufacturerW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"Manufacturer", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, ManufacturerW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"Manufacturer", strPtr, size, &size );
if (di) di->pszMfgName = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pszOEMUrl */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, OEM_UrlW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"OEM Url", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, OEM_UrlW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"OEM Url", strPtr, size, &size );
if (di) di->pszOEMUrl = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pszHardwareID */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, HardwareIDW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"HardwareID", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, HardwareIDW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"HardwareID", strPtr, size, &size );
if (di) di->pszHardwareID = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
}
/* .pszProvider */
- if (WINSPOOL_GetStringFromReg(hkeyDriver, ProviderW, strPtr, 0, &size)) {
+ if (WINSPOOL_GetStringFromReg( hkeyDriver, L"Provider", strPtr, 0, &size ))
+ {
*pcbNeeded += size;
if(*pcbNeeded <= cbBuf)
- WINSPOOL_GetStringFromReg(hkeyDriver, ProviderW, strPtr, size, &size);
+ WINSPOOL_GetStringFromReg( hkeyDriver, L"Provider", strPtr, size, &size );
if (di) di->pszProvider = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? pDriverStrings + (*pcbNeeded) : NULL;
@@ -4748,8 +4706,7 @@ BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment,
size = sizeof(DriverName);
DriverName[0] = 0;
- ret = RegQueryValueExW(hkeyPrinter, Printer_DriverW, 0, &type,
- (LPBYTE)DriverName, &size);
+ ret = RegQueryValueExW( hkeyPrinter, L"Printer Driver", 0, &type, (BYTE *)DriverName, &size );
RegCloseKey(hkeyPrinter);
if(ret != ERROR_SUCCESS) {
ERR("Can't get DriverName for printer %s\n", debugstr_w(name));
@@ -5186,7 +5143,6 @@ BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
LPBYTE pDriverInfo, DWORD cbBuf,
LPDWORD pcbNeeded, LPDWORD pcReturned)
{
- static const WCHAR allW[] = {'a','l','l',0};
BOOL ret;
DWORD found;
@@ -5213,7 +5169,7 @@ BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
memset( pDriverInfo, 0, cbBuf);
/* Exception: pull all printers */
- if (pEnvironment && !wcscmp( pEnvironment, allW ))
+ if (pEnvironment && !wcscmp( pEnvironment, L"all" ))
{
DWORD i, needed, bufsize = cbBuf;
DWORD total_found = 0;
@@ -5496,7 +5452,7 @@ BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
len = max(100, (insize + 20));
buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR));
- if (!GetProfileStringW(windowsW, deviceW, emptyStringW, buffer, len))
+ if (!GetProfileStringW( L"windows", L"device", L"", buffer, len ))
{
SetLastError (ERROR_FILE_NOT_FOUND);
retval = FALSE;
@@ -5650,7 +5606,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
if (!create_printers_reg_key( user_default_key, &hdev ))
{
- RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (wcslen( buffer ) + 1) * sizeof(WCHAR));
+ RegSetValueExW( hdev, L"device", 0, REG_SZ, (BYTE *)buffer, (wcslen( buffer ) + 1) * sizeof(WCHAR) );
RegCloseKey(hdev);
}
}
@@ -5763,8 +5719,8 @@ DWORD WINAPI SetPrinterDataA(HANDLE hPrinter, LPSTR pValueName, DWORD Type,
DWORD WINAPI SetPrinterDataW(HANDLE hPrinter, LPWSTR pValueName, DWORD Type,
LPBYTE pData, DWORD cbData)
{
- return SetPrinterDataExW(hPrinter, PrinterDriverDataW, pValueName, Type,
- pData, cbData);
+ return SetPrinterDataExW( hPrinter, L"PrinterDriverData", pValueName, Type,
+ pData, cbData );
}
/******************************************************************************
@@ -5886,8 +5842,8 @@ DWORD WINAPI GetPrinterDataA(HANDLE hPrinter, LPSTR pValueName, LPDWORD pType,
DWORD WINAPI GetPrinterDataW(HANDLE hPrinter, LPWSTR pValueName, LPDWORD pType,
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
{
- return GetPrinterDataExW(hPrinter, PrinterDriverDataW, pValueName, pType,
- pData, nSize, pcbNeeded);
+ return GetPrinterDataExW( hPrinter, L"PrinterDriverData", pValueName, pType,
+ pData, nSize, pcbNeeded );
}
/*******************************************************************************
@@ -7897,8 +7853,6 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
DWORD needed;
HKEY hkey;
WCHAR output[1024];
- static const WCHAR spooler_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
- 'P','r','i','n','t','i','n','g','\\','S','p','o','o','l','e','r',0};
if (!portname)
{
@@ -7910,7 +7864,7 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename),
debugstr_w(portname));
- if (!wcsncmp( portname, FILE_Port, wcslen( FILE_Port ) ))
+ if (!wcsncmp( portname, L"FILE:", ARRAY_SIZE(L"FILE:") - 1 ))
{
ret = schedule_file( job->filename );
}
@@ -7931,7 +7885,7 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
output[0] = 0;
/* @@ Wine registry key: HKCU\Software\Wine\Printing\Spooler */
- if (RegOpenKeyW( HKEY_CURRENT_USER, spooler_key, &hkey ) == ERROR_SUCCESS)
+ if (!RegOpenKeyW( HKEY_CURRENT_USER, L"Software\\Wine\\Printing\\Spooler", &hkey ))
{
DWORD type, count = sizeof(output);
RegQueryValueExW( hkey, portname, NULL, &type, (BYTE *)output, &count );
@@ -8030,7 +7984,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
return NULL;
pi5 = HeapAlloc(GetProcessHeap(), 0, len);
GetPrinterW(hPrinter, 5, (LPBYTE)pi5, len, &len);
- if(!pi5->pPortName || wcscmp( pi5->pPortName, FILE_Port ))
+ if(!pi5->pPortName || wcscmp( pi5->pPortName, L"FILE:" ))
{
HeapFree(GetProcessHeap(), 0, pi5);
return NULL;
@@ -8038,7 +7992,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
HeapFree(GetProcessHeap(), 0, pi5);
}
- if(doc->lpszOutput == NULL || !wcscmp( doc->lpszOutput, FILE_Port ))
+ if(doc->lpszOutput == NULL || !wcscmp( doc->lpszOutput, L"FILE:" ))
{
LPWSTR name;
--
2.23.0
1
0
[PATCH 3/4] winspool: Add a helper to open various printer registry keys.
by Huw Davies Oct. 27, 2021
by Huw Davies Oct. 27, 2021
Oct. 27, 2021
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winspool.drv/info.c | 255 ++++++++++++++++++++-------------------
1 file changed, 128 insertions(+), 127 deletions(-)
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index 7cffc9ae7ec..9bc5c5e7a8c 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -126,37 +126,6 @@ static opened_printer_t **printer_handles;
static UINT nb_printer_handles;
static LONG next_job_id = 1;
-static const WCHAR DriversW[] = { 'S','y','s','t','e','m','\\',
- 'C','u', 'r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
- 'c','o','n','t','r','o','l','\\',
- 'P','r','i','n','t','\\',
- 'E','n','v','i','r','o','n','m','e','n','t','s','\\',
- '%','s','\\','D','r','i','v','e','r','s','%','s',0 };
-
-static const WCHAR PrintersW[] = {'S','y','s','t','e','m','\\',
- 'C','u', 'r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
- 'C','o','n','t','r','o','l','\\',
- 'P','r','i','n','t','\\',
- 'P','r','i','n','t','e','r','s',0};
-
-static const WCHAR user_default_reg_key[] = { 'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'W','i','n','d','o','w','s',' ','N','T','\\',
- 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
- 'W','i','n','d','o','w','s',0};
-
-static const WCHAR user_printers_reg_key[] = { 'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'W','i','n','d','o','w','s',' ','N','T','\\',
- 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
- 'D','e','v','i','c','e','s',0};
-
-static const WCHAR WinNT_CV_PrinterPortsW[] = { 'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'W','i','n','d','o','w','s',' ','N','T','\\',
- 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
- 'P','r','i','n','t','e','r','P','o','r','t','s',0};
-
static WCHAR envname_win40W[] = {'W','i','n','d','o','w','s',' ','4','.','0',0};
static const WCHAR envname_x64W[] = {'W','i','n','d','o','w','s',' ','x','6','4',0};
static WCHAR envname_x86W[] = {'W','i','n','d','o','w','s',' ','N','T',' ','x','8','6',0};
@@ -456,17 +425,18 @@ static HKEY WINSPOOL_OpenDriverReg(const void *pEnvironment)
LPWSTR buffer;
const printenv_t *env;
unsigned int len;
+ static const WCHAR driver_fmt[] = L"System\\CurrentControlSet\\control\\Print\\Environments\\%s\\Drivers%s";
TRACE("(%s)\n", debugstr_w(pEnvironment));
env = validate_envW(pEnvironment);
if (!env) return NULL;
- len = wcslen( DriversW ) + wcslen( env->envname ) + wcslen( env->versionregpath ) + 1;
+ len = ARRAY_SIZE( driver_fmt ) + wcslen( env->envname ) + wcslen( env->versionregpath );
buffer = heap_alloc( len * sizeof(WCHAR) );
if (buffer)
{
- swprintf( buffer, len, DriversW, env->envname, env->versionregpath );
+ swprintf( buffer, len, driver_fmt, env->envname, env->versionregpath );
RegCreateKeyW( HKEY_LOCAL_MACHINE, buffer, &retval );
heap_free( buffer );
}
@@ -652,13 +622,37 @@ static HANDLE get_backend_handle( HANDLE hprn )
return printer->backend_printer;
}
+enum printers_key
+{
+ system_printers_key,
+ user_printers_key,
+ user_ports_key,
+ user_default_key,
+};
+
+static DWORD create_printers_reg_key( enum printers_key type, HKEY *key )
+{
+ switch( type )
+ {
+ case system_printers_key:
+ return RegCreateKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Print\\Printers", key );
+ case user_printers_key:
+ return RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices", key );
+ case user_ports_key:
+ return RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\PrinterPorts", key );
+ case user_default_key:
+ return RegCreateKeyW( HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows", key );
+ }
+ return ERROR_PATH_NOT_FOUND;
+}
+
static DWORD open_printer_reg_key( const WCHAR *name, HKEY *key )
{
HKEY printers;
DWORD err;
*key = NULL;
- err = RegCreateKeyW( HKEY_LOCAL_MACHINE, PrintersW, &printers );
+ err = create_printers_reg_key( system_printers_key, &printers );
if (err) return err;
err = RegOpenKeyW( printers, name, key );
@@ -810,7 +804,7 @@ static BOOL init_unix_printers( void )
NTSTATUS status;
int i;
- if (RegCreateKeyW( HKEY_LOCAL_MACHINE, PrintersW, &printers_key ) != ERROR_SUCCESS)
+ if (create_printers_reg_key( system_printers_key, &printers_key ))
{
ERR( "Can't create Printers key\n" );
return FALSE;
@@ -1207,7 +1201,7 @@ static HANDLE init_mutex;
void WINSPOOL_LoadSystemPrinters(void)
{
- HKEY hkey, hkeyPrinters;
+ HKEY printers_key, printer_key;
DWORD needed, num, i;
WCHAR PrinterName[256];
@@ -1229,21 +1223,18 @@ void WINSPOOL_LoadSystemPrinters(void)
/* This ensures that all printer entries have a valid Name value. If causes
problems later if they don't. If one is found to be missed we create one
and set it equal to the name of the key */
- if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) == ERROR_SUCCESS) {
- if(RegQueryInfoKeyW(hkeyPrinters, NULL, NULL, NULL, &num, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
- for(i = 0; i < num; i++) {
- if(RegEnumKeyW(hkeyPrinters, i, PrinterName, ARRAY_SIZE(PrinterName)) == ERROR_SUCCESS) {
- if(RegOpenKeyW(hkeyPrinters, PrinterName, &hkey) == ERROR_SUCCESS) {
- if(RegQueryValueExW(hkey, NameW, 0, 0, 0, &needed) == ERROR_FILE_NOT_FOUND) {
- set_reg_szW(hkey, NameW, PrinterName);
- }
- RegCloseKey(hkey);
+ if (!create_printers_reg_key( system_printers_key, &printers_key ))
+ {
+ if (!RegQueryInfoKeyW( printers_key, NULL, NULL, NULL, &num, NULL, NULL, NULL, NULL, NULL, NULL, NULL ))
+ for (i = 0; i < num; i++)
+ if (!RegEnumKeyW( printers_key, i, PrinterName, ARRAY_SIZE(PrinterName) ))
+ if (!RegOpenKeyW( printers_key, PrinterName, &printer_key ))
+ {
+ if (RegQueryValueExW( printer_key, NameW, 0, 0, 0, &needed ) == ERROR_FILE_NOT_FOUND)
+ set_reg_szW( printer_key, NameW, PrinterName );
+ RegCloseKey( printer_key );
}
- }
- }
- }
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
}
old_printer_check( FALSE );
@@ -2684,7 +2675,7 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
{
DWORD portlen = wcslen( pi->pPortName ) * sizeof(WCHAR);
WCHAR *devline;
- HKEY hkey;
+ HKEY key;
TRACE("(%p) %s\n", pi, debugstr_w(pi->pPrinterName));
@@ -2697,17 +2688,19 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
wcscat( devline, pi->pPortName );
TRACE("using %s\n", debugstr_w(devline));
- if (!RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey)) {
- RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
- (wcslen( devline ) + 1) * sizeof(WCHAR));
- RegCloseKey(hkey);
+ if (!create_printers_reg_key( user_printers_key, &key ))
+ {
+ RegSetValueExW( key, pi->pPrinterName, 0, REG_SZ, (BYTE *)devline,
+ (wcslen( devline ) + 1) * sizeof(WCHAR) );
+ RegCloseKey( key );
}
wcscat( devline, timeout_15_45 );
- if (!RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey)) {
- RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
- (wcslen( devline ) + 1) * sizeof(WCHAR));
- RegCloseKey(hkey);
+ if (!create_printers_reg_key( user_ports_key, &key ))
+ {
+ RegSetValueExW( key, pi->pPrinterName, 0, REG_SZ, (BYTE *)devline,
+ (wcslen( devline ) + 1) * sizeof(WCHAR) );
+ RegCloseKey( key );
}
HeapFree(GetProcessHeap(), 0, devline);
}
@@ -2721,7 +2714,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
PRINTER_INFO_2W *pi = (PRINTER_INFO_2W *) pPrinter;
LPDEVMODEW dm;
HANDLE retval;
- HKEY hkeyPrinter, hkeyPrinters, hkeyDriver, hkeyDrivers;
+ HKEY hkeyPrinter, printers_key, hkeyDriver, hkeyDrivers;
LONG size;
TRACE("(%s,%d,%p)\n", debugstr_w(pName), Level, pPrinter);
@@ -2740,16 +2733,17 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
- if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
- ERROR_SUCCESS) {
+ if (create_printers_reg_key( system_printers_key, &printers_key ))
+ {
ERR("Can't create Printers key\n");
return 0;
}
- if(!RegOpenKeyW(hkeyPrinters, pi->pPrinterName, &hkeyPrinter)) {
+ if (!RegOpenKeyW( printers_key, pi->pPrinterName, &hkeyPrinter ))
+ {
if (!RegQueryValueW(hkeyPrinter, AttributesW, NULL, NULL)) {
SetLastError(ERROR_PRINTER_ALREADY_EXISTS);
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return 0;
}
RegCloseKey(hkeyPrinter);
@@ -2757,13 +2751,13 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
hkeyDrivers = WINSPOOL_OpenDriverReg(NULL);
if(!hkeyDrivers) {
ERR("Can't create Drivers key\n");
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return 0;
}
if(RegOpenKeyW(hkeyDrivers, pi->pDriverName, &hkeyDriver) !=
ERROR_SUCCESS) {
WARN("Can't find driver %s\n", debugstr_w(pi->pDriverName));
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
RegCloseKey(hkeyDrivers);
SetLastError(ERROR_UNKNOWN_PRINTER_DRIVER);
return 0;
@@ -2775,15 +2769,15 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
{
FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor));
SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return 0;
}
- if(RegCreateKeyW(hkeyPrinters, pi->pPrinterName, &hkeyPrinter) !=
- ERROR_SUCCESS) {
+ if (RegCreateKeyW( printers_key, pi->pPrinterName, &hkeyPrinter ))
+ {
FIXME("Can't create printer %s\n", debugstr_w(pi->pPrinterName));
SetLastError(ERROR_INVALID_PRINTER_NAME);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return 0;
}
@@ -2839,7 +2833,7 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
if (!pi->pDevMode) HeapFree( GetProcessHeap(), 0, dm );
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
if(!OpenPrinterW(pi->pPrinterName, &retval, NULL)) {
ERR("OpenPrinter failing\n");
return 0;
@@ -2959,7 +2953,7 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
{
LPCWSTR lpNameW = get_opened_printer_name(hPrinter);
config_module_t *config_module;
- HKEY hkeyPrinters, hkey;
+ HKEY key;
WCHAR def[MAX_PATH];
DWORD size = ARRAY_SIZE(def);
@@ -2975,27 +2969,30 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
}
LeaveCriticalSection(&config_modules_cs);
- if(RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) == ERROR_SUCCESS) {
- RegDeleteTreeW(hkeyPrinters, lpNameW);
- RegCloseKey(hkeyPrinters);
+ if (!create_printers_reg_key( system_printers_key, &key ))
+ {
+ RegDeleteTreeW( key, lpNameW );
+ RegCloseKey( key );
}
- if(RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey) == ERROR_SUCCESS) {
- RegDeleteValueW(hkey, lpNameW);
- RegCloseKey(hkey);
+ if (!create_printers_reg_key( user_printers_key, &key ))
+ {
+ RegDeleteValueW( key, lpNameW );
+ RegCloseKey( key );
}
- if(RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey) == ERROR_SUCCESS) {
- RegDeleteValueW(hkey, lpNameW);
- RegCloseKey(hkey);
+ if (!create_printers_reg_key( user_ports_key, &key ) == ERROR_SUCCESS)
+ {
+ RegDeleteValueW( key, lpNameW );
+ RegCloseKey( key );
}
if (GetDefaultPrinterW( def, &size ) && !wcscmp( def, lpNameW ))
{
- if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey ))
+ if (!create_printers_reg_key( user_default_key, &key ))
{
- RegDeleteValueW( hkey, deviceW );
- RegCloseKey( hkey );
+ RegDeleteValueW( key, deviceW );
+ RegCloseKey( key );
}
SetDefaultPrinterW( NULL );
}
@@ -4222,7 +4219,7 @@ static BOOL WINSPOOL_EnumPrintersW(DWORD dwType, LPWSTR lpszName,
LPDWORD lpdwReturned)
{
- HKEY hkeyPrinters, hkeyPrinter;
+ HKEY printers_key, hkeyPrinter;
WCHAR PrinterName[255];
DWORD needed = 0, number = 0;
DWORD used, i, left;
@@ -4255,15 +4252,15 @@ static BOOL WINSPOOL_EnumPrintersW(DWORD dwType, LPWSTR lpszName,
return FALSE;
}
- if(RegCreateKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters) !=
- ERROR_SUCCESS) {
+ if (create_printers_reg_key( system_printers_key, &printers_key ))
+ {
ERR("Can't create Printers key\n");
return FALSE;
}
- if(RegQueryInfoKeyA(hkeyPrinters, NULL, NULL, NULL, &number, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) {
- RegCloseKey(hkeyPrinters);
+ if (RegQueryInfoKeyA( printers_key, NULL, NULL, NULL, &number, NULL, NULL, NULL, NULL, NULL, NULL, NULL ))
+ {
+ RegCloseKey( printers_key );
ERR("Can't query Printers key\n");
return FALSE;
}
@@ -4285,22 +4282,23 @@ static BOOL WINSPOOL_EnumPrintersW(DWORD dwType, LPWSTR lpszName,
default:
SetLastError(ERROR_INVALID_LEVEL);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return FALSE;
}
pi = (used <= cbBuf) ? lpbPrinters : NULL;
for(i = 0; i < number; i++) {
- if(RegEnumKeyW(hkeyPrinters, i, PrinterName, ARRAY_SIZE(PrinterName)) != ERROR_SUCCESS) {
+ if (RegEnumKeyW( printers_key, i, PrinterName, ARRAY_SIZE(PrinterName) ))
+ {
ERR("Can't enum key number %d\n", i);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return FALSE;
}
TRACE("Printer %d is %s\n", i, debugstr_w(PrinterName));
- if(RegOpenKeyW(hkeyPrinters, PrinterName, &hkeyPrinter) !=
- ERROR_SUCCESS) {
+ if (RegOpenKeyW( printers_key, PrinterName, &hkeyPrinter ))
+ {
ERR("Can't open key %s\n", debugstr_w(PrinterName));
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return FALSE;
}
@@ -4340,12 +4338,12 @@ static BOOL WINSPOOL_EnumPrintersW(DWORD dwType, LPWSTR lpszName,
default:
ERR("Shouldn't be here!\n");
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return FALSE;
}
RegCloseKey(hkeyPrinter);
}
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
if(lpdwNeeded)
*lpdwNeeded = used;
@@ -5609,16 +5607,16 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
pszPrinter = NULL;
/* we have no default Printer: search local Printers and use the first */
- if (!RegOpenKeyExW(HKEY_LOCAL_MACHINE, PrintersW, 0, KEY_READ, &hreg)) {
-
+ if (!create_printers_reg_key( system_printers_key, &hreg ))
+ {
default_printer[0] = '\0';
size = ARRAY_SIZE(default_printer);
- if (!RegEnumKeyExW(hreg, 0, default_printer, &size, NULL, NULL, NULL, NULL)) {
-
+ if (!RegEnumKeyExW( hreg, 0, default_printer, &size, NULL, NULL, NULL, NULL ))
+ {
pszPrinter = default_printer;
TRACE("using %s\n", debugstr_w(pszPrinter));
}
- RegCloseKey(hreg);
+ RegCloseKey( hreg );
}
if (pszPrinter == NULL) {
@@ -5632,8 +5630,8 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
namelen = wcslen( pszPrinter );
size = namelen + (MAX_PATH * 2) + 3; /* printer,driver,port and a 0 */
buffer = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
- if (!buffer ||
- (RegOpenKeyExW(HKEY_CURRENT_USER, user_printers_reg_key, 0, KEY_READ, &hreg) != ERROR_SUCCESS)) {
+ if (!buffer || create_printers_reg_key( user_printers_key, &hreg ))
+ {
HeapFree(GetProcessHeap(), 0, buffer);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
@@ -5650,7 +5648,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
if (!lres) {
HKEY hdev;
- if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hdev))
+ if (!create_printers_reg_key( user_default_key, &hdev ))
{
RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (wcslen( buffer ) + 1) * sizeof(WCHAR));
RegCloseKey(hdev);
@@ -5777,7 +5775,7 @@ DWORD WINAPI GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
{
opened_printer_t *printer;
- HKEY hkeyPrinters, hkeyPrinter = 0, hkeySubkey = 0;
+ HKEY printers_key, hkeyPrinter = 0, hkeySubkey = 0;
DWORD ret;
TRACE("(%p, %s, %s, %p, %p, %u, %p)\n", hPrinter, debugstr_a(pKeyName),
@@ -5786,34 +5784,35 @@ DWORD WINAPI GetPrinterDataExA(HANDLE hPrinter, LPCSTR pKeyName,
printer = get_opened_printer(hPrinter);
if(!printer) return ERROR_INVALID_HANDLE;
- ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
+ ret = create_printers_reg_key( system_printers_key, &printers_key );
if (ret) return ret;
TRACE("printer->name: %s\n", debugstr_w(printer->name));
if (printer->name) {
- ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
- if (ret) {
- RegCloseKey(hkeyPrinters);
+ ret = RegOpenKeyW( printers_key, printer->name, &hkeyPrinter );
+ if (ret)
+ {
+ RegCloseKey( printers_key );
return ret;
}
if((ret = RegOpenKeyA(hkeyPrinter, pKeyName, &hkeySubkey)) != ERROR_SUCCESS) {
WARN("Can't open subkey %s: %d\n", debugstr_a(pKeyName), ret);
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return ret;
}
}
*pcbNeeded = nSize;
- ret = RegQueryValueExA(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
- 0, pType, pData, pcbNeeded);
+ ret = RegQueryValueExA( printer->name ? hkeySubkey : printers_key, pValueName,
+ 0, pType, pData, pcbNeeded );
if (!ret && !pData) ret = ERROR_MORE_DATA;
RegCloseKey(hkeySubkey);
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
TRACE("--> %d\n", ret);
return ret;
@@ -5827,7 +5826,7 @@ DWORD WINAPI GetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
LPBYTE pData, DWORD nSize, LPDWORD pcbNeeded)
{
opened_printer_t *printer;
- HKEY hkeyPrinters, hkeyPrinter = 0, hkeySubkey = 0;
+ HKEY printers_key, hkeyPrinter = 0, hkeySubkey = 0;
DWORD ret;
TRACE("(%p, %s, %s, %p, %p, %u, %p)\n", hPrinter, debugstr_w(pKeyName),
@@ -5836,34 +5835,36 @@ DWORD WINAPI GetPrinterDataExW(HANDLE hPrinter, LPCWSTR pKeyName,
printer = get_opened_printer(hPrinter);
if(!printer) return ERROR_INVALID_HANDLE;
- ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, PrintersW, &hkeyPrinters);
+ ret = create_printers_reg_key( system_printers_key, &printers_key );
if (ret) return ret;
TRACE("printer->name: %s\n", debugstr_w(printer->name));
- if (printer->name) {
-
- ret = RegOpenKeyW(hkeyPrinters, printer->name, &hkeyPrinter);
- if (ret) {
- RegCloseKey(hkeyPrinters);
+ if (printer->name)
+ {
+ ret = RegOpenKeyW( printers_key, printer->name, &hkeyPrinter);
+ if (ret)
+ {
+ RegCloseKey( printers_key );
return ret;
}
- if((ret = RegOpenKeyW(hkeyPrinter, pKeyName, &hkeySubkey)) != ERROR_SUCCESS) {
+ if ((ret = RegOpenKeyW(hkeyPrinter, pKeyName, &hkeySubkey)) != ERROR_SUCCESS)
+ {
WARN("Can't open subkey %s: %d\n", debugstr_w(pKeyName), ret);
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
return ret;
}
}
*pcbNeeded = nSize;
- ret = RegQueryValueExW(printer->name ? hkeySubkey : hkeyPrinters, pValueName,
- 0, pType, pData, pcbNeeded);
+ ret = RegQueryValueExW( printer->name ? hkeySubkey : printers_key, pValueName,
+ 0, pType, pData, pcbNeeded );
if (!ret && !pData) ret = ERROR_MORE_DATA;
RegCloseKey(hkeySubkey);
RegCloseKey(hkeyPrinter);
- RegCloseKey(hkeyPrinters);
+ RegCloseKey( printers_key );
TRACE("--> %d\n", ret);
return ret;
--
2.23.0
1
0
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winspool.drv/Makefile.in | 3 +-
dlls/winspool.drv/cups.c | 47 +++++-----
dlls/winspool.drv/info.c | 157 ++++++++++++++++++----------------
dlls/winspool.drv/wspool.c | 16 ++--
dlls/winspool.drv/wspool.h | 17 ++--
5 files changed, 121 insertions(+), 119 deletions(-)
diff --git a/dlls/winspool.drv/Makefile.in b/dlls/winspool.drv/Makefile.in
index d40813d649c..673b26e1fae 100644
--- a/dlls/winspool.drv/Makefile.in
+++ b/dlls/winspool.drv/Makefile.in
@@ -1,12 +1,11 @@
EXTRADEFS = -D_SPOOL32_
MODULE = winspool.drv
+UNIXLIB = winspool.so
IMPORTLIB = winspool
IMPORTS = user32 gdi32 advapi32
EXTRAINCL = $(CUPS_CFLAGS)
EXTRALIBS = $(APPLICATIONSERVICES_LIBS)
-EXTRADLLFLAGS = -mcygwin
-
C_SRCS = \
cups.c \
info.c \
diff --git a/dlls/winspool.drv/cups.c b/dlls/winspool.drv/cups.c
index 511cf9a5c4d..2bc5c9aafad 100644
--- a/dlls/winspool.drv/cups.c
+++ b/dlls/winspool.drv/cups.c
@@ -17,20 +17,22 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#if 0
+#pragma makedep unix
+#endif
+
#include "config.h"
-#include "wine/port.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
+#include <dlfcn.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
-#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
-#endif
#ifdef HAVE_CUPS_CUPS_H
#include <cups/cups.h>
#endif
@@ -107,6 +109,7 @@
#include "ddk/winsplp.h"
#include "wine/debug.h"
#include "wine/unicode.h"
+#include "wine/unixlib.h"
#include "wspool.h"
@@ -115,21 +118,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(winspool);
static const WCHAR CUPS_Port[] = { 'C','U','P','S',':',0 };
static const WCHAR LPR_Port[] = { 'L','P','R',':',0 };
-/* Temporary helpers until switch to unixlib */
-#include "winnls.h"
-#include "wine/heap.h"
-#define malloc( sz ) heap_alloc( sz )
-#define free( ptr ) heap_free( ptr )
-static DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
-{
- return MultiByteToWideChar( CP_UNIXCP, 0, src, srclen, dst, dstlen );
-}
-static int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict )
-{
- /* FIXME: strict */
- return WideCharToMultiByte( CP_UNIXCP, 0, src, srclen, dst, dstlen, NULL, NULL );
-}
-
#ifdef SONAME_LIBCUPS
static void *libcups_handle;
@@ -158,7 +146,7 @@ static const char * (*pcupsLastErrorString)(void);
#endif /* SONAME_LIBCUPS */
-NTSTATUS unix_process_attach( void *arg )
+NTSTATUS process_attach( void *args )
{
#ifdef SONAME_LIBCUPS
libcups_handle = dlopen( SONAME_LIBCUPS, RTLD_NOW );
@@ -346,7 +334,7 @@ static int get_cups_default_options( const char *printer, int num_options, cups_
}
#endif /* SONAME_LIBCUPS */
-NTSTATUS unix_enum_printers( void *args )
+NTSTATUS enum_printers( void *args )
{
struct enum_printers_params *params = args;
#ifdef SONAME_LIBCUPS
@@ -416,7 +404,7 @@ NTSTATUS unix_enum_printers( void *args )
#endif /* SONAME_LIBCUPS */
}
-NTSTATUS unix_get_ppd( void *args )
+NTSTATUS get_ppd( void *args )
{
struct get_ppd_params *params = args;
char *unix_ppd = get_unix_file_name( params->ppd );
@@ -457,7 +445,7 @@ NTSTATUS unix_get_ppd( void *args )
return status;
}
-NTSTATUS unix_get_default_page_size( void *args )
+NTSTATUS get_default_page_size( void *args )
{
#ifdef HAVE_APPLICATIONSERVICES_APPLICATIONSERVICES_H
struct get_default_page_size_params *params = args;
@@ -503,7 +491,6 @@ end:
*/
static BOOL schedule_pipe( const WCHAR *cmd, const WCHAR *filename )
{
-#ifdef HAVE_FORK
char *unixname, *cmdA;
DWORD len;
int fds[2] = { -1, -1 }, file_fd = -1, no_read;
@@ -579,9 +566,6 @@ end:
free( cmdA );
free( unixname );
return ret;
-#else
- return FALSE;
-#endif
}
/*****************************************************************************
@@ -676,7 +660,7 @@ static BOOL schedule_cups( const WCHAR *printer_name, const WCHAR *filename, con
}
}
-BOOL unix_schedule_job( void *args )
+BOOL schedule_job( void *args )
{
struct schedule_job_params *params = args;
@@ -694,3 +678,12 @@ BOOL unix_schedule_job( void *args )
return FALSE;
}
+
+unixlib_entry_t __wine_unix_call_funcs[] =
+{
+ process_attach,
+ enum_printers,
+ get_default_page_size,
+ get_ppd,
+ schedule_job,
+};
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index f813e188058..7cffc9ae7ec 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -23,9 +23,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
-#include "config.h"
-
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,13 +43,13 @@
#include "wingdi.h"
#include "winspool.h"
#include "winternl.h"
+#include "winnls.h"
#include "wine/windef16.h"
-#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/list.h"
#include "wine/rbtree.h"
#include "wine/heap.h"
-#include "winnls.h"
+#include <wine/unixlib.h>
#include "ddk/winsplp.h"
#include "wspool.h"
@@ -276,7 +273,7 @@ static const printenv_t * const all_printenv[] = {&env_x86, &env_x64, &env_arm,
* NOTES
* An empty string is handled the same way as NULL.
* SetLastError(ERROR_INVALID_ENVIRONMENT) is called on Failure
- *
+ *
*/
static const printenv_t * validate_envW(LPCWSTR env)
@@ -289,7 +286,7 @@ static const printenv_t * validate_envW(LPCWSTR env)
{
for (i = 0; i < ARRAY_SIZE(all_printenv); i++)
{
- if (lstrcmpiW(env, all_printenv[i]->envname) == 0)
+ if (!wcsicmp( env, all_printenv[i]->envname ))
{
result = all_printenv[i];
break;
@@ -325,14 +322,14 @@ static inline PWSTR asciitounicode( UNICODE_STRING * usBufferPtr, LPCSTR src )
usBufferPtr->Buffer = NULL; /* so that RtlFreeUnicodeString won't barf */
return NULL;
}
-
+
static LPWSTR strdupW(LPCWSTR p)
{
LPWSTR ret;
DWORD len;
if(!p) return NULL;
- len = (strlenW(p) + 1) * sizeof(WCHAR);
+ len = (wcslen( p ) + 1) * sizeof(WCHAR);
ret = HeapAlloc(GetProcessHeap(), 0, len);
memcpy(ret, p, len);
return ret;
@@ -389,7 +386,7 @@ static DEVMODEA *DEVMODEdupWtoA( const DEVMODEW *dmW )
static void packed_string_WtoA( WCHAR *strW )
{
- DWORD len = strlenW( strW ), size = (len + 1) * sizeof(WCHAR), ret;
+ DWORD len = wcslen( strW ), size = (len + 1) * sizeof(WCHAR), ret;
char *str;
if (!len) return;
@@ -455,22 +452,23 @@ static inline const DWORD *form_string_info( DWORD level )
*/
static HKEY WINSPOOL_OpenDriverReg(const void *pEnvironment)
{
- HKEY retval = NULL;
+ HKEY retval = NULL;
LPWSTR buffer;
const printenv_t *env;
+ unsigned int len;
TRACE("(%s)\n", debugstr_w(pEnvironment));
env = validate_envW(pEnvironment);
if (!env) return NULL;
- buffer = HeapAlloc( GetProcessHeap(), 0,
- (strlenW(DriversW) + strlenW(env->envname) +
- strlenW(env->versionregpath) + 1) * sizeof(WCHAR));
- if(buffer) {
- wsprintfW(buffer, DriversW, env->envname, env->versionregpath);
- RegCreateKeyW(HKEY_LOCAL_MACHINE, buffer, &retval);
- HeapFree(GetProcessHeap(), 0, buffer);
+ len = wcslen( DriversW ) + wcslen( env->envname ) + wcslen( env->versionregpath ) + 1;
+ buffer = heap_alloc( len * sizeof(WCHAR) );
+ if (buffer)
+ {
+ swprintf( buffer, len, DriversW, env->envname, env->versionregpath );
+ RegCreateKeyW( HKEY_LOCAL_MACHINE, buffer, &retval );
+ heap_free( buffer );
}
return retval;
}
@@ -487,7 +485,7 @@ static CRITICAL_SECTION config_modules_cs = { &config_modules_cs_debug, -1, 0, 0
static int compare_config_modules(const void *key, const struct wine_rb_entry *entry)
{
config_module_t *module = WINE_RB_ENTRY_VALUE(entry, config_module_t, entry);
- return lstrcmpiW(key, module->name);
+ return wcsicmp( key, module->name );
}
static struct wine_rb_tree config_modules = { compare_config_modules };
@@ -549,7 +547,7 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
goto ret;
}
- len = lstrlenW(device);
+ len = wcslen( device );
if (!(ret = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(config_module_t, name[len + 1]))))
goto ret;
@@ -557,7 +555,7 @@ static config_module_t *get_config_module(const WCHAR *device, BOOL grab)
ret->module = driver_module;
ret->pDrvDeviceCapabilities = (void *)GetProcAddress(driver_module, "DrvDeviceCapabilities");
ret->pDrvDocumentProperties = (void *)GetProcAddress(driver_module, "DrvDocumentProperties");
- lstrcpyW(ret->name, device);
+ wcscpy( ret->name, device );
wine_rb_put(&config_modules, ret->name, &ret->entry);
ret:
@@ -582,7 +580,7 @@ static int multi_sz_lenA(const char *str)
if(!str) return 0;
do
{
- ptr += lstrlenA(ptr) + 1;
+ ptr += strlen( ptr ) + 1;
} while(*ptr);
return ptr - str + 1;
@@ -708,7 +706,7 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
{
static const WCHAR dot_ppd[] = {'.','p','p','d',0};
static const WCHAR invalid_chars[] = {'*','?','<','>','|','"','/','\\',0};
- int dir_len = strlenW( dir ), file_len = strlenW( file_name );
+ int dir_len = wcslen( dir ), file_len = wcslen( file_name );
int len = (dir_len + file_len + ARRAY_SIZE( dot_ppd )) * sizeof(WCHAR);
WCHAR *ppd = HeapAlloc( GetProcessHeap(), 0, len ), *p;
@@ -718,7 +716,7 @@ static WCHAR *get_ppd_filename( const WCHAR *dir, const WCHAR *file_name )
memcpy( ppd + dir_len + file_len, dot_ppd, sizeof(dot_ppd) );
p = ppd + dir_len;
- while ((p = strpbrkW( p, invalid_chars ))) *p++ = '_';
+ while ((p = wcspbrk( p, invalid_chars ))) *p++ = '_';
return ppd;
}
@@ -850,9 +848,9 @@ static BOOL init_unix_printers( void )
if (!ppd_dir && !(ppd_dir = get_ppd_dir())) break;
if (!add_printer_driver( printer->name, ppd_dir )) continue;
- port = heap_alloc( sizeof(CUPS_Port) + lstrlenW( printer->name ) * sizeof(WCHAR) );
- lstrcpyW( port, CUPS_Port );
- lstrcatW( port, printer->name );
+ port = heap_alloc( sizeof(CUPS_Port) + wcslen( printer->name ) * sizeof(WCHAR) );
+ wcscpy( port, CUPS_Port );
+ wcscat( port, printer->name );
memset( &pi2, 0, sizeof(PRINTER_INFO_2W) );
pi2.pPrinterName = printer->name;
@@ -934,7 +932,7 @@ static inline DWORD set_reg_szW(HKEY hkey, const WCHAR *keyname, const WCHAR *va
{
if (value)
return RegSetValueExW(hkey, keyname, 0, REG_SZ, (const BYTE*)value,
- (lstrlenW(value) + 1) * sizeof(WCHAR));
+ (wcslen( value ) + 1) * sizeof(WCHAR));
else
return ERROR_FILE_NOT_FOUND;
}
@@ -979,14 +977,16 @@ static LPWSTR get_servername_from_name(LPCWSTR name)
if (server == NULL) return NULL;
/* strip '\' and the printername */
- ptr = strchrW(server, '\\');
+ ptr = wcschr( server, '\\' );
if (ptr) ptr[0] = '\0';
TRACE("found %s\n", debugstr_w(server));
len = ARRAY_SIZE(buffer);
- if (GetComputerNameW(buffer, &len)) {
- if (lstrcmpW(buffer, server) == 0) {
+ if (GetComputerNameW(buffer, &len))
+ {
+ if (!wcscmp( buffer, server ))
+ {
/* The requested Servername is our computername */
HeapFree(GetProcessHeap(), 0, server);
return NULL;
@@ -1004,10 +1004,12 @@ static LPWSTR get_servername_from_name(LPCWSTR name)
static LPCWSTR get_basename_from_name(LPCWSTR name)
{
if (name == NULL) return NULL;
- if ((name[0] == '\\') && (name[1] == '\\')) {
+ if ((name[0] == '\\') && (name[1] == '\\'))
+ {
/* skip over the servername and search for the following '\' */
- name = strchrW(&name[2], '\\');
- if ((name) && (name[1])) {
+ name = wcschr( &name[2], '\\' );
+ if ((name) && (name[1]))
+ {
/* found a separator ('\') followed by a name:
skip over the separator and return the rest */
name++;
@@ -1075,7 +1077,7 @@ static HANDLE get_opened_printer_entry(LPWSTR name, LPPRINTER_DEFAULTSW pDefault
}
else
{
- if(!queue && (name) && !lstrcmpW(name, printer_handles[i]->name))
+ if(!queue && (name) && !wcscmp( name, printer_handles[i]->name ))
queue = printer_handles[i]->queue;
}
}
@@ -1167,8 +1169,8 @@ static void old_printer_check( BOOL delete_phase )
{
if (!pi[i].pPortName) continue;
- if (strncmpW( pi[i].pPortName, CUPS_Port, strlenW(CUPS_Port) ) &&
- strncmpW( pi[i].pPortName, LPR_Port, strlenW(LPR_Port) ))
+ if (wcsncmp( pi[i].pPortName, CUPS_Port, wcslen( CUPS_Port ) ) &&
+ wcsncmp( pi[i].pPortName, LPR_Port, wcslen( LPR_Port ) ))
continue;
if (open_printer_reg_key( pi[i].pPrinterName, &key )) continue;
@@ -2516,7 +2518,7 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
ADDJOB_INFO_1W *addjob;
TRACE("(%p,%d,%p,%d,%p)\n", hPrinter, Level, pData, cbBuf, pcbNeeded);
-
+
EnterCriticalSection(&printer_handles_cs);
printer = get_opened_printer(hPrinter);
@@ -2540,10 +2542,10 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
len = GetSystemDirectoryW(path, ARRAY_SIZE(path));
if(path[len - 1] != '\\')
path[len++] = '\\';
- memcpy(path + len, spool_path, sizeof(spool_path));
- sprintfW(filename, fmtW, path, job->job_id);
+ memcpy( path + len, spool_path, sizeof(spool_path) );
+ swprintf( filename, ARRAY_SIZE(filename), fmtW, path, job->job_id );
- len = strlenW(filename);
+ len = wcslen( filename );
job->filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
memcpy(job->filename, filename, (len + 1) * sizeof(WCHAR));
job->portname = NULL;
@@ -2559,7 +2561,7 @@ BOOL WINAPI AddJobW(HANDLE hPrinter, DWORD Level, LPBYTE pData, DWORD cbBuf, LPD
addjob->Path = (WCHAR *)(addjob + 1);
memcpy(addjob->Path, filename, (len + 1) * sizeof(WCHAR));
ret = TRUE;
- } else
+ } else
SetLastError(ERROR_INSUFFICIENT_BUFFER);
end:
@@ -2680,7 +2682,7 @@ BOOL WINAPI GetPrintProcessorDirectoryW(LPWSTR server, LPWSTR env,
*/
static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
{
- DWORD portlen = lstrlenW(pi->pPortName) * sizeof(WCHAR);
+ DWORD portlen = wcslen( pi->pPortName ) * sizeof(WCHAR);
WCHAR *devline;
HKEY hkey;
@@ -2688,22 +2690,23 @@ static void set_devices_and_printerports(PRINTER_INFO_2W *pi)
/* FIXME: the driver must change to "winspool" */
devline = HeapAlloc(GetProcessHeap(), 0, sizeof(driver_nt) + portlen + sizeof(timeout_15_45));
- if (devline) {
- lstrcpyW(devline, driver_nt);
- lstrcatW(devline, commaW);
- lstrcatW(devline, pi->pPortName);
+ if (devline)
+ {
+ wcscpy( devline, driver_nt );
+ wcscat( devline, commaW );
+ wcscat( devline, pi->pPortName );
TRACE("using %s\n", debugstr_w(devline));
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_printers_reg_key, &hkey)) {
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
- (lstrlenW(devline) + 1) * sizeof(WCHAR));
+ (wcslen( devline ) + 1) * sizeof(WCHAR));
RegCloseKey(hkey);
}
- lstrcatW(devline, timeout_15_45);
+ wcscat( devline, timeout_15_45 );
if (!RegCreateKeyW(HKEY_CURRENT_USER, WinNT_CV_PrinterPortsW, &hkey)) {
RegSetValueExW(hkey, pi->pPrinterName, 0, REG_SZ, (LPBYTE)devline,
- (lstrlenW(devline) + 1) * sizeof(WCHAR));
+ (wcslen( devline ) + 1) * sizeof(WCHAR));
RegCloseKey(hkey);
}
HeapFree(GetProcessHeap(), 0, devline);
@@ -2768,7 +2771,8 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
RegCloseKey(hkeyDriver);
RegCloseKey(hkeyDrivers);
- if(lstrcmpiW(pi->pPrintProcessor, WinPrintW)) { /* FIXME */
+ if(wcsicmp( pi->pPrintProcessor, WinPrintW ))
+ {
FIXME("Can't find processor %s\n", debugstr_w(pi->pPrintProcessor));
SetLastError(ERROR_UNKNOWN_PRINTPROCESSOR);
RegCloseKey(hkeyPrinters);
@@ -2825,8 +2829,9 @@ HANDLE WINAPI AddPrinterW(LPWSTR pName, DWORD Level, LPBYTE pPrinter)
}
else
{
- /* set devmode to printer name */
- lstrcpynW( dm->dmDeviceName, pi->pPrinterName, CCHDEVICENAME );
+ unsigned int len = min( ARRAY_SIZE( dm->dmDeviceName ) - 1, wcslen( pi->pPrinterName ) );
+ memcpy( dm->dmDeviceName, pi->pPrinterName, len * sizeof(WCHAR) );
+ dm->dmDeviceName[len] = '\0';
}
}
@@ -2985,7 +2990,7 @@ BOOL WINAPI DeletePrinter(HANDLE hPrinter)
RegCloseKey(hkey);
}
- if (GetDefaultPrinterW( def, &size ) && !strcmpW( def, lpNameW ))
+ if (GetDefaultPrinterW( def, &size ) && !wcscmp( def, lpNameW ))
{
if (!RegCreateKeyW( HKEY_CURRENT_USER, user_default_reg_key, &hkey ))
{
@@ -3554,7 +3559,7 @@ static BOOL get_filename_from_reg(HKEY hkey, LPCWSTR driverdir, DWORD dirlen, LP
/* we must build the full Path */
*needed += dirlen;
if ((out) && (outlen > dirlen)) {
- lstrcpyW((LPWSTR)out, driverdir);
+ wcscpy( (WCHAR *)out, driverdir );
out += dirlen;
outlen -= dirlen;
}
@@ -3563,16 +3568,16 @@ static BOOL get_filename_from_reg(HKEY hkey, LPCWSTR driverdir, DWORD dirlen, LP
}
/* write the filename */
- size = (lstrlenW(ptr) + 1) * sizeof(WCHAR);
+ size = (wcslen( ptr ) + 1) * sizeof(WCHAR);
if ((out) && (outlen >= size)) {
- lstrcpyW((LPWSTR)out, ptr);
+ wcscpy( (WCHAR *)out, ptr );
out += size;
outlen -= size;
}
else
out = NULL;
*needed += size;
- ptr += lstrlenW(ptr)+1;
+ ptr += wcslen( ptr ) + 1;
if ((type != REG_MULTI_SZ) || (!ptr[0])) ptr = NULL;
}
@@ -3634,7 +3639,7 @@ static void WINSPOOL_GetDefaultDevMode(LPBYTE ptr, DWORD buflen, DWORD *needed)
/* the driver will update registry with real values */
memset(dm, 0, sizeof(*dm));
dm->dmSize = sizeof(*dm);
- lstrcpyW(dm->dmDeviceName, winepsW);
+ wcscpy( dm->dmDeviceName, winepsW );
}
*needed = sizeof(DEVMODEW);
}
@@ -4487,9 +4492,9 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
if (di) ZeroMemory(di, di_sizeof[Level]);
- *pcbNeeded = (lstrlenW(DriverName) + 1) * sizeof(WCHAR);
+ *pcbNeeded = (wcslen( DriverName ) + 1) * sizeof(WCHAR);
if (*pcbNeeded <= cbBuf)
- strcpyW((LPWSTR)strPtr, DriverName);
+ wcscpy( (WCHAR *)strPtr, DriverName );
/* pName for level 1 has a different offset! */
if (Level == 1) {
@@ -4510,11 +4515,11 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
/* Should never Fail */
return FALSE;
}
- lstrcatW(driverdir, env->versionsubdir);
- lstrcatW(driverdir, backslashW);
+ wcscat( driverdir, env->versionsubdir );
+ wcscat( driverdir, backslashW );
/* dirlen must not include the terminating zero */
- dirlen = lstrlenW(driverdir) * sizeof(WCHAR);
+ dirlen = wcslen( driverdir ) * sizeof(WCHAR);
if (!DriverName[0] || RegOpenKeyW(hkeyDrivers, DriverName, &hkeyDriver) != ERROR_SUCCESS) {
ERR("Can't find driver %s in registry\n", debugstr_w(DriverName));
@@ -4523,11 +4528,11 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
}
/* pEnvironment */
- size = (lstrlenW(env->envname) + 1) * sizeof(WCHAR);
+ size = (wcslen( env->envname ) + 1) * sizeof(WCHAR);
*pcbNeeded += size;
if (*pcbNeeded <= cbBuf) {
- lstrcpyW((LPWSTR)strPtr, env->envname);
+ wcscpy( (WCHAR *)strPtr, env->envname );
if (di) di->pEnvironment = (LPWSTR)strPtr;
strPtr = (pDriverStrings) ? (pDriverStrings + (*pcbNeeded)) : NULL;
}
@@ -5210,7 +5215,7 @@ BOOL WINAPI EnumPrinterDriversW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level,
memset( pDriverInfo, 0, cbBuf);
/* Exception: pull all printers */
- if (pEnvironment && !strcmpW(pEnvironment, allW))
+ if (pEnvironment && !wcscmp( pEnvironment, allW ))
{
DWORD i, needed, bufsize = cbBuf;
DWORD total_found = 0;
@@ -5501,7 +5506,7 @@ BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
}
TRACE("%s\n", debugstr_w(buffer));
- if ((ptr = strchrW(buffer, ',')) == NULL)
+ if ((ptr = wcschr( buffer, ',' )) == NULL)
{
SetLastError(ERROR_INVALID_NAME);
retval = FALSE;
@@ -5509,14 +5514,14 @@ BOOL WINAPI GetDefaultPrinterW(LPWSTR name, LPDWORD namesize)
}
*ptr = 0;
- *namesize = strlenW(buffer) + 1;
+ *namesize = wcslen( buffer ) + 1;
if(!name || (*namesize > insize))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
retval = FALSE;
goto end;
}
- strcpyW(name, buffer);
+ wcscpy( name, buffer );
end:
HeapFree( GetProcessHeap(), 0, buffer);
@@ -5624,7 +5629,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
}
/* "pszPrinter" is never empty or NULL here. */
- namelen = lstrlenW(pszPrinter);
+ namelen = wcslen( pszPrinter );
size = namelen + (MAX_PATH * 2) + 3; /* printer,driver,port and a 0 */
buffer = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
if (!buffer ||
@@ -5647,7 +5652,7 @@ BOOL WINAPI SetDefaultPrinterW(LPCWSTR pszPrinter)
if (!RegCreateKeyW(HKEY_CURRENT_USER, user_default_reg_key, &hdev))
{
- RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (lstrlenW(buffer) + 1) * sizeof(WCHAR));
+ RegSetValueExW(hdev, deviceW, 0, REG_SZ, (BYTE *)buffer, (wcslen( buffer ) + 1) * sizeof(WCHAR));
RegCloseKey(hdev);
}
}
@@ -7525,7 +7530,7 @@ static BOOL string_to_buf(LPCWSTR str, LPBYTE ptr, DWORD cb, DWORD *size, BOOL u
if(unicode)
{
- *size = (strlenW(str) + 1) * sizeof(WCHAR);
+ *size = (wcslen( str ) + 1) * sizeof(WCHAR);
if(*size <= cb)
{
memcpy(ptr, str, *size);
@@ -7904,7 +7909,7 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename),
debugstr_w(portname));
- if (!strncmpW( portname, FILE_Port, strlenW( FILE_Port ) ))
+ if (!wcsncmp( portname, FILE_Port, wcslen( FILE_Port ) ))
{
ret = schedule_file( job->filename );
}
@@ -8024,7 +8029,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
return NULL;
pi5 = HeapAlloc(GetProcessHeap(), 0, len);
GetPrinterW(hPrinter, 5, (LPBYTE)pi5, len, &len);
- if(!pi5->pPortName || strcmpW(pi5->pPortName, FILE_Port))
+ if(!pi5->pPortName || wcscmp( pi5->pPortName, FILE_Port ))
{
HeapFree(GetProcessHeap(), 0, pi5);
return NULL;
@@ -8032,7 +8037,7 @@ LPWSTR WINAPI StartDocDlgW( HANDLE hPrinter, DOCINFOW *doc )
HeapFree(GetProcessHeap(), 0, pi5);
}
- if(doc->lpszOutput == NULL || !strcmpW(doc->lpszOutput, FILE_Port))
+ if(doc->lpszOutput == NULL || !wcscmp( doc->lpszOutput, FILE_Port ))
{
LPWSTR name;
diff --git a/dlls/winspool.drv/wspool.c b/dlls/winspool.drv/wspool.c
index 90d35bee73e..2555692b097 100644
--- a/dlls/winspool.drv/wspool.c
+++ b/dlls/winspool.drv/wspool.c
@@ -18,19 +18,17 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-
-
-#include "config.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winspool.h"
-
#include "winreg.h"
+#include "winternl.h"
#include "ddk/winsplp.h"
#include "wine/debug.h"
+#include "wine/unixlib.h"
#include "wspool.h"
@@ -50,11 +48,11 @@ static CRITICAL_SECTION backend_cs = { &backend_cs_debug, -1, 0, 0, 0, 0 };
/* ############################### */
HINSTANCE WINSPOOL_hInstance = NULL;
+unixlib_handle_t winspool_handle = 0;
-static HMODULE hlocalspl = NULL;
+static HMODULE hlocalspl;
static BOOL (WINAPI *pInitializePrintProvidor)(LPPRINTPROVIDOR, DWORD, LPWSTR);
-
-PRINTPROVIDOR * backend = NULL;
+PRINTPROVIDOR *backend = NULL;
/******************************************************************************
* load_backend [internal]
@@ -117,7 +115,9 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
case DLL_PROCESS_ATTACH:
WINSPOOL_hInstance = instance;
DisableThreadLibraryCalls( instance );
- UNIX_CALL( process_attach, NULL );
+ if (!NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
+ &winspool_handle, sizeof(winspool_handle), NULL ))
+ UNIX_CALL( process_attach, NULL );
WINSPOOL_LoadSystemPrinters();
break;
diff --git a/dlls/winspool.drv/wspool.h b/dlls/winspool.drv/wspool.h
index 899d5cbec90..39c14f24358 100644
--- a/dlls/winspool.drv/wspool.h
+++ b/dlls/winspool.drv/wspool.h
@@ -72,10 +72,15 @@ struct schedule_job_params
const WCHAR *wine_port;
};
-#define UNIX_CALL( func, params ) unix_ ## func( params )
+extern unixlib_handle_t winspool_handle DECLSPEC_HIDDEN;
-NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN;
-NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN;
-NTSTATUS unix_get_default_page_size( void * ) DECLSPEC_HIDDEN;
-NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
-NTSTATUS unix_schedule_job( void * ) DECLSPEC_HIDDEN;
+#define UNIX_CALL( func, params ) __wine_unix_call( winspool_handle, unix_ ## func, params )
+
+enum cups_funcs
+{
+ unix_process_attach,
+ unix_enum_printers,
+ unix_get_default_page_size,
+ unix_get_ppd,
+ unix_schedule_job,
+};
--
2.23.0
1
0
Oct. 27, 2021
Signed-off-by: Huw Davies <huw(a)codeweavers.com>
---
dlls/winspool.drv/cups.c | 268 ++++++++++++++++++++++++++++-
dlls/winspool.drv/info.c | 344 ++++---------------------------------
dlls/winspool.drv/wspool.h | 9 +
3 files changed, 300 insertions(+), 321 deletions(-)
diff --git a/dlls/winspool.drv/cups.c b/dlls/winspool.drv/cups.c
index ae771eba46c..511cf9a5c4d 100644
--- a/dlls/winspool.drv/cups.c
+++ b/dlls/winspool.drv/cups.c
@@ -23,8 +23,14 @@
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
+#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
#ifdef HAVE_CUPS_CUPS_H
#include <cups/cups.h>
#endif
@@ -106,6 +112,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(winspool);
+static const WCHAR CUPS_Port[] = { 'C','U','P','S',':',0 };
+static const WCHAR LPR_Port[] = { 'L','P','R',':',0 };
+
/* Temporary helpers until switch to unixlib */
#include "winnls.h"
#include "wine/heap.h"
@@ -123,7 +132,7 @@ static int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dst
#ifdef SONAME_LIBCUPS
-void *libcups_handle = NULL;
+static void *libcups_handle;
#define CUPS_FUNCS \
DO_FUNC(cupsAddOption); \
@@ -139,13 +148,13 @@ void *libcups_handle = NULL;
DO_FUNC(cupsGetPPD3); \
DO_FUNC(cupsLastErrorString)
-#define DO_FUNC(f) typeof(f) *p##f = NULL
+#define DO_FUNC(f) static typeof(f) *p##f
CUPS_FUNCS;
#undef DO_FUNC
-cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *) = NULL;
-const char * (*pcupsGetPPD)(const char *) = NULL;
-http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t) = NULL;
-const char * (*pcupsLastErrorString)(void) = NULL;
+static cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *);
+static const char * (*pcupsGetPPD)(const char *);
+static http_status_t (*pcupsGetPPD3)(http_t *, const char *, time_t *, char *, size_t);
+static const char * (*pcupsLastErrorString)(void);
#endif /* SONAME_LIBCUPS */
@@ -285,6 +294,56 @@ static http_status_t cupsGetPPD3_wrapper( http_t *http, const char *name, time_t
}
return HTTP_OK;
}
+
+/*****************************************************************************
+ * get_cups_jobs_ticket_options
+ *
+ * Explicitly set CUPS options based on any %cupsJobTicket lines.
+ * The CUPS scheduler only looks for these in Print-File requests, and since
+ * cupsPrintFile uses Create-Job / Send-Document, the ticket lines don't get
+ * parsed.
+ */
+static int get_cups_job_ticket_options( const char *file, int num_options, cups_option_t **options )
+{
+ FILE *fp = fopen( file, "r" );
+ char buf[257]; /* DSC max of 256 + '\0' */
+ const char *ps_adobe = "%!PS-Adobe-";
+ const char *cups_job = "%cupsJobTicket:";
+
+ if (!fp) return num_options;
+ if (!fgets( buf, sizeof(buf), fp )) goto end;
+ if (strncmp( buf, ps_adobe, strlen( ps_adobe ) )) goto end;
+ while (fgets( buf, sizeof(buf), fp ))
+ {
+ if (strncmp( buf, cups_job, strlen( cups_job ) )) break;
+ num_options = pcupsParseOptions( buf + strlen( cups_job ), num_options, options );
+ }
+
+end:
+ fclose( fp );
+ return num_options;
+}
+
+static int get_cups_default_options( const char *printer, int num_options, cups_option_t **options )
+{
+ cups_dest_t *dest;
+ int i;
+
+ if (!pcupsGetNamedDest) return num_options;
+
+ dest = pcupsGetNamedDest( NULL, printer, NULL );
+ if (!dest) return num_options;
+
+ for (i = 0; i < dest->num_options; i++)
+ {
+ if (!pcupsGetOption( dest->options[i].name, num_options, *options ))
+ num_options = pcupsAddOption( dest->options[i].name, dest->options[i].value,
+ num_options, options );
+ }
+
+ pcupsFreeDests( 1, dest );
+ return num_options;
+}
#endif /* SONAME_LIBCUPS */
NTSTATUS unix_enum_printers( void *args )
@@ -438,3 +497,200 @@ end:
return STATUS_NOT_IMPLEMENTED;
#endif
}
+
+/*****************************************************************************
+ * schedule_pipe
+ */
+static BOOL schedule_pipe( const WCHAR *cmd, const WCHAR *filename )
+{
+#ifdef HAVE_FORK
+ char *unixname, *cmdA;
+ DWORD len;
+ int fds[2] = { -1, -1 }, file_fd = -1, no_read;
+ BOOL ret = FALSE;
+ char buf[1024];
+ pid_t pid, wret;
+ int status;
+
+ if (!(unixname = get_unix_file_name( filename ))) return FALSE;
+
+ len = strlenW( cmd );
+ cmdA = malloc( len * 3 + 1);
+ ntdll_wcstoumbs( cmd, len + 1, cmdA, len * 3 + 1, FALSE );
+
+ TRACE( "printing with: %s\n", cmdA );
+
+ if ((file_fd = open( unixname, O_RDONLY )) == -1) goto end;
+
+ if (pipe( fds ))
+ {
+ ERR( "pipe() failed!\n" );
+ goto end;
+ }
+
+ if ((pid = fork()) == 0)
+ {
+ close( 0 );
+ dup2( fds[0], 0 );
+ close( fds[1] );
+
+ /* reset signals that we previously set to SIG_IGN */
+ signal( SIGPIPE, SIG_DFL );
+
+ execl( "/bin/sh", "/bin/sh", "-c", cmdA, NULL );
+ _exit( 1 );
+ }
+ else if (pid == -1)
+ {
+ ERR( "fork() failed!\n" );
+ goto end;
+ }
+
+ close( fds[0] );
+ fds[0] = -1;
+ while ((no_read = read( file_fd, buf, sizeof(buf) )) > 0)
+ write( fds[1], buf, no_read );
+
+ close( fds[1] );
+ fds[1] = -1;
+
+ /* reap child */
+ do {
+ wret = waitpid( pid, &status, 0 );
+ } while (wret < 0 && errno == EINTR);
+ if (wret < 0)
+ {
+ ERR( "waitpid() failed!\n" );
+ goto end;
+ }
+ if (!WIFEXITED(status) || WEXITSTATUS(status))
+ {
+ ERR( "child process failed! %d\n", status );
+ goto end;
+ }
+
+ ret = TRUE;
+
+end:
+ if (file_fd != -1) close( file_fd );
+ if (fds[0] != -1) close( fds[0] );
+ if (fds[1] != -1) close( fds[1] );
+
+ free( cmdA );
+ free( unixname );
+ return ret;
+#else
+ return FALSE;
+#endif
+}
+
+/*****************************************************************************
+ * schedule_unixfile
+ */
+static BOOL schedule_unixfile( const WCHAR *output, const WCHAR *filename )
+{
+ char *unixname, *outputA;
+ DWORD len;
+ BOOL ret;
+
+ if (!(unixname = get_unix_file_name( filename ))) return FALSE;
+
+ len = strlenW( output );
+ outputA = malloc( len * 3 + 1);
+ ntdll_wcstoumbs( output, len + 1, outputA, len * 3 + 1, FALSE );
+
+ ret = copy_file( unixname, outputA );
+
+ free( outputA );
+ free( unixname );
+ return ret;
+}
+
+/*****************************************************************************
+ * schedule_lpr
+ */
+static BOOL schedule_lpr( const WCHAR *printer_name, const WCHAR *filename )
+{
+ static const WCHAR lpr[] = { 'l','p','r',' ','-','P','\'' };
+ static const WCHAR quote[] = { '\'',0 };
+ int printer_len = strlenW( printer_name );
+ WCHAR *cmd;
+ BOOL ret;
+
+ cmd = malloc( printer_len * sizeof(WCHAR) + sizeof(lpr) + sizeof(quote) );
+ memcpy( cmd, lpr, sizeof(lpr) );
+ memcpy( cmd + ARRAY_SIZE(lpr), printer_name, printer_len * sizeof(WCHAR) );
+ memcpy( cmd + ARRAY_SIZE(lpr) + printer_len, quote, sizeof(quote) );
+
+ ret = schedule_pipe( cmd, filename );
+
+ free( cmd );
+ return ret;
+}
+
+/*****************************************************************************
+ * schedule_cups
+ */
+static BOOL schedule_cups( const WCHAR *printer_name, const WCHAR *filename, const WCHAR *document_title )
+{
+#ifdef SONAME_LIBCUPS
+ if (pcupsPrintFile)
+ {
+ char *unixname, *queue, *unix_doc_title;
+ cups_option_t *options = NULL;
+ int num_options = 0, i;
+ DWORD len;
+ BOOL ret;
+
+ if (!(unixname = get_unix_file_name( filename ))) return FALSE;
+ len = strlenW( printer_name );
+ queue = malloc( len * 3 + 1);
+ ntdll_wcstoumbs( printer_name, len + 1, queue, len * 3 + 1, FALSE );
+
+ len = strlenW( document_title );
+ unix_doc_title = malloc( len * 3 + 1 );
+ ntdll_wcstoumbs( document_title, len + 1, unix_doc_title, len + 3 + 1, FALSE );
+
+ num_options = get_cups_job_ticket_options( unixname, num_options, &options );
+ num_options = get_cups_default_options( queue, num_options, &options );
+
+ TRACE( "printing via cups with options:\n" );
+ for (i = 0; i < num_options; i++)
+ TRACE( "\t%d: %s = %s\n", i, options[i].name, options[i].value );
+
+ ret = pcupsPrintFile( queue, unixname, unix_doc_title, num_options, options );
+ if (ret == 0 && pcupsLastErrorString)
+ WARN( "cupsPrintFile failed with error %s\n", debugstr_a( pcupsLastErrorString() ) );
+
+ pcupsFreeOptions( num_options, options );
+
+ free( unix_doc_title );
+ free( queue );
+ free( unixname );
+ return ret;
+ }
+ else
+#endif
+ {
+ return schedule_lpr( printer_name, filename );
+ }
+}
+
+BOOL unix_schedule_job( void *args )
+{
+ struct schedule_job_params *params = args;
+
+ if (params->wine_port[0] == '|')
+ return schedule_pipe( params->wine_port + 1, params->filename );
+
+ if (params->wine_port[0])
+ return schedule_unixfile( params->wine_port, params->filename );
+
+ if (!strncmpW( params->port, LPR_Port, ARRAY_SIZE(LPR_Port) - 1 ))
+ return schedule_lpr( params->port + ARRAY_SIZE(LPR_Port) - 1, params->filename );
+
+ if (!strncmpW( params->port, CUPS_Port, ARRAY_SIZE(CUPS_Port) - 1 ))
+ return schedule_cups( params->port + ARRAY_SIZE(CUPS_Port) - 1, params->filename, params->document_title );
+
+ return FALSE;
+}
diff --git a/dlls/winspool.drv/info.c b/dlls/winspool.drv/info.c
index a8b0a0365ae..f813e188058 100644
--- a/dlls/winspool.drv/info.c
+++ b/dlls/winspool.drv/info.c
@@ -25,7 +25,6 @@
*/
#include "config.h"
-#include "wine/port.h"
#include <stdarg.h>
#include <stdio.h>
@@ -33,20 +32,6 @@
#include <string.h>
#include <ctype.h>
#include <stddef.h>
-#include <errno.h>
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#include <signal.h>
-#ifdef HAVE_CUPS_CUPS_H
-# include <cups/cups.h>
-#endif
-#ifdef HAVE_CUPS_PPD_H
-# include <cups/ppd.h>
-#endif
#define NONAMELESSSTRUCT
#define NONAMELESSUNION
@@ -77,7 +62,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(winspool);
/* ############################### */
static CRITICAL_SECTION printer_handles_cs;
-static CRITICAL_SECTION_DEBUG printer_handles_cs_debug =
+static CRITICAL_SECTION_DEBUG printer_handles_cs_debug =
{
0, 0, &printer_handles_cs,
{ &printer_handles_cs_debug.ProcessLocksList, &printer_handles_cs_debug.ProcessLocksList },
@@ -817,30 +802,6 @@ static WCHAR *get_ppd_dir( void )
return dir;
}
-#ifdef SONAME_LIBCUPS
-
-extern void *libcups_handle;
-
-#define CUPS_FUNCS \
- DO_FUNC(cupsAddOption); \
- DO_FUNC(cupsFreeDests); \
- DO_FUNC(cupsFreeOptions); \
- DO_FUNC(cupsGetOption); \
- DO_FUNC(cupsParseOptions); \
- DO_FUNC(cupsPrintFile)
-#define CUPS_OPT_FUNCS \
- DO_FUNC(cupsGetNamedDest); \
- DO_FUNC(cupsGetPPD); \
- DO_FUNC(cupsGetPPD3); \
- DO_FUNC(cupsLastErrorString)
-
-#define DO_FUNC(f) extern typeof(f) *p##f
-CUPS_FUNCS;
-#undef DO_FUNC
-extern cups_dest_t * (*pcupsGetNamedDest)(http_t *, const char *, const char *);
-extern const char * (*pcupsLastErrorString)(void);
-#endif
-
static BOOL init_unix_printers( void )
{
WCHAR *port, *ppd_dir = NULL, *default_printer = NULL;
@@ -7806,214 +7767,6 @@ BOOL WINAPI GetJobW(HANDLE hPrinter, DWORD JobId, DWORD Level, LPBYTE pJob,
return get_job_info(hPrinter, JobId, Level, pJob, cbBuf, pcbNeeded, TRUE);
}
-/*****************************************************************************
- * schedule_pipe
- */
-static BOOL schedule_pipe(LPCWSTR cmd, LPCWSTR filename)
-{
-#ifdef HAVE_FORK
- char *unixname, *cmdA;
- DWORD len;
- int fds[2] = {-1, -1}, file_fd = -1, no_read;
- BOOL ret = FALSE;
- char buf[1024];
- pid_t pid, wret;
- int status;
-
- if(!(unixname = wine_get_unix_file_name(filename)))
- return FALSE;
-
- len = WideCharToMultiByte(CP_UNIXCP, 0, cmd, -1, NULL, 0, NULL, NULL);
- cmdA = HeapAlloc(GetProcessHeap(), 0, len);
- WideCharToMultiByte(CP_UNIXCP, 0, cmd, -1, cmdA, len, NULL, NULL);
-
- TRACE("printing with: %s\n", cmdA);
-
- if((file_fd = open(unixname, O_RDONLY)) == -1)
- goto end;
-
- if (pipe(fds))
- {
- ERR("pipe() failed!\n");
- goto end;
- }
-
- if ((pid = fork()) == 0)
- {
- close(0);
- dup2(fds[0], 0);
- close(fds[1]);
-
- /* reset signals that we previously set to SIG_IGN */
- signal(SIGPIPE, SIG_DFL);
-
- execl("/bin/sh", "/bin/sh", "-c", cmdA, NULL);
- _exit(1);
- }
- else if (pid == -1)
- {
- ERR("fork() failed!\n");
- goto end;
- }
-
- close(fds[0]);
- fds[0] = -1;
- while((no_read = read(file_fd, buf, sizeof(buf))) > 0)
- write(fds[1], buf, no_read);
-
- close(fds[1]);
- fds[1] = -1;
-
- /* reap child */
- do {
- wret = waitpid(pid, &status, 0);
- } while (wret < 0 && errno == EINTR);
- if (wret < 0)
- {
- ERR("waitpid() failed!\n");
- goto end;
- }
- if (!WIFEXITED(status) || WEXITSTATUS(status))
- {
- ERR("child process failed! %d\n", status);
- goto end;
- }
-
- ret = TRUE;
-
-end:
- if(file_fd != -1) close(file_fd);
- if(fds[0] != -1) close(fds[0]);
- if(fds[1] != -1) close(fds[1]);
-
- HeapFree(GetProcessHeap(), 0, cmdA);
- HeapFree(GetProcessHeap(), 0, unixname);
- return ret;
-#else
- return FALSE;
-#endif
-}
-
-/*****************************************************************************
- * schedule_lpr
- */
-static BOOL schedule_lpr(LPCWSTR printer_name, LPCWSTR filename)
-{
- static const WCHAR fmtW[] = {'l','p','r',' ','-','P','\'','%','s','\'',0};
- WCHAR *cmd;
- BOOL r;
-
- cmd = HeapAlloc(GetProcessHeap(), 0, strlenW(printer_name) * sizeof(WCHAR) + sizeof(fmtW));
- sprintfW(cmd, fmtW, printer_name);
-
- r = schedule_pipe(cmd, filename);
-
- HeapFree(GetProcessHeap(), 0, cmd);
- return r;
-}
-
-#ifdef SONAME_LIBCUPS
-/*****************************************************************************
- * get_cups_jobs_ticket_options
- *
- * Explicitly set CUPS options based on any %cupsJobTicket lines.
- * The CUPS scheduler only looks for these in Print-File requests, and since
- * cupsPrintFile uses Create-Job / Send-Document, the ticket lines don't get
- * parsed.
- */
-static int get_cups_job_ticket_options( const char *file, int num_options, cups_option_t **options )
-{
- FILE *fp = fopen( file, "r" );
- char buf[257]; /* DSC max of 256 + '\0' */
- const char *ps_adobe = "%!PS-Adobe-";
- const char *cups_job = "%cupsJobTicket:";
-
- if (!fp) return num_options;
- if (!fgets( buf, sizeof(buf), fp )) goto end;
- if (strncmp( buf, ps_adobe, strlen( ps_adobe ) )) goto end;
- while (fgets( buf, sizeof(buf), fp ))
- {
- if (strncmp( buf, cups_job, strlen( cups_job ) )) break;
- num_options = pcupsParseOptions( buf + strlen( cups_job ), num_options, options );
- }
-
-end:
- fclose( fp );
- return num_options;
-}
-
-static int get_cups_default_options( const char *printer, int num_options, cups_option_t **options )
-{
- cups_dest_t *dest;
- int i;
-
- if (!pcupsGetNamedDest) return num_options;
-
- dest = pcupsGetNamedDest( NULL, printer, NULL );
- if (!dest) return num_options;
-
- for (i = 0; i < dest->num_options; i++)
- {
- if (!pcupsGetOption( dest->options[i].name, num_options, *options ))
- num_options = pcupsAddOption( dest->options[i].name, dest->options[i].value,
- num_options, options );
- }
-
- pcupsFreeDests( 1, dest );
- return num_options;
-}
-#endif
-
-/*****************************************************************************
- * schedule_cups
- */
-static BOOL schedule_cups(LPCWSTR printer_name, LPCWSTR filename, LPCWSTR document_title)
-{
-#ifdef SONAME_LIBCUPS
- if(pcupsPrintFile)
- {
- char *unixname, *queue, *unix_doc_title;
- DWORD len;
- BOOL ret;
- int num_options = 0, i;
- cups_option_t *options = NULL;
-
- if(!(unixname = wine_get_unix_file_name(filename)))
- return FALSE;
-
- len = WideCharToMultiByte(CP_UNIXCP, 0, printer_name, -1, NULL, 0, NULL, NULL);
- queue = HeapAlloc(GetProcessHeap(), 0, len);
- WideCharToMultiByte(CP_UNIXCP, 0, printer_name, -1, queue, len, NULL, NULL);
-
- len = WideCharToMultiByte(CP_UNIXCP, 0, document_title, -1, NULL, 0, NULL, NULL);
- unix_doc_title = HeapAlloc(GetProcessHeap(), 0, len);
- WideCharToMultiByte(CP_UNIXCP, 0, document_title, -1, unix_doc_title, len, NULL, NULL);
-
- num_options = get_cups_job_ticket_options( unixname, num_options, &options );
- num_options = get_cups_default_options( queue, num_options, &options );
-
- TRACE( "printing via cups with options:\n" );
- for (i = 0; i < num_options; i++)
- TRACE( "\t%d: %s = %s\n", i, options[i].name, options[i].value );
-
- ret = pcupsPrintFile( queue, unixname, unix_doc_title, num_options, options );
- if (ret == 0 && pcupsLastErrorString)
- WARN("cupsPrintFile failed with error %s\n", debugstr_a(pcupsLastErrorString()));
-
- pcupsFreeOptions( num_options, options );
-
- HeapFree(GetProcessHeap(), 0, unix_doc_title);
- HeapFree(GetProcessHeap(), 0, queue);
- HeapFree(GetProcessHeap(), 0, unixname);
- return ret;
- }
- else
-#endif
- {
- return schedule_lpr(printer_name, filename);
- }
-}
-
static INT_PTR CALLBACK file_dlg_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
LPWSTR filename;
@@ -8106,41 +7859,6 @@ static BOOL schedule_file(LPCWSTR filename)
return FALSE;
}
-/*****************************************************************************
- * schedule_unixfile
- */
-static BOOL schedule_unixfile(LPCWSTR output, LPCWSTR filename)
-{
- int in_fd, out_fd, no_read;
- char buf[1024];
- BOOL ret = FALSE;
- char *unixname, *outputA;
- DWORD len;
-
- if(!(unixname = wine_get_unix_file_name(filename)))
- return FALSE;
-
- len = WideCharToMultiByte(CP_UNIXCP, 0, output, -1, NULL, 0, NULL, NULL);
- outputA = HeapAlloc(GetProcessHeap(), 0, len);
- WideCharToMultiByte(CP_UNIXCP, 0, output, -1, outputA, len, NULL, NULL);
-
- out_fd = open(outputA, O_CREAT | O_TRUNC | O_WRONLY, 0666);
- in_fd = open(unixname, O_RDONLY);
- if(out_fd == -1 || in_fd == -1)
- goto end;
-
- while((no_read = read(in_fd, buf, sizeof(buf))) > 0)
- write(out_fd, buf, no_read);
-
- ret = TRUE;
-end:
- if(in_fd != -1) close(in_fd);
- if(out_fd != -1) close(out_fd);
- HeapFree(GetProcessHeap(), 0, outputA);
- HeapFree(GetProcessHeap(), 0, unixname);
- return ret;
-}
-
/*****************************************************************************
* ScheduleJob [WINSPOOL.@]
*
@@ -8169,6 +7887,7 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
{
PRINTER_INFO_5W *pi5 = NULL;
LPWSTR portname = job->portname;
+ UNICODE_STRING nt_name;
DWORD needed;
HKEY hkey;
WCHAR output[1024];
@@ -8184,45 +7903,40 @@ BOOL WINAPI ScheduleJob( HANDLE hPrinter, DWORD dwJobID )
}
TRACE("need to schedule job %d filename %s to port %s\n", job->job_id, debugstr_w(job->filename),
debugstr_w(portname));
-
- output[0] = 0;
- /* @@ Wine registry key: HKCU\Software\Wine\Printing\Spooler */
- if(RegOpenKeyW(HKEY_CURRENT_USER, spooler_key, &hkey) == ERROR_SUCCESS)
- {
- DWORD type, count = sizeof(output);
- RegQueryValueExW(hkey, portname, NULL, &type, (LPBYTE)output, &count);
- RegCloseKey(hkey);
- }
- if(output[0] == '|')
- {
- ret = schedule_pipe(output + 1, job->filename);
- }
- else if(output[0])
- {
- ret = schedule_unixfile(output, job->filename);
- }
- else if(!strncmpW(portname, LPR_Port, strlenW(LPR_Port)))
- {
- ret = schedule_lpr(portname + strlenW(LPR_Port), job->filename);
- }
- else if(!strncmpW(portname, CUPS_Port, strlenW(CUPS_Port)))
- {
- ret = schedule_cups(portname + strlenW(CUPS_Port), job->filename, job->document_title);
- }
- else if(!strncmpW(portname, FILE_Port, strlenW(FILE_Port)))
+ if (!strncmpW( portname, FILE_Port, strlenW( FILE_Port ) ))
{
- ret = schedule_file(job->filename);
+ ret = schedule_file( job->filename );
}
- else if(isalpha(portname[0]) && portname[1] == ':')
+ else if (isalpha(portname[0]) && portname[1] == ':')
{
- TRACE("copying to %s\n", debugstr_w(portname));
- ret = CopyFileW(job->filename, portname, FALSE);
+ TRACE( "copying to %s\n", debugstr_w( portname ) );
+ ret = CopyFileW( job->filename, portname, FALSE );
}
- else
+ else if (RtlDosPathNameToNtPathName_U( job->filename, &nt_name, NULL, NULL ))
{
- FIXME("can't schedule to port %s\n", debugstr_w(portname));
+ struct schedule_job_params params =
+ {
+ .filename = nt_name.Buffer,
+ .port = portname,
+ .document_title = job->document_title,
+ .wine_port = output
+ };
+
+ output[0] = 0;
+ /* @@ Wine registry key: HKCU\Software\Wine\Printing\Spooler */
+ if (RegOpenKeyW( HKEY_CURRENT_USER, spooler_key, &hkey ) == ERROR_SUCCESS)
+ {
+ DWORD type, count = sizeof(output);
+ RegQueryValueExW( hkey, portname, NULL, &type, (BYTE *)output, &count );
+ RegCloseKey( hkey );
+ }
+ ret = UNIX_CALL( schedule_job, ¶ms );
+ RtlFreeUnicodeString( &nt_name );
}
+ else ret = FALSE;
+
+ if (!ret) FIXME( "can't schedule to port %s\n", debugstr_w( portname ) );
HeapFree(GetProcessHeap(), 0, pi5);
CloseHandle(hf);
DeleteFileW(job->filename);
diff --git a/dlls/winspool.drv/wspool.h b/dlls/winspool.drv/wspool.h
index 578ed39733d..899d5cbec90 100644
--- a/dlls/winspool.drv/wspool.h
+++ b/dlls/winspool.drv/wspool.h
@@ -64,9 +64,18 @@ struct get_ppd_params
const WCHAR *ppd;
};
+struct schedule_job_params
+{
+ const WCHAR *filename;
+ const WCHAR *port;
+ const WCHAR *document_title;
+ const WCHAR *wine_port;
+};
+
#define UNIX_CALL( func, params ) unix_ ## func( params )
NTSTATUS unix_process_attach( void * ) DECLSPEC_HIDDEN;
NTSTATUS unix_enum_printers( void * ) DECLSPEC_HIDDEN;
NTSTATUS unix_get_default_page_size( void * ) DECLSPEC_HIDDEN;
NTSTATUS unix_get_ppd( void * ) DECLSPEC_HIDDEN;
+NTSTATUS unix_schedule_job( void * ) DECLSPEC_HIDDEN;
--
2.23.0
1
0
Oct. 27, 2021
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/msdasql/msdasql_main.c | 50 +++++++++++++++++++++++++++++++++++
dlls/msdasql/tests/provider.c | 27 +++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c
index 0f23d50ae80..76b93ac0490 100644
--- a/dlls/msdasql/msdasql_main.c
+++ b/dlls/msdasql/msdasql_main.c
@@ -178,6 +178,7 @@ struct msdasql
IDBProperties IDBProperties_iface;
IDBInitialize IDBInitialize_iface;
IDBCreateSession IDBCreateSession_iface;
+ IPersist IPersist_iface;
LONG ref;
};
@@ -202,6 +203,11 @@ static inline struct msdasql *impl_from_IDBCreateSession(IDBCreateSession *iface
return CONTAINING_RECORD(iface, struct msdasql, IDBCreateSession_iface);
}
+static inline struct msdasql *impl_from_IPersist( IPersist *iface )
+{
+ return CONTAINING_RECORD( iface, struct msdasql, IPersist_iface );
+}
+
static HRESULT WINAPI msdsql_QueryInterface(IUnknown *iface, REFIID riid, void **out)
{
struct msdasql *provider = impl_from_IUnknown(iface);
@@ -225,6 +231,10 @@ static HRESULT WINAPI msdsql_QueryInterface(IUnknown *iface, REFIID riid, void *
{
*out = &provider->IDBCreateSession_iface;
}
+ else if(IsEqualGUID(&IID_IPersist, riid))
+ {
+ *out = &provider->IPersist_iface;
+ }
else
{
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
@@ -457,6 +467,45 @@ static const struct IDBCreateSessionVtbl dbsess_vtbl =
dbsess_CreateSession
};
+static HRESULT WINAPI persist_QueryInterface(IPersist *iface, REFIID riid, void **ppv)
+{
+ struct msdasql *provider = impl_from_IPersist( iface );
+ return IUnknown_QueryInterface(&provider->MSDASQL_iface, riid, ppv);
+}
+
+static ULONG WINAPI persist_AddRef(IPersist *iface)
+{
+ struct msdasql *provider = impl_from_IPersist( iface );
+ return IUnknown_AddRef(&provider->MSDASQL_iface);
+}
+
+static ULONG WINAPI persist_Release(IPersist *iface)
+{
+ struct msdasql *provider = impl_from_IPersist( iface );
+ return IUnknown_Release(&provider->MSDASQL_iface);
+}
+
+static HRESULT WINAPI persist_GetClassID(IPersist *iface, CLSID *classid)
+{
+ struct msdasql *provider = impl_from_IPersist( iface );
+
+ TRACE("(%p)->(%p)\n", provider, classid);
+
+ if(!classid)
+ return E_INVALIDARG;
+
+ *classid = CLSID_MSDASQL;
+ return S_OK;
+
+}
+
+static const IPersistVtbl persistVtbl = {
+ persist_QueryInterface,
+ persist_AddRef,
+ persist_Release,
+ persist_GetClassID
+};
+
static HRESULT create_msdasql_provider(REFIID riid, void **ppv)
{
struct msdasql *provider;
@@ -470,6 +519,7 @@ static HRESULT create_msdasql_provider(REFIID riid, void **ppv)
provider->IDBProperties_iface.lpVtbl = &dbprops_vtbl;
provider->IDBInitialize_iface.lpVtbl = &dbinit_vtbl;
provider->IDBCreateSession_iface.lpVtbl = &dbsess_vtbl;
+ provider->IPersist_iface.lpVtbl = &persistVtbl;
provider->ref = 1;
hr = IUnknown_QueryInterface(&provider->MSDASQL_iface, riid, ppv);
diff --git a/dlls/msdasql/tests/provider.c b/dlls/msdasql/tests/provider.c
index 2e90d2f848d..4cab6a24daf 100644
--- a/dlls/msdasql/tests/provider.c
+++ b/dlls/msdasql/tests/provider.c
@@ -38,6 +38,32 @@ static char mdbpath[MAX_PATH];
static const VARTYPE intptr_vartype = (sizeof(void *) == 8 ? VT_I8 : VT_I4);
+static void test_msdasql(void)
+{
+ HRESULT hr;
+ IUnknown *unk;
+ IPersist *persist;
+ CLSID classid;
+
+ hr = CoCreateInstance( &CLSID_MSDASQL, NULL, CLSCTX_ALL, &IID_IUnknown, (void **)&unk);
+ ok(hr == S_OK, "Failed to create object 0x%08x\n", hr);
+ if (FAILED(hr))
+ {
+ return;
+ }
+
+ hr = IUnknown_QueryInterface(unk, &IID_IPersist, (void**)&persist);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ hr = IPersist_GetClassID(persist, &classid);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(IsEqualGUID(&classid, &CLSID_MSDASQL), "got %s\n", debugstr_guid(&classid));
+
+ IPersist_Release(persist);
+
+ IUnknown_Release(unk);
+}
+
static void test_Properties(void)
{
HRESULT hr;
@@ -275,6 +301,7 @@ START_TEST(provider)
setup_database();
+ test_msdasql();
test_Properties();
test_sessions();
--
2.33.0
1
0
[PATCH v3 4/5] msdasql: Implement IDBCreateSession CreateSession
by Alistair Leslie-Hughes Oct. 27, 2021
by Alistair Leslie-Hughes Oct. 27, 2021
Oct. 27, 2021
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/msdasql/Makefile.in | 3 +-
dlls/msdasql/msdasql_main.c | 12 +++-
dlls/msdasql/msdasql_private.h | 19 ++++++
dlls/msdasql/session.c | 114 +++++++++++++++++++++++++++++++++
4 files changed, 145 insertions(+), 3 deletions(-)
create mode 100644 dlls/msdasql/msdasql_private.h
create mode 100644 dlls/msdasql/session.c
diff --git a/dlls/msdasql/Makefile.in b/dlls/msdasql/Makefile.in
index 04d9cb29f2a..ee8fa672623 100644
--- a/dlls/msdasql/Makefile.in
+++ b/dlls/msdasql/Makefile.in
@@ -4,7 +4,8 @@ IMPORTS = uuid ole32 oleaut32
EXTRADLLFLAGS = -Wb,--prefer-native
C_SRCS = \
- msdasql_main.c
+ msdasql_main.c \
+ session.c
RC_SRCS = msdasql.rc
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c
index b6f0c8136e9..0f23d50ae80 100644
--- a/dlls/msdasql/msdasql_main.c
+++ b/dlls/msdasql/msdasql_main.c
@@ -30,6 +30,8 @@
#include "initguid.h"
#include "msdasql.h"
+#include "msdasql_private.h"
+
WINE_DEFAULT_DEBUG_CHANNEL(msdasql);
DEFINE_GUID(DBPROPSET_DBINIT, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
@@ -435,10 +437,16 @@ static HRESULT WINAPI dbsess_CreateSession(IDBCreateSession *iface, IUnknown *ou
IUnknown **session)
{
struct msdasql *provider = impl_from_IDBCreateSession(iface);
+ HRESULT hr;
- FIXME("%p, outer %p, riid %s, session %p stub\n", provider, outer, debugstr_guid(riid), session);
+ TRACE("%p, outer %p, riid %s, session %p stub\n", provider, outer, debugstr_guid(riid), session);
- return E_FAIL;
+ if (outer)
+ FIXME("outer currently not supported.\n");
+
+ hr = create_db_session(riid, (void**)session);
+
+ return hr;
}
static const struct IDBCreateSessionVtbl dbsess_vtbl =
diff --git a/dlls/msdasql/msdasql_private.h b/dlls/msdasql/msdasql_private.h
new file mode 100644
index 00000000000..a3d73498fe9
--- /dev/null
+++ b/dlls/msdasql/msdasql_private.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2020 Alistair Leslie-Hughes
+ *
+ * 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
+ */
+
+HRESULT create_db_session(REFIID riid, void **unk) DECLSPEC_HIDDEN;
diff --git a/dlls/msdasql/session.c b/dlls/msdasql/session.c
new file mode 100644
index 00000000000..57174be40f8
--- /dev/null
+++ b/dlls/msdasql/session.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2020 Alistair Leslie-Hughes
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "objbase.h"
+#include "rpcproxy.h"
+#include "msdasc.h"
+#include "wine/heap.h"
+#include "wine/debug.h"
+
+#include "msdasql.h"
+
+#include "msdasql_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(msdasql);
+
+struct msdasql_session
+{
+ IUnknown session_iface;
+ LONG refs;
+};
+
+static inline struct msdasql_session *impl_from_IUnknown( IUnknown *iface )
+{
+ return CONTAINING_RECORD( iface, struct msdasql_session, session_iface );
+}
+
+static HRESULT WINAPI session_QueryInterface(IUnknown *iface, REFIID riid, void **ppv)
+{
+ struct msdasql_session *session = impl_from_IUnknown( iface );
+
+ TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), ppv );
+ *ppv = NULL;
+
+ if(IsEqualGUID(&IID_IUnknown, riid))
+ {
+ TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
+ *ppv = &session->session_iface;
+ }
+
+ if(*ppv)
+ {
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+ }
+
+ FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI session_AddRef(IUnknown *iface)
+{
+ struct msdasql_session *session = impl_from_IUnknown( iface );
+ LONG refs = InterlockedIncrement( &session->refs );
+ TRACE( "%p new refcount %d\n", session, refs );
+ return refs;
+}
+
+static ULONG WINAPI session_Release(IUnknown *iface)
+{
+ struct msdasql_session *session = impl_from_IUnknown( iface );
+ LONG refs = InterlockedDecrement( &session->refs );
+ TRACE( "%p new refcount %d\n", session, refs );
+ if (!refs)
+ {
+ TRACE( "destroying %p\n", session );
+ heap_free( session );
+ }
+ return refs;
+}
+
+static const IUnknownVtbl unkfactoryVtbl =
+{
+ session_QueryInterface,
+ session_AddRef,
+ session_Release,
+};
+
+HRESULT create_db_session(REFIID riid, void **unk)
+{
+ struct msdasql_session *session;
+ HRESULT hr;
+
+ session = heap_alloc(sizeof(*session));
+ if (!session)
+ return E_OUTOFMEMORY;
+
+ session->session_iface.lpVtbl = &unkfactoryVtbl;
+ session->refs = 1;
+
+ hr = IUnknown_QueryInterface(&session->session_iface, riid, unk);
+ IUnknown_Release(&session->session_iface);
+ return hr;
+}
--
2.33.0
1
0
Oct. 27, 2021
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/msdasql/msdasql_main.c | 50 +++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c
index 96a1bc392e2..b6f0c8136e9 100644
--- a/dlls/msdasql/msdasql_main.c
+++ b/dlls/msdasql/msdasql_main.c
@@ -175,6 +175,7 @@ struct msdasql
IUnknown MSDASQL_iface;
IDBProperties IDBProperties_iface;
IDBInitialize IDBInitialize_iface;
+ IDBCreateSession IDBCreateSession_iface;
LONG ref;
};
@@ -194,6 +195,11 @@ static inline struct msdasql *impl_from_IDBInitialize(IDBInitialize *iface)
return CONTAINING_RECORD(iface, struct msdasql, IDBInitialize_iface);
}
+static inline struct msdasql *impl_from_IDBCreateSession(IDBCreateSession *iface)
+{
+ return CONTAINING_RECORD(iface, struct msdasql, IDBCreateSession_iface);
+}
+
static HRESULT WINAPI msdsql_QueryInterface(IUnknown *iface, REFIID riid, void **out)
{
struct msdasql *provider = impl_from_IUnknown(iface);
@@ -213,6 +219,10 @@ static HRESULT WINAPI msdsql_QueryInterface(IUnknown *iface, REFIID riid, void *
{
*out = &provider->IDBInitialize_iface;
}
+ else if (IsEqualGUID(riid, &IID_IDBCreateSession))
+ {
+ *out = &provider->IDBCreateSession_iface;
+ }
else
{
FIXME("(%s, %p)\n", debugstr_guid(riid), out);
@@ -400,6 +410,45 @@ static const struct IDBInitializeVtbl dbinit_vtbl =
dbinit_Uninitialize
};
+static HRESULT WINAPI dbsess_QueryInterface(IDBCreateSession *iface, REFIID riid, void **ppvObject)
+{
+ struct msdasql *provider = impl_from_IDBCreateSession(iface);
+
+ return IUnknown_QueryInterface(&provider->MSDASQL_iface, riid, ppvObject);
+}
+
+static ULONG WINAPI dbsess_AddRef(IDBCreateSession *iface)
+{
+ struct msdasql *provider = impl_from_IDBCreateSession(iface);
+
+ return IUnknown_AddRef(&provider->MSDASQL_iface);
+}
+
+static ULONG WINAPI dbsess_Release(IDBCreateSession *iface)
+{
+ struct msdasql *provider = impl_from_IDBCreateSession(iface);
+
+ return IUnknown_Release(&provider->MSDASQL_iface);
+}
+
+static HRESULT WINAPI dbsess_CreateSession(IDBCreateSession *iface, IUnknown *outer, REFIID riid,
+ IUnknown **session)
+{
+ struct msdasql *provider = impl_from_IDBCreateSession(iface);
+
+ FIXME("%p, outer %p, riid %s, session %p stub\n", provider, outer, debugstr_guid(riid), session);
+
+ return E_FAIL;
+}
+
+static const struct IDBCreateSessionVtbl dbsess_vtbl =
+{
+ dbsess_QueryInterface,
+ dbsess_AddRef,
+ dbsess_Release,
+ dbsess_CreateSession
+};
+
static HRESULT create_msdasql_provider(REFIID riid, void **ppv)
{
struct msdasql *provider;
@@ -412,6 +461,7 @@ static HRESULT create_msdasql_provider(REFIID riid, void **ppv)
provider->MSDASQL_iface.lpVtbl = &msdsql_vtbl;
provider->IDBProperties_iface.lpVtbl = &dbprops_vtbl;
provider->IDBInitialize_iface.lpVtbl = &dbinit_vtbl;
+ provider->IDBCreateSession_iface.lpVtbl = &dbsess_vtbl;
provider->ref = 1;
hr = IUnknown_QueryInterface(&provider->MSDASQL_iface, riid, ppv);
--
2.33.0
1
0
[PATCH v3 2/5] msdasql: Implement IDBProperties GetPropertyInfo
by Alistair Leslie-Hughes Oct. 27, 2021
by Alistair Leslie-Hughes Oct. 27, 2021
Oct. 27, 2021
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
dlls/msdasql/Makefile.in | 2 +-
dlls/msdasql/msdasql_main.c | 106 +++++++++++++++++++++++++++++++++-
dlls/msdasql/tests/provider.c | 11 +++-
dlls/oledb32/tests/database.c | 8 ++-
4 files changed, 120 insertions(+), 7 deletions(-)
diff --git a/dlls/msdasql/Makefile.in b/dlls/msdasql/Makefile.in
index 8c99c8ea6f0..04d9cb29f2a 100644
--- a/dlls/msdasql/Makefile.in
+++ b/dlls/msdasql/Makefile.in
@@ -1,5 +1,5 @@
MODULE = msdasql.dll
-IMPORTS = uuid
+IMPORTS = uuid ole32 oleaut32
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/msdasql/msdasql_main.c b/dlls/msdasql/msdasql_main.c
index 00dbcec6780..96a1bc392e2 100644
--- a/dlls/msdasql/msdasql_main.c
+++ b/dlls/msdasql/msdasql_main.c
@@ -32,6 +32,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(msdasql);
+DEFINE_GUID(DBPROPSET_DBINIT, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
+
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
@@ -100,6 +102,74 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID riid, void **ppv )
return CLASS_E_CLASSNOTAVAILABLE;
}
+struct dbproperty
+{
+ const WCHAR *name;
+ DBPROPID id;
+ DBPROPOPTIONS options;
+ VARTYPE type;
+ HRESULT (*convert_dbproperty)(const WCHAR *src, VARIANT *dest);
+};
+
+struct mode_propval
+{
+ const WCHAR *name;
+ DWORD value;
+};
+
+static int __cdecl dbmodeprop_compare(const void *a, const void *b)
+{
+ const WCHAR *src = a;
+ const struct mode_propval *propval = b;
+ return wcsicmp(src, propval->name);
+}
+
+static HRESULT convert_dbproperty_mode(const WCHAR *src, VARIANT *dest)
+{
+ struct mode_propval mode_propvals[] =
+ {
+ { L"Read", DB_MODE_READ },
+ { L"ReadWrite", DB_MODE_READWRITE },
+ { L"Share Deny None", DB_MODE_SHARE_DENY_NONE },
+ { L"Share Deny Read", DB_MODE_SHARE_DENY_READ },
+ { L"Share Deny Write", DB_MODE_SHARE_DENY_WRITE },
+ { L"Share Exclusive", DB_MODE_SHARE_EXCLUSIVE },
+ { L"Write", DB_MODE_WRITE },
+ };
+ struct mode_propval *prop;
+
+ if ((prop = bsearch(src, mode_propvals, ARRAY_SIZE(mode_propvals),
+ sizeof(struct mode_propval), dbmodeprop_compare)))
+ {
+ V_VT(dest) = VT_I4;
+ V_I4(dest) = prop->value;
+ TRACE("%s = %#x\n", debugstr_w(src), prop->value);
+ return S_OK;
+ }
+
+ return E_FAIL;
+}
+
+static const VARTYPE intptr_vartype = (sizeof(void *) == 8 ? VT_I8 : VT_I4);
+
+static const struct dbproperty dbproperties[] =
+{
+ { L"Password", DBPROP_AUTH_PASSWORD, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
+ { L"Persist Security Info", DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, DBPROPOPTIONS_OPTIONAL, VT_BOOL },
+ { L"User ID", DBPROP_AUTH_USERID, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
+ { L"Data Source", DBPROP_INIT_DATASOURCE, DBPROPOPTIONS_REQUIRED, VT_BSTR },
+ { L"Window Handle", DBPROP_INIT_HWND, DBPROPOPTIONS_OPTIONAL, intptr_vartype },
+ { L"Location", DBPROP_INIT_LOCATION, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
+ { L"Mode", DBPROP_INIT_MODE, DBPROPOPTIONS_OPTIONAL, VT_I4, convert_dbproperty_mode },
+ { L"Prompt", DBPROP_INIT_PROMPT, DBPROPOPTIONS_OPTIONAL, VT_I2 },
+ { L"Connect Timeout", DBPROP_INIT_TIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
+ { L"Extended Properties", DBPROP_INIT_PROVIDERSTRING, DBPROPOPTIONS_REQUIRED, VT_BSTR },
+ { L"Locale Identifier", DBPROP_INIT_LCID, DBPROPOPTIONS_OPTIONAL, VT_I4 },
+ { L"Initial Catalog", DBPROP_INIT_CATALOG, DBPROPOPTIONS_OPTIONAL, VT_BSTR },
+ { L"OLE DB Services", DBPROP_INIT_OLEDBSERVICES, DBPROPOPTIONS_OPTIONAL, VT_I4 },
+ { L"General Timeout", DBPROP_INIT_GENERALTIMEOUT, DBPROPOPTIONS_OPTIONAL, VT_I4 },
+};
+
struct msdasql
{
IUnknown MSDASQL_iface;
@@ -222,11 +292,43 @@ static HRESULT WINAPI dbprops_GetPropertyInfo(IDBProperties *iface, ULONG cPrope
DBPROPINFOSET **prgPropertyInfoSets, OLECHAR **ppDescBuffer)
{
struct msdasql *provider = impl_from_IDBProperties(iface);
+ int i;
+ DBPROPINFOSET *infoset;
+ int size = 1;
+ OLECHAR *ptr;
- FIXME("(%p)->(%d %p %p %p %p)\n", provider, cPropertyIDSets, rgPropertyIDSets, pcPropertyInfoSets,
+ TRACE("(%p)->(%d %p %p %p %p)\n", provider, cPropertyIDSets, rgPropertyIDSets, pcPropertyInfoSets,
prgPropertyInfoSets, ppDescBuffer);
- return E_NOTIMPL;
+ infoset = CoTaskMemAlloc(sizeof(DBPROPINFOSET));
+ memcpy(&infoset->guidPropertySet, &DBPROPSET_DBINIT, sizeof(GUID));
+ infoset->cPropertyInfos = ARRAY_SIZE(dbproperties);
+ infoset->rgPropertyInfos = CoTaskMemAlloc(sizeof(DBPROPINFO) * ARRAY_SIZE(dbproperties));
+
+ for(i=0; i < ARRAY_SIZE(dbproperties); i++)
+ {
+ size += lstrlenW(dbproperties[i].name) + 1;
+ }
+
+ ptr = *ppDescBuffer = CoTaskMemAlloc(size * sizeof(WCHAR));
+ memset(*ppDescBuffer, 0, size * sizeof(WCHAR));
+
+ for(i=0; i < ARRAY_SIZE(dbproperties); i++)
+ {
+ lstrcpyW(ptr, dbproperties[i].name);
+ infoset->rgPropertyInfos[i].pwszDescription = ptr;
+ infoset->rgPropertyInfos[i].dwPropertyID = dbproperties[i].id;
+ infoset->rgPropertyInfos[i].dwFlags = DBPROPFLAGS_DBINIT | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE;
+ infoset->rgPropertyInfos[i].vtType = dbproperties[i].type;
+ V_VT(&infoset->rgPropertyInfos[i].vValues) = VT_EMPTY;
+
+ ptr += lstrlenW(dbproperties[i].name) + 1;
+ }
+
+ *pcPropertyInfoSets = 1;
+ *prgPropertyInfoSets = infoset;
+
+ return S_OK;
}
static HRESULT WINAPI dbprops_SetProperties(IDBProperties *iface, ULONG cPropertySets,
diff --git a/dlls/msdasql/tests/provider.c b/dlls/msdasql/tests/provider.c
index 96d33f6bd10..2e90d2f848d 100644
--- a/dlls/msdasql/tests/provider.c
+++ b/dlls/msdasql/tests/provider.c
@@ -22,6 +22,7 @@
#include "msdasc.h"
#include "oledb.h"
#include "odbcinst.h"
+#include "wtypes.h"
#include "initguid.h"
@@ -30,10 +31,13 @@
#include "wine/test.h"
DEFINE_GUID(DBPROPSET_DBINITALL, 0xc8b522ca, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
+DEFINE_GUID(DBPROPSET_DBINIT, 0xc8b522bc, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
static BOOL db_created;
static char mdbpath[MAX_PATH];
+static const VARTYPE intptr_vartype = (sizeof(void *) == 8 ? VT_I8 : VT_I4);
+
static void test_Properties(void)
{
HRESULT hr;
@@ -52,16 +56,21 @@ static void test_Properties(void)
infocount = 0;
hr = IDBProperties_GetPropertyInfo(props, 1, &propidset, &infocount, &propinfoset, &desc);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK)
{
ULONG i;
+ VARTYPE types[14] = { VT_BSTR, VT_BOOL, VT_BSTR, VT_BSTR, intptr_vartype, VT_BSTR, VT_I4, VT_I2 , VT_I4, VT_BSTR, VT_I4, VT_BSTR, VT_I4, VT_I4 };
+ ok(IsEqualGUID(&propinfoset->guidPropertySet, &DBPROPSET_DBINIT), "got %s\n", debugstr_guid(&propinfoset->guidPropertySet));
ok(propinfoset->cPropertyInfos == 14, "got %d\n", propinfoset->cPropertyInfos);
for (i = 0; i < propinfoset->cPropertyInfos; i++)
{
trace("%d: pwszDescription: %s\n", i, debugstr_w(propinfoset->rgPropertyInfos[i].pwszDescription) );
+ ok(propinfoset->rgPropertyInfos[i].vtType == types[i], "got %d\n", propinfoset->rgPropertyInfos[i].vtType);
+ ok(propinfoset->rgPropertyInfos[i].dwFlags == (DBPROPFLAGS_DBINIT | DBPROPFLAGS_READ | DBPROPFLAGS_WRITE),
+ "got %d\n", propinfoset->rgPropertyInfos[i].dwFlags);
}
for (i = 0; i < propinfoset->cPropertyInfos; i++)
diff --git a/dlls/oledb32/tests/database.c b/dlls/oledb32/tests/database.c
index 3baa91b87a4..775da0f7b61 100644
--- a/dlls/oledb32/tests/database.c
+++ b/dlls/oledb32/tests/database.c
@@ -82,7 +82,7 @@ static void test_GetDataSource(WCHAR *initstring)
EXPECT_REF(dbinit, 2);
EXPECT_REF(props, 2);
hr = IDBProperties_GetPropertyInfo(props, 0, NULL, &cnt, &pInfoset, &ary);
- todo_wine ok(hr == S_OK, "got %08x\n", hr);
+ ok(hr == S_OK, "got %08x\n", hr);
if(hr == S_OK)
{
ULONG i;
@@ -1006,7 +1006,7 @@ static void test_odbc_provider(void)
infocount = 0;
hr = IDBProperties_GetPropertyInfo(props, 1, &propidset, &infocount, &propinfoset, &desc);
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK)
{
ULONG i;
@@ -1039,7 +1039,8 @@ static void test_odbc_provider(void)
CoTaskMemFree(propinfoset);
hr = IDBProperties_GetProperties(props, 1, &propidlist, &propcnt, &propset);
- ok(hr == S_OK, "got 0x%08x\n", hr);
+ todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
+ if (hr == S_OK) { /* Remove if, once _GetProperties is implemented */
ok(propidlist.cPropertyIDs == 14, "got %d\n", propinfoset->cPropertyInfos);
for (i = 0; i < propidlist.cPropertyIDs; i++)
@@ -1049,6 +1050,7 @@ static void test_odbc_provider(void)
propidlist.rgPropertyIDs[i] = propinfoset->rgPropertyInfos[i].dwPropertyID;
}
+ }
CoTaskMemFree(propidlist.rgPropertyIDs);
CoTaskMemFree(propset);
--
2.33.0
1
0