~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/dxdiagn/container.c

Version: ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /* 
  2  * IDxDiagContainer Implementation
  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 #define COBJMACROS
 25 #include "dxdiag_private.h"
 26 #include "wine/debug.h"
 27 #include "wine/unicode.h"
 28 
 29 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
 30 
 31 /* IDxDiagContainer IUnknown parts follow: */
 32 HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFIID riid, LPVOID *ppobj)
 33 {
 34     IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
 35 
 36     if (IsEqualGUID(riid, &IID_IUnknown)
 37         || IsEqualGUID(riid, &IID_IDxDiagContainer)) {
 38         IUnknown_AddRef(iface);
 39         *ppobj = This;
 40         return S_OK;
 41     }
 42 
 43     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
 44     return E_NOINTERFACE;
 45 }
 46 
 47 static ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) {
 48     IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
 49     ULONG refCount = InterlockedIncrement(&This->ref);
 50 
 51     TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
 52 
 53     DXDIAGN_LockModule();
 54 
 55     return refCount;
 56 }
 57 
 58 static ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) {
 59     IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
 60     ULONG refCount = InterlockedDecrement(&This->ref);
 61 
 62     TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
 63 
 64     if (!refCount) {
 65         HeapFree(GetProcessHeap(), 0, This);
 66     }
 67 
 68     DXDIAGN_UnlockModule();
 69     
 70     return refCount;
 71 }
 72 
 73 /* IDxDiagContainer Interface follow: */
 74 static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
 75   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
 76   TRACE("(%p)\n", iface);
 77   if (NULL == pdwCount) {
 78     return E_INVALIDARG;
 79   }
 80   *pdwCount = This->nSubContainers;
 81   return S_OK;
 82 }
 83 
 84 static HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) {
 85   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
 86   IDxDiagContainerImpl_SubContainer* p = NULL;
 87   DWORD i = 0;
 88   
 89   TRACE("(%p, %u, %s, %u)\n", iface, dwIndex, debugstr_w(pwszContainer), cchContainer);
 90 
 91   if (NULL == pwszContainer) {
 92     return E_INVALIDARG;
 93   }
 94   if (256 > cchContainer) {
 95     return DXDIAG_E_INSUFFICIENT_BUFFER;
 96   }
 97   
 98   p = This->subContainers;
 99   while (NULL != p) {
100     if (dwIndex == i) {  
101       if (cchContainer <= strlenW(p->contName)) {
102         return DXDIAG_E_INSUFFICIENT_BUFFER;
103       }
104       lstrcpynW(pwszContainer, p->contName, cchContainer);
105       return S_OK;
106     }
107     p = p->next;
108     ++i;
109   }  
110   return E_INVALIDARG;
111 }
112 
113 static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainerInternal(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
114   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
115   IDxDiagContainerImpl_SubContainer* p = NULL;
116 
117   p = This->subContainers;
118   while (NULL != p) {
119     if (0 == lstrcmpW(p->contName, pwszContainer)) {
120       *ppInstance = p->pCont;
121       return S_OK;
122     }
123     p = p->next;
124   }
125   return E_INVALIDARG;
126 }
127 
128 static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
129   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
130   IDxDiagContainer* pContainer = NULL;
131   LPWSTR tmp, orig_tmp;
132   INT tmp_len;
133   WCHAR* cur;
134   HRESULT hr = E_INVALIDARG;
135 
136   FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszContainer), ppInstance);
137 
138   if (NULL == ppInstance || NULL == pwszContainer) {
139     return E_INVALIDARG;
140   }
141 
142   pContainer = (PDXDIAGCONTAINER) This;
143 
144   tmp_len = strlenW(pwszContainer) + 1;
145   orig_tmp = tmp = HeapAlloc(GetProcessHeap(), 0, tmp_len * sizeof(WCHAR));
146   if (NULL == tmp) return E_FAIL;
147   lstrcpynW(tmp, pwszContainer, tmp_len);
148 
149   cur = strchrW(tmp, '.');
150   while (NULL != cur) {
151     *cur = '\0'; /* cut tmp string to '.' */
152     hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer);
153     if (!SUCCEEDED(hr) || NULL == pContainer)
154       goto on_error;
155     cur++; /* go after '.' (just replaced by \0) */
156     tmp = cur;
157     cur = strchrW(tmp, '.');
158   }
159 
160   hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, ppInstance);
161   if (SUCCEEDED(hr)) {
162     IDxDiagContainerImpl_AddRef(*ppInstance);
163   }
164 
165 on_error:
166   HeapFree(GetProcessHeap(), 0, orig_tmp);
167   return hr;
168 }
169 
170 static HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
171   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
172   TRACE("(%p)\n", iface);
173   if (NULL == pdwCount) {
174     return E_INVALIDARG;
175   }
176   *pdwCount = This->nProperties;
177   return S_OK;
178 }
179 
180 static HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) {
181   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
182   IDxDiagContainerImpl_Property* p = NULL;
183   DWORD i = 0;
184   
185   FIXME("(%p, %u, %s, %u)\n", iface, dwIndex, debugstr_w(pwszPropName), cchPropName);
186 
187   if (NULL == pwszPropName) {
188     return E_INVALIDARG;
189   }
190   if (256 > cchPropName) {
191     return DXDIAG_E_INSUFFICIENT_BUFFER;
192   }
193   
194   p = This->properties;
195   while (NULL != p) {
196     if (dwIndex == i) {  
197       if (cchPropName <= lstrlenW(p->vName)) {
198         return DXDIAG_E_INSUFFICIENT_BUFFER;
199       }
200       lstrcpynW(pwszPropName, p->vName, cchPropName);
201       return S_OK;
202     }
203     p = p->next;
204     ++i;
205   }  
206   return E_INVALIDARG;
207 }
208 
209 static HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) {
210   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
211   IDxDiagContainerImpl_Property* p = NULL;
212   FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pvarProp);
213 
214   if (NULL == pvarProp || NULL == pwszPropName) {
215     return E_INVALIDARG;
216   }
217 
218   p = This->properties;
219   while (NULL != p) {
220     if (0 == lstrcmpW(p->vName, pwszPropName)) {      
221       VariantCopy(pvarProp, &p->v);
222       return S_OK;
223     }
224     p = p->next;
225   }
226   return S_OK;
227 }
228 
229 HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp) {
230   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
231   IDxDiagContainerImpl_Property* p = NULL;
232   IDxDiagContainerImpl_Property* pNew = NULL;
233 
234   FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pVarProp);
235 
236   if (NULL == pVarProp || NULL == pwszPropName) {
237     return E_INVALIDARG;
238   }
239 
240   pNew =  HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl_Property));
241   if (NULL == pNew) {
242     return E_OUTOFMEMORY;
243   }
244   VariantInit(&pNew->v);
245   VariantCopy(&pNew->v, pVarProp);
246   pNew->vName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszPropName) + 1) * sizeof(WCHAR));
247   lstrcpyW(pNew->vName, pwszPropName);
248   pNew->next = NULL;
249 
250   p = This->properties;
251   if (NULL == p) {
252     This->properties = pNew;
253   } else {
254     while (NULL != p->next) {
255       p = p->next;
256     }
257     p->next = pNew;
258   }
259   ++This->nProperties;
260   return S_OK;
261 }
262 
263 HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont) {
264   IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
265   IDxDiagContainerImpl_SubContainer* p = NULL;
266   IDxDiagContainerImpl_SubContainer* pNew = NULL;
267 
268   FIXME("(%p, %s, %p)\n", iface, debugstr_w(pszContName), pSubCont);
269 
270   if (NULL == pSubCont || NULL == pszContName) {
271     return E_INVALIDARG;
272   }
273 
274   pNew =  HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl_SubContainer));
275   if (NULL == pNew) {
276     return E_OUTOFMEMORY;
277   }
278   pNew->pCont = pSubCont;
279   pNew->contName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pszContName) + 1) * sizeof(WCHAR));
280   lstrcpyW(pNew->contName, pszContName);
281   pNew->next = NULL;
282 
283   p = This->subContainers;
284   if (NULL == p) {
285     This->subContainers = pNew;
286   } else {
287     while (NULL != p->next) {
288       p = p->next;
289     }
290     p->next = pNew;
291   }
292   ++This->nSubContainers;
293   return S_OK;
294 }
295 
296 static const IDxDiagContainerVtbl DxDiagContainer_Vtbl =
297 {
298     IDxDiagContainerImpl_QueryInterface,
299     IDxDiagContainerImpl_AddRef,
300     IDxDiagContainerImpl_Release,
301     IDxDiagContainerImpl_GetNumberOfChildContainers,
302     IDxDiagContainerImpl_EnumChildContainerNames,
303     IDxDiagContainerImpl_GetChildContainer,
304     IDxDiagContainerImpl_GetNumberOfProps,
305     IDxDiagContainerImpl_EnumPropNames,
306     IDxDiagContainerImpl_GetProp
307 };
308 
309 
310 HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) {
311   IDxDiagContainerImpl* container;
312 
313   TRACE("(%p, %p)\n", debugstr_guid(riid), ppobj);
314   
315   container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl));
316   if (NULL == container) {
317     *ppobj = NULL;
318     return E_OUTOFMEMORY;
319   }
320   container->lpVtbl = &DxDiagContainer_Vtbl;
321   container->ref = 0; /* will be inited with QueryInterface */
322   return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj);
323 }
324 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.