Export functions by ordinal, cryptnet.dll at least depends on it.
[wine] / dlls / wldap32 / rename.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_rename_extA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
44     PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
45     PLDAPControlA *clientctrls, ULONG *message )
46 {
47     ULONG ret = LDAP_NOT_SUPPORTED;
48 #ifdef HAVE_LDAP
49     WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
50     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
51
52     ret = WLDAP32_LDAP_NO_MEMORY;
53
54     TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_a(dn),
55            debugstr_a(newrdn), debugstr_a(newparent), delete,
56            serverctrls, clientctrls, message );
57
58     if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
59
60     if (dn) {
61         dnW = strAtoW( dn );
62         if (!dnW) goto exit;
63     }
64     if (newrdn) {
65         newrdnW = strAtoW( newrdn );
66         if (!newrdnW) goto exit;
67     }
68     if (newparent) {
69         newparentW = strAtoW( newparent );
70         if (!newparentW) goto exit;
71     }
72     if (serverctrls) {
73         serverctrlsW = controlarrayAtoW( serverctrls );
74         if (!serverctrlsW) goto exit;
75     }
76     if (clientctrls) {
77         clientctrlsW = controlarrayAtoW( clientctrls );
78         if (!clientctrlsW) goto exit;
79     }
80
81     ret = ldap_rename_extW( ld, dnW, newrdnW, newparentW, delete,
82                             serverctrlsW, clientctrlsW, message );
83
84 exit:
85     strfreeW( dnW );
86     strfreeW( newrdnW );
87     strfreeW( newparentW );
88     controlarrayfreeW( serverctrlsW );
89     controlarrayfreeW( clientctrlsW );
90
91 #endif
92     return ret;
93 }
94
95 ULONG ldap_rename_extW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
96     PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
97     PLDAPControlW *clientctrls, ULONG *message )
98 {
99     ULONG ret = LDAP_NOT_SUPPORTED;
100 #ifdef HAVE_LDAP
101     char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
102     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
103
104     ret = WLDAP32_LDAP_NO_MEMORY;
105
106     TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p, %p)\n", ld, debugstr_w(dn),
107            debugstr_w(newrdn), debugstr_w(newparent), delete,
108            serverctrls, clientctrls, message );
109
110     if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
111
112     if (dn) {
113         dnU = strWtoU( dn );
114         if (!dnU) goto exit;
115     }
116     if (newrdn) {
117         newrdnU = strWtoU( newrdn );
118         if (!newrdnU) goto exit;
119     }
120     if (newparent) {
121         newparentU = strWtoU( newparent );
122         if (!newparentU) goto exit;
123     }
124     if (serverctrls) {
125         serverctrlsU = controlarrayWtoU( serverctrls );
126         if (!serverctrlsU) goto exit;
127     }
128     if (clientctrls) {
129         clientctrlsU = controlarrayWtoU( clientctrls );
130         if (!clientctrlsU) goto exit;
131     }
132
133     ret = ldap_rename( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
134                        delete, serverctrlsU, clientctrlsU, (int *)message );
135
136 exit:
137     strfreeU( dnU );
138     strfreeU( newrdnU );
139     strfreeU( newparentU );
140     controlarrayfreeU( serverctrlsU );
141     controlarrayfreeU( clientctrlsU );
142
143 #endif
144     return ret;
145 }
146
147 ULONG ldap_rename_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, PCHAR newrdn,
148     PCHAR newparent, INT delete, PLDAPControlA *serverctrls,
149     PLDAPControlA *clientctrls )
150 {
151     ULONG ret = LDAP_NOT_SUPPORTED;
152 #ifdef HAVE_LDAP
153     WCHAR *dnW = NULL, *newrdnW = NULL, *newparentW = NULL;
154     LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
155
156     ret = WLDAP32_LDAP_NO_MEMORY;
157
158     TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_a(dn),
159            debugstr_a(newrdn), debugstr_a(newparent), delete,
160            serverctrls, clientctrls );
161
162     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
163
164     if (dn) {
165         dnW = strAtoW( dn );
166         if (!dnW) goto exit;
167     }
168     if (newrdn) {
169         newrdnW = strAtoW( newrdn );
170         if (!newrdnW) goto exit;
171     }
172     if (newparent) {
173         newparentW = strAtoW( newparent );
174         if (!newparentW) goto exit;
175     }
176     if (serverctrls) {
177         serverctrlsW = controlarrayAtoW( serverctrls );
178         if (!serverctrlsW) goto exit;
179     }
180     if (clientctrls) {
181         clientctrlsW = controlarrayAtoW( clientctrls );
182         if (!clientctrlsW) goto exit;
183     }
184
185     ret = ldap_rename_ext_sW( ld, dnW, newrdnW, newparentW, delete,
186                               serverctrlsW, clientctrlsW );
187
188 exit:
189     strfreeW( dnW );
190     strfreeW( newrdnW );
191     strfreeW( newparentW );
192     controlarrayfreeW( serverctrlsW );
193     controlarrayfreeW( clientctrlsW );
194
195 #endif
196     return ret;
197 }
198
199 ULONG ldap_rename_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, PWCHAR newrdn,
200     PWCHAR newparent, INT delete, PLDAPControlW *serverctrls,
201     PLDAPControlW *clientctrls )
202 {
203     ULONG ret = LDAP_NOT_SUPPORTED;
204 #ifdef HAVE_LDAP
205     char *dnU = NULL, *newrdnU = NULL, *newparentU = NULL;
206     LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
207
208     ret = WLDAP32_LDAP_NO_MEMORY;
209
210     TRACE( "(%p, %s, %s, %s, 0x%02x, %p, %p)\n", ld, debugstr_w(dn),
211            debugstr_w(newrdn), debugstr_w(newparent), delete,
212            serverctrls, clientctrls );
213
214     if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
215
216     if (dn) {
217         dnU = strWtoU( dn );
218         if (!dnU) goto exit;
219     }
220     if (newrdn) {
221         newrdnU = strWtoU( newrdn );
222         if (!newrdnU) goto exit;
223     }
224     if (newparent) {
225         newparentU = strWtoU( newparent );
226         if (!newparentU) goto exit;
227     }
228     if (serverctrls) {
229         serverctrlsU = controlarrayWtoU( serverctrls );
230         if (!serverctrlsU) goto exit;
231     }
232     if (clientctrls) {
233         clientctrlsU = controlarrayWtoU( clientctrls );
234         if (!clientctrlsU) goto exit;
235     }
236
237     ret = ldap_rename_s( ld, dn ? dnU : "", newrdn ? newrdnU : "", newparentU,
238                          delete, serverctrlsU, clientctrlsU );
239
240 exit:
241     strfreeU( dnU );
242     strfreeU( newrdnU );
243     strfreeU( newparentU );
244     controlarrayfreeU( serverctrlsU );
245     controlarrayfreeU( clientctrlsU );
246
247 #endif
248     return ret;
249 }