ws2_32: Use assignment instead of memcpy to copy structs.
[wine] / dlls / wbemprox / qualifier.c
1 /*
2  * Copyright 2013 Hans Leidekker for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #define COBJMACROS
20
21 #include "config.h"
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "objbase.h"
27 #include "wbemcli.h"
28
29 #include "wine/debug.h"
30 #include "wbemprox_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(wbemprox);
33
34 struct qualifier_set
35 {
36     IWbemQualifierSet IWbemQualifierSet_iface;
37     LONG refs;
38 };
39
40 static inline struct qualifier_set *impl_from_IWbemQualifierSet(
41     IWbemQualifierSet *iface )
42 {
43     return CONTAINING_RECORD(iface, struct qualifier_set, IWbemQualifierSet_iface);
44 }
45
46 static ULONG WINAPI qualifier_set_AddRef(
47     IWbemQualifierSet *iface )
48 {
49     struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
50     return InterlockedIncrement( &set->refs );
51 }
52
53 static ULONG WINAPI qualifier_set_Release(
54     IWbemQualifierSet *iface )
55 {
56     struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
57     LONG refs = InterlockedDecrement( &set->refs );
58     if (!refs)
59     {
60         TRACE("destroying %p\n", set);
61         heap_free( set );
62     }
63     return refs;
64 }
65
66 static HRESULT WINAPI qualifier_set_QueryInterface(
67     IWbemQualifierSet *iface,
68     REFIID riid,
69     void **ppvObject )
70 {
71     struct qualifier_set *set = impl_from_IWbemQualifierSet( iface );
72
73     TRACE("%p, %s, %p\n", set, debugstr_guid( riid ), ppvObject );
74
75     if ( IsEqualGUID( riid, &IID_IWbemQualifierSet ) ||
76          IsEqualGUID( riid, &IID_IUnknown ) )
77     {
78         *ppvObject = set;
79     }
80     else
81     {
82         FIXME("interface %s not implemented\n", debugstr_guid(riid));
83         return E_NOINTERFACE;
84     }
85     IWbemQualifierSet_AddRef( iface );
86     return S_OK;
87 }
88
89 static HRESULT WINAPI qualifier_set_Get(
90     IWbemQualifierSet *iface,
91     LPCWSTR wszName,
92     LONG lFlags,
93     VARIANT *pVal,
94     LONG *plFlavor )
95 {
96     FIXME("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, plFlavor);
97     return E_NOTIMPL;
98 }
99
100 static HRESULT WINAPI qualifier_set_Put(
101     IWbemQualifierSet *iface,
102     LPCWSTR wszName,
103     VARIANT *pVal,
104     LONG lFlavor )
105 {
106     FIXME("%p, %s, %p, %d\n", iface, debugstr_w(wszName), pVal, lFlavor);
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI qualifier_set_Delete(
111     IWbemQualifierSet *iface,
112     LPCWSTR wszName )
113 {
114     FIXME("%p, %s\n", iface, debugstr_w(wszName));
115     return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI qualifier_set_GetNames(
119     IWbemQualifierSet *iface,
120     LONG lFlags,
121     SAFEARRAY **pNames )
122 {
123     FIXME("%p, %08x, %p\n", iface, lFlags, pNames);
124     return E_NOTIMPL;
125 }
126
127 static HRESULT WINAPI qualifier_set_BeginEnumeration(
128     IWbemQualifierSet *iface,
129     LONG lFlags )
130 {
131     FIXME("%p, %08x\n", iface, lFlags);
132     return E_NOTIMPL;
133 }
134
135 static HRESULT WINAPI qualifier_set_Next(
136     IWbemQualifierSet *iface,
137     LONG lFlags,
138     BSTR *pstrName,
139     VARIANT *pVal,
140     LONG *plFlavor )
141 {
142     FIXME("%p, %08x, %p, %p, %p\n", iface, lFlags, pstrName, pVal, plFlavor);
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI qualifier_set_EndEnumeration(
147     IWbemQualifierSet *iface )
148 {
149     FIXME("%p\n", iface);
150     return E_NOTIMPL;
151 }
152
153 static const IWbemQualifierSetVtbl qualifier_set_vtbl =
154 {
155     qualifier_set_QueryInterface,
156     qualifier_set_AddRef,
157     qualifier_set_Release,
158     qualifier_set_Get,
159     qualifier_set_Put,
160     qualifier_set_Delete,
161     qualifier_set_GetNames,
162     qualifier_set_BeginEnumeration,
163     qualifier_set_Next,
164     qualifier_set_EndEnumeration
165 };
166
167 HRESULT WbemQualifierSet_create(
168     IUnknown *pUnkOuter, LPVOID *ppObj )
169 {
170     struct qualifier_set *set;
171
172     TRACE("%p, %p\n", pUnkOuter, ppObj);
173
174     if (!(set = heap_alloc( sizeof(*set) ))) return E_OUTOFMEMORY;
175
176     set->IWbemQualifierSet_iface.lpVtbl = &qualifier_set_vtbl;
177     set->refs = 1;
178
179     *ppObj = &set->IWbemQualifierSet_iface;
180
181     TRACE("returning iface %p\n", *ppObj);
182     return S_OK;
183 }