winecoreaudio: Remove some unused structure fields.
[wine] / dlls / wldap32 / delete.c
1 /*
2  * WLDAP32 - LDAP support for Wine
3  *
4  * Copyright 2005 Hans Leidekker
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include "wine/port.h"
24 #include "wine/debug.h"
25
26 #include <stdarg.h>
27
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
31
32 #ifdef HAVE_LDAP_H
33 #include <ldap.h>
34 #endif
35
36 #include "winldap_private.h"
37 #include "wldap32.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
40
41 /***********************************************************************
42  *      ldap_deleteA     (WLDAP32.@)
43  *
44  * See ldap_deleteW.
45  */
46 ULONG CDECL ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
47 {
48     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
49 #ifdef HAVE_LDAP
50     WCHAR *dnW = NULL;
51
52     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
53
54     if (!ld) return ~0u;
55
56     if (dn) {
57         dnW = strAtoW( dn );
58         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
59     }
60
61     ret = ldap_deleteW( ld, dnW );
62     strfreeW( dnW );
63
64 #endif
65     return ret;
66 }
67
68 /***********************************************************************
69  *      ldap_deleteW     (WLDAP32.@)
70  *
71  * Delete an entry from a directory tree (asynchronous operation).
72  *
73  * PARAMS
74  *  ld      [I] Pointer to an LDAP context.
75  *  dn      [I] DN of the entry to delete.
76  *
77  * RETURNS
78  *  Success: Message ID of the add operation.
79  *  Failure: An LDAP error code.
80  *
81  * NOTES
82  *  Call ldap_result with the message ID to get the result of
83  *  the operation. Cancel the operation by calling ldap_abandon
84  *  with the message ID.
85  */
86 ULONG CDECL ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
87 {
88     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
89 #ifdef HAVE_LDAP
90     char *dnU = NULL;
91     int msg;
92
93     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
94
95     if (!ld) return ~0u;
96
97     if (dn) {
98         dnU = strWtoU( dn );
99         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
100     }
101
102     ret = ldap_delete_ext( ld, dn ? dnU : "", NULL, NULL, &msg );
103
104     if (ret == LDAP_SUCCESS)
105         ret = msg;
106     else
107         ret = ~0u;
108
109     strfreeU( dnU );
110
111 #endif
112     return ret;
113 }
114
115 /***********************************************************************
116  *      ldap_delete_extA     (WLDAP32.@)
117  *
118  * See ldap_delete_extW.
119  */
120 ULONG CDECL ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
121     PLDAPControlA *clientctrls, ULONG *message )
122 {
123     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
124 #ifdef HAVE_LDAP
125     WCHAR *dnW = NULL;
126     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
127
128     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
129            clientctrls, message );
130
131     ret = WLDAP32_LDAP_NO_MEMORY;
132
133     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
134
135     if (dn) {
136         dnW = strAtoW( dn );
137         if (!dnW) goto exit;
138     }
139     if (serverctrls) {
140         serverctrlsW = controlarrayAtoW( serverctrls );
141         if (!serverctrlsW) goto exit;
142     }
143     if (clientctrls) {
144         clientctrlsW = controlarrayAtoW( clientctrls );
145         if (!clientctrlsW) goto exit;
146     }
147
148     ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
149
150 exit:
151     strfreeW( dnW );
152     controlarrayfreeW( serverctrlsW );
153     controlarrayfreeW( clientctrlsW );
154
155 #endif
156     return ret;
157 }
158
159 /***********************************************************************
160  *      ldap_delete_extW     (WLDAP32.@)
161  *
162  * Delete an entry from a directory tree (asynchronous operation).
163  *
164  * PARAMS
165  *  ld          [I] Pointer to an LDAP context.
166  *  dn          [I] DN of the entry to delete.
167  *  serverctrls [I] Array of LDAP server controls.
168  *  clientctrls [I] Array of LDAP client controls.
169  *  message     [O] Message ID of the delete operation.
170  *
171  * RETURNS
172  *  Success: LDAP_SUCCESS
173  *  Failure: An LDAP error code.
174  *
175  * NOTES
176  *  Call ldap_result with the message ID to get the result of
177  *  the operation. The serverctrls and clientctrls parameters are
178  *  optional and should be set to NULL if not used.
179  */
180 ULONG CDECL ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
181     PLDAPControlW *clientctrls, ULONG *message )
182 {
183     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
184 #ifdef HAVE_LDAP
185     char *dnU = NULL;
186     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
187     int dummy;
188
189     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
190            clientctrls, message );
191
192     ret = WLDAP32_LDAP_NO_MEMORY;
193
194     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
195
196     if (dn) {
197         dnU = strWtoU( dn );
198         if (!dnU) goto exit;
199     }
200     if (serverctrls) {
201         serverctrlsU = controlarrayWtoU( serverctrls );
202         if (!serverctrlsU) goto exit;
203     }
204     if (clientctrls) {
205         clientctrlsU = controlarrayWtoU( clientctrls );
206         if (!clientctrlsU) goto exit;
207     }
208
209     ret = map_error( ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
210                                       message ? (int *)message : &dummy ));
211
212 exit:
213     strfreeU( dnU );
214     controlarrayfreeU( serverctrlsU );
215     controlarrayfreeU( clientctrlsU );
216
217 #endif
218     return ret;
219 }
220
221 /***********************************************************************
222  *      ldap_delete_ext_sA     (WLDAP32.@)
223  *
224  * See ldap_delete_ext_sW.
225  */
226 ULONG CDECL ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
227     PLDAPControlA *clientctrls )
228 {
229     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
230 #ifdef HAVE_LDAP
231     WCHAR *dnW = NULL;
232     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
233
234     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
235            clientctrls );
236
237     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
238
239     if (dn) {
240         dnW = strAtoW( dn );
241         if (!dnW) goto exit;
242     }
243     if (serverctrls) {
244         serverctrlsW = controlarrayAtoW( serverctrls );
245         if (!serverctrlsW) goto exit;
246     }
247     if (clientctrls) {
248         clientctrlsW = controlarrayAtoW( clientctrls );
249         if (!clientctrlsW) goto exit;
250     }
251
252     ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
253
254 exit:
255     strfreeW( dnW );
256     controlarrayfreeW( serverctrlsW );
257     controlarrayfreeW( clientctrlsW );
258
259 #endif
260     return ret;
261 }
262
263 /***********************************************************************
264  *      ldap_delete_ext_sW     (WLDAP32.@)
265  *
266  * Delete an entry from a directory tree (synchronous operation).
267  *
268  * PARAMS
269  *  ld          [I] Pointer to an LDAP context.
270  *  dn          [I] DN of the entry to delete.
271  *  serverctrls [I] Array of LDAP server controls.
272  *  clientctrls [I] Array of LDAP client controls.
273  *
274  * RETURNS
275  *  Success: LDAP_SUCCESS
276  *  Failure: An LDAP error code.
277  *
278  * NOTES
279  *  The serverctrls and clientctrls parameters are optional and
280  *  should be set to NULL if not used.
281  */
282 ULONG CDECL ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
283     PLDAPControlW *clientctrls )
284 {
285     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
286 #ifdef HAVE_LDAP
287     char *dnU = NULL;
288     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
289
290     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
291            clientctrls );
292
293     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
294
295     if (dn) {
296         dnU = strWtoU( dn );
297         if (!dnU) goto exit;
298     }
299     if (serverctrls) {
300         serverctrlsU = controlarrayWtoU( serverctrls );
301         if (!serverctrlsU) goto exit;
302     }
303     if (clientctrls) {
304         clientctrlsU = controlarrayWtoU( clientctrls );
305         if (!clientctrlsU) goto exit;
306     }
307
308     ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU ));
309
310 exit:
311     strfreeU( dnU );
312     controlarrayfreeU( serverctrlsU );
313     controlarrayfreeU( clientctrlsU );
314
315 #endif
316     return ret;
317 }
318  
319 /***********************************************************************
320  *      ldap_delete_sA     (WLDAP32.@)
321  *
322  * See ldap_delete_sW.
323  */
324 ULONG CDECL ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
325 {
326     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
327 #ifdef HAVE_LDAP
328     WCHAR *dnW = NULL;
329
330     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
331
332     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
333
334     if (dn) {
335         dnW = strAtoW( dn );
336         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
337     }
338
339     ret = ldap_delete_sW( ld, dnW );
340     strfreeW( dnW );
341
342 #endif
343     return ret;
344 }
345
346 /***********************************************************************
347  *      ldap_delete_sW     (WLDAP32.@)
348  *
349  * Delete an entry from a directory tree (synchronous operation).
350  *
351  * PARAMS
352  *  ld      [I] Pointer to an LDAP context.
353  *  dn      [I] DN of the entry to delete.
354  *
355  * RETURNS
356  *  Success: LDAP_SUCCESS
357  *  Failure: An LDAP error code.
358  */
359 ULONG CDECL ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
360 {
361     ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
362 #ifdef HAVE_LDAP
363     char *dnU = NULL;
364
365     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
366
367     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
368
369     if (dn) {
370         dnU = strWtoU( dn );
371         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
372     }
373
374     ret = map_error( ldap_delete_ext_s( ld, dn ? dnU : "", NULL, NULL ));
375     strfreeU( dnU );
376
377 #endif
378     return ret;
379 }