gdi: Fix test for GetGlyphIndicesW on non Unicode systems.
[wine/hacks.git] / dlls / wldap32 / modify.c
blobd0d8dea660b95eabe12496c56a223312f29c3778
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 #endif
36 #ifndef LDAP_NOT_SUPPORTED
37 #define LDAP_NOT_SUPPORTED 0x5c
38 #endif
40 #include "winldap_private.h"
41 #include "wldap32.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
45 #ifdef HAVE_LDAP
46 static LDAPMod *nullmods[] = { NULL };
47 #endif
49 /***********************************************************************
50 * ldap_modifyA (WLDAP32.@)
52 * See ldap_modifyW.
54 ULONG CDECL ldap_modifyA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
56 ULONG ret = LDAP_NOT_SUPPORTED;
57 #ifdef HAVE_LDAP
58 WCHAR *dnW = NULL;
59 LDAPModW **modsW = NULL;
61 ret = WLDAP32_LDAP_NO_MEMORY;
63 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
65 if (!ld) return ~0UL;
67 if (dn) {
68 dnW = strAtoW( dn );
69 if (!dnW) goto exit;
71 if (mods) {
72 modsW = modarrayAtoW( mods );
73 if (!modsW) goto exit;
76 ret = ldap_modifyW( ld, dnW, modsW );
78 exit:
79 strfreeW( dnW );
80 modarrayfreeW( modsW );
82 #endif
83 return ret;
86 /***********************************************************************
87 * ldap_modifyW (WLDAP32.@)
89 * Change an entry in a directory tree (asynchronous operation).
91 * PARAMS
92 * ld [I] Pointer to an LDAP context.
93 * dn [I] DN of the entry to change.
94 * mods [I] Pointer to an array of LDAPModW structures, each
95 * specifying an attribute and its values to change.
97 * RETURNS
98 * Success: Message ID of the modify operation.
99 * Failure: An LDAP error code.
101 * NOTES
102 * Call ldap_result with the message ID to get the result of
103 * the operation. Cancel the operation by calling ldap_abandon
104 * with the message ID.
106 ULONG CDECL ldap_modifyW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
108 ULONG ret = LDAP_NOT_SUPPORTED;
109 #ifdef HAVE_LDAP
110 char *dnU = NULL;
111 LDAPMod **modsU = NULL;
112 int msg;
114 ret = WLDAP32_LDAP_NO_MEMORY;
116 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
118 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
120 if (dn) {
121 dnU = strWtoU( dn );
122 if (!dnU) goto exit;
124 if (mods) {
125 modsU = modarrayWtoU( mods );
126 if (!modsU) goto exit;
129 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods,
130 NULL, NULL, &msg );
132 if (ret == LDAP_SUCCESS)
133 ret = msg;
134 else
135 ret = ~0UL;
137 exit:
138 strfreeU( dnU );
139 modarrayfreeU( modsU );
141 #endif
142 return ret;
145 /***********************************************************************
146 * ldap_modify_extA (WLDAP32.@)
148 * See ldap_modify_extW.
150 ULONG CDECL ldap_modify_extA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
151 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
153 ULONG ret = LDAP_NOT_SUPPORTED;
154 #ifdef HAVE_LDAP
155 WCHAR *dnW = NULL;
156 LDAPModW **modsW = NULL;
157 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
159 ret = WLDAP32_LDAP_NO_MEMORY;
161 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
162 serverctrls, clientctrls, message );
164 if (!ld) return ~0UL;
166 if (dn) {
167 dnW = strAtoW( dn );
168 if (!dnW) goto exit;
170 if (mods) {
171 modsW = modarrayAtoW( mods );
172 if (!modsW) goto exit;
174 if (serverctrls) {
175 serverctrlsW = controlarrayAtoW( serverctrls );
176 if (!serverctrlsW) goto exit;
178 if (clientctrls) {
179 clientctrlsW = controlarrayAtoW( clientctrls );
180 if (!clientctrlsW) goto exit;
183 ret = ldap_modify_extW( ld, dnW, modsW, serverctrlsW, clientctrlsW, message );
185 exit:
186 strfreeW( dnW );
187 modarrayfreeW( modsW );
188 controlarrayfreeW( serverctrlsW );
189 controlarrayfreeW( clientctrlsW );
191 #endif
192 return ret;
195 /***********************************************************************
196 * ldap_modify_extW (WLDAP32.@)
198 * Change an entry in a directory tree (asynchronous operation).
200 * PARAMS
201 * ld [I] Pointer to an LDAP context.
202 * dn [I] DN of the entry to change.
203 * mods [I] Pointer to an array of LDAPModW structures, each
204 * specifying an attribute and its values to change.
205 * serverctrls [I] Array of LDAP server controls.
206 * clientctrls [I] Array of LDAP client controls.
207 * message [O] Message ID of the modify operation.
209 * RETURNS
210 * Success: LDAP_SUCCESS
211 * Failure: An LDAP error code.
213 * NOTES
214 * Call ldap_result with the message ID to get the result of
215 * the operation. The serverctrls and clientctrls parameters are
216 * optional and should be set to NULL if not used.
218 ULONG CDECL ldap_modify_extW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
219 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
221 ULONG ret = LDAP_NOT_SUPPORTED;
222 #ifdef HAVE_LDAP
223 char *dnU = NULL;
224 LDAPMod **modsU = NULL;
225 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
226 int dummy;
228 ret = WLDAP32_LDAP_NO_MEMORY;
230 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
231 serverctrls, clientctrls, message );
233 if (!ld) return ~0UL;
235 if (dn) {
236 dnU = strWtoU( dn );
237 if (!dnU) goto exit;
239 if (mods) {
240 modsU = modarrayWtoU( mods );
241 if (!modsU) goto exit;
243 if (serverctrls) {
244 serverctrlsU = controlarrayWtoU( serverctrls );
245 if (!serverctrlsU) goto exit;
247 if (clientctrls) {
248 clientctrlsU = controlarrayWtoU( clientctrls );
249 if (!clientctrlsU) goto exit;
252 ret = ldap_modify_ext( ld, dn ? dnU : "", mods ? modsU : nullmods, serverctrlsU,
253 clientctrlsU, message ? (int *)message : &dummy );
255 exit:
256 strfreeU( dnU );
257 modarrayfreeU( modsU );
258 controlarrayfreeU( serverctrlsU );
259 controlarrayfreeU( clientctrlsU );
261 #endif
262 return ret;
265 /***********************************************************************
266 * ldap_modify_ext_sA (WLDAP32.@)
268 * See ldap_modify_ext_sW.
270 ULONG CDECL ldap_modify_ext_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[],
271 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls )
273 ULONG ret = LDAP_NOT_SUPPORTED;
274 #ifdef HAVE_LDAP
275 WCHAR *dnW = NULL;
276 LDAPModW **modsW = NULL;
277 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
279 ret = WLDAP32_LDAP_NO_MEMORY;
281 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), mods,
282 serverctrls, clientctrls );
284 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
286 if (dn) {
287 dnW = strAtoW( dn );
288 if (!dnW) goto exit;
290 if (mods) {
291 modsW = modarrayAtoW( mods );
292 if (!modsW) goto exit;
294 if (serverctrls) {
295 serverctrlsW = controlarrayAtoW( serverctrls );
296 if (!serverctrlsW) goto exit;
298 if (clientctrls) {
299 clientctrlsW = controlarrayAtoW( clientctrls );
300 if (!clientctrlsW) goto exit;
303 ret = ldap_modify_ext_sW( ld, dnW, modsW, serverctrlsW, clientctrlsW );
305 exit:
306 strfreeW( dnW );
307 modarrayfreeW( modsW );
308 controlarrayfreeW( serverctrlsW );
309 controlarrayfreeW( clientctrlsW );
311 #endif
312 return ret;
315 /***********************************************************************
316 * ldap_modify_ext_sW (WLDAP32.@)
318 * Change an entry in a directory tree (synchronous operation).
320 * PARAMS
321 * ld [I] Pointer to an LDAP context.
322 * dn [I] DN of the entry to change.
323 * mods [I] Pointer to an array of LDAPModW structures, each
324 * specifying an attribute and its values to change.
325 * serverctrls [I] Array of LDAP server controls.
326 * clientctrls [I] Array of LDAP client controls.
328 * RETURNS
329 * Success: LDAP_SUCCESS
330 * Failure: An LDAP error code.
332 * NOTES
333 * The serverctrls and clientctrls parameters are optional and
334 * should be set to NULL if not used.
336 ULONG CDECL ldap_modify_ext_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[],
337 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls )
339 ULONG ret = LDAP_NOT_SUPPORTED;
340 #ifdef HAVE_LDAP
341 char *dnU = NULL;
342 LDAPMod **modsU = NULL;
343 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
345 ret = WLDAP32_LDAP_NO_MEMORY;
347 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), mods,
348 serverctrls, clientctrls );
350 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
352 if (dn) {
353 dnU = strWtoU( dn );
354 if (!dnU) goto exit;
356 if (mods) {
357 modsU = modarrayWtoU( mods );
358 if (!modsU) goto exit;
360 if (serverctrls) {
361 serverctrlsU = controlarrayWtoU( serverctrls );
362 if (!serverctrlsU) goto exit;
364 if (clientctrls) {
365 clientctrlsU = controlarrayWtoU( clientctrls );
366 if (!clientctrlsU) goto exit;
369 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods,
370 serverctrlsU, clientctrlsU );
372 exit:
373 strfreeU( dnU );
374 modarrayfreeU( modsU );
375 controlarrayfreeU( serverctrlsU );
376 controlarrayfreeU( clientctrlsU );
378 #endif
379 return ret;
382 /***********************************************************************
383 * ldap_modify_sA (WLDAP32.@)
385 * See ldap_modify_sW.
387 ULONG CDECL ldap_modify_sA( WLDAP32_LDAP *ld, PCHAR dn, LDAPModA *mods[] )
389 ULONG ret = LDAP_NOT_SUPPORTED;
390 #ifdef HAVE_LDAP
391 WCHAR *dnW = NULL;
392 LDAPModW **modsW = NULL;
394 ret = WLDAP32_LDAP_NO_MEMORY;
396 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), mods );
398 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
400 if (dn) {
401 dnW = strAtoW( dn );
402 if (!dnW) goto exit;
404 if (mods) {
405 modsW = modarrayAtoW( mods );
406 if (!modsW) goto exit;
409 ret = ldap_modify_sW( ld, dnW, modsW );
411 exit:
412 strfreeW( dnW );
413 modarrayfreeW( modsW );
415 #endif
416 return ret;
419 /***********************************************************************
420 * ldap_modify_sW (WLDAP32.@)
422 * Change an entry in a directory tree (synchronous operation).
424 * PARAMS
425 * ld [I] Pointer to an LDAP context.
426 * dn [I] DN of the entry to change.
427 * attrs [I] Pointer to an array of LDAPModW structures, each
428 * specifying an attribute and its values to change.
430 * RETURNS
431 * Success: LDAP_SUCCESS
432 * Failure: An LDAP error code.
434 ULONG CDECL ldap_modify_sW( WLDAP32_LDAP *ld, PWCHAR dn, LDAPModW *mods[] )
436 ULONG ret = LDAP_NOT_SUPPORTED;
437 #ifdef HAVE_LDAP
438 char *dnU = NULL;
439 LDAPMod **modsU = NULL;
441 ret = WLDAP32_LDAP_NO_MEMORY;
443 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), mods );
445 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
447 if (dn) {
448 dnU = strWtoU( dn );
449 if (!dnU) goto exit;
451 if (mods) {
452 modsU = modarrayWtoU( mods );
453 if (!modsU) goto exit;
456 ret = ldap_modify_ext_s( ld, dn ? dnU : "", mods ? modsU : nullmods, NULL, NULL );
458 exit:
459 strfreeU( dnU );
460 modarrayfreeU( modsU );
462 #endif
463 return ret;