wineconsole: Free registry key name (valgrind).
[wine.git] / dlls / dpnet / address.c
blob9266fea0b0e048971f92acc6dc14ec9937c93daa
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 ref = InterlockedIncrement(&This->ref);
63 TRACE("(%p) ref=%u\n", This, ref);
65 return ref;
68 static ULONG WINAPI IDirectPlay8AddressImpl_Release(IDirectPlay8Address *iface)
70 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
71 ULONG ref = InterlockedDecrement(&This->ref);
73 TRACE("(%p) ref=%u\n", This, ref);
75 if (!ref) {
76 HeapFree(GetProcessHeap(), 0, This);
78 return ref;
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 if(!pguidSP)
174 return DPNERR_INVALIDPOINTER;
176 if(!This->init)
177 return DPNERR_DOESNOTEXIST;
179 *pguidSP = This->SP_guid;
180 return DPN_OK;
183 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address *iface,
184 void *pvUserData, DWORD *pdwBufferSize)
186 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
187 TRACE("(%p): stub\n", This);
188 return DPN_OK;
191 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address *iface,
192 const GUID *const pguidSP)
194 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
196 TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
198 if(!pguidSP)
199 return DPNERR_INVALIDPOINTER;
201 This->init = TRUE;
202 This->SP_guid = *pguidSP;
203 return DPN_OK;
206 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address *iface,
207 const void *const pvUserData, const DWORD dwDataSize)
209 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
210 TRACE("(%p): stub\n", This);
211 return DPN_OK;
214 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address *iface,
215 DWORD *pdwNumComponents)
217 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
218 TRACE("(%p): stub\n", This);
219 return DPN_OK;
222 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address *iface,
223 const WCHAR *const pwszName, void *pvBuffer, DWORD *pdwBufferSize, DWORD *pdwDataType)
225 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
226 TRACE("(%p): stub\n", This);
227 return DPN_OK;
230 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address *iface,
231 const DWORD dwComponentID, WCHAR *pwszName, DWORD *pdwNameLen, void *pvBuffer,
232 DWORD *pdwBufferSize, DWORD *pdwDataType)
234 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
235 TRACE("(%p): stub\n", This);
236 return DPN_OK;
239 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address *iface,
240 const WCHAR *const pwszName, const void* const lpvData, const DWORD dwDataSize,
241 const DWORD dwDataType)
243 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
244 TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
246 if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
247 switch (dwDataType) {
248 case DPNA_DATATYPE_DWORD:
249 if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
250 TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
251 break;
252 case DPNA_DATATYPE_GUID:
253 if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
254 TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid(lpvData));
255 break;
256 case DPNA_DATATYPE_STRING:
257 TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
258 break;
259 case DPNA_DATATYPE_BINARY:
260 TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
261 break;
264 return DPN_OK;
267 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(IDirectPlay8Address *iface, GUID *pDevGuid) {
268 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
269 TRACE("(%p): stub\n", This);
270 return DPN_OK;
273 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(IDirectPlay8Address *iface,
274 const GUID *const devGuid)
276 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
277 TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
278 return DPN_OK;
281 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(IDirectPlay8Address *iface,
282 void *pvAddress, DWORD dwDataSize)
284 IDirectPlay8AddressImpl *This = impl_from_IDirectPlay8Address(iface);
285 TRACE("(%p): stub\n", This);
286 return DPN_OK;
289 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
291 IDirectPlay8AddressImpl_QueryInterface,
292 IDirectPlay8AddressImpl_AddRef,
293 IDirectPlay8AddressImpl_Release,
294 IDirectPlay8AddressImpl_BuildFromURLW,
295 IDirectPlay8AddressImpl_BuildFromURLA,
296 IDirectPlay8AddressImpl_Duplicate,
297 IDirectPlay8AddressImpl_SetEqual,
298 IDirectPlay8AddressImpl_IsEqual,
299 IDirectPlay8AddressImpl_Clear,
300 IDirectPlay8AddressImpl_GetURLW,
301 IDirectPlay8AddressImpl_GetURLA,
302 IDirectPlay8AddressImpl_GetSP,
303 IDirectPlay8AddressImpl_GetUserData,
304 IDirectPlay8AddressImpl_SetSP,
305 IDirectPlay8AddressImpl_SetUserData,
306 IDirectPlay8AddressImpl_GetNumComponents,
307 IDirectPlay8AddressImpl_GetComponentByName,
308 IDirectPlay8AddressImpl_GetComponentByIndex,
309 IDirectPlay8AddressImpl_AddComponent,
310 IDirectPlay8AddressImpl_GetDevice,
311 IDirectPlay8AddressImpl_SetDevice,
312 IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
315 HRESULT DPNET_CreateDirectPlay8Address(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj)
317 IDirectPlay8AddressImpl* client;
318 HRESULT ret;
320 TRACE("(%p, %s, %p)\n", pUnkOuter, debugstr_guid(riid), ppobj);
322 *ppobj = NULL;
324 client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
325 if (!client)
326 return E_OUTOFMEMORY;
328 client->IDirectPlay8Address_iface.lpVtbl = &DirectPlay8Address_Vtbl;
329 client->ref = 1;
331 ret = IDirectPlay8AddressImpl_QueryInterface(&client->IDirectPlay8Address_iface, riid, ppobj);
332 IDirectPlay8AddressImpl_Release(&client->IDirectPlay8Address_iface);
334 return ret;