quartz: Free two assert calls from having side effects.
[wine/testsucceed.git] / dlls / dpnet / address.c
blob78c83507c8251376797bf79a5264f0353d00bde9
1 /*
2 * DirectPlay8 Address
3 *
4 * Copyright 2004 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
24 #include <stdarg.h>
26 #define COBJMACROS
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "objbase.h"
32 #include "wine/debug.h"
34 #include "dplay8.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
39 static inline IDirectPlay8AddressImpl *impl_from_IDirectPlay8Address(IDirectPlay8Address *iface)
41 return CONTAINING_RECORD(iface, IDirectPlay8AddressImpl, IDirectPlay8Address_iface);
44 /* IDirectPlay8Address IUnknown parts follow: */
45 static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(IDirectPlay8Address *iface,
46 REFIID riid, void **ppv)
48 if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
49 IUnknown_AddRef(iface);
50 *ppv = iface;
51 return DPN_OK;
54 WARN("(%p)->(%s,%p),not found\n", iface, debugstr_guid(riid), ppv);
55 return E_NOINTERFACE;
58 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(IDirectPlay8Address *iface)
60 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
61 ULONG refCount = InterlockedIncrement(&This->ref);
63 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
65 return refCount;
68 static ULONG WINAPI IDirectPlay8AddressImpl_Release(IDirectPlay8Address *iface)
70 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
71 ULONG refCount = InterlockedDecrement(&This->ref);
73 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
75 if (!refCount) {
76 HeapFree(GetProcessHeap(), 0, This);
78 return refCount;
81 /* returns name of given GUID */
82 static const char *debugstr_SP(const GUID *id) {
83 static const guid_info guids[] = {
84 /* CLSIDs */
85 GE(CLSID_DP8SP_IPX),
86 GE(CLSID_DP8SP_TCPIP),
87 GE(CLSID_DP8SP_SERIAL),
88 GE(CLSID_DP8SP_MODEM)
90 unsigned int i;
92 if (!id) return "(null)";
94 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
95 if (IsEqualGUID(id, guids[i].guid))
96 return guids[i].name;
98 /* if we didn't find it, act like standard debugstr_guid */
99 return debugstr_guid(id);
102 /* IDirectPlay8Address Interface follow: */
104 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(IDirectPlay8Address *iface,
105 WCHAR *pwszSourceURL)
107 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
108 TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
109 return DPN_OK;
112 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address *iface,
113 CHAR *pszSourceURL)
115 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
116 TRACE("(%p, %s): stub\n", This, pszSourceURL);
117 return DPN_OK;
120 static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address *iface,
121 IDirectPlay8Address **ppdpaNewAddress)
123 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
124 TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
125 return DPN_OK;
128 static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address *iface,
129 IDirectPlay8Address *pdpaAddress)
131 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
132 TRACE("(%p, %p): stub\n", This, pdpaAddress);
133 return DPN_OK;
136 static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(IDirectPlay8Address *iface,
137 IDirectPlay8Address *pdpaAddress)
139 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
140 TRACE("(%p, %p): stub\n", This, pdpaAddress);
141 return DPN_OK;
144 static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(IDirectPlay8Address *iface)
146 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
147 TRACE("(%p): stub\n", This);
148 return DPN_OK;
151 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(IDirectPlay8Address *iface, WCHAR *pwszURL,
152 DWORD *pdwNumChars)
154 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
155 TRACE("(%p): stub\n", This);
156 return DPN_OK;
159 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(IDirectPlay8Address *iface, CHAR *pszURL,
160 DWORD *pdwNumChars)
162 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
163 TRACE("(%p): stub\n", This);
164 return DPN_OK;
167 static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(IDirectPlay8Address *iface, GUID *pguidSP)
169 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
171 TRACE("(%p, %p)\n", iface, pguidSP);
173 *pguidSP = This->SP_guid;
174 return DPN_OK;
177 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *iface,
178 void *pvUserData, DWORD *pdwBufferSize)
180 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
181 TRACE("(%p): stub\n", This);
182 return DPN_OK;
185 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address *iface,
186 const GUID *const pguidSP)
188 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
190 TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
192 This->SP_guid = *pguidSP;
193 return DPN_OK;
196 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *iface,
197 const void *const pvUserData, const DWORD dwDataSize)
199 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
200 TRACE("(%p): stub\n", This);
201 return DPN_OK;
204 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address *iface,
205 DWORD *pdwNumComponents)
207 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
208 TRACE("(%p): stub\n", This);
209 return DPN_OK;
212 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface,
213 const WCHAR *const pwszName, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType)
215 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
216 TRACE("(%p): stub\n", This);
217 return DPN_OK;
220 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address *iface,
221 const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer,
222 DWORD *pdwBufferSize, DWORD *pdwDataType)
224 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
225 TRACE("(%p): stub\n", This);
226 return DPN_OK;
229 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *iface,
230 const WCHAR *const pwszName, const void* const lpvData, const DWORD dwDataSize,
231 const DWORD dwDataType)
233 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
234 TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
236 if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
237 switch (dwDataType) {
238 case DPNA_DATATYPE_DWORD:
239 if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
240 TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
241 break;
242 case DPNA_DATATYPE_GUID:
243 if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
244 TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid(lpvData));
245 break;
246 case DPNA_DATATYPE_STRING:
247 TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
248 break;
249 case DPNA_DATATYPE_BINARY:
250 TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
251 break;
254 return DPN_OK;
257 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(IDirectPlay8Address *iface, GUID *pDevGuid) {
258 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
259 TRACE("(%p): stub\n", This);
260 return DPN_OK;
263 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(IDirectPlay8Address *iface,
264 const GUID *const devGuid)
266 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
267 TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
268 return DPN_OK;
271 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(IDirectPlay8Address *iface,
272 void *pvAddress, DWORD dwDataSize)
274 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
275 TRACE("(%p): stub\n", This);
276 return DPN_OK;
279 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
281 IDirectPlay8AddressImpl_QueryInterface,
282 IDirectPlay8AddressImpl_AddRef,
283 IDirectPlay8AddressImpl_Release,
284 IDirectPlay8AddressImpl_BuildFromURLW,
285 IDirectPlay8AddressImpl_BuildFromURLA,
286 IDirectPlay8AddressImpl_Duplicate,
287 IDirectPlay8AddressImpl_SetEqual,
288 IDirectPlay8AddressImpl_IsEqual,
289 IDirectPlay8AddressImpl_Clear,
290 IDirectPlay8AddressImpl_GetURLW,
291 IDirectPlay8AddressImpl_GetURLA,
292 IDirectPlay8AddressImpl_GetSP,
293 IDirectPlay8AddressImpl_GetUserData,
294 IDirectPlay8AddressImpl_SetSP,
295 IDirectPlay8AddressImpl_SetUserData,
296 IDirectPlay8AddressImpl_GetNumComponents,
297 IDirectPlay8AddressImpl_GetComponentByName,
298 IDirectPlay8AddressImpl_GetComponentByIndex,
299 IDirectPlay8AddressImpl_AddComponent,
300 IDirectPlay8AddressImpl_GetDevice,
301 IDirectPlay8AddressImpl_SetDevice,
302 IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
305 HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
306 IDirectPlay8AddressImpl* client;
308 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
310 client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
311 if (NULL == client) {
312 *ppobj = NULL;
313 return E_OUTOFMEMORY;
315 client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
316 client->ref = 0; /* will be inited with QueryInterface */
317 return IDirectPlay8AddressImpl_QueryInterface (&client->IDirectPlay8Address_iface, riid, ppobj);