usp10: Update tests in test_ScriptItemIzeShapePlace to match Windows results.
[wine/multimedia.git] / dlls / wldap32 / delete.c
blob6a461cbb1e7fb5bda30ce12d4dbce06bce4b2387
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"
23 #include "wine/port.h"
24 #include "wine/debug.h"
26 #include <stdarg.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #else
35 #define LDAP_NOT_SUPPORTED 0x5c
36 #endif
38 #include "winldap_private.h"
39 #include "wldap32.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
43 /***********************************************************************
44 * ldap_deleteA (WLDAP32.@)
46 * See ldap_deleteW.
48 ULONG ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
50 ULONG ret = LDAP_NOT_SUPPORTED;
51 #ifdef HAVE_LDAP
52 WCHAR *dnW = NULL;
54 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
56 if (!ld) return ~0UL;
58 if (dn) {
59 dnW = strAtoW( dn );
60 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
63 ret = ldap_deleteW( ld, dnW );
64 strfreeW( dnW );
66 #endif
67 return ret;
70 /***********************************************************************
71 * ldap_deleteW (WLDAP32.@)
73 * Delete an entry from a directory tree (asynchronous operation).
75 * PARAMS
76 * ld [I] Pointer to an LDAP context.
77 * dn [I] DN of the entry to delete.
79 * RETURNS
80 * Success: Message ID of the add operation.
81 * Failure: An LDAP error code.
83 * NOTES
84 * Call ldap_result with the message ID to get the result of
85 * the operation. Cancel the operation by calling ldap_abandon
86 * with the message ID.
88 ULONG ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
90 ULONG ret = LDAP_NOT_SUPPORTED;
91 #ifdef HAVE_LDAP
92 char *dnU = NULL;
93 int msg;
95 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
97 if (!ld) return ~0UL;
99 if (dn) {
100 dnU = strWtoU( dn );
101 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
104 ret = ldap_delete_ext( ld, dn ? dnU : "", NULL, NULL, &msg );
106 if (ret == LDAP_SUCCESS)
107 ret = msg;
108 else
109 ret = ~0UL;
111 strfreeU( dnU );
113 #endif
114 return ret;
117 /***********************************************************************
118 * ldap_delete_extA (WLDAP32.@)
120 * See ldap_delete_extW.
122 ULONG ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
123 PLDAPControlA *clientctrls, ULONG *message )
125 ULONG ret = LDAP_NOT_SUPPORTED;
126 #ifdef HAVE_LDAP
127 WCHAR *dnW = NULL;
128 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
130 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
131 clientctrls, message );
133 ret = WLDAP32_LDAP_NO_MEMORY;
135 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
137 if (dn) {
138 dnW = strAtoW( dn );
139 if (!dnW) goto exit;
141 if (serverctrls) {
142 serverctrlsW = controlarrayAtoW( serverctrls );
143 if (!serverctrlsW) goto exit;
145 if (clientctrls) {
146 clientctrlsW = controlarrayAtoW( clientctrls );
147 if (!clientctrlsW) goto exit;
150 ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
152 exit:
153 strfreeW( dnW );
154 controlarrayfreeW( serverctrlsW );
155 controlarrayfreeW( clientctrlsW );
157 #endif
158 return ret;
161 /***********************************************************************
162 * ldap_delete_extW (WLDAP32.@)
164 * Delete an entry from a directory tree (asynchronous operation).
166 * PARAMS
167 * ld [I] Pointer to an LDAP context.
168 * dn [I] DN of the entry to delete.
169 * serverctrls [I] Array of LDAP server controls.
170 * clientctrls [I] Array of LDAP client controls.
171 * message [O] Message ID of the delete operation.
173 * RETURNS
174 * Success: LDAP_SUCCESS
175 * Failure: An LDAP error code.
177 * NOTES
178 * Call ldap_result with the message ID to get the result of
179 * the operation. The serverctrls and clientctrls parameters are
180 * optional and should be set to NULL if not used.
182 ULONG ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
183 PLDAPControlW *clientctrls, ULONG *message )
185 ULONG ret = LDAP_NOT_SUPPORTED;
186 #ifdef HAVE_LDAP
187 char *dnU = NULL;
188 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
189 int dummy;
191 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
192 clientctrls, message );
194 ret = WLDAP32_LDAP_NO_MEMORY;
196 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
198 if (dn) {
199 dnU = strWtoU( dn );
200 if (!dnU) goto exit;
202 if (serverctrls) {
203 serverctrlsU = controlarrayWtoU( serverctrls );
204 if (!serverctrlsU) goto exit;
206 if (clientctrls) {
207 clientctrlsU = controlarrayWtoU( clientctrls );
208 if (!clientctrlsU) goto exit;
211 ret = ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
212 message ? (int *)message : &dummy );
214 exit:
215 strfreeU( dnU );
216 controlarrayfreeU( serverctrlsU );
217 controlarrayfreeU( clientctrlsU );
219 #endif
220 return ret;
223 /***********************************************************************
224 * ldap_delete_ext_sA (WLDAP32.@)
226 * See ldap_delete_ext_sW.
228 ULONG ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
229 PLDAPControlA *clientctrls )
231 ULONG ret = LDAP_NOT_SUPPORTED;
232 #ifdef HAVE_LDAP
233 WCHAR *dnW = NULL;
234 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
236 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
237 clientctrls );
239 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
241 if (dn) {
242 dnW = strAtoW( dn );
243 if (!dnW) goto exit;
245 if (serverctrls) {
246 serverctrlsW = controlarrayAtoW( serverctrls );
247 if (!serverctrlsW) goto exit;
249 if (clientctrls) {
250 clientctrlsW = controlarrayAtoW( clientctrls );
251 if (!clientctrlsW) goto exit;
254 ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
256 exit:
257 strfreeW( dnW );
258 controlarrayfreeW( serverctrlsW );
259 controlarrayfreeW( clientctrlsW );
261 #endif
262 return ret;
265 /***********************************************************************
266 * ldap_delete_ext_sW (WLDAP32.@)
268 * Delete an entry from a directory tree (synchronous operation).
270 * PARAMS
271 * ld [I] Pointer to an LDAP context.
272 * dn [I] DN of the entry to delete.
273 * serverctrls [I] Array of LDAP server controls.
274 * clientctrls [I] Array of LDAP client controls.
276 * RETURNS
277 * Success: LDAP_SUCCESS
278 * Failure: An LDAP error code.
280 * NOTES
281 * The serverctrls and clientctrls parameters are optional and
282 * should be set to NULL if not used.
284 ULONG ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
285 PLDAPControlW *clientctrls )
287 ULONG ret = LDAP_NOT_SUPPORTED;
288 #ifdef HAVE_LDAP
289 char *dnU = NULL;
290 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
292 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
293 clientctrls );
295 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
297 if (dn) {
298 dnU = strWtoU( dn );
299 if (!dnU) goto exit;
301 if (serverctrls) {
302 serverctrlsU = controlarrayWtoU( serverctrls );
303 if (!serverctrlsU) goto exit;
305 if (clientctrls) {
306 clientctrlsU = controlarrayWtoU( clientctrls );
307 if (!clientctrlsU) goto exit;
310 ret = ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU );
312 exit:
313 strfreeU( dnU );
314 controlarrayfreeU( serverctrlsU );
315 controlarrayfreeU( clientctrlsU );
317 #endif
318 return ret;
321 /***********************************************************************
322 * ldap_delete_sA (WLDAP32.@)
324 * See ldap_delete_sW.
326 ULONG ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
328 ULONG ret = LDAP_NOT_SUPPORTED;
329 #ifdef HAVE_LDAP
330 WCHAR *dnW = NULL;
332 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
334 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
336 if (dn) {
337 dnW = strAtoW( dn );
338 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
341 ret = ldap_delete_sW( ld, dnW );
342 strfreeW( dnW );
344 #endif
345 return ret;
348 /***********************************************************************
349 * ldap_delete_sW (WLDAP32.@)
351 * Delete an entry from a directory tree (synchronous operation).
353 * PARAMS
354 * ld [I] Pointer to an LDAP context.
355 * dn [I] DN of the entry to delete.
357 * RETURNS
358 * Success: LDAP_SUCCESS
359 * Failure: An LDAP error code.
361 ULONG ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
363 ULONG ret = LDAP_NOT_SUPPORTED;
364 #ifdef HAVE_LDAP
365 char *dnU = NULL;
367 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
369 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
371 if (dn) {
372 dnU = strWtoU( dn );
373 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
376 ret = ldap_delete_ext_s( ld, dn ? dnU : "", NULL, NULL );
377 strfreeU( dnU );
379 #endif
380 return ret;