Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/dlls/activeds/dnwithbinary.c
5968 views
1
/*
2
* Copyright 2023 Dmitry Timoshkov
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
#include <stdarg.h>
20
21
#define COBJMACROS
22
23
#include "windef.h"
24
#include "winbase.h"
25
#include "iads.h"
26
#include "adserr.h"
27
28
#include "wine/debug.h"
29
30
WINE_DEFAULT_DEBUG_CHANNEL(activeds);
31
32
typedef struct
33
{
34
IADsDNWithBinary IADsDNWithBinary_iface;
35
LONG ref;
36
BSTR dn;
37
VARIANT bin;
38
} ADsDNWithBinary;
39
40
static inline ADsDNWithBinary *impl_from_IADsDNWithBinary(IADsDNWithBinary *iface)
41
{
42
return CONTAINING_RECORD(iface, ADsDNWithBinary, IADsDNWithBinary_iface);
43
}
44
45
static HRESULT WINAPI dnb_QueryInterface(IADsDNWithBinary *iface, REFIID riid, void **obj)
46
{
47
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
48
49
if (!riid || !obj) return E_INVALIDARG;
50
51
if (IsEqualGUID(riid, &IID_IUnknown) ||
52
IsEqualGUID(riid, &IID_IDispatch) ||
53
IsEqualGUID(riid, &IID_IADsDNWithBinary))
54
{
55
IADsDNWithBinary_AddRef(iface);
56
*obj = iface;
57
return S_OK;
58
}
59
60
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
61
return E_NOINTERFACE;
62
}
63
64
static ULONG WINAPI dnb_AddRef(IADsDNWithBinary *iface)
65
{
66
ADsDNWithBinary *path = impl_from_IADsDNWithBinary(iface);
67
return InterlockedIncrement(&path->ref);
68
}
69
70
static ULONG WINAPI dnb_Release(IADsDNWithBinary *iface)
71
{
72
ADsDNWithBinary *dnb = impl_from_IADsDNWithBinary(iface);
73
LONG ref = InterlockedDecrement(&dnb->ref);
74
75
if (!ref)
76
{
77
TRACE("destroying %p\n", iface);
78
SysFreeString(dnb->dn);
79
VariantClear(&dnb->bin);
80
free(dnb);
81
}
82
83
return ref;
84
}
85
86
static HRESULT WINAPI dnb_GetTypeInfoCount(IADsDNWithBinary *iface, UINT *count)
87
{
88
FIXME("%p,%p: stub\n", iface, count);
89
return E_NOTIMPL;
90
}
91
92
static HRESULT WINAPI dnb_GetTypeInfo(IADsDNWithBinary *iface, UINT index, LCID lcid, ITypeInfo **info)
93
{
94
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
95
return E_NOTIMPL;
96
}
97
98
static HRESULT WINAPI dnb_GetIDsOfNames(IADsDNWithBinary *iface, REFIID riid, LPOLESTR *names,
99
UINT count, LCID lcid, DISPID *dispid)
100
{
101
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
102
return E_NOTIMPL;
103
}
104
105
static HRESULT WINAPI dnb_Invoke(IADsDNWithBinary *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
106
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
107
{
108
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
109
params, result, excepinfo, argerr);
110
return E_NOTIMPL;
111
}
112
113
static HRESULT WINAPI dnb_get_BinaryValue(IADsDNWithBinary *iface, VARIANT *value)
114
{
115
ADsDNWithBinary *dnb = impl_from_IADsDNWithBinary(iface);
116
117
TRACE("%p,%p\n", iface, value);
118
119
VariantInit(value);
120
return VariantCopy(value, &dnb->bin);
121
}
122
123
static HRESULT WINAPI dnb_put_BinaryValue(IADsDNWithBinary *iface, VARIANT value)
124
{
125
ADsDNWithBinary *dnb = impl_from_IADsDNWithBinary(iface);
126
127
TRACE("%p,%s\n", iface, wine_dbgstr_variant(&value));
128
129
VariantClear(&dnb->bin);
130
return VariantCopy(&dnb->bin, &value);
131
}
132
133
static HRESULT WINAPI dnb_get_DNString(IADsDNWithBinary *iface, BSTR *value)
134
{
135
ADsDNWithBinary *dnb = impl_from_IADsDNWithBinary(iface);
136
137
TRACE("%p,%p\n", iface, value);
138
139
*value = SysAllocString(dnb->dn);
140
return *value ? S_OK : E_OUTOFMEMORY;
141
}
142
143
static HRESULT WINAPI dnb_put_DNString(IADsDNWithBinary *iface, BSTR value)
144
{
145
ADsDNWithBinary *dnb = impl_from_IADsDNWithBinary(iface);
146
147
TRACE("%p,%s\n", iface, debugstr_w(value));
148
149
SysFreeString(dnb->dn);
150
dnb->dn = SysAllocString(value);
151
return dnb->dn ? S_OK : E_OUTOFMEMORY;
152
}
153
154
static const IADsDNWithBinaryVtbl IADsDNWithBinary_vtbl =
155
{
156
dnb_QueryInterface,
157
dnb_AddRef,
158
dnb_Release,
159
dnb_GetTypeInfoCount,
160
dnb_GetTypeInfo,
161
dnb_GetIDsOfNames,
162
dnb_Invoke,
163
dnb_get_BinaryValue,
164
dnb_put_BinaryValue,
165
dnb_get_DNString,
166
dnb_put_DNString
167
};
168
169
HRESULT ADsDNWithBinary_create(REFIID riid, void **obj)
170
{
171
ADsDNWithBinary *dnb;
172
HRESULT hr;
173
174
dnb = malloc(sizeof(*dnb));
175
if (!dnb) return E_OUTOFMEMORY;
176
177
dnb->IADsDNWithBinary_iface.lpVtbl = &IADsDNWithBinary_vtbl;
178
dnb->ref = 1;
179
dnb->dn = NULL;
180
VariantInit(&dnb->bin);
181
182
hr = IADsDNWithBinary_QueryInterface(&dnb->IADsDNWithBinary_iface, riid, obj);
183
IADsDNWithBinary_Release(&dnb->IADsDNWithBinary_iface);
184
185
return hr;
186
}
187
188