dpnet: Implement IDirectPlay8Address GetComponentByIndex
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Wed Nov 26 23:11:36 CST 2014
Hi,
Changelog:
dpnet: Implement IDirectPlay8Address GetComponentByIndex
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 7c205c4c678345208cab50786d8ea64802c924ef Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Thu, 27 Nov 2014 15:57:44 +1100
Subject: [PATCH] Implement IDirectPlay8Address GetComponentByIndex
To: wine-patches <wine-patches at winehq.org>
---
dlls/dpnet/address.c | 54 +++++++++++++++++++++++++++++++++++++++++++---
dlls/dpnet/tests/address.c | 14 ++++++------
2 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/dlls/dpnet/address.c b/dlls/dpnet/address.c
index 2062bc4..dfff0c6 100644
--- a/dlls/dpnet/address.c
+++ b/dlls/dpnet/address.c
@@ -369,9 +369,57 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Ad
const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer,
DWORD *pdwBufferSize, DWORD *pdwDataType)
{
- IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
- TRACE("(%p): stub\n", This);
- return DPN_OK;
+ IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
+ struct component *entry;
+ DWORD count = 0;
+
+ TRACE("(%p)->(%p %p %p %p)\n", This, pwszName, pvBuffer, pdwBufferSize, pdwDataType);
+
+ if(!pdwNameLen || !pdwBufferSize)
+ return E_POINTER;
+
+ if(dwComponentID > list_count(&This->components))
+ return DPNERR_DOESNOTEXIST;
+
+ LIST_FOR_EACH_ENTRY(entry, &This->components, struct component, entry)
+ {
+ if(count == dwComponentID)
+ {
+ if(*pdwBufferSize < entry->size)
+ {
+ *pdwBufferSize = entry->size;
+ return DPNERR_BUFFERTOOSMALL;
+ }
+
+ *pdwBufferSize = entry->size;
+ *pdwDataType = entry->type;
+
+ switch (entry->type)
+ {
+ case DPNA_DATATYPE_DWORD:
+ memcpy(pvBuffer, &entry->data.value, sizeof(DWORD));
+ break;
+ case DPNA_DATATYPE_GUID:
+ memcpy(pvBuffer, &entry->data.guid, sizeof(GUID));
+ break;
+ case DPNA_DATATYPE_STRING:
+ memcpy(pvBuffer, &entry->data.string, entry->size);
+ break;
+ case DPNA_DATATYPE_STRING_ANSI:
+ memcpy(pvBuffer, &entry->data.ansi, entry->size);
+ break;
+ case DPNA_DATATYPE_BINARY:
+ memcpy(pvBuffer, &entry->data.binary, entry->size);
+ break;
+ }
+
+ return S_OK;
+ }
+
+ count++;
+ }
+
+ return DPNERR_DOESNOTEXIST;
}
static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *iface,
diff --git a/dlls/dpnet/tests/address.c b/dlls/dpnet/tests/address.c
index 59c5431..31fa179 100644
--- a/dlls/dpnet/tests/address.c
+++ b/dlls/dpnet/tests/address.c
@@ -145,13 +145,13 @@ static void address_addcomponents(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, &namelen, NULL, &bufflen, &type);
- todo_wine ok(hr == DPNERR_DOESNOTEXIST, "got 0x%08x\n", hr);
+ ok(hr == DPNERR_DOESNOTEXIST, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, NULL, NULL, &bufflen, &type);
- todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
+ ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 100, NULL, &namelen, NULL, NULL, &type);
- todo_wine ok(hr == E_POINTER, "got 0x%08x\n", hr);
+ ok(hr == E_POINTER, "got 0x%08x\n", hr);
trace("GetNumComponents=%d\n", components);
for(i=0; i < components; i++)
@@ -163,7 +163,7 @@ static void address_addcomponents(void)
namelen = 0;
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, i, NULL, &namelen, NULL, &bufflen, &type);
- todo_wine ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
+ ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, namelen * sizeof(WCHAR));
buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bufflen);
@@ -228,14 +228,14 @@ static void address_setsp(void)
ok(components == 1, "components=%d\n", components);
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 0, NULL, &namelen, NULL, &bufflen, &type);
- todo_wine ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
+ ok(hr == DPNERR_BUFFERTOOSMALL, "got 0x%08x\n", hr);
name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, namelen * sizeof(WCHAR));
hr = IDirectPlay8Address_GetComponentByIndex(localaddr, 0, name, &namelen, (void*)&guid, &bufflen, &type);
ok(hr == S_OK, "got 0x%08x\n", hr);
- todo_wine ok(type == DPNA_DATATYPE_GUID, "wrong datatype: %d\n", type);
- todo_wine ok(IsEqualGUID(&guid, &CLSID_DP8SP_TCPIP), "wrong guid\n");
+ ok(type == DPNA_DATATYPE_GUID, "wrong datatype: %d\n", type);
+ ok(IsEqualGUID(&guid, &CLSID_DP8SP_TCPIP), "wrong guid\n");
HeapFree(GetProcessHeap(), 0, name);
--
1.9.1
More information about the wine-patches
mailing list