- N_PSYM stabs blocks (aka parameters) can also contain a typedef
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 #else
35 #define LDAP_NOT_SUPPORTED  0x5c
36 #endif
37
38 #include "winldap_private.h"
39 #include "wldap32.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
42
43 ULONG ldap_deleteA( WLDAP32_LDAP *ld, PCHAR dn )
44 {
45     ULONG ret = LDAP_NOT_SUPPORTED;
46 #ifdef HAVE_LDAP
47     WCHAR *dnW = NULL;
48
49     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
50
51     if (!ld) return ~0UL;
52
53     if (dn) {
54         dnW = strAtoW( dn );
55         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
56     }
57
58     ret = ldap_deleteW( ld, dnW );
59     strfreeW( dnW );
60
61 #endif
62     return ret;
63 }
64
65 ULONG ldap_deleteW( WLDAP32_LDAP *ld, PWCHAR dn )
66 {
67     ULONG ret = LDAP_NOT_SUPPORTED;
68 #ifdef HAVE_LDAP
69     char *dnU = NULL;
70
71     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
72
73     if (!ld) return ~0UL;
74
75     if (dn) {
76         dnU = strWtoU( dn );
77         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
78     }
79
80     ret = ldap_delete( ld, dn ? dnU : "" );
81     strfreeU( dnU );
82
83 #endif
84     return ret;
85 }
86
87 ULONG ldap_delete_extA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
88     PLDAPControlA *clientctrls, ULONG *message )
89 {
90     ULONG ret = LDAP_NOT_SUPPORTED;
91 #ifdef HAVE_LDAP
92     WCHAR *dnW = NULL;
93     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
94
95     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
96            clientctrls, message );
97
98     ret = WLDAP32_LDAP_NO_MEMORY;
99
100     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
101
102     if (dn) {
103         dnW = strAtoW( dn );
104         if (!dnW) goto exit;
105     }
106     if (serverctrls) {
107         serverctrlsW = controlarrayAtoW( serverctrls );
108         if (!serverctrlsW) goto exit;
109     }
110     if (clientctrls) {
111         clientctrlsW = controlarrayAtoW( clientctrls );
112         if (!clientctrlsW) goto exit;
113     }
114
115     ret = ldap_delete_extW( ld, dnW, serverctrlsW, clientctrlsW, message );
116
117 exit:
118     strfreeW( dnW );
119     controlarrayfreeW( serverctrlsW );
120     controlarrayfreeW( clientctrlsW );
121
122 #endif
123     return ret;
124 }
125
126 ULONG ldap_delete_extW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
127     PLDAPControlW *clientctrls, ULONG *message )
128 {
129     ULONG ret = LDAP_NOT_SUPPORTED;
130 #ifdef HAVE_LDAP
131     char *dnU = NULL;
132     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
133     int dummy;
134
135     TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
136            clientctrls, message );
137
138     ret = WLDAP32_LDAP_NO_MEMORY;
139
140     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
141
142     if (dn) {
143         dnU = strWtoU( dn );
144         if (!dnU) goto exit;
145     }
146     if (serverctrls) {
147         serverctrlsU = controlarrayWtoU( serverctrls );
148         if (!serverctrlsU) goto exit;
149     }
150     if (clientctrls) {
151         clientctrlsU = controlarrayWtoU( clientctrls );
152         if (!clientctrlsU) goto exit;
153     }
154
155     ret = ldap_delete_ext( ld, dn ? dnU : "", serverctrlsU, clientctrlsU,
156                            message ? (int *)message : &dummy );
157
158 exit:
159     strfreeU( dnU );
160     controlarrayfreeU( serverctrlsU );
161     controlarrayfreeU( clientctrlsU );
162
163 #endif
164     return ret;
165 }
166
167 ULONG ldap_delete_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PLDAPControlA *serverctrls,
168     PLDAPControlA *clientctrls )
169 {
170     ULONG ret = LDAP_NOT_SUPPORTED;
171 #ifdef HAVE_LDAP
172     WCHAR *dnW = NULL;
173     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
174
175     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_a(dn), serverctrls,
176            clientctrls );
177
178     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
179
180     if (dn) {
181         dnW = strAtoW( dn );
182         if (!dnW) goto exit;
183     }
184     if (serverctrls) {
185         serverctrlsW = controlarrayAtoW( serverctrls );
186         if (!serverctrlsW) goto exit;
187     }
188     if (clientctrls) {
189         clientctrlsW = controlarrayAtoW( clientctrls );
190         if (!clientctrlsW) goto exit;
191     }
192
193     ret = ldap_delete_ext_sW( ld, dnW, serverctrlsW, clientctrlsW );
194
195 exit:
196     strfreeW( dnW );
197     controlarrayfreeW( serverctrlsW );
198     controlarrayfreeW( clientctrlsW );
199
200 #endif
201     return ret;
202 }
203
204 ULONG ldap_delete_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PLDAPControlW *serverctrls,
205     PLDAPControlW *clientctrls )
206 {
207     ULONG ret = LDAP_NOT_SUPPORTED;
208 #ifdef HAVE_LDAP
209     char *dnU = NULL;
210     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
211
212     TRACE( "(%p, %s, %p, %p)\n", ld, debugstr_w(dn), serverctrls,
213            clientctrls );
214
215     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
216
217     if (dn) {
218         dnU = strWtoU( dn );
219         if (!dnU) goto exit;
220     }
221     if (serverctrls) {
222         serverctrlsU = controlarrayWtoU( serverctrls );
223         if (!serverctrlsU) goto exit;
224     }
225     if (clientctrls) {
226         clientctrlsU = controlarrayWtoU( clientctrls );
227         if (!clientctrlsU) goto exit;
228     }
229
230     ret = ldap_delete_ext_s( ld, dn ? dnU : "", serverctrlsU, clientctrlsU );
231
232 exit:
233     strfreeU( dnU );
234     controlarrayfreeU( serverctrlsU );
235     controlarrayfreeU( clientctrlsU );
236
237 #endif
238     return ret;
239 }
240  
241 ULONG ldap_delete_sA( WLDAP32_LDAP *ld, PCHAR dn )
242 {
243     ULONG ret = LDAP_NOT_SUPPORTED;
244 #ifdef HAVE_LDAP
245     WCHAR *dnW = NULL;
246
247     TRACE( "(%p, %s)\n", ld, debugstr_a(dn) );
248
249     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
250
251     if (dn) {
252         dnW = strAtoW( dn );
253         if (!dnW) return WLDAP32_LDAP_NO_MEMORY;
254     }
255
256     ret = ldap_delete_sW( ld, dnW );
257     strfreeW( dnW );
258
259 #endif
260     return ret;
261 }
262
263 ULONG ldap_delete_sW( WLDAP32_LDAP *ld, PWCHAR dn )
264 {
265     ULONG ret = LDAP_NOT_SUPPORTED;
266 #ifdef HAVE_LDAP
267     char *dnU = NULL;
268
269     TRACE( "(%p, %s)\n", ld, debugstr_w(dn) );
270
271     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
272
273     if (dn) {
274         dnU = strWtoU( dn );
275         if (!dnU) return WLDAP32_LDAP_NO_MEMORY;
276     }
277
278     ret = ldap_delete_s( ld, dn ? dnU : "" );
279     strfreeU( dnU );
280
281 #endif
282     return ret;
283 }