wined3d: Remove fake nvidia card in GetAdapterIdentifier.
[wine/dibdrv.git] / dlls / wldap32 / control.c
blobc7b84233670f6c334942614e0eeb33dbfd519de0
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_control_freeA (WLDAP32.@)
47 * See ldap_control_freeW.
49 ULONG CDECL ldap_control_freeA( LDAPControlA *control )
51 ULONG ret = LDAP_SUCCESS;
52 #ifdef HAVE_LDAP
54 TRACE( "(%p)\n", control );
55 controlfreeA( control );
57 #endif
58 return ret;
61 /***********************************************************************
62 * ldap_control_freeW (WLDAP32.@)
64 * Free an LDAPControl structure.
66 * PARAMS
67 * control [I] LDAPControl structure to free.
69 * RETURNS
70 * LDAP_SUCCESS
72 ULONG CDECL ldap_control_freeW( LDAPControlW *control )
74 ULONG ret = LDAP_SUCCESS;
75 #ifdef HAVE_LDAP
77 TRACE( "(%p)\n", control );
78 controlfreeW( control );
80 #endif
81 return ret;
84 /***********************************************************************
85 * ldap_controls_freeA (WLDAP32.@)
87 * See ldap_controls_freeW.
89 ULONG CDECL ldap_controls_freeA( LDAPControlA **controls )
91 ULONG ret = LDAP_SUCCESS;
92 #ifdef HAVE_LDAP
94 TRACE( "(%p)\n", controls );
95 controlarrayfreeA( controls );
97 #endif
98 return ret;
101 /***********************************************************************
102 * ldap_controls_freeW (WLDAP32.@)
104 * Free an array of LDAPControl structures.
106 * PARAMS
107 * controls [I] Array of LDAPControl structures to free.
109 * RETURNS
110 * LDAP_SUCCESS
112 ULONG CDECL ldap_controls_freeW( LDAPControlW **controls )
114 ULONG ret = LDAP_SUCCESS;
115 #ifdef HAVE_LDAP
117 TRACE( "(%p)\n", controls );
118 controlarrayfreeW( controls );
120 #endif
121 return ret;
124 /***********************************************************************
125 * ldap_create_sort_controlA (WLDAP32.@)
127 * See ldap_create_sort_controlW.
129 ULONG CDECL ldap_create_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkey,
130 UCHAR critical, PLDAPControlA *control )
132 ULONG ret = LDAP_NOT_SUPPORTED;
133 #ifdef HAVE_LDAP
134 LDAPSortKeyW **sortkeyW = NULL;
135 LDAPControlW *controlW = NULL;
137 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
139 if (!ld || !sortkey || !control)
140 return WLDAP32_LDAP_PARAM_ERROR;
142 sortkeyW = sortkeyarrayAtoW( sortkey );
143 if (!sortkeyW) return WLDAP32_LDAP_NO_MEMORY;
145 ret = ldap_create_sort_controlW( ld, sortkeyW, critical, &controlW );
147 *control = controlWtoA( controlW );
148 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
150 ldap_control_freeW( controlW );
151 sortkeyarrayfreeW( sortkeyW );
153 #endif
154 return ret;
157 /***********************************************************************
158 * ldap_create_sort_controlW (WLDAP32.@)
160 * Create a control for server sorted search results.
162 * PARAMS
163 * ld [I] Pointer to an LDAP context.
164 * sortkey [I] Array of LDAPSortKey structures, each specifying an
165 * attribute to use as a sort key, a matching rule and
166 * the sort order (ascending or descending).
167 * critical [I] Tells the server this control is critical to the
168 * search operation.
169 * control [O] LDAPControl created.
171 * RETURNS
172 * Success: LDAP_SUCCESS
173 * Failure: An LDAP error code.
175 * NOTES
176 * Pass the created control as a server control in subsequent calls
177 * to ldap_search_ext(_s) to obtain sorted search results.
179 ULONG CDECL ldap_create_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkey,
180 UCHAR critical, PLDAPControlW *control )
182 ULONG ret = LDAP_NOT_SUPPORTED;
183 #ifdef HAVE_LDAP
184 LDAPSortKey **sortkeyU = NULL;
185 LDAPControl *controlU = NULL;
187 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, sortkey, critical, control );
189 if (!ld || !sortkey || !control)
190 return WLDAP32_LDAP_PARAM_ERROR;
192 sortkeyU = sortkeyarrayWtoU( sortkey );
193 if (!sortkeyU) return WLDAP32_LDAP_NO_MEMORY;
195 ret = ldap_create_sort_control( ld, sortkeyU, critical, &controlU );
197 *control = controlUtoW( controlU );
198 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
200 ldap_control_free( controlU );
201 sortkeyarrayfreeU( sortkeyU );
203 #endif
204 return ret;
207 /***********************************************************************
208 * ldap_create_vlv_controlA (WLDAP32.@)
210 * See ldap_create_vlv_controlW.
212 INT CDECL ldap_create_vlv_controlA( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
213 UCHAR critical, LDAPControlA **control )
215 INT ret = LDAP_NOT_SUPPORTED;
216 #ifdef HAVE_LDAP
217 LDAPControlW *controlW = NULL;
219 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
221 if (!ld || !control) return ~0UL;
223 ret = ldap_create_vlv_controlW( ld, info, critical, &controlW );
225 if (ret == LDAP_SUCCESS)
227 *control = controlWtoA( controlW );
228 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
229 ldap_control_freeW( controlW );
232 #endif
233 return ret;
236 /***********************************************************************
237 * ldap_create_vlv_controlW (WLDAP32.@)
239 * Create a virtual list view control.
241 * PARAMS
242 * ld [I] Pointer to an LDAP context.
243 * info [I] LDAPVLVInfo structure specifying a list view window.
244 * critical [I] Tells the server this control is critical to the
245 * search operation.
246 * control [O] LDAPControl created.
248 * RETURNS
249 * Success: LDAP_SUCCESS
250 * Failure: An LDAP error code.
252 * NOTES
253 * Pass the created control in conjuction with a sort control as
254 * server controls in subsequent calls to ldap_search_ext(_s). The
255 * server will then return a sorted, contiguous subset of results
256 * that meets the criteria specified in the LDAPVLVInfo structure.
258 INT CDECL ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
259 UCHAR critical, LDAPControlW **control )
261 INT ret = LDAP_NOT_SUPPORTED;
262 #ifdef HAVE_LDAP
263 LDAPControl *controlU = NULL;
265 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
267 if (!ld || !control) return ~0UL;
269 ret = ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, &controlU );
271 if (ret == LDAP_SUCCESS)
273 *control = controlUtoW( controlU );
274 if (!*control) ret = WLDAP32_LDAP_NO_MEMORY;
275 ldap_control_free( controlU );
278 #endif
279 return ret;
282 /***********************************************************************
283 * ldap_encode_sort_controlA (WLDAP32.@)
285 * See ldap_encode_sort_controlW.
287 ULONG CDECL ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys,
288 PLDAPControlA control, BOOLEAN critical )
290 return ldap_create_sort_controlA( ld, sortkeys, critical, &control );
293 /***********************************************************************
294 * ldap_encode_sort_controlW (WLDAP32.@)
296 * Create a control for server sorted search results.
298 * PARAMS
299 * ld [I] Pointer to an LDAP context.
300 * sortkey [I] Array of LDAPSortKey structures, each specifying an
301 * attribute to use as a sort key, a matching rule and
302 * the sort order (ascending or descending).
303 * critical [I] Tells the server this control is critical to the
304 * search operation.
305 * control [O] LDAPControl created.
307 * RETURNS
308 * Success: LDAP_SUCCESS
309 * Failure: An LDAP error code.
311 * NOTES
312 * This function is obsolete. Use its equivalent
313 * ldap_create_sort_control instead.
315 ULONG CDECL ldap_encode_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkeys,
316 PLDAPControlW control, BOOLEAN critical )
318 return ldap_create_sort_controlW( ld, sortkeys, critical, &control );
321 /***********************************************************************
322 * ldap_free_controlsA (WLDAP32.@)
324 * See ldap_free_controlsW.
326 ULONG CDECL ldap_free_controlsA( LDAPControlA **controls )
328 return ldap_controls_freeA( controls );
331 /***********************************************************************
332 * ldap_free_controlsW (WLDAP32.@)
334 * Free an array of LDAPControl structures.
336 * PARAMS
337 * controls [I] Array of LDAPControl structures to free.
339 * RETURNS
340 * LDAP_SUCCESS
342 * NOTES
343 * Obsolete, use ldap_controls_freeW.
345 ULONG CDECL ldap_free_controlsW( LDAPControlW **controls )
347 return ldap_controls_freeW( controls );