d3dxof: Fix tzip and bzip files tests on all windows platform.
[wine] / dlls / dpnet / address.c
1 /* 
2  * DirectPlay8 Address
3  * 
4  * Copyright 2004 Raphael Junqueira
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "config.h"
23
24 #include <stdarg.h>
25
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"
33
34 #include "dplay8.h"
35 #include "dpnet_private.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
38
39 /* IDirectPlay8Address IUnknown parts follow: */
40 static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(PDIRECTPLAY8ADDRESS iface, REFIID riid, LPVOID *ppobj)
41 {
42     IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
43
44     if (IsEqualGUID(riid, &IID_IUnknown)
45         || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
46         IUnknown_AddRef(iface);
47         *ppobj = This;
48         return DPN_OK;
49     }
50
51     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
52     return E_NOINTERFACE;
53 }
54
55 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(PDIRECTPLAY8ADDRESS iface) {
56     IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
57     ULONG refCount = InterlockedIncrement(&This->ref);
58
59     TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
60
61     return refCount;
62 }
63
64 static ULONG WINAPI IDirectPlay8AddressImpl_Release(PDIRECTPLAY8ADDRESS iface) {
65     IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
66     ULONG refCount = InterlockedDecrement(&This->ref);
67
68     TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
69
70     if (!refCount) {
71         HeapFree(GetProcessHeap(), 0, This);
72     }
73     return refCount;
74 }
75
76 /* returns name of given GUID */
77 static const char *debugstr_SP(const GUID *id) {
78   static const guid_info guids[] = {
79     /* CLSIDs */
80     GE(CLSID_DP8SP_IPX),
81     GE(CLSID_DP8SP_TCPIP),
82     GE(CLSID_DP8SP_SERIAL),
83     GE(CLSID_DP8SP_MODEM)
84   };
85   unsigned int i;
86
87   if (!id) return "(null)";
88
89   for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
90     if (IsEqualGUID(id, guids[i].guid))
91       return guids[i].name;
92   }
93   /* if we didn't find it, act like standard debugstr_guid */
94   return debugstr_guid(id);
95 }
96
97 /* IDirectPlay8Address Interface follow: */
98
99 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszSourceURL) { 
100   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
101   TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
102   return DPN_OK; 
103 }
104
105 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszSourceURL) { 
106   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
107   TRACE("(%p, %s): stub\n", This, pszSourceURL);
108   return DPN_OK; 
109 }
110
111 static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS* ppdpaNewAddress) { 
112   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
113   TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
114   return DPN_OK; 
115 }
116
117 static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) { 
118   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
119   TRACE("(%p, %p): stub\n", This, pdpaAddress);
120   return DPN_OK; 
121 }
122
123 static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) { 
124   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
125   TRACE("(%p, %p): stub\n", This, pdpaAddress);
126   return DPN_OK; 
127 }
128
129 static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(PDIRECTPLAY8ADDRESS iface) { 
130   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
131   TRACE("(%p): stub\n", This);
132   return DPN_OK; 
133 }
134
135 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszURL, PDWORD pdwNumChars) { 
136   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
137   TRACE("(%p): stub\n", This);
138   return DPN_OK; 
139 }
140
141 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszURL, PDWORD pdwNumChars) { 
142   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
143   TRACE("(%p): stub\n", This);
144   return DPN_OK; 
145 }
146
147 static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(PDIRECTPLAY8ADDRESS iface, GUID* pguidSP) { 
148   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
149   TRACE("(%p, %p)\n", iface, pguidSP);
150   *pguidSP = This->SP_guid;
151   return DPN_OK; 
152 }
153
154 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(PDIRECTPLAY8ADDRESS iface, LPVOID pvUserData, PDWORD pdwBufferSize) { 
155   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
156   TRACE("(%p): stub\n", This);
157   return DPN_OK; 
158 }
159
160 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST pguidSP) { 
161   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
162   TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
163   This->SP_guid = *pguidSP;
164   return DPN_OK; 
165 }
166
167 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(PDIRECTPLAY8ADDRESS iface, CONST void* CONST pvUserData, CONST DWORD dwDataSize) { 
168   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
169   TRACE("(%p): stub\n", This);
170   return DPN_OK; 
171 }
172
173 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(PDIRECTPLAY8ADDRESS iface, PDWORD pdwNumComponents) { 
174   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
175   TRACE("(%p): stub\n", This);
176   return DPN_OK; 
177 }
178
179 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) { 
180   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
181   TRACE("(%p): stub\n", This);
182   return DPN_OK; 
183 }
184
185 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(PDIRECTPLAY8ADDRESS iface, CONST DWORD dwComponentID, WCHAR* pwszName, 
186                                                            PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) { 
187   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
188   TRACE("(%p): stub\n", This);
189   return DPN_OK; 
190 }
191
192 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, 
193                                                     CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType) { 
194   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
195   TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
196   
197   if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
198   switch (dwDataType) {
199   case DPNA_DATATYPE_DWORD:
200     if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
201     TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
202     break;
203   case DPNA_DATATYPE_GUID:
204     if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
205     TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid(lpvData));
206     break;
207   case DPNA_DATATYPE_STRING:
208     TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
209     break;
210   case DPNA_DATATYPE_BINARY:
211     TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
212     break;
213   }
214   
215   return DPN_OK; 
216 }
217
218 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(PDIRECTPLAY8ADDRESS iface, GUID* pDevGuid) {   
219   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
220   TRACE("(%p): stub\n", This);
221   return DPN_OK; 
222 }
223
224 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST devGuid) { 
225   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
226   TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
227   return DPN_OK; 
228 }
229
230 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(PDIRECTPLAY8ADDRESS iface, LPVOID pvAddress, DWORD dwDataSize) { 
231   IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
232   TRACE("(%p): stub\n", This);
233   return DPN_OK; 
234 }
235
236 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
237 {
238     IDirectPlay8AddressImpl_QueryInterface,
239     IDirectPlay8AddressImpl_AddRef,
240     IDirectPlay8AddressImpl_Release,
241     IDirectPlay8AddressImpl_BuildFromURLW,
242     IDirectPlay8AddressImpl_BuildFromURLA,
243     IDirectPlay8AddressImpl_Duplicate,
244     IDirectPlay8AddressImpl_SetEqual,
245     IDirectPlay8AddressImpl_IsEqual,
246     IDirectPlay8AddressImpl_Clear,
247     IDirectPlay8AddressImpl_GetURLW,
248     IDirectPlay8AddressImpl_GetURLA,
249     IDirectPlay8AddressImpl_GetSP,
250     IDirectPlay8AddressImpl_GetUserData,
251     IDirectPlay8AddressImpl_SetSP,
252     IDirectPlay8AddressImpl_SetUserData,
253     IDirectPlay8AddressImpl_GetNumComponents,
254     IDirectPlay8AddressImpl_GetComponentByName,
255     IDirectPlay8AddressImpl_GetComponentByIndex,
256     IDirectPlay8AddressImpl_AddComponent,
257     IDirectPlay8AddressImpl_GetDevice,
258     IDirectPlay8AddressImpl_SetDevice,
259     IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
260 };
261
262 HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
263   IDirectPlay8AddressImpl* client;
264
265   TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
266   
267   client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
268   if (NULL == client) {
269     *ppobj = NULL;
270     return E_OUTOFMEMORY;
271   }
272   client->lpVtbl = &DirectPlay8Address_Vtbl;
273   client->ref = 0; /* will be inited with QueryInterface */
274   return IDirectPlay8AddressImpl_QueryInterface ((PDIRECTPLAY8ADDRESS)client, riid, ppobj);
275 }