wined3d: UBYTE4 data shouldn't be normalized.
[wine/hacks.git] / dlls / wldap32 / extended.c
bloba3dbc2e3304554ca01463019336473720f48f3a1
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 #else
35 #define LDAP_SUCCESS 0x00
36 #define LDAP_NOT_SUPPORTED 0x5c
37 #endif
39 #include "winldap_private.h"
40 #include "wldap32.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
44 /***********************************************************************
45 * ldap_close_extended_op (WLDAP32.@)
47 * Close an extended operation.
49 * PARAMS
50 * ld [I] Pointer to an LDAP context.
51 * msgid [I] Message ID of the operation to be closed.
53 * RETURNS
54 * Success: LDAP_SUCCESS
55 * Failure: An LDAP error code.
57 * NOTES
58 * Contrary to native, OpenLDAP does not require us to close
59 * extended operations, so this is a no-op.
61 ULONG CDECL ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid )
63 TRACE( "(%p, 0x%08x)\n", ld, msgid );
65 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
66 return LDAP_SUCCESS;
69 /***********************************************************************
70 * ldap_extended_operationA (WLDAP32.@)
72 * See ldap_extended_operationW.
74 ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
75 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
77 ULONG ret = LDAP_NOT_SUPPORTED;
78 #ifdef HAVE_LDAP
79 WCHAR *oidW = NULL;
80 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
82 ret = WLDAP32_LDAP_NO_MEMORY;
84 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
85 clientctrls, message );
87 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
89 if (oid) {
90 oidW = strAtoW( oid );
91 if (!oidW) goto exit;
93 if (serverctrls) {
94 serverctrlsW = controlarrayAtoW( serverctrls );
95 if (!serverctrlsW) goto exit;
97 if (clientctrls) {
98 clientctrlsW = controlarrayAtoW( clientctrls );
99 if (!clientctrlsW) goto exit;
102 ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
104 exit:
105 strfreeW( oidW );
106 controlarrayfreeW( serverctrlsW );
107 controlarrayfreeW( clientctrlsW );
109 #endif
110 return ret;
113 /***********************************************************************
114 * ldap_extended_operationW (WLDAP32.@)
116 * Perform an extended operation (asynchronous mode).
118 * PARAMS
119 * ld [I] Pointer to an LDAP context.
120 * oid [I] OID of the extended operation.
121 * data [I] Data needed by the operation.
122 * serverctrls [I] Array of LDAP server controls.
123 * clientctrls [I] Array of LDAP client controls.
124 * message [O] Message ID of the extended operation.
126 * RETURNS
127 * Success: LDAP_SUCCESS
128 * Failure: An LDAP error code.
130 * NOTES
131 * The data parameter should be set to NULL if the operation
132 * requires no data. Call ldap_result with the message ID to
133 * get the result of the operation or ldap_abandon to cancel
134 * the operation. The serverctrls and clientctrls parameters
135 * are optional and should be set to NULL if not used. Call
136 * ldap_close_extended_op to close the operation.
138 ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
139 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
141 ULONG ret = LDAP_NOT_SUPPORTED;
142 #ifdef HAVE_LDAP
143 char *oidU = NULL;
144 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
146 ret = WLDAP32_LDAP_NO_MEMORY;
148 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
149 clientctrls, message );
151 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
153 if (oid) {
154 oidU = strWtoU( oid );
155 if (!oidU) goto exit;
157 if (serverctrls) {
158 serverctrlsU = controlarrayWtoU( serverctrls );
159 if (!serverctrlsU) goto exit;
161 if (clientctrls) {
162 clientctrlsU = controlarrayWtoU( clientctrls );
163 if (!clientctrlsU) goto exit;
166 ret = ldap_extended_operation( ld, oid ? oidU : "", (struct berval *)data,
167 serverctrlsU, clientctrlsU, (int *)message );
169 exit:
170 strfreeU( oidU );
171 controlarrayfreeU( serverctrlsU );
172 controlarrayfreeU( clientctrlsU );
174 #endif
175 return ret;
178 /***********************************************************************
179 * ldap_extended_operation_sA (WLDAP32.@)
181 * See ldap_extended_operation_sW.
183 ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
184 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid,
185 struct WLDAP32_berval **retdata )
187 ULONG ret = LDAP_NOT_SUPPORTED;
188 #ifdef HAVE_LDAP
189 WCHAR *oidW = NULL, *retoidW = NULL;
190 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
192 ret = WLDAP32_LDAP_NO_MEMORY;
194 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
195 clientctrls, retoid, retdata );
197 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
199 if (oid) {
200 oidW = strAtoW( oid );
201 if (!oidW) goto exit;
203 if (serverctrls) {
204 serverctrlsW = controlarrayAtoW( serverctrls );
205 if (!serverctrlsW) goto exit;
207 if (clientctrls) {
208 clientctrlsW = controlarrayAtoW( clientctrls );
209 if (!clientctrlsW) goto exit;
212 ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW,
213 &retoidW, retdata );
215 if (retoid && retoidW) {
216 *retoid = strWtoA( retoidW );
217 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
218 ldap_memfreeW( retoidW );
221 exit:
222 strfreeW( oidW );
223 controlarrayfreeW( serverctrlsW );
224 controlarrayfreeW( clientctrlsW );
226 #endif
227 return ret;
230 /***********************************************************************
231 * ldap_extended_operation_sW (WLDAP32.@)
233 * Perform an extended operation (synchronous mode).
235 * PARAMS
236 * ld [I] Pointer to an LDAP context.
237 * oid [I] OID of the extended operation.
238 * data [I] Data needed by the operation.
239 * serverctrls [I] Array of LDAP server controls.
240 * clientctrls [I] Array of LDAP client controls.
241 * retoid [O] OID of the server response message.
242 * retdata [O] Data returned by the server.
244 * RETURNS
245 * Success: LDAP_SUCCESS
246 * Failure: An LDAP error code.
248 * NOTES
249 * The data parameter should be set to NULL if the operation
250 * requires no data. The serverctrls, clientctrls, retoid and
251 * and retdata parameters are also optional. Set to NULL if not
252 * used. Free retoid and retdata after use with ldap_memfree.
254 ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
255 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid,
256 struct WLDAP32_berval **retdata )
258 ULONG ret = LDAP_NOT_SUPPORTED;
259 #ifdef HAVE_LDAP
260 char *oidU = NULL, *retoidU = NULL;
261 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
263 ret = WLDAP32_LDAP_NO_MEMORY;
265 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
266 clientctrls, retoid, retdata );
268 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
270 if (oid) {
271 oidU = strWtoU( oid );
272 if (!oidU) goto exit;
274 if (serverctrls) {
275 serverctrlsU = controlarrayWtoU( serverctrls );
276 if (!serverctrlsU) goto exit;
278 if (clientctrls) {
279 clientctrlsU = controlarrayWtoU( clientctrls );
280 if (!clientctrlsU) goto exit;
283 ret = ldap_extended_operation_s( ld, oid ? oidU : "", (struct berval *)data, serverctrlsU,
284 clientctrlsU, &retoidU, (struct berval **)retdata );
286 if (retoid && retoidU) {
287 *retoid = strUtoW( retoidU );
288 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
289 ldap_memfree( retoidU );
292 exit:
293 strfreeU( oidU );
294 controlarrayfreeU( serverctrlsU );
295 controlarrayfreeU( clientctrlsU );
297 #endif
298 return ret;