gdi32: Change an ERR to a WARN for fonts with too-long names.
[wine/multimedia.git] / dlls / wldap32 / delete.c
blob47e1cb4f2cb271b33bd211a0d0bbd0d4f3f137fd
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_deleteA (WLDAP32.@)
42 * See ldap_deleteW.
44 ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
46 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
47 #ifdef HAVE_LDAP
48 WCHAR *dnW = NULL;
50 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
52 if (!ld) return ~0u;
54 if (dn) {
55 dnW = strAtoW( dn );
56 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
59 ret = ldap_deleteW( ld, dnW );
60 strfreeW( dnW );
62 #endif
63 return ret;
66 /***********************************************************************
67 * ldap_deleteW (WLDAP32.@)
69 * Delete an entry from a directory tree (asynchronous operation).
71 * PARAMS
72 * ld [I] Pointer to an LDAP context.
73 * dn [I] DN of the entry to delete.
75 * RETURNS
76 * Success: Message ID of the add operation.
77 * Failure: An LDAP error code.
79 * NOTES
80 * Call ldap_result with the message ID to get the result of
81 * the operation. Cancel the operation by calling ldap_abandon
82 * with the message ID.
84 ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
86 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
87 #ifdef HAVE_LDAP
88 char *dnU = NULL;
89 int msg;
91 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
93 if (!ld) return ~0u;
95 if (dn) {
96 dnU = strWtoU( dn );
97 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
100 ret = ldap_delete_ext( ld, dn ? dnU : "", NULL, NULL, &msg );
102 if (ret == LDAP_SUCCESS)
103 ret = msg;
104 else
105 ret = ~0u;
107 strfreeU( dnU );
109 #endif
110 return ret;
113 /***********************************************************************
114 * ldap_delete_extA (WLDAP32.@)
116 * See ldap_delete_extW.
118 ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
119 PLDAPControlA *clientctrls, ULONG *message )
121 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
122 #ifdef HAVE_LDAP
123 WCHAR *dnW = NULL;
124 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
126 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
127 clientctrls, message );
129 ret = WLDAP32_LDAP_NO_MEMORY;
131 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
133 if (dn) {
134 dnW = strAtoW( dn );
135 if (!dnW) goto exit;
137 if (serverctrls) {
138 serverctrlsW = controlarrayAtoW( serverctrls );
139 if (!serverctrlsW) goto exit;
141 if (clientctrls) {
142 clientctrlsW = controlarrayAtoW( clientctrls );
143 if (!clientctrlsW) goto exit;
146 ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
148 exit:
149 strfreeW( dnW );
150 controlarrayfreeW( serverctrlsW );
151 controlarrayfreeW( clientctrlsW );
153 #endif
154 return ret;
157 /***********************************************************************
158 * ldap_delete_extW (WLDAP32.@)
160 * Delete an entry from a directory tree (asynchronous operation).
162 * PARAMS
163 * ld [I] Pointer to an LDAP context.
164 * dn [I] DN of the entry to delete.
165 * serverctrls [I] Array of LDAP server controls.
166 * clientctrls [I] Array of LDAP client controls.
167 * message [O] Message ID of the delete operation.
169 * RETURNS
170 * Success: LDAP_SUCCESS
171 * Failure: An LDAP error code.
173 * NOTES
174 * Call ldap_result with the message ID to get the result of
175 * the operation. The serverctrls and clientctrls parameters are
176 * optional and should be set to NULL if not used.
178 ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
179 PLDAPControlW *clientctrls, ULONG *message )
181 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
182 #ifdef HAVE_LDAP
183 char *dnU = NULL;
184 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
185 int dummy;
187 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
188 clientctrls, message );
190 ret = WLDAP32_LDAP_NO_MEMORY;
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
194 if (dn) {
195 dnU = strWtoU( dn );
196 if (!dnU) goto exit;
198 if (serverctrls) {
199 serverctrlsU = controlarrayWtoU( serverctrls );
200 if (!serverctrlsU) goto exit;
202 if (clientctrls) {
203 clientctrlsU = controlarrayWtoU( clientctrls );
204 if (!clientctrlsU) goto exit;
207 ret = map_error( ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
208 message ? (int *)message : &dummy ));
210 exit:
211 strfreeU( dnU );
212 controlarrayfreeU( serverctrlsU );
213 controlarrayfreeU( clientctrlsU );
215 #endif
216 return ret;
219 /***********************************************************************
220 * ldap_delete_ext_sA (WLDAP32.@)
222 * See ldap_delete_ext_sW.
224 ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
225 PLDAPControlA *clientctrls )
227 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
228 #ifdef HAVE_LDAP
229 WCHAR *dnW = NULL;
230 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
232 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
233 clientctrls );
235 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
237 if (dn) {
238 dnW = strAtoW( dn );
239 if (!dnW) goto exit;
241 if (serverctrls) {
242 serverctrlsW = controlarrayAtoW( serverctrls );
243 if (!serverctrlsW) goto exit;
245 if (clientctrls) {
246 clientctrlsW = controlarrayAtoW( clientctrls );
247 if (!clientctrlsW) goto exit;
250 ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
252 exit:
253 strfreeW( dnW );
254 controlarrayfreeW( serverctrlsW );
255 controlarrayfreeW( clientctrlsW );
257 #endif
258 return ret;
261 /***********************************************************************
262 * ldap_delete_ext_sW (WLDAP32.@)
264 * Delete an entry from a directory tree (synchronous operation).
266 * PARAMS
267 * ld [I] Pointer to an LDAP context.
268 * dn [I] DN of the entry to delete.
269 * serverctrls [I] Array of LDAP server controls.
270 * clientctrls [I] Array of LDAP client controls.
272 * RETURNS
273 * Success: LDAP_SUCCESS
274 * Failure: An LDAP error code.
276 * NOTES
277 * The serverctrls and clientctrls parameters are optional and
278 * should be set to NULL if not used.
280 ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
281 PLDAPControlW *clientctrls )
283 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
284 #ifdef HAVE_LDAP
285 char *dnU = NULL;
286 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
288 TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
289 clientctrls );
291 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
293 if (dn) {
294 dnU = strWtoU( dn );
295 if (!dnU) goto exit;
297 if (serverctrls) {
298 serverctrlsU = controlarrayWtoU( serverctrls );
299 if (!serverctrlsU) goto exit;
301 if (clientctrls) {
302 clientctrlsU = controlarrayWtoU( clientctrls );
303 if (!clientctrlsU) goto exit;
306 ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
308 exit:
309 strfreeU( dnU );
310 controlarrayfreeU( serverctrlsU );
311 controlarrayfreeU( clientctrlsU );
313 #endif
314 return ret;
317 /***********************************************************************
318 * ldap_delete_sA (WLDAP32.@)
320 * See ldap_delete_sW.
322 ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
324 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
325 #ifdef HAVE_LDAP
326 WCHAR *dnW = NULL;
328 TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
330 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
332 if (dn) {
333 dnW = strAtoW( dn );
334 if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
337 ret = ldap_delete_sW( ld, dnW );
338 strfreeW( dnW );
340 #endif
341 return ret;
344 /***********************************************************************
345 * ldap_delete_sW (WLDAP32.@)
347 * Delete an entry from a directory tree (synchronous operation).
349 * PARAMS
350 * ld [I] Pointer to an LDAP context.
351 * dn [I] DN of the entry to delete.
353 * RETURNS
354 * Success: LDAP_SUCCESS
355 * Failure: An LDAP error code.
357 ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
359 ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
360 #ifdef HAVE_LDAP
361 char *dnU = NULL;
363 TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
365 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
367 if (dn) {
368 dnU = strWtoU( dn );
369 if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
372 ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", NULL, NULL ));
373 strfreeU( dnU );
375 #endif
376 return ret;