KLDAP Library
w32-ldap-help.h
00001 /* w32-ldap-help.h - Map utf8 based API into a wchar_t API. 00002 00003 Copyright (c) 2010 Andre Heinecke <aheinecke@intevation.de> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef W32_LDAP_HELP_H 00022 #define W32_LDAP_HELP_H 00023 00024 #include <windows.h> 00025 #ifdef UNICODE 00026 # undef UNICODE 00027 # include <winldap.h> 00028 # include <winber.h> 00029 # define UNICODE 00030 #else 00031 # include <winldap.h> 00032 # include <winber.h> 00033 #endif // UNICODE 00034 00035 /* 00036 * From the openldap manpage: 00037 * ber_len_t is an unsigned integer of at least 32 bits used to represent 00038 * a length. It is commonly equivalent to a size_t. ber_slen_t is the 00039 * signed variant to ber_len_t. 00040 */ 00041 typedef ULONG ber_len_t; 00042 00043 #ifndef timeval 00044 #define timeval l_timeval 00045 #endif 00046 00047 #ifdef _WIN32_WCE 00048 #include "wce-ldap-help.h" 00049 #endif 00050 00051 /* Redirect used ldap functions to functions with win_ prefix 00052 * to further redirect those depending on the Windows Flavour */ 00053 //#define ldap_err2string(a) win_ldap_err2string(a) 00054 #define ldap_init(a,b) win_ldap_init(a,b) 00055 #define ldap_sasl_bind(a, b, c, d, e, f, g) \ 00056 win_ldap_sasl_bind(a, b, c, d, e, f, g) 00057 #define ldap_sasl_bind_s(a, b, c, d, e, f, g) \ 00058 win_ldap_sasl_bind_s(a, b, c, d, e, f, g) 00059 #define ldap_parse_sasl_bind_result ( a, b, c, d, e ) \ 00060 win_ldap_parse_sasl_bind_result((a), (b), (c), (d), (e)) 00061 #define ldap_get_dn(a, b) win_ldap_get_dn(a,b) 00062 #define ldap_memfree(a) win_ldap_memfree(a) 00063 #define ldap_mods_free(a, b) win_ldap_mods_free(a, b) 00064 #define ldap_first_attribute(a, b, c) \ 00065 win_ldap_first_attribute(a, b, c) 00066 #define ldap_get_values_len(a, b, c) \ 00067 win_ldap_get_values_len(a, b, c) 00068 #define ldap_next_attribute(a, b, c ) \ 00069 win_ldap_next_attribute(a, b, c) 00070 #define ldap_parse_result(a, b, c, d, e, f, g, h) \ 00071 win_ldap_parse_result(a, b, c, d, e, f, g, h) 00072 #define ldap_parse_extended_result(a, b, c, d, e) \ 00073 win_ldap_parse_extended_result(a, b, c, d, e) 00074 #define ldap_add_ext(a, b, c, d, e, f) \ 00075 win_ldap_add_ext((a), (b), (c), (d), (e), (f)) 00076 #define ldap_add_ext_s(a, b, c, d, e) \ 00077 win_ldap_add_ext_s((a), (b), (c), (d), (e)) 00078 # define ldap_compare_ext_s(a, b, c, d, e, f) \ 00079 win_ldap_compare_ext_s((a), (b), (c), (d), (e), (f)) 00080 # define ldap_compare_ext(a, b, c, d, e, f, g) \ 00081 win_ldap_compare_ext((a), (b), (c), (d), (e), (f), (g)) 00082 # define ldap_modify_ext_s(a, b, c, d, e ) \ 00083 win_ldap_modify_ext_s((a), (b), (c), (d), (e)) 00084 # define ldap_search_ext(a, b, c, d, e, f, g, h, i, j, k) \ 00085 win_ldap_search_ext((a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k)) 00086 #define ldap_rename_ext( a, b, c, d, e, f, g, h ) \ 00087 win_ldap_rename_ext((a), (b), (c), (d), (e), (f), (g), (h) ) 00088 #define ldap_rename( a, b, c, d, e, f, g, h ) \ 00089 ldap_rename_ext((a), (b), (c), (d), (e), (f), (g), (h) ) 00090 #define ldap_delete_ext(a, b, c, d, e ) \ 00091 win_ldap_delete_ext((a), (b), (c), (d), (e) ) 00092 #define ldap_modify_ext(a, b, c, d, e, f ) \ 00093 win_ldap_modify_ext( (a), (b), (c), (d), (e), (f)) 00094 #define ldap_abandon_ext(a, b, c, d) \ 00095 win_ldap_abandon_ext((a), (b), (c), (d)) 00096 #define ldap_controls_free(a) win_ldap_controls_free(a) 00097 00098 // Use the functions that are available on the platform 00099 // or redirect to wrapper functions 00100 #ifdef _WIN32_WCE 00101 # define win_ldap_init(a,b) \ 00102 my_win_ldap_initA ((a), (b)) 00103 # define win_ldap_simple_bind_s(a,b,c) \ 00104 my_win_ldap_simple_bind_sA ((a),(b),(c)) 00105 /* Contrary to documentation the sasl_bind functions 00106 * are not availabe for wince 00107 00108 # define win_ldap_sasl_bind(a, b, c, d, e, f, g) \ 00109 ldap_sasl_bindA(a, b, c, d, e, f, g) 00110 # define win_ldap_sasl_bind_result ( a, b, c, d, e ) \ 00111 my_win_ldap_sasl_bind_result (((a), (b), (c), (d), (e)) 00112 # define win_ldap_sasl_bind_s(a, b, c, d, e, f, g) \ 00113 ldap_sasl_bind_s(a, b, c, d, e, f, g)*/ 00114 # define win_ldap_search_st(a,b,c,d,e,f,g,h) \ 00115 my_win_ldap_search_stA ((a), (b), (c), (d), (e), (f), (g), (h)) 00116 # define win_ldap_first_attribute(a,b,c) \ 00117 my_win_ldap_first_attributeA ((a),(b),(c)) 00118 # define win_ldap_next_attribute(a,b,c) \ 00119 my_win_ldap_next_attributeA ((a),(b),(c)) 00120 # define win_ldap_get_values_len(a,b,c) \ 00121 my_win_ldap_get_values_lenA ((a),(b),(c)) 00122 # define win_ldap_get_dn(a,b) \ 00123 my_win_ldap_get_dnA((a),(b)) 00124 # define win_ldap_parse_extended_result(a, b, c, d, e ) \ 00125 my_win_ldap_parse_extended_resultA((a), (b), (c), (d), (e)) 00126 # define win_ldap_memfree(a) free(a) 00127 # define win_ldap_controls_free(a) \ 00128 my_win_ldap_controls_freeA((a)) 00129 # define win_ldap_mods_free(a, b) \ 00130 my_win_ldap_mods_freeA((a), (b)) 00131 # define win_ldap_parse_result(a, b, c, d, e, f, g, h ) \ 00132 my_win_ldap_parse_resultA((a), (b), ((ulong *) c), (d), (e), (f), (g), (h)) 00133 # define win_ldap_search_ext(a, b, c, d, e, f, g, h, i, j, k) \ 00134 my_win_ldap_search_extA((a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k)) 00135 # define win_ldap_add_ext_s(a, b, c, d, e) \ 00136 my_win_ldap_add_ext_sA((a), (b), (c), (d), (e)) 00137 # define win_ldap_add_ext(a, b, c, d, e, f) \ 00138 my_win_ldap_add_extA((a), (b), (c), (d), (e), ( (ulong * ) f)) 00139 #define win_ldap_rename_ext( a, b, c, d, e, f, g, h ) \ 00140 ldap_rename_extA((a), (b), (c), (d), (e), (f), (g), ( ( ulong * ) h) ) 00141 #define win_ldap_delete_ext( a, b, c, d, e ) \ 00142 ldap_delete_extA((a), (b), (c), (d), ( ( ulong* ) e) ) 00143 #define win_ldap_modify_ext( a, b, c, d, e, f ) \ 00144 ldap_modify_extA( (a), (b), (c), (d), (e), ( ( ulong * ) f) ) 00145 #define win_ldap_modify_ext_s( a, b, c, d, e ) \ 00146 ldap_modify_ext_sA( (a), (b), (c), (d), (e) ) 00147 # define win_ldap_compare_ext(a, b, c, d, e, f, g) \ 00148 my_win_ldap_compare_extA((a), (b), (c), NULL, (d), (e), (f), ( ( ulong* ) g)) 00149 #define win_ldap_compare_ext_s(a, b, c, d, e, f) \ 00150 my_win_ldap_compare_ext_sA( (a), (b), (c), NULL, (d), (e), (f) ) 00151 #define win_ldap_abandon_ext(a, b, c, d) \ 00152 ldap_abandon((a), (b)) 00153 #else 00154 /* Windows offers ASCII variants of most LDAP functions 00155 * we only have to ensure that those are used */ 00156 # define LDAPControl LDAPControlA 00157 # define LDAPMod LDAPModA 00158 # define win_ldap_init(a,b) ldap_initA ((a), (b)) 00159 # define win_ldap_simple_bind_s(a,b,c) ldap_simple_bind_sA ((a), (b), (c)) 00160 # define win_ldap_sasl_bind(a, b, c, d, e, f, g) \ 00161 ldap_sasl_bindA(a, b, c, d, e, f, g) 00162 # define win_ldap_sasl_bind_s(a, b, c, d, e, f, g) \ 00163 ldap_sasl_bind_sA(a, b, c, d, e, f, g) 00164 # define win_ldap_search_st(a,b,c,d,e,f,g,h) \ 00165 ldap_search_stA ((a), (b), (c), (d), (e), (f), (g), (h)) 00166 # define win_ldap_search_ext(a, b, c, d, e, f, g, h, i, j, k) \ 00167 my_win_ldap_search_ext((a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k)) 00168 # define win_ldap_get_dn(a, b) ldap_get_dnA((a), (b)) 00169 # define win_ldap_first_attribute(a,b,c) ldap_first_attributeA ((a), (b), (c)) 00170 # define win_ldap_next_attribute(a,b,c) ldap_next_attributeA ((a), (b), (c)) 00171 # define win_ldap_get_values_len(a,b,c) ldap_get_values_lenA ((a), (b), (c)) 00172 # define win_ldap_memfree(a) ldap_memfreeA ((a)) 00173 # define win_ldap_err2string(a) ldap_err2stringA((a)) 00174 # define win_ldap_controls_free(a) ldap_controls_freeA((a)) 00175 # define win_ldap_mods_free(a, b) ldap_mods_freeA((a), (b)) 00176 # define win_ldap_add_ext(a, b, c, d, e, f) \ 00177 ldap_add_extA((a), (b), (c), (d), (e), ((ulong*)f)) 00178 # define win_ldap_add_ext_s(a, b, c, d, e) \ 00179 ldap_add_ext_sA((a), (b), (c), (d), (e)) 00180 # define win_ldap_parse_extended_result(a, b, c, d, e ) \ 00181 ldap_parse_extended_resultA((*a), (b), (c), (d), (e)) 00182 # define win_ldap_parse_result(a, b, c, d, e, f, g, h ) \ 00183 ldap_parse_resultA((a), (b), ((ulong *)c), (d), (e), (f), (g), (h)) 00184 # define win_ldap_modify_ext_s(a, b, c, d, e ) \ 00185 ldap_modify_ext_sW((a), (b), (c), (d), (e)) 00186 # define win_ldap_compare_ext_s(a, b, c, d, e, f ) \ 00187 ldap_compare_ext_sA((a), (b), (c), (d), (e), (f)) 00188 #endif /*_WIN32_WCE*/ 00189 #endif /*W32_LDAP_HELP_H*/