File indexing completed on 2024-06-02 05:24:05

0001 // krazy:excludeall=style
0002 /* w32-ldap-help.h - Map utf8 based API into a wchar_t API.
0003 
0004   SPDX-FileCopyrightText: 2010 Andre Heinecke <aheinecke@intevation.de>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007  */
0008 
0009 #pragma once
0010 
0011 #include <windows.h>
0012 #ifdef UNICODE
0013 #undef UNICODE
0014 #include <winber.h>
0015 #include <winldap.h>
0016 #define UNICODE
0017 #else
0018 #include <winber.h>
0019 #include <winldap.h>
0020 #endif // UNICODE
0021 
0022 /*
0023  * From the openldap manpage:
0024  * ber_len_t  is an unsigned integer of at least 32 bits used to represent
0025  * a length.  It is commonly equivalent to a size_t.   ber_slen_t  is  the
0026  *  signed variant to ber_len_t.
0027  */
0028 typedef ULONG ber_len_t;
0029 
0030 #ifndef timeval
0031 #define timeval l_timeval
0032 #endif
0033 
0034 /* Redirect used ldap functions to functions with win_ prefix
0035  * to further redirect those depending on the Windows Flavour */
0036 // #define ldap_err2string(a) win_ldap_err2string(a)
0037 #define ldap_init(a, b) win_ldap_init(a, b)
0038 #define ldap_sasl_bind(a, b, c, d, e, f, g) win_ldap_sasl_bind(a, b, c, d, e, f, g)
0039 #define ldap_sasl_bind_s(a, b, c, d, e, f, g) win_ldap_sasl_bind_s(a, b, c, d, e, f, g)
0040 #define ldap_parse_sasl_bind_result (a, b, c, d, e) win_ldap_parse_sasl_bind_result((a), (b), (c), (d), (e))
0041 #define ldap_get_dn(a, b) win_ldap_get_dn(a, b)
0042 #define ldap_memfree(a) win_ldap_memfree(a)
0043 #define ldap_mods_free(a, b) win_ldap_mods_free(a, b)
0044 #define ldap_first_attribute(a, b, c) win_ldap_first_attribute(a, b, c)
0045 #define ldap_get_values_len(a, b, c) win_ldap_get_values_len(a, b, c)
0046 #define ldap_next_attribute(a, b, c) win_ldap_next_attribute(a, b, c)
0047 #define ldap_parse_result(a, b, c, d, e, f, g, h) win_ldap_parse_result(a, b, c, d, e, f, g, h)
0048 #define ldap_parse_extended_result(a, b, c, d, e) win_ldap_parse_extended_result(a, b, c, d, e)
0049 #define ldap_add_ext(a, b, c, d, e, f) win_ldap_add_ext((a), (b), (c), (d), (e), (f))
0050 #define ldap_add_ext_s(a, b, c, d, e) win_ldap_add_ext_s((a), (b), (c), (d), (e))
0051 #define ldap_compare_ext_s(a, b, c, d, e, f) win_ldap_compare_ext_s((a), (b), (c), (d), (e), (f))
0052 #define ldap_compare_ext(a, b, c, d, e, f, g) win_ldap_compare_ext((a), (b), (c), (d), (e), (f), (g))
0053 #define ldap_modify_ext_s(a, b, c, d, e) win_ldap_modify_ext_s((a), (b), (c), (d), (e))
0054 #define ldap_search_ext(a, b, c, d, e, f, g, h, i, j, k) win_ldap_search_ext((a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k))
0055 #define ldap_rename_ext(a, b, c, d, e, f, g, h) win_ldap_rename_ext((a), (b), (c), (d), (e), (f), (g), (h))
0056 #define ldap_rename(a, b, c, d, e, f, g, h) ldap_rename_ext((a), (b), (c), (d), (e), (f), (g), (h))
0057 #define ldap_delete_ext(a, b, c, d, e) win_ldap_delete_ext((a), (b), (c), (d), (e))
0058 #define ldap_modify_ext(a, b, c, d, e, f) win_ldap_modify_ext((a), (b), (c), (d), (e), (f))
0059 #define ldap_abandon_ext(a, b, c, d) win_ldap_abandon_ext((a), (b), (c), (d))
0060 #define ldap_controls_free(a) win_ldap_controls_free(a)
0061 
0062 // Use the functions that are available on the platform
0063 // or redirect to wrapper functions
0064 
0065 /* Windows offers ASCII variants of most LDAP functions
0066  * we only have to ensure that those are used */
0067 #define LDAPControl LDAPControlA
0068 #define LDAPMod LDAPModA
0069 #define win_ldap_init(a, b) ldap_initA((a), (b))
0070 #define win_ldap_simple_bind_s(a, b, c) ldap_simple_bind_sA((a), (b), (c))
0071 #define win_ldap_sasl_bind(a, b, c, d, e, f, g) ldap_sasl_bindA(a, b, c, d, e, f, g)
0072 #define win_ldap_sasl_bind_s(a, b, c, d, e, f, g) ldap_sasl_bind_sA(a, b, c, d, e, f, g)
0073 #define win_ldap_search_st(a, b, c, d, e, f, g, h) ldap_search_stA((a), (b), (c), (d), (e), (f), (g), (h))
0074 #define win_ldap_search_ext(a, b, c, d, e, f, g, h, i, j, k) my_win_ldap_search_ext((a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k))
0075 #define win_ldap_get_dn(a, b) ldap_get_dnA((a), (b))
0076 #define win_ldap_first_attribute(a, b, c) ldap_first_attributeA((a), (b), (c))
0077 #define win_ldap_next_attribute(a, b, c) ldap_next_attributeA((a), (b), (c))
0078 #define win_ldap_get_values_len(a, b, c) ldap_get_values_lenA((a), (b), (c))
0079 #define win_ldap_memfree(a) ldap_memfreeA((a))
0080 #define win_ldap_err2string(a) ldap_err2stringA((a))
0081 #define win_ldap_controls_free(a) ldap_controls_freeA((a))
0082 #define win_ldap_mods_free(a, b) ldap_mods_freeA((a), (b))
0083 #define win_ldap_add_ext(a, b, c, d, e, f) ldap_add_extA((a), (b), (c), (d), (e), ((ulong *)f))
0084 #define win_ldap_add_ext_s(a, b, c, d, e) ldap_add_ext_sA((a), (b), (c), (d), (e))
0085 #define win_ldap_parse_extended_result(a, b, c, d, e) ldap_parse_extended_resultA((*a), (b), (c), (d), (e))
0086 #define win_ldap_parse_result(a, b, c, d, e, f, g, h) ldap_parse_resultA((a), (b), ((ulong *)c), (d), (e), (f), (g), (h))
0087 #define win_ldap_modify_ext_s(a, b, c, d, e) ldap_modify_ext_sW((a), (b), (c), (d), (e))
0088 #define win_ldap_compare_ext_s(a, b, c, d, e, f) ldap_compare_ext_sA((a), (b), (c), (d), (e), (f))