Commit c41d2750 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

dpnet: Improve error checking in Get/Set SP.

parent daac5b1f
......@@ -166,12 +166,18 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(IDirectPlay8Address *iface
static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(IDirectPlay8Address *iface, GUID *pguidSP)
{
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
TRACE("(%p, %p)\n", iface, pguidSP);
TRACE("(%p, %p)\n", iface, pguidSP);
*pguidSP = This->SP_guid;
return DPN_OK;
if(!pguidSP)
return DPNERR_INVALIDPOINTER;
if(!This->init)
return DPNERR_DOESNOTEXIST;
*pguidSP = This->SP_guid;
return DPN_OK;
}
static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *iface,
......@@ -185,12 +191,16 @@ static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *i
static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address *iface,
const GUID *const pguidSP)
{
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
This->SP_guid = *pguidSP;
return DPN_OK;
if(!pguidSP)
return DPNERR_INVALIDPOINTER;
This->init = TRUE;
This->SP_guid = *pguidSP;
return DPN_OK;
}
static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *iface,
......
......@@ -64,7 +64,7 @@ struct IDirectPlay8AddressImpl
LONG ref;
/* IDirectPlay8Address fields */
GUID SP_guid;
const WCHAR *url;
BOOL init;
};
/*****************************************************************************
......
TESTDLL = dpnet.dll
IMPORTS = dpnet ole32 dxguid
IMPORTS = dxguid uuid dpnet ole32
C_SRCS = \
address.c \
peer.c \
server.c
/*
* Copyright 2014 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 WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <dplay8.h>
#include "wine/test.h"
/* {6733C6E8-A0D6-450E-8C18-CEACF331DC27} */
static const GUID IID_Random = {0x6733c6e8, 0xa0d6, 0x450e, { 0x8c, 0x18, 0xce, 0xac, 0xf3, 0x31, 0xdc, 0x27 } };
static void create_directplay_address(void)
{
HRESULT hr;
IDirectPlay8Address *localaddr = NULL;
hr = CoCreateInstance( &CLSID_DirectPlay8Address, NULL, CLSCTX_ALL, &IID_IDirectPlay8Address, (LPVOID*)&localaddr);
ok(hr == S_OK, "Failed to create IDirectPlay8Address object");
if(SUCCEEDED(hr))
{
GUID guidsp;
hr = IDirectPlay8Address_GetSP(localaddr, NULL);
ok(hr == DPNERR_INVALIDPOINTER, "GetSP failed 0x%08x\n", hr);
hr = IDirectPlay8Address_GetSP(localaddr, &guidsp);
ok(hr == DPNERR_DOESNOTEXIST, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_SetSP(localaddr, &GUID_NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetSP(localaddr, &guidsp);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&guidsp, &GUID_NULL), "wrong guid: %s\n", wine_dbgstr_guid(&guidsp));
hr = IDirectPlay8Address_SetSP(localaddr, &IID_Random);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetSP(localaddr, &guidsp);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&guidsp, &IID_Random), "wrong guid: %s\n", wine_dbgstr_guid(&guidsp));
hr = IDirectPlay8Address_SetSP(localaddr, &CLSID_DP8SP_TCPIP);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDirectPlay8Address_GetSP(localaddr, &guidsp);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&guidsp, &CLSID_DP8SP_TCPIP), "wrong guid: %s\n", wine_dbgstr_guid(&guidsp));
IDirectPlay8Address_Release(localaddr);
}
}
START_TEST(address)
{
HRESULT hr;
hr = CoInitialize(0);
ok(hr == S_OK, "failed to init com\n");
if(hr != S_OK)
return;
create_directplay_address();
CoUninitialize();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment