user: Tests for when the menu is incorrect because of duplication of a
[wine/multimedia.git] / dlls / wldap32 / control.c
blob5c4b41342aa8b97dcc0dfad2bd6a7a882ee83171
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 /***********************************************************************
45 * ldap_control_freeA (WLDAP32.@)
47 * See ldap_control_freeW.
49 ULONG 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 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 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 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 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 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 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) return ~0UL;
223 ret = ldap_create_vlv_controlW( ld, info, critical, controlW );
225 *control = controlWtoA( *controlW );
226 ldap_control_freeW( *controlW );
228 #endif
229 return ret;
232 /***********************************************************************
233 * ldap_create_vlv_controlW (WLDAP32.@)
235 * Create a virtual list view control.
237 * PARAMS
238 * ld [I] Pointer to an LDAP context.
239 * info [I] LDAPVLVInfo structure specifying a list view window.
240 * critical [I] Tells the server this control is critical to the
241 * search operation.
242 * control [O] LDAPControl created.
244 * RETURNS
245 * Success: LDAP_SUCCESS
246 * Failure: An LDAP error code.
248 * NOTES
249 * Pass the created control in conjuction with a sort control as
250 * server controls in subsequent calls to ldap_search_ext(_s). The
251 * server will then return a sorted, contiguous subset of results
252 * that meets the criteria specified in the LDAPVLVInfo structure.
254 INT ldap_create_vlv_controlW( WLDAP32_LDAP *ld, WLDAP32_LDAPVLVInfo *info,
255 UCHAR critical, LDAPControlW **control )
257 INT ret = LDAP_NOT_SUPPORTED;
258 #ifdef HAVE_LDAP
259 LDAPControl **controlU = NULL;
261 TRACE( "(%p, %p, 0x%02x, %p)\n", ld, info, critical, control );
263 if (!ld) return ~0UL;
265 ret = ldap_create_vlv_control( ld, (LDAPVLVInfo *)info, controlU );
267 *control = controlUtoW( *controlU );
268 ldap_control_free( *controlU );
270 #endif
271 return ret;
274 /***********************************************************************
275 * ldap_encode_sort_controlA (WLDAP32.@)
277 * See ldap_encode_sort_controlW.
279 ULONG ldap_encode_sort_controlA( WLDAP32_LDAP *ld, PLDAPSortKeyA *sortkeys,
280 PLDAPControlA control, BOOLEAN critical )
282 return ldap_create_sort_controlA( ld, sortkeys, critical, &control );
285 /***********************************************************************
286 * ldap_encode_sort_controlW (WLDAP32.@)
288 * Create a control for server sorted search results.
290 * PARAMS
291 * ld [I] Pointer to an LDAP context.
292 * sortkey [I] Array of LDAPSortKey structures, each specifying an
293 * attribute to use as a sort key, a matching rule and
294 * the sort order (ascending or descending).
295 * critical [I] Tells the server this control is critical to the
296 * search operation.
297 * control [O] LDAPControl created.
299 * RETURNS
300 * Success: LDAP_SUCCESS
301 * Failure: An LDAP error code.
303 * NOTES
304 * This function is obsolete. Use its equivalent
305 * ldap_create_sort_control instead.
307 ULONG ldap_encode_sort_controlW( WLDAP32_LDAP *ld, PLDAPSortKeyW *sortkeys,
308 PLDAPControlW control, BOOLEAN critical )
310 return ldap_create_sort_controlW( ld, sortkeys, critical, &control );
313 /***********************************************************************
314 * ldap_free_controlsA (WLDAP32.@)
316 * See ldap_free_controlsW.
318 ULONG ldap_free_controlsA( LDAPControlA **controls )
320 return ldap_controls_freeA( controls );
323 /***********************************************************************
324 * ldap_free_controlsW (WLDAP32.@)
326 * Free an array of LDAPControl structures.
328 * PARAMS
329 * controls [I] Array of LDAPControl structures to free.
331 * RETURNS
332 * LDAP_SUCCESS
334 * NOTES
335 * Obsolete, use ldap_controls_freeW.
337 ULONG ldap_free_controlsW( LDAPControlW **controls )
339 return ldap_controls_freeW( controls );