d3d9/tests: Accept AMD GPU sysmem sample failure in test_mipmap_upload.
[wine.git] / dlls / wldap32 / compare.c
blobb42651855381e87f645b1d7ac690a348fb1f5717
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_compareA (WLDAP32.@)
34 ULONG CDECL ldap_compareA( LDAP *ld, char *dn, char *attr, char *value )
36 ULONG ret = ~0u;
37 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
39 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(attr), debugstr_a(value) );
41 if (!ld || !attr) return ~0u;
43 if (dn && !(dnW = strAtoW( dn ))) goto exit;
44 if (!(attrW = strAtoW( attr ))) goto exit;
45 if (value && !(valueW = strAtoW( value ))) goto exit;
47 ret = ldap_compareW( ld, dnW, attrW, valueW );
49 exit:
50 free( dnW );
51 free( attrW );
52 free( valueW );
53 return ret;
56 /***********************************************************************
57 * ldap_compareW (WLDAP32.@)
59 ULONG CDECL ldap_compareW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value )
61 ULONG msg, ret;
63 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(attr), debugstr_w(value) );
65 ret = ldap_compare_extW( ld, dn, attr, value, NULL, NULL, NULL, &msg );
66 if (ret == WLDAP32_LDAP_SUCCESS) return msg;
67 return ~0u;
70 /***********************************************************************
71 * ldap_compare_extA (WLDAP32.@)
73 ULONG CDECL ldap_compare_extA( LDAP *ld, char *dn, char *attr, char *value, struct WLDAP32_berval *data,
74 LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG *message )
76 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
77 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
78 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
80 TRACE( "(%p, %s, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_a(dn), debugstr_a(attr), debugstr_a(value),
81 data, serverctrls, clientctrls, message );
83 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
84 if (!attr) return WLDAP32_LDAP_NO_MEMORY;
86 if (dn && !(dnW = strAtoW( dn ))) goto exit;
87 if (!(attrW = strAtoW( attr ))) goto exit;
88 if (value && !(valueW = strAtoW( value ))) goto exit;
89 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
90 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
92 ret = ldap_compare_extW( ld, dnW, attrW, valueW, data, serverctrlsW, clientctrlsW, message );
94 exit:
95 free( dnW );
96 free( attrW );
97 free( valueW );
98 controlarrayfreeW( serverctrlsW );
99 controlarrayfreeW( clientctrlsW );
100 return ret;
103 /***********************************************************************
104 * ldap_compare_extW (WLDAP32.@)
106 ULONG CDECL ldap_compare_extW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value, struct WLDAP32_berval *data,
107 LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG *message )
109 ULONG ret;
110 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
111 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
112 struct berval *dataU = NULL, val = { 0, NULL };
114 TRACE( "(%p, %s, %s, %s, %p, %p, %p, %p)\n", ld, debugstr_w(dn), debugstr_w(attr), debugstr_w(value),
115 data, serverctrls, clientctrls, message );
117 if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
118 if (!attr) return WLDAP32_LDAP_NO_MEMORY;
119 if ((ret = WLDAP32_ldap_connect( ld, NULL ))) return ret;
121 ret = WLDAP32_LDAP_NO_MEMORY;
122 if (!(dnU = dn ? strWtoU( dn ) : strdup( "" ))) goto exit;
123 if (!(attrU = strWtoU( attr ))) goto exit;
124 if (!data)
126 if (value)
128 if (!(valueU = strWtoU( value ))) goto exit;
129 val.bv_len = strlen( valueU );
130 val.bv_val = valueU;
133 else if (!(dataU = bervalWtoU( data ))) goto exit;
135 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
136 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
137 else
139 ret = map_error( ldap_compare_ext( CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU, clientctrlsU,
140 (int *)message ) );
143 exit:
144 free( dnU );
145 free( attrU );
146 free( valueU );
147 free( dataU );
148 controlarrayfreeU( serverctrlsU );
149 controlarrayfreeU( clientctrlsU );
150 return ret;
153 /***********************************************************************
154 * ldap_compare_ext_sA (WLDAP32.@)
156 ULONG CDECL ldap_compare_ext_sA( LDAP *ld, char *dn, char *attr, char *value, struct WLDAP32_berval *data,
157 LDAPControlA **serverctrls, LDAPControlA **clientctrls )
159 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
160 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
161 LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
163 TRACE( "(%p, %s, %s, %s, %p, %p, %p)\n", ld, debugstr_a(dn), debugstr_a(attr), debugstr_a(value),
164 data, serverctrls, clientctrls );
166 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
167 if (!attr) return LDAP_UNDEFINED_TYPE;
169 if (dn && !(dnW = strAtoW( dn ))) goto exit;
170 if (!(attrW = strAtoW( attr ))) goto exit;
171 if (value && !(valueW = strAtoW( value ))) goto exit;
172 if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
173 if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
175 ret = ldap_compare_ext_sW( ld, dnW, attrW, valueW, data, serverctrlsW, clientctrlsW );
177 exit:
178 free( dnW );
179 free( attrW );
180 free( valueW );
181 controlarrayfreeW( serverctrlsW );
182 controlarrayfreeW( clientctrlsW );
183 return ret;
186 /***********************************************************************
187 * ldap_compare_ext_sW (WLDAP32.@)
189 ULONG CDECL ldap_compare_ext_sW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value, struct WLDAP32_berval *data,
190 LDAPControlW **serverctrls, LDAPControlW **clientctrls )
192 ULONG ret;
193 char *dnU = NULL, *attrU = NULL, *valueU = NULL;
194 LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
195 struct berval *dataU = NULL, val = { 0, NULL };
197 TRACE( "(%p, %s, %s, %s, %p, %p, %p)\n", ld, debugstr_w(dn), debugstr_w(attr), debugstr_w(value), data,
198 serverctrls, clientctrls );
200 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
201 if (!attr) return LDAP_UNDEFINED_TYPE;
202 if ((ret = WLDAP32_ldap_connect( ld, NULL ))) return ret;
204 ret = WLDAP32_LDAP_NO_MEMORY;
205 if (!(dnU = dn ? strWtoU( dn ) : strdup( "" ))) goto exit;
206 if (!(attrU = strWtoU( attr ))) goto exit;
207 if (!data)
209 if (value)
211 if (!(valueU = strWtoU( value ))) goto exit;
212 val.bv_len = strlen( valueU );
213 val.bv_val = valueU;
216 else if (!(dataU = bervalWtoU( data ))) goto exit;
218 if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
219 if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
220 else
222 ret = map_error( ldap_compare_ext_s( CTX(ld), dnU, attrU, dataU ? dataU : &val, serverctrlsU, clientctrlsU ) );
224 exit:
225 free( dnU );
226 free( attrU );
227 free( valueU );
228 free( dataU );
229 controlarrayfreeU( serverctrlsU );
230 controlarrayfreeU( clientctrlsU );
231 return ret;
234 /***********************************************************************
235 * ldap_compare_sA (WLDAP32.@)
237 ULONG CDECL ldap_compare_sA( LDAP *ld, PCHAR dn, PCHAR attr, PCHAR value )
239 ULONG ret = WLDAP32_LDAP_NO_MEMORY;
240 WCHAR *dnW = NULL, *attrW = NULL, *valueW = NULL;
242 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_a(dn), debugstr_a(attr), debugstr_a(value) );
244 if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
245 if (!attr) return WLDAP32_LDAP_UNDEFINED_TYPE;
247 if (dn && !(dnW = strAtoW( dn ))) goto exit;
248 if (!(attrW = strAtoW( attr ))) goto exit;
249 if (value && !(valueW = strAtoW( value ))) goto exit;
251 ret = ldap_compare_sW( ld, dnW, attrW, valueW );
253 exit:
254 free( dnW );
255 free( attrW );
256 free( valueW );
257 return ret;
260 /***********************************************************************
261 * ldap_compare_sW (WLDAP32.@)
263 ULONG CDECL ldap_compare_sW( LDAP *ld, WCHAR *dn, WCHAR *attr, WCHAR *value )
265 TRACE( "(%p, %s, %s, %s)\n", ld, debugstr_w(dn), debugstr_w(attr), debugstr_w(value) );
266 return ldap_compare_ext_sW( ld, dn, attr, value, NULL, NULL, NULL );