Fix MsiRecordSetString for NULL strings and update test case.
[wine.git] / dlls / dxdiagn / container.c
blob0b502eab4fb8bb26dcc4eda95b91fd3a2d83f044
1 /*
2 * IDxDiagContainer Implementation
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "dxdiag_private.h"
24 #include "wine/debug.h"
25 #include "wine/unicode.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
29 /* IDxDiagContainer IUnknown parts follow: */
30 HRESULT WINAPI IDxDiagContainerImpl_QueryInterface(PDXDIAGCONTAINER iface, REFIID riid, LPVOID *ppobj)
32 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
34 if (IsEqualGUID(riid, &IID_IUnknown)
35 || IsEqualGUID(riid, &IID_IDxDiagContainer)) {
36 IDxDiagContainerImpl_AddRef(iface);
37 *ppobj = This;
38 return S_OK;
41 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
42 return E_NOINTERFACE;
45 ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) {
46 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
47 ULONG refCount = InterlockedIncrement(&This->ref);
49 TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
51 return refCount;
54 ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) {
55 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
56 ULONG refCount = InterlockedDecrement(&This->ref);
58 TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);
60 if (!refCount) {
61 HeapFree(GetProcessHeap(), 0, This);
63 return refCount;
66 /* IDxDiagContainer Interface follow: */
67 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfChildContainers(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
68 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
69 TRACE("(%p)\n", iface);
70 if (NULL == pdwCount) {
71 return E_INVALIDARG;
73 *pdwCount = This->nSubContainers;
74 return S_OK;
77 HRESULT WINAPI IDxDiagContainerImpl_EnumChildContainerNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) {
78 IDxDiagContainerImpl_SubContainer* p = NULL;
79 DWORD i = 0;
80 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
82 TRACE("(%p, %lu, %s, %lu)\n", iface, dwIndex, debugstr_w(pwszContainer), cchContainer);
84 if (NULL == pwszContainer) {
85 return E_INVALIDARG;
87 if (256 > cchContainer) {
88 return DXDIAG_E_INSUFFICIENT_BUFFER;
91 p = This->subContainers;
92 while (NULL != p) {
93 if (dwIndex == i) {
94 if (cchContainer <= strlenW(p->contName)) {
95 return DXDIAG_E_INSUFFICIENT_BUFFER;
97 lstrcpynW(pwszContainer, p->contName, cchContainer);
98 return S_OK;
100 p = p->next;
101 ++i;
103 return E_INVALIDARG;
106 HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pwszContainer, IDxDiagContainer** ppInstance) {
107 IDxDiagContainerImpl_SubContainer* p = NULL;
108 IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface;
110 FIXME("(%p, %s, %p)\n", iface, debugstr_w(pwszContainer), ppInstance);
112 if (NULL == ppInstance || NULL == pwszContainer) {
113 return E_INVALIDARG;
116 p = This->subContainers;
117 while (NULL != p) {
118 if (0 == lstrcmpW(p->contName, pwszContainer)) {
119 IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)p, &IID_IDxDiagContainer, (void**) ppInstance);
120 return S_OK;
122 p = p->next;
125 return E_INVALIDARG;
128 HRESULT WINAPI IDxDiagContainerImpl_GetNumberOfProps(PDXDIAGCONTAINER iface, DWORD* pdwCount) {
129 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
130 FIXME("(%p, %p): stub\n", iface, pdwCount);
131 return S_OK;
134 HRESULT WINAPI IDxDiagContainerImpl_EnumPropNames(PDXDIAGCONTAINER iface, DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) {
135 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
136 FIXME("(%p, %lu, %s, %lu): stub\n", iface, dwIndex, debugstr_w(pwszPropName), cchPropName);
137 return S_OK;
140 HRESULT WINAPI IDxDiagContainerImpl_GetProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pvarProp) {
141 /* IDxDiagContainerImpl *This = (IDxDiagContainerImpl *)iface; */
142 FIXME("(%p, %s, %p): stub\n", iface, debugstr_w(pwszPropName), pvarProp);
143 return S_OK;
147 IDxDiagContainerVtbl DxDiagContainer_Vtbl =
149 IDxDiagContainerImpl_QueryInterface,
150 IDxDiagContainerImpl_AddRef,
151 IDxDiagContainerImpl_Release,
152 IDxDiagContainerImpl_GetNumberOfChildContainers,
153 IDxDiagContainerImpl_EnumChildContainerNames,
154 IDxDiagContainerImpl_GetChildContainer,
155 IDxDiagContainerImpl_GetNumberOfProps,
156 IDxDiagContainerImpl_EnumPropNames,
157 IDxDiagContainerImpl_GetProp
161 HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj) {
162 IDxDiagContainerImpl* container;
164 TRACE("(%p, %p)\n", debugstr_guid(riid), ppobj);
166 container = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagContainerImpl));
167 if (NULL == container) {
168 *ppobj = NULL;
169 return E_OUTOFMEMORY;
171 container->lpVtbl = &DxDiagContainer_Vtbl;
172 container->ref = 0; /* will be inited with QueryInterface */
173 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)container, riid, ppobj);