Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencontainer.c
Go to the documentation of this file.
00001 /* 00002 * IDxDiagContainer Implementation 00003 * 00004 * Copyright 2004 Raphael Junqueira 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #include "config.h" 00023 #include "dxdiag_private.h" 00024 #include "wine/debug.h" 00025 #include "wine/unicode.h" 00026 00027 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag); 00028 00029 /* IDxDiagContainer IUnknown parts follow: */ 00030 HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFIID riid, LPVOID *ppobj) 00031 { 00032 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00033 00034 if (IsEqualGUID(riid, &IID_IUnknown) 00035 || IsEqualGUID(riid, &IID_IDxDiagContainer)) { 00036 IDxDiagContainerImpl_AddRef(iface); 00037 *ppobj = This; 00038 return S_OK; 00039 } 00040 00041 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj); 00042 return E_NOINTERFACE; 00043 } 00044 00045 ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) { 00046 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00047 ULONG refCount = InterlockedIncrement(&This->ref); 00048 00049 TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); 00050 00051 DXDIAGN_LockModule(); 00052 00053 return refCount; 00054 } 00055 00056 ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) { 00057 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00058 ULONG refCount = InterlockedDecrement(&This->ref); 00059 00060 TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1); 00061 00062 if (!refCount) { 00063 HeapFree(GetProcessHeap(), 0, This); 00064 } 00065 00066 DXDIAGN_UnlockModule(); 00067 00068 return refCount; 00069 } 00070 00071 /* IDxDiagContainer Interface follow: */ 00072 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCONTAINER iface, DWORD* pdwCount) { 00073 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00074 TRACE("(%p)\n", iface); 00075 if (NULL == pdwCount) { 00076 return E_INVALIDARG; 00077 } 00078 *pdwCount = This->nSubContainers; 00079 return S_OK; 00080 } 00081 00082 HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) { 00083 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00084 IDxDiagContainerImpl_SubContainer* p = NULL; 00085 DWORD i = 0; 00086 00087 TRACE("(%p, %lu, %s, %lu)\n", iface, dwIndex, debugstr_w(pwszContainer), cchContainer); 00088 00089 if (NULL == pwszContainer) { 00090 return E_INVALIDARG; 00091 } 00092 if (256 > cchContainer) { 00093 return DXDIAG_E_INSUFFICIENT_BUFFER; 00094 } 00095 00096 p = This->subContainers; 00097 while (NULL != p) { 00098 if (dwIndex == i) { 00099 if (cchContainer <= strlenW(p->contName)) { 00100 return DXDIAG_E_INSUFFICIENT_BUFFER; 00101 } 00102 lstrcpynW(pwszContainer, p->contName, cchContainer); 00103 return S_OK; 00104 } 00105 p = p->next; 00106 ++i; 00107 } 00108 return E_INVALIDARG; 00109 } 00110 00111 HRESULT WINAPI IDxDiagContainerImpl_GetChildContainerInternal(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) { 00112 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00113 IDxDiagContainerImpl_SubContainer* p = NULL; 00114 00115 p = This->subContainers; 00116 while (NULL != p) { 00117 if (0 == lstrcmpW(p->contName, pwszContainer)) { 00118 *ppInstance = (PDXDIAGCONTAINER)p->pCont; 00119 return S_OK; 00120 } 00121 p = p->next; 00122 } 00123 return E_INVALIDARG; 00124 } 00125 00126 HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) { 00127 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00128 IDxDiagContainer* pContainer = NULL; 00129 LPWSTR tmp, orig_tmp; 00130 INT tmp_len; 00131 WCHAR* cur; 00132 HRESULT hr = E_INVALIDARG; 00133 00134 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszContainer), ppInstance); 00135 00136 if (NULL == ppInstance || NULL == pwszContainer) { 00137 return E_INVALIDARG; 00138 } 00139 00140 pContainer = (PDXDIAGCONTAINER) This; 00141 00142 tmp_len = strlenW(pwszContainer) + 1; 00143 orig_tmp = tmp = HeapAlloc(GetProcessHeap(), 0, tmp_len * sizeof(WCHAR)); 00144 if (NULL == tmp) return E_FAIL; 00145 lstrcpynW(tmp, pwszContainer, tmp_len); 00146 00147 cur = strchrW(tmp, '.'); 00148 while (NULL != cur) { 00149 *cur = '\0'; /* cut tmp string to '.' */ 00150 hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer); 00151 if (!SUCCEEDED(hr) || NULL == pContainer) 00152 goto on_error; 00153 cur++; /* go after '.' (just replaced by \0) */ 00154 tmp = cur; 00155 cur = strchrW(tmp, '.'); 00156 } 00157 00158 hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, ppInstance); 00159 if (SUCCEEDED(hr)) { 00160 IDxDiagContainerImpl_AddRef((PDXDIAGCONTAINER)*ppInstance); 00161 } 00162 00163 on_error: 00164 HeapFree(GetProcessHeap(), 0, orig_tmp); 00165 return hr; 00166 } 00167 00168 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER iface, DWORD* pdwCount) { 00169 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00170 TRACE("(%p)\n", iface); 00171 if (NULL == pdwCount) { 00172 return E_INVALIDARG; 00173 } 00174 *pdwCount = This->nProperties; 00175 return S_OK; 00176 } 00177 00178 HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) { 00179 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00180 IDxDiagContainerImpl_Property* p = NULL; 00181 DWORD i = 0; 00182 00183 FIXME("(%p, %lu, %s, %lu)\n", iface, dwIndex, debugstr_w(pwszPropName), cchPropName); 00184 00185 if (NULL == pwszPropName) { 00186 return E_INVALIDARG; 00187 } 00188 if (256 > cchPropName) { 00189 return DXDIAG_E_INSUFFICIENT_BUFFER; 00190 } 00191 00192 p = This->properties; 00193 while (NULL != p) { 00194 if (dwIndex == i) { 00195 if (cchPropName <= lstrlenW(p->vName)) { 00196 return DXDIAG_E_INSUFFICIENT_BUFFER; 00197 } 00198 lstrcpynW(pwszPropName, p->vName, cchPropName); 00199 return S_OK; 00200 } 00201 p = p->next; 00202 ++i; 00203 } 00204 return E_INVALIDARG; 00205 } 00206 00207 HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) { 00208 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00209 IDxDiagContainerImpl_Property* p = NULL; 00210 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pvarProp); 00211 00212 if (NULL == pvarProp || NULL == pwszPropName) { 00213 return E_INVALIDARG; 00214 } 00215 00216 p = This->properties; 00217 while (NULL != p) { 00218 if (0 == lstrcmpW(p->vName, pwszPropName)) { 00219 VariantCopy(pvarProp, &p->v); 00220 return S_OK; 00221 } 00222 p = p->next; 00223 } 00224 return S_OK; 00225 } 00226 00227 HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp) { 00228 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00229 IDxDiagContainerImpl_Property* p = NULL; 00230 IDxDiagContainerImpl_Property* pNew = NULL; 00231 00232 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszPropName), pVarProp); 00233 00234 if (NULL == pVarProp || NULL == pwszPropName) { 00235 return E_INVALIDARG; 00236 } 00237 00238 pNew = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl_Property)); 00239 if (NULL == pNew) { 00240 return E_OUTOFMEMORY; 00241 } 00242 VariantInit(&pNew->v); 00243 VariantCopy(&pNew->v, pVarProp); 00244 pNew->vName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszPropName) + 1) * sizeof(WCHAR)); 00245 lstrcpyW(pNew->vName, pwszPropName); 00246 pNew->next = NULL; 00247 00248 p = This->properties; 00249 if (NULL == p) { 00250 This->properties = pNew; 00251 } else { 00252 while (NULL != p->next) { 00253 p = p->next; 00254 } 00255 p->next = pNew; 00256 } 00257 ++This->nProperties; 00258 return S_OK; 00259 } 00260 00261 HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont) { 00262 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; 00263 IDxDiagContainerImpl_SubContainer* p = NULL; 00264 IDxDiagContainerImpl_SubContainer* pNew = NULL; 00265 00266 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pszContName), pSubCont); 00267 00268 if (NULL == pSubCont || NULL == pszContName) { 00269 return E_INVALIDARG; 00270 } 00271 00272 pNew = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl_SubContainer)); 00273 if (NULL == pNew) { 00274 return E_OUTOFMEMORY; 00275 } 00276 pNew->pCont = pSubCont; 00277 pNew->contName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pszContName) + 1) * sizeof(WCHAR)); 00278 lstrcpyW(pNew->contName, pszContName); 00279 pNew->next = NULL; 00280 00281 p = This->subContainers; 00282 if (NULL == p) { 00283 This->subContainers = pNew; 00284 } else { 00285 while (NULL != p->next) { 00286 p = p->next; 00287 } 00288 p->next = pNew; 00289 } 00290 ++This->nSubContainers; 00291 return S_OK; 00292 } 00293 00294 static const IDxDiagContainerVtbl DxDiagContainer_Vtbl = 00295 { 00296 IDxDiagContainerImpl_QueryInterface, 00297 IDxDiagContainerImpl_AddRef, 00298 IDxDiagContainerImpl_Release, 00299 IDxDiagContainerImpl_GetNumberOfChildContainers, 00300 IDxDiagContainerImpl_EnumChildContainerNames, 00301 IDxDiagContainerImpl_GetChildContainer, 00302 IDxDiagContainerImpl_GetNumberOfProps, 00303 IDxDiagContainerImpl_EnumPropNames, 00304 IDxDiagContainerImpl_GetProp 00305 }; 00306 00307 00308 HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) { 00309 IDxDiagContainerImpl* container; 00310 00311 TRACE("(%p, %p)\n", debugstr_guid(riid), ppobj); 00312 00313 container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl)); 00314 if (NULL == container) { 00315 *ppobj = NULL; 00316 return E_OUTOFMEMORY; 00317 } 00318 container->lpVtbl = &DxDiagContainer_Vtbl; 00319 container->ref = 0; /* will be inited with QueryInterface */ 00320 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj); 00321 } Generated on Mon May 28 2012 04:21:19 for ReactOS by
1.7.6.1
|