conhost: Fix ctrl-c handling.
[wine.git] / dlls / wldap32 / extended.c
blobce4773e6961acde22d11468be206891d6913f915
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"
26 #include "wine/debug.h"
27 #include "winldap_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
31 /***********************************************************************
32 * ldap_close_extended_op (WLDAP32.@)
34 ULONG CDECL ldap_close_extended_op( LDAP *ld, ULONG msgid )
36 TRACE( "(%p, %#lx)\n", ld, msgid );
38 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
39 return WLDAP32_LDAP_SUCCESS;
42 /***********************************************************************
43 * ldap_extended_operationA (WLDAP32.@)
45 ULONG CDECL ldap_extended_operationA( LDAP *ld, char *oid, struct WLDAP32_berval *data, LDAPControlA **serverctrls,
46 LDAPControlA **clientctrls, ULONG *message )
48 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
49 WCHAR *oidW = NULL;
50 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
52 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, message );
54 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
56 if (oid && !(oidW = strAtoW( oid ))) goto exit;
57 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
58 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
60 ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
62 exit:
63 free( oidW );
64 controlarrayfreeW( serverctrlsW );
65 controlarrayfreeW( clientctrlsW );
66 return ret;
69 /***********************************************************************
70 * ldap_extended_operationW (WLDAP32.@)
72 ULONG CDECL ldap_extended_operationW( LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data, LDAPControlW **serverctrls,
73 LDAPControlW **clientctrls, ULONG *message )
75 ULONG ret;
76 char *oidU = NULL;
77 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
78 struct berval *dataU = NULL;
80 TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, message );
82 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
83 if ((ret = WLDAP32_ldap_connect( ld, NULL ))) return ret;
85 ret = WLDAP32_LDAP_NO_MEMORY;
86 if (oid && !(oidU = strWtoU( oid ))) goto exit;
87 if (data && !(dataU = bervalWtoU( data ))) goto exit;
88 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
89 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
90 else
92 ret = map_error( ldap_extended_operation( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU, (int *)message ) );
95 exit:
96 free( oidU );
97 free( dataU );
98 controlarrayfreeU( serverctrlsU );
99 controlarrayfreeU( clientctrlsU );
100 return ret;
103 /***********************************************************************
104 * ldap_extended_operation_sA (WLDAP32.@)
106 ULONG CDECL ldap_extended_operation_sA( LDAP *ld, char *oid, struct WLDAP32_berval *data, LDAPControlA **serverctrls,
107 LDAPControlA **clientctrls, char **retoid, struct WLDAP32_berval **retdata )
109 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
110 WCHAR *oidW = NULL, *retoidW = NULL;
111 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
113 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, retoid, retdata );
115 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
117 if (oid && !(oidW = strAtoW( oid ))) goto exit;
118 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
119 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
121 ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW, &retoidW, retdata );
122 if (retoid && retoidW)
124 char *str = strWtoA( retoidW );
125 if (str) *retoid = str;
126 else ret = WLDAP32_LDAP_NO_MEMORY;
127 ldap_memfreeW( retoidW );
130 exit:
131 free( oidW );
132 controlarrayfreeW( serverctrlsW );
133 controlarrayfreeW( clientctrlsW );
134 return ret;
137 /***********************************************************************
138 * ldap_extended_operation_sW (WLDAP32.@)
140 ULONG CDECL ldap_extended_operation_sW( LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data, LDAPControlW **serverctrls,
141 LDAPControlW **clientctrls, WCHAR **retoid, struct WLDAP32_berval **retdata )
143 ULONG ret;
144 char *oidU = NULL, *retoidU = NULL;
145 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
146 struct berval *retdataU, *dataU = NULL;
148 TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, retoid, retdata );
150 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
151 if ((ret = WLDAP32_ldap_connect( ld, NULL ))) return ret;
153 ret = WLDAP32_LDAP_NO_MEMORY;
154 if (oid && !(oidU = strWtoU( oid ))) goto exit;
155 if (data && !(dataU = bervalWtoU( data ))) goto exit;
156 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
157 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
158 else
160 ret = map_error( ldap_extended_operation_s( CTX(ld), oidU, dataU, serverctrlsU, clientctrlsU, &retoidU,
161 &retdataU ) );
164 if (retoid && retoidU)
166 WCHAR *str = strUtoW( retoidU );
167 if (str) *retoid = str;
168 else ret = WLDAP32_LDAP_NO_MEMORY;
169 ldap_memfree( retoidU );
171 if (retdata && retdataU)
173 struct WLDAP32_berval *bv = bervalUtoW( retdataU );
174 if (bv) *retdata = bv;
175 else ret = WLDAP32_LDAP_NO_MEMORY;
176 ber_bvfree( retdataU );
179 exit:
180 free( oidU );
181 free( dataU );
182 controlarrayfreeU( serverctrlsU );
183 controlarrayfreeU( clientctrlsU );
184 return ret;