Partially implement and test the shelllink object's
[wine/multimedia.git] / dlls / wldap32 / extended.c
blobcbb440dd00a7f38a51ee85b4886fdef065283a70
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 ULONG ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid )
46 TRACE( "(%p, 0x%08lx)\n", ld, msgid );
48 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
49 return LDAP_SUCCESS;
52 ULONG ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
53 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
55 ULONG ret = LDAP_NOT_SUPPORTED;
56 #ifdef HAVE_LDAP
57 WCHAR *oidW = NULL;
58 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
60 ret = WLDAP32_LDAP_NO_MEMORY;
62 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
63 clientctrls, message );
65 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
67 if (oid) {
68 oidW = strAtoW( oid );
69 if (!oidW) goto exit;
71 if (serverctrls) {
72 serverctrlsW = controlarrayAtoW( serverctrls );
73 if (!serverctrlsW) goto exit;
75 if (clientctrls) {
76 clientctrlsW = controlarrayAtoW( clientctrls );
77 if (!clientctrlsW) goto exit;
80 ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
82 exit:
83 strfreeW( oidW );
84 controlarrayfreeW( serverctrlsW );
85 controlarrayfreeW( clientctrlsW );
87 #endif
88 return ret;
91 ULONG ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
92 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
94 ULONG ret = LDAP_NOT_SUPPORTED;
95 #ifdef HAVE_LDAP
96 char *oidU = NULL;
97 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
99 ret = WLDAP32_LDAP_NO_MEMORY;
101 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
102 clientctrls, message );
104 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
106 if (oid) {
107 oidU = strWtoU( oid );
108 if (!oidU) goto exit;
110 if (serverctrls) {
111 serverctrlsU = controlarrayWtoU( serverctrls );
112 if (!serverctrlsU) goto exit;
114 if (clientctrls) {
115 clientctrlsU = controlarrayWtoU( clientctrls );
116 if (!clientctrlsU) goto exit;
119 ret = ldap_extended_operation( ld, oid ? oidU : "", (struct berval *)data,
120 serverctrlsU, clientctrlsU, (int *)message );
122 exit:
123 strfreeU( oidU );
124 controlarrayfreeU( serverctrlsU );
125 controlarrayfreeU( clientctrlsU );
127 #endif
128 return ret;
131 ULONG ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
132 PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid,
133 struct WLDAP32_berval **retdata )
135 ULONG ret = LDAP_NOT_SUPPORTED;
136 #ifdef HAVE_LDAP
137 WCHAR *oidW = NULL, *retoidW = NULL;
138 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
140 ret = WLDAP32_LDAP_NO_MEMORY;
142 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
143 clientctrls, retoid, retdata );
145 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
147 if (oid) {
148 oidW = strAtoW( oid );
149 if (!oidW) goto exit;
151 if (serverctrls) {
152 serverctrlsW = controlarrayAtoW( serverctrls );
153 if (!serverctrlsW) goto exit;
155 if (clientctrls) {
156 clientctrlsW = controlarrayAtoW( clientctrls );
157 if (!clientctrlsW) goto exit;
160 ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW,
161 &retoidW, retdata );
163 if (retoid && retoidW) {
164 *retoid = strWtoA( retoidW );
165 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
166 ldap_memfreeW( retoidW );
169 exit:
170 strfreeW( oidW );
171 controlarrayfreeW( serverctrlsW );
172 controlarrayfreeW( clientctrlsW );
174 #endif
175 return ret;
178 ULONG ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
179 PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid,
180 struct WLDAP32_berval **retdata )
182 ULONG ret = LDAP_NOT_SUPPORTED;
183 #ifdef HAVE_LDAP
184 char *oidU = NULL, *retoidU = NULL;
185 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
187 ret = WLDAP32_LDAP_NO_MEMORY;
189 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
190 clientctrls, retoid, retdata );
192 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
194 if (oid) {
195 oidU = strWtoU( oid );
196 if (!oidU) goto exit;
198 if (serverctrls) {
199 serverctrlsU = controlarrayWtoU( serverctrls );
200 if (!serverctrlsU) goto exit;
202 if (clientctrls) {
203 clientctrlsU = controlarrayWtoU( clientctrls );
204 if (!clientctrlsU) goto exit;
207 ret = ldap_extended_operation_s( ld, oid ? oidU : "", (struct berval *)data, serverctrlsU,
208 clientctrlsU, &retoidU, (struct berval **)retdata );
210 if (retoid && retoidU) {
211 *retoid = strUtoW( retoidU );
212 if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
213 ldap_memfree( retoidU );
216 exit:
217 strfreeU( oidU );
218 controlarrayfreeU( serverctrlsU );
219 controlarrayfreeU( clientctrlsU );
221 #endif
222 return ret;