gdi32: Use NtGdiPolyPolyDraw for PolylineTo implementation.
[wine.git] / dlls / wldap32 / add.c
blobe9684f2d209fcd603d7d3ec3e1a288cc5025982c
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 <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winnls.h"
25 #include "winldap.h"
27 #include "wine/debug.h"
28 #include "winldap_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
32 /***********************************************************************
33 * ldap_addA (WLDAP32.@)
35 * See ldap_addW.
37 ULONG CDECL ldap_addA( LDAP *ld, char *dn, LDAPModA **attrs )
39 ULONG ret = LDAP_NO_MEMORY;
40 WCHAR *dnW = NULL;
41 LDAPModW **attrsW = NULL;
43 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
45 if (!ld) return ~0u;
47 if (dn && !(dnW = strAtoW( dn ))) goto exit;
48 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
50 ret = ldap_addW( ld, dnW, attrsW );
52 exit:
53 free( dnW );
54 modarrayfreeW( attrsW );
55 return ret;
58 /***********************************************************************
59 * ldap_addW (WLDAP32.@)
61 * Add an entry to a directory tree (asynchronous operation).
63 * PARAMS
64 * ld [I] Pointer to an LDAP context.
65 * dn [I] DN of the entry to add.
66 * attrs [I] Pointer to an array of LDAPModW structures, each
67 * specifying an attribute and its values to add.
69 * RETURNS
70 * Success: Message ID of the add operation.
71 * Failure: An LDAP error code.
73 * NOTES
74 * Call ldap_result with the message ID to get the result of
75 * the operation. Cancel the operation by calling ldap_abandon
76 * with the message ID.
78 ULONG CDECL ldap_addW( LDAP *ld, WCHAR *dn, LDAPModW **attrs )
80 ULONG ret, msg;
82 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
84 ret = ldap_add_extW( ld, dn, attrs, NULL, NULL, &msg );
85 if (ret == LDAP_SUCCESS) return msg;
86 return ~0u;
89 /***********************************************************************
90 * ldap_add_extA (WLDAP32.@)
92 * See ldap_add_extW.
94 ULONG CDECL ldap_add_extA( LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **serverctrls,
95 LDAPControlA **clientctrls, ULONG *message )
97 ULONG ret = LDAP_NO_MEMORY;
98 WCHAR *dnW = NULL;
99 LDAPModW **attrsW = NULL;
100 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
102 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), attrs, serverctrls, clientctrls, message );
104 if (!ld) return LDAP_PARAM_ERROR;
106 if (dn && !(dnW = strAtoW( dn ))) goto exit;
107 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
108 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
109 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
111 ret = ldap_add_extW( ld, dnW, attrsW, serverctrlsW, clientctrlsW, message );
113 exit:
114 free( dnW );
115 modarrayfreeW( attrsW );
116 controlarrayfreeW( serverctrlsW );
117 controlarrayfreeW( clientctrlsW );
118 return ret;
121 /***********************************************************************
122 * ldap_add_extW (WLDAP32.@)
124 * Add an entry to a directory tree (asynchronous operation).
126 * PARAMS
127 * ld [I] Pointer to an LDAP context.
128 * dn [I] DN of the entry to add.
129 * attrs [I] Pointer to an array of LDAPModW structures, each
130 * specifying an attribute and its values to add.
131 * serverctrls [I] Array of LDAP server controls.
132 * clientctrls [I] Array of LDAP client controls.
133 * message [O] Message ID of the add operation.
135 * RETURNS
136 * Success: LDAP_SUCCESS
137 * Failure: An LDAP error code.
139 * NOTES
140 * Call ldap_result with the message ID to get the result of
141 * the operation. The serverctrls and clientctrls parameters are
142 * optional and should be set to NULL if not used.
144 ULONG CDECL ldap_add_extW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW **serverctrls,
145 LDAPControlW **clientctrls, ULONG *message )
147 ULONG ret = LDAP_NO_MEMORY;
148 char *dnU = NULL;
149 LDAPModU **attrsU = NULL;
150 LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
152 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), attrs, serverctrls, clientctrls, message );
154 if (!ld) return LDAP_PARAM_ERROR;
156 if (dn && !(dnU = strWtoU( dn ))) goto exit;
157 if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
158 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
159 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
161 ret = map_error( ldap_funcs->fn_ldap_add_ext( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU, message ) );
163 exit:
164 free( dnU );
165 modarrayfreeU( attrsU );
166 controlarrayfreeU( serverctrlsU );
167 controlarrayfreeU( clientctrlsU );
168 return ret;
171 /***********************************************************************
172 * ldap_add_ext_sA (WLDAP32.@)
174 * See ldap_add_ext_sW.
176 ULONG CDECL ldap_add_ext_sA( LDAP *ld, char *dn, LDAPModA **attrs, LDAPControlA **serverctrls,
177 LDAPControlA **clientctrls )
179 ULONG ret = LDAP_NO_MEMORY;
180 WCHAR *dnW = NULL;
181 LDAPModW **attrsW = NULL;
182 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
184 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), attrs, serverctrls, clientctrls );
186 if (!ld) return LDAP_PARAM_ERROR;
188 if (dn && !(dnW = strAtoW( dn ))) goto exit;
189 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
190 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
191 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
193 ret = ldap_add_ext_sW( ld, dnW, attrsW, serverctrlsW, clientctrlsW );
195 exit:
196 free( dnW );
197 modarrayfreeW( attrsW );
198 controlarrayfreeW( serverctrlsW );
199 controlarrayfreeW( clientctrlsW );
200 return ret;
203 /***********************************************************************
204 * ldap_add_ext_sW (WLDAP32.@)
206 * Add an entry to a directory tree (synchronous operation).
208 * PARAMS
209 * ld [I] Pointer to an LDAP context.
210 * dn [I] DN of the entry to add.
211 * attrs [I] Pointer to an array of LDAPModW structures, each
212 * specifying an attribute and its values to add.
213 * serverctrls [I] Array of LDAP server controls.
214 * clientctrls [I] Array of LDAP client controls.
216 * RETURNS
217 * Success: LDAP_SUCCESS
218 * Failure: An LDAP error code.
220 * NOTES
221 * The serverctrls and clientctrls parameters are optional and
222 * should be set to NULL if not used.
224 ULONG CDECL ldap_add_ext_sW( LDAP *ld, WCHAR *dn, LDAPModW **attrs, LDAPControlW **serverctrls,
225 LDAPControlW **clientctrls )
227 ULONG ret = LDAP_NO_MEMORY;
228 char *dnU = NULL;
229 LDAPModU **attrsU = NULL;
230 LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
232 TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), attrs, serverctrls, clientctrls );
234 if (!ld) return LDAP_PARAM_ERROR;
236 if (dn && !(dnU = strWtoU( dn ))) goto exit;
237 if (attrs && !(attrsU = modarrayWtoU( attrs ))) goto exit;
238 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
239 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
241 ret = map_error( ldap_funcs->fn_ldap_add_ext_s( CTX(ld), dnU, attrsU, serverctrlsU, clientctrlsU ) );
243 exit:
244 free( dnU );
245 modarrayfreeU( attrsU );
246 controlarrayfreeU( serverctrlsU );
247 controlarrayfreeU( clientctrlsU );
248 return ret;
251 /***********************************************************************
252 * ldap_add_sA (WLDAP32.@)
254 * See ldap_add_sW.
256 ULONG CDECL ldap_add_sA( LDAP *ld, char *dn, LDAPModA **attrs )
258 ULONG ret = LDAP_NO_MEMORY;
259 WCHAR *dnW = NULL;
260 LDAPModW **attrsW = NULL;
262 TRACE( "(%p, %s, %p)\n", ld, debugstr_a(dn), attrs );
264 if (!ld) return LDAP_PARAM_ERROR;
266 if (dn && !(dnW = strAtoW( dn ))) goto exit;
267 if (attrs && !(attrsW = modarrayAtoW( attrs ))) goto exit;
269 ret = ldap_add_sW( ld, dnW, attrsW );
271 exit:
272 free( dnW );
273 modarrayfreeW( attrsW );
274 return ret;
277 /***********************************************************************
278 * ldap_add_sW (WLDAP32.@)
280 * Add an entry to a directory tree (synchronous operation).
282 * PARAMS
283 * ld [I] Pointer to an LDAP context.
284 * dn [I] DN of the entry to add.
285 * attrs [I] Pointer to an array of LDAPModW structures, each
286 * specifying an attribute and its values to add.
288 * RETURNS
289 * Success: LDAP_SUCCESS
290 * Failure: An LDAP error code.
292 ULONG CDECL ldap_add_sW( LDAP *ld, WCHAR *dn, LDAPModW **attrs )
294 TRACE( "(%p, %s, %p)\n", ld, debugstr_w(dn), attrs );
295 return ldap_add_ext_sW( ld, dn, attrs, NULL, NULL );