quartz: Standardize COM aggregation for NullRenderer.
[wine/multimedia.git] / dlls / wldap32 / extended.c
blobb05c3c5f1a5dd2bc5f88d088139a69f1850dccde
1 /*
2 * WLDAP32 - LDAP support for Wine
4 * Copyright 2005 Hans Leidekker
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #ifdef HAVE_LDAP_H
26 #include <ldap.h>
27 #endif
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winnls.h"
33 #include "winldap_private.h"
34 #include "wldap32.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
39 /***********************************************************************
40 * ldap_close_extended_op (WLDAP32.@)
42 * Close an extended operation.
44 * PARAMS
45 * ld [I] Pointer to an LDAP context.
46 * msgid [I] Message ID of the operation to be closed.
48 * RETURNS
49 * Success: LDAP_SUCCESS
50 * Failure: An LDAP error code.
52 * NOTES
53 * Contrary to native, OpenLDAP does not require us to close
54 * extended operations, so this is a no-op.
56 ULONG CDECL ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid )
58 TRACE( "(%p, 0x%08x)\n", ld, msgid );
60 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
61 return WLDAP32_LDAP_SUCCESS;
64 /***********************************************************************
65 * ldap_extended_operationA (WLDAP32.@)
67 * See ldap_extended_operationW.
69 ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
70 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
72 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
73 #ifdef HAVE_LDAP
74 WCHAR *oidW = NULL;
75 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
77 ret = WLDAP32_LDAP_NO_MEMORY;
79 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
80 clientctrls, message );
82 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
84 if (oid) {
85 oidW = strAtoW( oid );
86 if (!oidW) goto exit;
88 if (serverctrls) {
89 serverctrlsW = controlarrayAtoW( serverctrls );
90 if (!serverctrlsW) goto exit;
92 if (clientctrls) {
93 clientctrlsW = controlarrayAtoW( clientctrls );
94 if (!clientctrlsW) goto exit;
97 ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
99 exit:
100 strfreeW( oidW );
101 controlarrayfreeW( serverctrlsW );
102 controlarrayfreeW( clientctrlsW );
104 #endif
105 return ret;
108 /***********************************************************************
109 * ldap_extended_operationW (WLDAP32.@)
111 * Perform an extended operation (asynchronous mode).
113 * PARAMS
114 * ld [I] Pointer to an LDAP context.
115 * oid [I] OID of the extended operation.
116 * data [I] Data needed by the operation.
117 * serverctrls [I] Array of LDAP server controls.
118 * clientctrls [I] Array of LDAP client controls.
119 * message [O] Message ID of the extended operation.
121 * RETURNS
122 * Success: LDAP_SUCCESS
123 * Failure: An LDAP error code.
125 * NOTES
126 * The data parameter should be set to NULL if the operation
127 * requires no data. Call ldap_result with the message ID to
128 * get the result of the operation or ldap_abandon to cancel
129 * the operation. The serverctrls and clientctrls parameters
130 * are optional and should be set to NULL if not used. Call
131 * ldap_close_extended_op to close the operation.
133 ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
134 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
136 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
137 #ifdef HAVE_LDAP
138 char *oidU = NULL;
139 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
141 ret = WLDAP32_LDAP_NO_MEMORY;
143 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
144 clientctrls, message );
146 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
148 if (oid) {
149 oidU = strWtoU( oid );
150 if (!oidU) goto exit;
152 if (serverctrls) {
153 serverctrlsU = controlarrayWtoU( serverctrls );
154 if (!serverctrlsU) goto exit;
156 if (clientctrls) {
157 clientctrlsU = controlarrayWtoU( clientctrls );
158 if (!clientctrlsU) goto exit;
161 ret = map_error( ldap_extended_operation( ld, oid ? oidU : "", (struct berval *)data,
162 serverctrlsU, clientctrlsU, (int *)message ));
164 exit:
165 strfreeU( oidU );
166 controlarrayfreeU( serverctrlsU );
167 controlarrayfreeU( clientctrlsU );
169 #endif
170 return ret;
173 /***********************************************************************
174 * ldap_extended_operation_sA (WLDAP32.@)
176 * See ldap_extended_operation_sW.
178 ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
179 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid,
180 struct WLDAP32_berval **retdata )
182 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
183 #ifdef HAVE_LDAP
184 WCHAR *oidW = NULL, *retoidW = NULL;
185 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
187 ret = WLDAP32_LDAP_NO_MEMORY;
189 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
190 clientctrls, retoid, retdata );
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
194 if (oid) {
195 oidW = strAtoW( oid );
196 if (!oidW) goto exit;
198 if (serverctrls) {
199 serverctrlsW = controlarrayAtoW( serverctrls );
200 if (!serverctrlsW) goto exit;
202 if (clientctrls) {
203 clientctrlsW = controlarrayAtoW( clientctrls );
204 if (!clientctrlsW) goto exit;
207 ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW,
208 &retoidW, retdata );
210 if (retoid && retoidW) {
211 *retoid = strWtoA( retoidW );
212 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
213 ldap_memfreeW( retoidW );
216 exit:
217 strfreeW( oidW );
218 controlarrayfreeW( serverctrlsW );
219 controlarrayfreeW( clientctrlsW );
221 #endif
222 return ret;
225 /***********************************************************************
226 * ldap_extended_operation_sW (WLDAP32.@)
228 * Perform an extended operation (synchronous mode).
230 * PARAMS
231 * ld [I] Pointer to an LDAP context.
232 * oid [I] OID of the extended operation.
233 * data [I] Data needed by the operation.
234 * serverctrls [I] Array of LDAP server controls.
235 * clientctrls [I] Array of LDAP client controls.
236 * retoid [O] OID of the server response message.
237 * retdata [O] Data returned by the server.
239 * RETURNS
240 * Success: LDAP_SUCCESS
241 * Failure: An LDAP error code.
243 * NOTES
244 * The data parameter should be set to NULL if the operation
245 * requires no data. The serverctrls, clientctrls, retoid and
246 * and retdata parameters are also optional. Set to NULL if not
247 * used. Free retoid and retdata after use with ldap_memfree.
249 ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
250 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid,
251 struct WLDAP32_berval **retdata )
253 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
254 #ifdef HAVE_LDAP
255 char *oidU = NULL, *retoidU = NULL;
256 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
258 ret = WLDAP32_LDAP_NO_MEMORY;
260 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
261 clientctrls, retoid, retdata );
263 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
265 if (oid) {
266 oidU = strWtoU( oid );
267 if (!oidU) goto exit;
269 if (serverctrls) {
270 serverctrlsU = controlarrayWtoU( serverctrls );
271 if (!serverctrlsU) goto exit;
273 if (clientctrls) {
274 clientctrlsU = controlarrayWtoU( clientctrls );
275 if (!clientctrlsU) goto exit;
278 ret = map_error( ldap_extended_operation_s( ld, oid ? oidU : "", (struct berval *)data, serverctrlsU,
279 clientctrlsU, &retoidU, (struct berval **)retdata ));
281 if (retoid && retoidU) {
282 *retoid = strUtoW( retoidU );
283 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
284 ldap_memfree( retoidU );
287 exit:
288 strfreeU( oidU );
289 controlarrayfreeU( serverctrlsU );
290 controlarrayfreeU( clientctrlsU );
292 #endif
293 return ret;