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
28 #define LDAP_NEEDS_PROTOTYPES
32 #define WLDAP32_LBER_ERROR (~0l)
35 WLDAP32_LDAP_SUCCESS
= 0x00,
36 WLDAP32_LDAP_OPERATIONS_ERROR
= 0x01,
37 WLDAP32_LDAP_PROTOCOL_ERROR
= 0x02,
38 WLDAP32_LDAP_TIMELIMIT_EXCEEDED
= 0x03,
39 WLDAP32_LDAP_SIZELIMIT_EXCEEDED
= 0x04,
40 WLDAP32_LDAP_COMPARE_FALSE
= 0x05,
41 WLDAP32_LDAP_COMPARE_TRUE
= 0x06,
42 WLDAP32_LDAP_AUTH_METHOD_NOT_SUPPORTED
= 0x07,
43 WLDAP32_LDAP_STRONG_AUTH_REQUIRED
= 0x08,
44 WLDAP32_LDAP_REFERRAL_V2
= 0x09,
45 WLDAP32_LDAP_PARTIAL_RESULTS
= 0x09,
46 WLDAP32_LDAP_REFERRAL
= 0x0a,
47 WLDAP32_LDAP_ADMIN_LIMIT_EXCEEDED
= 0x0b,
48 WLDAP32_LDAP_UNAVAILABLE_CRIT_EXTENSION
= 0x0c,
49 WLDAP32_LDAP_CONFIDENTIALITY_REQUIRED
= 0x0d,
50 WLDAP32_LDAP_SASL_BIND_IN_PROGRESS
= 0x0e,
52 WLDAP32_LDAP_NO_SUCH_ATTRIBUTE
= 0x10,
53 WLDAP32_LDAP_UNDEFINED_TYPE
= 0x11,
54 WLDAP32_LDAP_INAPPROPRIATE_MATCHING
= 0x12,
55 WLDAP32_LDAP_CONSTRAINT_VIOLATION
= 0x13,
56 WLDAP32_LDAP_ATTRIBUTE_OR_VALUE_EXISTS
= 0x14,
57 WLDAP32_LDAP_INVALID_SYNTAX
= 0x15,
59 WLDAP32_LDAP_NO_SUCH_OBJECT
= 0x20,
60 WLDAP32_LDAP_ALIAS_PROBLEM
= 0x21,
61 WLDAP32_LDAP_INVALID_DN_SYNTAX
= 0x22,
62 WLDAP32_LDAP_IS_LEAF
= 0x23,
63 WLDAP32_LDAP_ALIAS_DEREF_PROBLEM
= 0x24,
65 WLDAP32_LDAP_INAPPROPRIATE_AUTH
= 0x30,
66 WLDAP32_LDAP_INVALID_CREDENTIALS
= 0x31,
67 WLDAP32_LDAP_INSUFFICIENT_RIGHTS
= 0x32,
68 WLDAP32_LDAP_BUSY
= 0x33,
69 WLDAP32_LDAP_UNAVAILABLE
= 0x34,
70 WLDAP32_LDAP_UNWILLING_TO_PERFORM
= 0x35,
71 WLDAP32_LDAP_LOOP_DETECT
= 0x36,
72 WLDAP32_LDAP_SORT_CONTROL_MISSING
= 0x3C,
73 WLDAP32_LDAP_OFFSET_RANGE_ERROR
= 0x3D,
75 WLDAP32_LDAP_NAMING_VIOLATION
= 0x40,
76 WLDAP32_LDAP_OBJECT_CLASS_VIOLATION
= 0x41,
77 WLDAP32_LDAP_NOT_ALLOWED_ON_NONLEAF
= 0x42,
78 WLDAP32_LDAP_NOT_ALLOWED_ON_RDN
= 0x43,
79 WLDAP32_LDAP_ALREADY_EXISTS
= 0x44,
80 WLDAP32_LDAP_NO_OBJECT_CLASS_MODS
= 0x45,
81 WLDAP32_LDAP_RESULTS_TOO_LARGE
= 0x46,
82 WLDAP32_LDAP_AFFECTS_MULTIPLE_DSAS
= 0x47,
84 WLDAP32_LDAP_VIRTUAL_LIST_VIEW_ERROR
= 0x4c,
86 WLDAP32_LDAP_OTHER
= 0x50,
87 WLDAP32_LDAP_SERVER_DOWN
= 0x51,
88 WLDAP32_LDAP_LOCAL_ERROR
= 0x52,
89 WLDAP32_LDAP_ENCODING_ERROR
= 0x53,
90 WLDAP32_LDAP_DECODING_ERROR
= 0x54,
91 WLDAP32_LDAP_TIMEOUT
= 0x55,
92 WLDAP32_LDAP_AUTH_UNKNOWN
= 0x56,
93 WLDAP32_LDAP_FILTER_ERROR
= 0x57,
94 WLDAP32_LDAP_USER_CANCELLED
= 0x58,
95 WLDAP32_LDAP_PARAM_ERROR
= 0x59,
96 WLDAP32_LDAP_NO_MEMORY
= 0x5a,
97 WLDAP32_LDAP_CONNECT_ERROR
= 0x5b,
98 WLDAP32_LDAP_NOT_SUPPORTED
= 0x5c,
99 WLDAP32_LDAP_CONTROL_NOT_FOUND
= 0x5d,
100 WLDAP32_LDAP_NO_RESULTS_RETURNED
= 0x5e,
101 WLDAP32_LDAP_MORE_RESULTS_TO_RETURN
= 0x5f,
103 WLDAP32_LDAP_CLIENT_LOOP
= 0x60,
104 WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED
= 0x61
105 } WLDAP32_LDAP_RETCODE
;
107 #define WLDAP32_LDAP_SCOPE_BASE 0x00
108 #define WLDAP32_LDAP_SCOPE_ONELEVEL 0x01
109 #define WLDAP32_LDAP_SCOPE_SUBTREE 0x02
111 #define WLDAP32_LBER_USE_DER 0x01
113 #define WLDAP32_LDAP_OPT_API_INFO 0x00
114 #define WLDAP32_LDAP_OPT_DESC 0x01
115 #define WLDAP32_LDAP_OPT_DEREF 0x02
116 #define WLDAP32_LDAP_OPT_SIZELIMIT 0x03
117 #define WLDAP32_LDAP_OPT_TIMELIMIT 0x04
118 #define WLDAP32_LDAP_OPT_THREAD_FN_PTRS 0x05
119 #define WLDAP32_LDAP_OPT_REBIND_FN 0x06
120 #define WLDAP32_LDAP_OPT_REBIND_ARG 0x07
121 #define WLDAP32_LDAP_OPT_REFERRALS 0x08
122 #define WLDAP32_LDAP_OPT_RESTART 0x09
123 #define WLDAP32_LDAP_OPT_SSL 0x0a
124 #define WLDAP32_LDAP_OPT_IO_FN_PTRS 0x0b
125 #define WLDAP32_LDAP_OPT_CACHE_FN_PTRS 0x0d
126 #define WLDAP32_LDAP_OPT_CACHE_STRATEGY 0x0e
127 #define WLDAP32_LDAP_OPT_CACHE_ENABLE 0x0f
128 #define WLDAP32_LDAP_OPT_REFERRAL_HOP_LIMIT 0x10
129 #define WLDAP32_LDAP_OPT_PROTOCOL_VERSION 0x11
130 #define WLDAP32_LDAP_OPT_VERSION 0x11
131 #define WLDAP32_LDAP_OPT_SERVER_CONTROLS 0x12
132 #define WLDAP32_LDAP_OPT_API_FEATURE_INFO 0x15
133 #define WLDAP32_LDAP_OPT_HOST_NAME 0x30
134 #define WLDAP32_LDAP_OPT_ERROR_NUMBER 0x31
135 #define WLDAP32_LDAP_OPT_ERROR_STRING 0x32
136 #define WLDAP32_LDAP_OPT_SERVER_ERROR 0x33
137 #define WLDAP32_LDAP_OPT_SERVER_EXT_ERROR 0x34
138 #define WLDAP32_LDAP_OPT_PING_KEEP_ALIVE 0x36
139 #define WLDAP32_LDAP_OPT_PING_WAIT_TIME 0x37
140 #define WLDAP32_LDAP_OPT_PING_LIMIT 0x38
141 #define WLDAP32_LDAP_OPT_DNSDOMAIN_NAME 0x3b
142 #define WLDAP32_LDAP_OPT_GETDSNAME_FLAGS 0x3d
143 #define WLDAP32_LDAP_OPT_HOST_REACHABLE 0x3e
144 #define WLDAP32_LDAP_OPT_PROMPT_CREDENTIALS 0x3f
145 #define WLDAP32_LDAP_OPT_TCP_KEEPALIVE 0x40
146 #define WLDAP32_LDAP_OPT_FAST_CONCURRENT_BIND 0x41
147 #define WLDAP32_LDAP_OPT_SEND_TIMEOUT 0x42
148 #define WLDAP32_LDAP_OPT_REFERRAL_CALLBACK 0x70
149 #define WLDAP32_LDAP_OPT_CLIENT_CERTIFICATE 0x80
150 #define WLDAP32_LDAP_OPT_SERVER_CERTIFICATE 0x81
151 #define WLDAP32_LDAP_OPT_AUTO_RECONNECT 0x91
152 #define WLDAP32_LDAP_OPT_SSPI_FLAGS 0x92
153 #define WLDAP32_LDAP_OPT_SSL_INFO 0x93
154 #define WLDAP32_LDAP_OPT_REF_DEREF_CONN_PER_MSG 0x94
155 #define WLDAP32_LDAP_OPT_TLS LDAP_OPT_SSL
156 #define WLDAP32_LDAP_OPT_TLS_INFO LDAP_OPT_SSL_INFO
157 #define WLDAP32_LDAP_OPT_SIGN 0x95
158 #define WLDAP32_LDAP_OPT_ENCRYPT 0x96
159 #define WLDAP32_LDAP_OPT_SASL_METHOD 0x97
160 #define WLDAP32_LDAP_OPT_AREC_EXCLUSIVE 0x98
161 #define WLDAP32_LDAP_OPT_SECURITY_CONTEXT 0x99
162 #define WLDAP32_LDAP_OPT_ROOTDSE_CACHE 0x9a
164 #define WLDAP32_LDAP_OPT_ON ((void *)1)
165 #define WLDAP32_LDAP_OPT_OFF ((void *)0)
167 #define WLDAP32_LDAP_VERSION1 1
168 #define WLDAP32_LDAP_VERSION2 2
169 #define WLDAP32_LDAP_VERSION3 3
170 #define WLDAP32_LDAP_VERSION WLDAP32_LDAP_VERSION2
172 #define LDAP_CHASE_SUBORDINATE_REFERRALS 0x20
173 #define LDAP_CHASE_EXTERNAL_REFERRALS 0x40
175 #define WLDAP32_LDAP_AUTH_SIMPLE 0x80
176 #define WLDAP32_LDAP_AUTH_SASL 0x83
177 #define WLDAP32_LDAP_AUTH_OTHERKIND 0x86
179 #define WLDAP32_LDAP_AUTH_EXTERNAL (WLDAP32_LDAP_AUTH_OTHERKIND | 0x0020)
180 #define WLDAP32_LDAP_AUTH_SICILY (WLDAP32_LDAP_AUTH_OTHERKIND | 0x0200)
181 #define WLDAP32_LDAP_AUTH_NEGOTIATE (WLDAP32_LDAP_AUTH_OTHERKIND | 0x0400)
182 #define WLDAP32_LDAP_AUTH_MSN (WLDAP32_LDAP_AUTH_OTHERKIND | 0x0800)
183 #define WLDAP32_LDAP_AUTH_NTLM (WLDAP32_LDAP_AUTH_OTHERKIND | 0x1000)
184 #define WLDAP32_LDAP_AUTH_DPA (WLDAP32_LDAP_AUTH_OTHERKIND | 0x2000)
185 #define WLDAP32_LDAP_AUTH_DIGEST (WLDAP32_LDAP_AUTH_OTHERKIND | 0x4000)
187 typedef struct WLDAP32_berval
191 } LDAP_BERVAL
, *PLDAP_BERVAL
, BERVAL
, *PBERVAL
;
193 typedef struct WLDAP32_berelement
196 } WLDAP32_BerElement
;
211 UCHAR ld_lberoptions
;
221 ULONG ld_cldaptimeout
;
222 ULONG ld_refhoplimit
;
226 typedef BOOLEAN (CDECL QUERYCLIENTCERT
)(LDAP
*, SecPkgContext_IssuerListInfoEx
*, const CERT_CONTEXT
**);
227 typedef BOOLEAN (CDECL VERIFYSERVERCERT
)(LDAP
*, const CERT_CONTEXT
**);
232 struct berval
**server_ctrls
;
233 QUERYCLIENTCERT
*client_cert_callback
;
234 VERIFYSERVERCERT
*server_cert_callback
;
237 C_ASSERT(sizeof(struct private_data
) < FIELD_OFFSET(struct ld_sb
, sb_naddr
) - FIELD_OFFSET(struct ld_sb
, Reserved1
));
239 #define CTX(ld) (((struct private_data *)ld->ld_sb.Reserved1)->ctx)
240 #define SERVER_CTRLS(ld) (((struct private_data *)ld->ld_sb.Reserved1)->server_ctrls)
241 #define CLIENT_CERT_CALLBACK(ld) (((struct private_data *)ld->ld_sb.Reserved1)->client_cert_callback)
242 #define SERVER_CERT_CALLBACK(ld) (((struct private_data *)ld->ld_sb.Reserved1)->server_cert_callback)
243 #define CONNECTED(ld) (((struct private_data *)ld->ld_sb.Reserved1)->connected)
245 #define MSG(entry) (entry->Request)
246 #define BER(ber) ((BerElement *)((ber)->opaque))
248 typedef struct l_timeval
252 } LDAP_TIMEVAL
, *PLDAP_TIMEVAL
;
254 #define LDAP_PAGED_RESULT_OID_STRING "1.2.840.113556.1.4.319"
255 #define LDAP_SERVER_RESP_SORT_OID "1.2.840.113556.1.4.474"
256 #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
258 #define LDAP_PAGED_RESULT_OID_STRING_W L"1.2.840.113556.1.4.319"
259 #define LDAP_SERVER_RESP_SORT_OID_W L"1.2.840.113556.1.4.474"
260 #define LDAP_CONTROL_VLVRESPONSE_W L"2.16.840.1.113730.3.4.10"
262 typedef struct ldapcontrolA
265 struct WLDAP32_berval ldctl_value
;
266 BOOLEAN ldctl_iscritical
;
267 } LDAPControlA
, *PLDAPControlA
;
269 typedef struct ldapcontrolW
272 struct WLDAP32_berval ldctl_value
;
273 BOOLEAN ldctl_iscritical
;
274 } LDAPControlW
, *PLDAPControlW
;
276 typedef struct ldapmodA
{
281 struct WLDAP32_berval
**modv_bvals
;
283 } LDAPModA
, *PLDAPModA
;
285 typedef struct ldapmodW
{
289 WCHAR
**modv_strvals
;
290 struct WLDAP32_berval
**modv_bvals
;
292 } LDAPModW
, *PLDAPModW
;
294 typedef struct ldapsortkeyA
297 char *sk_matchruleoid
;
298 BOOLEAN sk_reverseorder
;
299 } LDAPSortKeyA
, *PLDAPSortKeyA
;
301 typedef struct ldapsortkeyW
304 WCHAR
*sk_matchruleoid
;
305 BOOLEAN sk_reverseorder
;
306 } LDAPSortKeyW
, *PLDAPSortKeyW
;
308 typedef struct WLDAP32_ldapvlvinfo
311 ULONG ldvlv_before_count
;
312 ULONG ldvlv_after_count
;
315 BERVAL
*ldvlv_attrvalue
;
316 BERVAL
*ldvlv_context
;
317 void *ldvlv_extradata
;
318 } WLDAP32_LDAPVLVInfo
, *WLDAP32_PLDAPVLVInfo
;
320 typedef struct ldapmsg
325 struct ldapmsg
*lm_chain
;
326 struct ldapmsg
*lm_next
;
335 BOOLEAN ConnectionReferenced
;
336 } WLDAP32_LDAPMessage
, *WLDAP32_PLDAPMessage
;
338 typedef struct ldap_version_info
343 } LDAP_VERSION_INFO
, *PLDAP_VERSION_INFO
;
345 typedef struct ldap_apifeature_infoA
347 int ldapaif_info_version
;
350 } LDAPAPIFeatureInfoA
;
352 typedef struct ldap_apifeature_infoW
354 int ldapaif_info_version
;
357 } LDAPAPIFeatureInfoW
;
359 typedef struct ldapapiinfoA
361 int ldapai_info_version
;
362 int ldapai_api_version
;
363 int ldapai_protocol_version
;
364 char **ldapai_extensions
;
365 char *ldapai_vendor_name
;
366 int ldapai_vendor_version
;
369 typedef struct ldapapiinfoW
371 int ldapai_info_version
;
372 int ldapai_api_version
;
373 int ldapai_protocol_version
;
374 WCHAR
**ldapai_extensions
;
375 WCHAR
*ldapai_vendor_name
;
376 int ldapai_vendor_version
;
379 typedef struct ldapsearch
386 LDAPControlW
**serverctrls
;
387 LDAPControlW
**clientctrls
;
388 struct l_timeval timeout
;
390 struct WLDAP32_berval
*cookie
;
393 void CDECL
WLDAP32_ber_bvecfree( BERVAL
** );
394 void CDECL
WLDAP32_ber_bvfree( BERVAL
* );
395 void CDECL
WLDAP32_ber_free( WLDAP32_BerElement
*, int );
396 WLDAP32_BerElement
* CDECL
WLDAP32_ber_alloc_t( int ) __WINE_DEALLOC(WLDAP32_ber_free
);
397 BERVAL
* CDECL
WLDAP32_ber_bvdup( BERVAL
* ) __WINE_DEALLOC(WLDAP32_ber_bvfree
);
398 ULONG CDECL
WLDAP32_ber_first_element( WLDAP32_BerElement
*, ULONG
*, char ** );
399 int CDECL
WLDAP32_ber_flatten( WLDAP32_BerElement
*, BERVAL
** );
400 WLDAP32_BerElement
* CDECL
WLDAP32_ber_init( BERVAL
* ) __WINE_DEALLOC(WLDAP32_ber_free
);
401 ULONG CDECL
WLDAP32_ber_next_element( WLDAP32_BerElement
*, ULONG
*, char * );
402 ULONG CDECL
WLDAP32_ber_peek_tag( WLDAP32_BerElement
*, ULONG
* );
403 ULONG CDECL
WLDAP32_ber_skip_tag( WLDAP32_BerElement
*, ULONG
* );
404 int WINAPIV
WLDAP32_ber_printf( WLDAP32_BerElement
*, char *, ... );
405 ULONG WINAPIV
WLDAP32_ber_scanf( WLDAP32_BerElement
*, char *, ... );
407 void CDECL
ldap_memfreeA( char * );
408 void CDECL
ldap_memfreeW( WCHAR
* );
409 ULONG CDECL
ldap_value_freeA( char ** );
410 ULONG CDECL
ldap_value_freeW( WCHAR
** );
411 ULONG CDECL
WLDAP32_ldap_msgfree( WLDAP32_LDAPMessage
* );
412 ULONG CDECL
WLDAP32_ldap_value_free_len(struct WLDAP32_berval
**);
413 ULONG CDECL
ldap_addA( LDAP
*, char *, LDAPModA
** );
414 ULONG CDECL
ldap_addW( LDAP
*, WCHAR
*, LDAPModW
** );
415 ULONG CDECL
ldap_add_extA( LDAP
*, char *, LDAPModA
**, LDAPControlA
**, LDAPControlA
**, ULONG
* );
416 ULONG CDECL
ldap_add_extW( LDAP
*, WCHAR
*, LDAPModW
**, LDAPControlW
**, LDAPControlW
**, ULONG
* );
417 ULONG CDECL
ldap_add_ext_sA( LDAP
*, char *, LDAPModA
**, LDAPControlA
**, LDAPControlA
** );
418 ULONG CDECL
ldap_add_ext_sW( LDAP
*, WCHAR
*, LDAPModW
**, LDAPControlW
**, LDAPControlW
** );
419 ULONG CDECL
ldap_add_sA( LDAP
*, char *, LDAPModA
** );
420 ULONG CDECL
ldap_add_sW( LDAP
*, WCHAR
*, LDAPModW
** );
421 ULONG CDECL
ldap_bindA( LDAP
*, char *, char *, ULONG
);
422 ULONG CDECL
ldap_bindW( LDAP
*, WCHAR
*, WCHAR
*, ULONG
);
423 ULONG CDECL
ldap_bind_sA( LDAP
*, char *, char *, ULONG
);
424 ULONG CDECL
ldap_bind_sW( LDAP
*, WCHAR
*, WCHAR
*, ULONG
);
425 ULONG CDECL
ldap_sasl_bindA( LDAP
*, const PCHAR
, const PCHAR
, const BERVAL
*, LDAPControlA
**,
426 LDAPControlA
**, int * );
427 ULONG CDECL
ldap_sasl_bindW( LDAP
*, const PWCHAR
, const PWCHAR
, const BERVAL
*, LDAPControlW
**,
428 LDAPControlW
**, int * );
429 ULONG CDECL
ldap_sasl_bind_sA( LDAP
*,const PCHAR
, const PCHAR
, const BERVAL
*, LDAPControlA
**,
430 LDAPControlA
**, BERVAL
** );
431 ULONG CDECL
ldap_sasl_bind_sW( LDAP
*,const PWCHAR
, const PWCHAR
,const BERVAL
*, LDAPControlW
**,
432 LDAPControlW
**, BERVAL
** );
433 ULONG CDECL
ldap_simple_bindA( LDAP
*, char *, char * );
434 ULONG CDECL
ldap_simple_bindW( LDAP
*, WCHAR
*, WCHAR
* );
435 ULONG CDECL
ldap_simple_bind_sA( LDAP
*, char *, char * );
436 ULONG CDECL
ldap_simple_bind_sW( LDAP
*, WCHAR
*, WCHAR
* );
437 ULONG CDECL
ldap_compareA( LDAP
*, char *, char *, char * );
438 ULONG CDECL
ldap_compareW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
* );
439 ULONG CDECL
ldap_compare_extA( LDAP
*, char *, char *, char *, struct WLDAP32_berval
*, LDAPControlA
**,
440 LDAPControlA
**, ULONG
* );
441 ULONG CDECL
ldap_compare_extW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
*, struct WLDAP32_berval
*, LDAPControlW
**,
442 LDAPControlW
**, ULONG
* );
443 ULONG CDECL
ldap_compare_ext_sA( LDAP
*, char *, char *, char *, struct WLDAP32_berval
*, LDAPControlA
**,
445 ULONG CDECL
ldap_compare_ext_sW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
*, struct WLDAP32_berval
*, LDAPControlW
**,
447 ULONG CDECL
ldap_compare_sA( LDAP
*, char *, char *, char * );
448 ULONG CDECL
ldap_compare_sW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
* );
449 ULONG CDECL
WLDAP32_ldap_connect( LDAP
*, struct l_timeval
* );
450 ULONG CDECL
ldap_create_sort_controlA( LDAP
*, LDAPSortKeyA
**, UCHAR
, LDAPControlA
** );
451 ULONG CDECL
ldap_create_sort_controlW( LDAP
*, LDAPSortKeyW
**, UCHAR
, LDAPControlW
** );
452 int CDECL
ldap_create_vlv_controlA( LDAP
*, WLDAP32_LDAPVLVInfo
*, UCHAR
, LDAPControlA
** );
453 int CDECL
ldap_create_vlv_controlW( LDAP
*, WLDAP32_LDAPVLVInfo
*, UCHAR
, LDAPControlW
** );
454 ULONG CDECL
ldap_deleteA( LDAP
*, char * );
455 ULONG CDECL
ldap_deleteW( LDAP
*, WCHAR
* );
456 ULONG CDECL
ldap_delete_extA( LDAP
*, char *, LDAPControlA
**, LDAPControlA
**, ULONG
* );
457 ULONG CDECL
ldap_delete_extW( LDAP
*, WCHAR
*, LDAPControlW
**, LDAPControlW
**, ULONG
* );
458 ULONG CDECL
ldap_delete_ext_sA( LDAP
*, char *, LDAPControlA
**, LDAPControlA
** );
459 ULONG CDECL
ldap_delete_ext_sW( LDAP
*, WCHAR
*, LDAPControlW
**, LDAPControlW
** );
460 ULONG CDECL
ldap_delete_sA( LDAP
*, char * );
461 ULONG CDECL
ldap_delete_sW( LDAP
*, WCHAR
* );
462 char * CDECL
ldap_dn2ufnA( char * ) __WINE_DEALLOC(ldap_memfreeA
) __WINE_MALLOC
;
463 WCHAR
* CDECL
ldap_dn2ufnW( WCHAR
* ) __WINE_DEALLOC(ldap_memfreeW
) __WINE_MALLOC
;
464 char ** CDECL
ldap_explode_dnA( char *, ULONG
) __WINE_DEALLOC(ldap_value_freeA
);
465 WCHAR
** CDECL
ldap_explode_dnW( WCHAR
*, ULONG
) __WINE_DEALLOC(ldap_value_freeW
);
466 char * CDECL
ldap_get_dnA( LDAP
*, WLDAP32_LDAPMessage
* ) __WINE_DEALLOC(ldap_memfreeA
) __WINE_MALLOC
;
467 WCHAR
* CDECL
ldap_get_dnW( LDAP
*, WLDAP32_LDAPMessage
* ) __WINE_DEALLOC(ldap_memfreeW
) __WINE_MALLOC
;
468 ULONG CDECL
ldap_ufn2dnA( char *, char ** );
469 ULONG CDECL
ldap_ufn2dnW( WCHAR
*, WCHAR
** );
470 ULONG CDECL
ldap_extended_operationA( LDAP
*, char *, struct WLDAP32_berval
*, LDAPControlA
**, LDAPControlA
**,
472 ULONG CDECL
ldap_extended_operationW( LDAP
*, WCHAR
*, struct WLDAP32_berval
*, LDAPControlW
**, LDAPControlW
**,
474 ULONG CDECL
ldap_extended_operation_sA( LDAP
*, char *, struct WLDAP32_berval
*, LDAPControlA
**, LDAPControlA
**,
475 char **, struct WLDAP32_berval
** );
476 ULONG CDECL
ldap_extended_operation_sW( LDAP
*, WCHAR
*, struct WLDAP32_berval
*, LDAPControlW
**, LDAPControlW
**,
477 WCHAR
**, struct WLDAP32_berval
** );
478 LDAP
* CDECL
cldap_openA( char *, ULONG
);
479 LDAP
* CDECL
cldap_openW( WCHAR
*, ULONG
);
480 LDAP
* CDECL
ldap_initA( const PCHAR
, ULONG
);
481 LDAP
* CDECL
ldap_initW( const PWCHAR
, ULONG
);
482 LDAP
* CDECL
ldap_openA( char *, ULONG
);
483 LDAP
* CDECL
ldap_openW( WCHAR
*, ULONG
);
484 LDAP
* CDECL
ldap_sslinitA( char *, ULONG
, int );
485 LDAP
* CDECL
ldap_sslinitW( WCHAR
*, ULONG
, int );
486 ULONG CDECL
ldap_start_tls_sA( LDAP
*, ULONG
*, WLDAP32_LDAPMessage
**, LDAPControlA
**, LDAPControlA
** );
487 ULONG CDECL
ldap_start_tls_sW( LDAP
*, ULONG
*, WLDAP32_LDAPMessage
**, LDAPControlW
**, LDAPControlW
** );
488 ULONG CDECL
ldap_check_filterA( LDAP
*, char * );
489 ULONG CDECL
ldap_check_filterW( LDAP
*, WCHAR
* );
490 char * CDECL
ldap_first_attributeA( LDAP
*, WLDAP32_LDAPMessage
*,
491 WLDAP32_BerElement
** ) __WINE_DEALLOC(ldap_memfreeA
) __WINE_MALLOC
;
492 WCHAR
* CDECL
ldap_first_attributeW( LDAP
*, WLDAP32_LDAPMessage
*,
493 WLDAP32_BerElement
** ) __WINE_DEALLOC(ldap_memfreeW
) __WINE_MALLOC
;
494 char * CDECL
ldap_next_attributeA( LDAP
*, WLDAP32_LDAPMessage
*,
495 WLDAP32_BerElement
* ) __WINE_DEALLOC(ldap_memfreeA
) __WINE_MALLOC
;
496 WCHAR
* CDECL
ldap_next_attributeW( LDAP
*, WLDAP32_LDAPMessage
*,
497 WLDAP32_BerElement
* ) __WINE_DEALLOC(ldap_memfreeW
) __WINE_MALLOC
;
498 ULONG CDECL
WLDAP32_ldap_result( LDAP
*, ULONG
, ULONG
, struct l_timeval
*, WLDAP32_LDAPMessage
** );
499 ULONG CDECL
ldap_modifyA( LDAP
*, char *, LDAPModA
** );
500 ULONG CDECL
ldap_modifyW( LDAP
*, WCHAR
*, LDAPModW
** );
501 ULONG CDECL
ldap_modify_extA( LDAP
*, char *, LDAPModA
**, LDAPControlA
**, LDAPControlA
**, ULONG
* );
502 ULONG CDECL
ldap_modify_extW( LDAP
*, WCHAR
*, LDAPModW
**, LDAPControlW
**, LDAPControlW
**, ULONG
* );
503 ULONG CDECL
ldap_modify_ext_sA( LDAP
*, char *, LDAPModA
**, LDAPControlA
**, LDAPControlA
** );
504 ULONG CDECL
ldap_modify_ext_sW( LDAP
*, WCHAR
*, LDAPModW
**, LDAPControlW
**, LDAPControlW
** );
505 ULONG CDECL
ldap_modify_sA( LDAP
*, char *, LDAPModA
** );
506 ULONG CDECL
ldap_modify_sW( LDAP
*, WCHAR
*, LDAPModW
** );
507 ULONG CDECL
ldap_modrdnA( LDAP
*, char *, char * );
508 ULONG CDECL
ldap_modrdnW( LDAP
*, WCHAR
*, WCHAR
* );
509 ULONG CDECL
ldap_modrdn2A( LDAP
*, char *, char *, int );
510 ULONG CDECL
ldap_modrdn2W( LDAP
*, WCHAR
*, WCHAR
*, int );
511 ULONG CDECL
ldap_modrdn2_sA( LDAP
*, char *, char *, int );
512 ULONG CDECL
ldap_modrdn2_sW( LDAP
*, WCHAR
*, WCHAR
*, int );
513 ULONG CDECL
ldap_modrdn_sA( LDAP
*, char *, char * );
514 ULONG CDECL
ldap_modrdn_sW( LDAP
*, WCHAR
*, WCHAR
* );
515 ULONG CDECL
ldap_get_optionA( LDAP
*, int, void * );
516 ULONG CDECL
ldap_get_optionW( LDAP
*, int, void * );
517 ULONG CDECL
ldap_set_optionA( LDAP
*, int, void * );
518 ULONG CDECL
ldap_set_optionW( LDAP
*, int, void * );
519 ULONG CDECL
ldap_create_page_controlA( LDAP
*, ULONG
, struct WLDAP32_berval
*, UCHAR
, LDAPControlA
** );
520 ULONG CDECL
ldap_create_page_controlW( LDAP
*, ULONG
, struct WLDAP32_berval
*, UCHAR
, LDAPControlW
** );
521 ULONG CDECL
ldap_control_freeA( LDAPControlA
* );
522 ULONG CDECL
ldap_control_freeW( LDAPControlW
* );
523 ULONG CDECL
ldap_search_ext_sA( LDAP
*, char *, ULONG
, char *, char **, ULONG
, LDAPControlA
**, LDAPControlA
**,
524 struct l_timeval
*, ULONG
, WLDAP32_LDAPMessage
** );
525 ULONG CDECL
ldap_search_ext_sW( LDAP
*, WCHAR
*, ULONG
, WCHAR
*, WCHAR
**, ULONG
, LDAPControlW
**, LDAPControlW
**,
526 struct l_timeval
*, ULONG
, WLDAP32_LDAPMessage
** );
527 ULONG CDECL
ldap_get_paged_count( LDAP
*, LDAPSearch
*, ULONG
*, WLDAP32_LDAPMessage
* );
528 ULONG CDECL
ldap_parse_resultA( LDAP
*, WLDAP32_LDAPMessage
*, ULONG
*, char **, char **, char ***,
529 LDAPControlA
***, BOOLEAN
);
530 ULONG CDECL
ldap_parse_resultW( LDAP
*, WLDAP32_LDAPMessage
*, ULONG
*, WCHAR
**, WCHAR
**, WCHAR
***,
531 LDAPControlW
***, BOOLEAN
);
532 ULONG CDECL
ldap_parse_page_controlA( LDAP
*, LDAPControlA
**, ULONG
*, struct WLDAP32_berval
** );
533 ULONG CDECL
ldap_parse_page_controlW( LDAP
*, LDAPControlW
**, ULONG
*, struct WLDAP32_berval
** );
534 ULONG CDECL
ldap_controls_freeA( LDAPControlA
** );
535 ULONG CDECL
ldap_controls_freeW( LDAPControlW
** );
536 ULONG CDECL
ldap_parse_extended_resultA( LDAP
*, WLDAP32_LDAPMessage
*, char **, struct WLDAP32_berval
**, BOOLEAN
);
537 ULONG CDECL
ldap_parse_extended_resultW( LDAP
*, WLDAP32_LDAPMessage
*, WCHAR
**, struct WLDAP32_berval
**, BOOLEAN
);
538 ULONG CDECL
ldap_parse_referenceA( LDAP
*, WLDAP32_LDAPMessage
*, char *** );
539 ULONG CDECL
ldap_parse_referenceW( LDAP
*, WLDAP32_LDAPMessage
*, WCHAR
*** );
540 ULONG CDECL
ldap_parse_sort_controlA( LDAP
*, LDAPControlA
**, ULONG
*, char ** );
541 ULONG CDECL
ldap_parse_sort_controlW( LDAP
*, LDAPControlW
**, ULONG
*, WCHAR
** );
542 int CDECL
ldap_parse_vlv_controlA( LDAP
*, LDAPControlA
**, ULONG
*, ULONG
*, struct WLDAP32_berval
**, int * );
543 int CDECL
ldap_parse_vlv_controlW( LDAP
*, LDAPControlW
**, ULONG
*, ULONG
*, struct WLDAP32_berval
**, int * );
544 ULONG CDECL
ldap_rename_extA( LDAP
*, char *, char *, char *, int, LDAPControlA
**, LDAPControlA
**, ULONG
* );
545 ULONG CDECL
ldap_rename_extW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
*, int, LDAPControlW
**, LDAPControlW
**, ULONG
* );
546 ULONG CDECL
ldap_rename_ext_sA( LDAP
*, char *, char *, char *, int, LDAPControlA
**, LDAPControlA
** );
547 ULONG CDECL
ldap_rename_ext_sW( LDAP
*, WCHAR
*, WCHAR
*, WCHAR
*, int, LDAPControlW
**, LDAPControlW
** );
548 ULONG CDECL
ldap_searchA( LDAP
*, char *, ULONG
, char *, char **, ULONG
);
549 ULONG CDECL
ldap_searchW( LDAP
*, WCHAR
*, ULONG
, WCHAR
*, WCHAR
**, ULONG
);
550 ULONG CDECL
ldap_search_extA( LDAP
*, char *, ULONG
, char *, char **, ULONG
, LDAPControlA
**, LDAPControlA
**,
551 ULONG
, ULONG
, ULONG
* );
552 ULONG CDECL
ldap_search_extW( LDAP
*, PWCHAR
, ULONG
, PWCHAR
, PWCHAR
[], ULONG
, LDAPControlW
**, LDAPControlW
**,
553 ULONG
, ULONG
, ULONG
* );
554 ULONG CDECL
ldap_search_sA( LDAP
*, char *, ULONG
, char *, char **, ULONG
, WLDAP32_LDAPMessage
** );
555 ULONG CDECL
ldap_search_sW( LDAP
*, WCHAR
*, ULONG
, WCHAR
*, WCHAR
**, ULONG
, WLDAP32_LDAPMessage
** );
556 ULONG CDECL
ldap_search_stA( LDAP
*, const PCHAR
, ULONG
, const PCHAR
, char **, ULONG
, struct l_timeval
*,
557 WLDAP32_LDAPMessage
** );
558 ULONG CDECL
ldap_search_stW( LDAP
*, const PWCHAR
, ULONG
, const PWCHAR
, WCHAR
**, ULONG
, struct l_timeval
*,
559 WLDAP32_LDAPMessage
** );
560 char ** CDECL
ldap_get_valuesA( LDAP
*, WLDAP32_LDAPMessage
*, char * ) __WINE_DEALLOC(ldap_value_freeA
);
561 WCHAR
** CDECL
ldap_get_valuesW( LDAP
*, WLDAP32_LDAPMessage
*, WCHAR
* ) __WINE_DEALLOC(ldap_value_freeW
);
562 struct WLDAP32_berval
** CDECL
ldap_get_values_lenA( LDAP
*, LDAPMessage
*,
563 char * ) __WINE_DEALLOC(WLDAP32_ldap_value_free_len
);
564 struct WLDAP32_berval
** CDECL
ldap_get_values_lenW( LDAP
*, LDAPMessage
*,
565 WCHAR
* ) __WINE_DEALLOC(WLDAP32_ldap_value_free_len
);
567 ULONG
map_error( int );
569 static inline char *strWtoU( const WCHAR
*str
)
574 int len
= WideCharToMultiByte( CP_UTF8
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
575 if ((ret
= malloc( len
))) WideCharToMultiByte( CP_UTF8
, 0, str
, -1, ret
, len
, NULL
, NULL
);
580 static inline char *strnWtoU( const WCHAR
*str
, DWORD in_len
, DWORD
*out_len
)
586 DWORD len
= WideCharToMultiByte( CP_UTF8
, 0, str
, in_len
, NULL
, 0, NULL
, NULL
);
587 if ((ret
= malloc( len
+ 1 )))
589 WideCharToMultiByte( CP_UTF8
, 0, str
, in_len
, ret
, len
, NULL
, NULL
);
597 static inline WCHAR
*strAtoW( const char *str
)
602 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, -1, NULL
, 0 );
603 if ((ret
= malloc( len
* sizeof(WCHAR
) ))) MultiByteToWideChar( CP_ACP
, 0, str
, -1, ret
, len
);
608 static inline WCHAR
*strnAtoW( const char *str
, DWORD in_len
, DWORD
*out_len
)
614 DWORD len
= MultiByteToWideChar( CP_ACP
, 0, str
, in_len
, NULL
, 0 );
615 if ((ret
= malloc( (len
+ 1) * sizeof(WCHAR
) )))
617 MultiByteToWideChar( CP_ACP
, 0, str
, in_len
, ret
, len
);
625 static inline char *strreplace( const char *s
, const char *before
, const char *after
)
627 char *ret
= malloc( strlen( s
) + strlen( after
) / strlen( before
) + 1 );
628 char *cur
, *prev
= ret
;
632 for (cur
= strstr( s
, before
); cur
; cur
= strstr( prev
, before
))
634 strncat( ret
, prev
, cur
- prev
);
635 strcat( ret
, after
);
636 prev
= cur
+ strlen( before
);
638 strncat( ret
, prev
, cur
- prev
);
643 static inline DWORD
bvarraylenW( struct WLDAP32_berval
**bv
)
645 struct WLDAP32_berval
**p
= bv
;
650 static inline DWORD
strarraylenW( WCHAR
**strarray
)
652 WCHAR
**p
= strarray
;
657 static inline char **strarrayWtoU( WCHAR
**strarray
)
664 size
= sizeof(char *) * (strarraylenW( strarray
) + 1);
665 if ((ret
= malloc( size
)))
667 WCHAR
**p
= strarray
;
670 while (*p
) *q
++ = strWtoU( *p
++ );
677 static inline WCHAR
**strarraydupW( WCHAR
**strarray
)
684 size
= sizeof(WCHAR
*) * (strarraylenW( strarray
) + 1);
685 if ((ret
= malloc( size
)))
687 WCHAR
**p
= strarray
, **q
= ret
;
689 while (*p
) *q
++ = wcsdup( *p
++ );
696 static inline char *strWtoA( const WCHAR
*str
)
701 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, str
, -1, NULL
, 0, NULL
, NULL
);
702 if ((ret
= malloc( len
))) WideCharToMultiByte( CP_ACP
, 0, str
, -1, ret
, len
, NULL
, NULL
);
707 static inline char **strarrayWtoA( WCHAR
**strarray
)
714 size
= sizeof(char *) * (strarraylenW( strarray
) + 1);
715 if ((ret
= malloc( size
)))
717 WCHAR
**p
= strarray
;
720 while (*p
) *q
++ = strWtoA( *p
++ );
727 static inline DWORD
modarraylenW( LDAPModW
**modarray
)
729 LDAPModW
**p
= modarray
;
734 static inline struct berval
*bervalWtoU( const struct WLDAP32_berval
*bv
)
737 DWORD size
= sizeof(*ret
) + bv
->bv_len
;
739 if ((ret
= malloc( size
)))
741 char *val
= (char *)(ret
+ 1);
743 ret
->bv_len
= bv
->bv_len
;
745 memcpy( val
, bv
->bv_val
, bv
->bv_len
);
750 static inline DWORD
bvarraylenU( struct berval
**bv
)
752 struct berval
**p
= bv
;
757 static inline struct WLDAP32_berval
*bervalUtoW( const struct berval
*bv
)
759 struct WLDAP32_berval
*ret
;
760 DWORD size
= sizeof(*ret
) + bv
->bv_len
;
762 assert( bv
->bv_len
<= ~0u );
764 if ((ret
= malloc( size
)))
766 char *val
= (char *)(ret
+ 1);
768 ret
->bv_len
= bv
->bv_len
;
770 memcpy( val
, bv
->bv_val
, bv
->bv_len
);
775 static inline struct WLDAP32_berval
**bvarrayUtoW( struct berval
**bv
)
777 struct WLDAP32_berval
**ret
= NULL
;
782 size
= sizeof(*ret
) * (bvarraylenU( bv
) + 1);
783 if ((ret
= malloc( size
)))
785 struct berval
**p
= bv
;
786 struct WLDAP32_berval
**q
= ret
;
788 while (*p
) *q
++ = bervalUtoW( *p
++ );
795 static inline struct berval
**bvarrayWtoU( struct WLDAP32_berval
**bv
)
797 struct berval
**ret
= NULL
;
802 size
= sizeof(*ret
) * (bvarraylenW( bv
) + 1);
803 if ((ret
= malloc( size
)))
805 struct WLDAP32_berval
**p
= bv
;
806 struct berval
**q
= ret
;
808 while (*p
) *q
++ = bervalWtoU( *p
++ );
815 static inline LDAPMod
*modWtoU( const LDAPModW
*mod
)
819 if ((ret
= malloc( sizeof(*ret
) )))
821 ret
->mod_op
= mod
->mod_op
;
822 ret
->mod_type
= strWtoU( mod
->mod_type
);
824 if (mod
->mod_op
& LDAP_MOD_BVALUES
)
825 ret
->mod_vals
.modv_bvals
= bvarrayWtoU( mod
->mod_vals
.modv_bvals
);
827 ret
->mod_vals
.modv_strvals
= strarrayWtoU( mod
->mod_vals
.modv_strvals
);
832 static inline LDAPMod
**modarrayWtoU( LDAPModW
**modarray
)
834 LDAPMod
**ret
= NULL
;
839 size
= sizeof(*ret
) * (modarraylenW( modarray
) + 1);
840 if ((ret
= malloc( size
)))
842 LDAPModW
**p
= modarray
;
845 while (*p
) *q
++ = modWtoU( *p
++ );
852 static inline void bvarrayfreeU( struct berval
**bv
)
854 struct berval
**p
= bv
;
855 while (*p
) free( *p
++ );
859 static inline void strarrayfreeU( char **strarray
)
864 while (*p
) free( *p
++ );
869 static inline void modfreeU( LDAPMod
*mod
)
871 if (mod
->mod_op
& LDAP_MOD_BVALUES
)
872 bvarrayfreeU( mod
->mod_vals
.modv_bvals
);
874 strarrayfreeU( mod
->mod_vals
.modv_strvals
);
875 free( mod
->mod_type
);
879 static inline void modarrayfreeU( LDAPMod
**modarray
)
883 LDAPMod
**p
= modarray
;
884 while (*p
) modfreeU( *p
++ );
889 static inline DWORD
modarraylenA( LDAPModA
**modarray
)
891 LDAPModA
**p
= modarray
;
896 static inline struct WLDAP32_berval
*bervalWtoW( const struct WLDAP32_berval
*bv
)
898 struct WLDAP32_berval
*ret
;
899 DWORD size
= sizeof(*ret
) + bv
->bv_len
;
901 if ((ret
= malloc( size
)))
903 char *val
= (char *)(ret
+ 1);
905 ret
->bv_len
= bv
->bv_len
;
907 memcpy( val
, bv
->bv_val
, bv
->bv_len
);
912 static inline struct WLDAP32_berval
**bvarrayWtoW( struct WLDAP32_berval
**bv
)
914 struct WLDAP32_berval
**ret
= NULL
;
919 size
= sizeof(*ret
) * (bvarraylenW( bv
) + 1);
920 if ((ret
= malloc( size
)))
922 struct WLDAP32_berval
**p
= bv
, **q
= ret
;
924 while (*p
) *q
++ = bervalWtoW( *p
++ );
931 static inline DWORD
strarraylenA( char **strarray
)
938 static inline WCHAR
**strarrayAtoW( char **strarray
)
945 size
= sizeof(*ret
) * (strarraylenA( strarray
) + 1);
946 if ((ret
= malloc( size
)))
951 while (*p
) *q
++ = strAtoW( *p
++ );
958 static inline LDAPModW
*modAtoW( const LDAPModA
*mod
)
962 if ((ret
= malloc( sizeof(*ret
) )))
964 ret
->mod_op
= mod
->mod_op
;
965 ret
->mod_type
= strAtoW( mod
->mod_type
);
967 if (mod
->mod_op
& LDAP_MOD_BVALUES
)
968 ret
->mod_vals
.modv_bvals
= bvarrayWtoW( mod
->mod_vals
.modv_bvals
);
970 ret
->mod_vals
.modv_strvals
= strarrayAtoW( mod
->mod_vals
.modv_strvals
);
975 static inline LDAPModW
**modarrayAtoW( LDAPModA
**modarray
)
977 LDAPModW
**ret
= NULL
;
982 size
= sizeof(*ret
) * (modarraylenA( modarray
) + 1);
983 if ((ret
= malloc( size
)))
985 LDAPModA
**p
= modarray
;
988 while (*p
) *q
++ = modAtoW( *p
++ );
995 static inline void bvarrayfreeW( struct WLDAP32_berval
**bv
)
997 struct WLDAP32_berval
**p
= bv
;
998 while (*p
) free( *p
++ );
1002 static inline void strarrayfreeW( WCHAR
**strarray
)
1006 WCHAR
**p
= strarray
;
1007 while (*p
) free( *p
++ );
1012 static inline void modfreeW( LDAPModW
*mod
)
1014 if (mod
->mod_op
& LDAP_MOD_BVALUES
)
1015 bvarrayfreeW( mod
->mod_vals
.modv_bvals
);
1017 strarrayfreeW( mod
->mod_vals
.modv_strvals
);
1018 free( mod
->mod_type
);
1022 static inline void modarrayfreeW( LDAPModW
**modarray
)
1026 LDAPModW
**p
= modarray
;
1027 while (*p
) modfreeW( *p
++ );
1032 static inline DWORD
controlarraylenA( LDAPControlA
**controlarray
)
1034 LDAPControlA
**p
= controlarray
;
1036 return p
- controlarray
;
1039 static inline LDAPControlW
*controlAtoW( const LDAPControlA
*control
)
1042 DWORD len
= control
->ldctl_value
.bv_len
;
1045 if (control
->ldctl_value
.bv_val
)
1047 if (!(val
= malloc( len
))) return NULL
;
1048 memcpy( val
, control
->ldctl_value
.bv_val
, len
);
1051 if (!(ret
= malloc( sizeof(*ret
) )))
1057 ret
->ldctl_oid
= strAtoW( control
->ldctl_oid
);
1058 ret
->ldctl_value
.bv_len
= len
;
1059 ret
->ldctl_value
.bv_val
= val
;
1060 ret
->ldctl_iscritical
= control
->ldctl_iscritical
;
1065 static inline LDAPControlW
**controlarrayAtoW( LDAPControlA
**controlarray
)
1067 LDAPControlW
**ret
= NULL
;
1072 size
= sizeof(*ret
) * (controlarraylenA( controlarray
) + 1);
1073 if ((ret
= malloc( size
)))
1075 LDAPControlA
**p
= controlarray
;
1076 LDAPControlW
**q
= ret
;
1078 while (*p
) *q
++ = controlAtoW( *p
++ );
1085 static inline void controlfreeW( LDAPControlW
*control
)
1089 free( control
->ldctl_oid
);
1090 free( control
->ldctl_value
.bv_val
);
1095 static inline void controlarrayfreeW( LDAPControlW
**controlarray
)
1099 LDAPControlW
**p
= controlarray
;
1100 while (*p
) controlfreeW( *p
++ );
1101 free( controlarray
);
1105 static inline DWORD
controlarraylenW( LDAPControlW
**controlarray
)
1107 LDAPControlW
**p
= controlarray
;
1109 return p
- controlarray
;
1112 static inline LDAPControlA
*controlWtoA( const LDAPControlW
*control
)
1115 DWORD len
= control
->ldctl_value
.bv_len
;
1118 if (control
->ldctl_value
.bv_val
)
1120 if (!(val
= malloc( len
))) return NULL
;
1121 memcpy( val
, control
->ldctl_value
.bv_val
, len
);
1124 if (!(ret
= malloc( sizeof(*ret
) )))
1130 ret
->ldctl_oid
= strWtoA( control
->ldctl_oid
);
1131 ret
->ldctl_value
.bv_len
= len
;
1132 ret
->ldctl_value
.bv_val
= val
;
1133 ret
->ldctl_iscritical
= control
->ldctl_iscritical
;
1138 static inline void strarrayfreeA( char **strarray
)
1142 char **p
= strarray
;
1143 while (*p
) free( *p
++ );
1148 static inline void controlfreeA( LDAPControlA
*control
)
1152 free( control
->ldctl_oid
);
1153 free( control
->ldctl_value
.bv_val
);
1158 static inline void controlarrayfreeA( LDAPControlA
**controlarray
)
1162 LDAPControlA
**p
= controlarray
;
1163 while (*p
) controlfreeA( *p
++ );
1164 free( controlarray
);
1168 static inline LDAPControl
*controlWtoU( const LDAPControlW
*control
)
1171 DWORD len
= control
->ldctl_value
.bv_len
;
1174 if (control
->ldctl_value
.bv_val
)
1176 if (!(val
= malloc( len
))) return NULL
;
1177 memcpy( val
, control
->ldctl_value
.bv_val
, len
);
1180 if (!(ret
= malloc( sizeof(*ret
) )))
1186 ret
->ldctl_oid
= strWtoU( control
->ldctl_oid
);
1187 ret
->ldctl_value
.bv_len
= len
;
1188 ret
->ldctl_value
.bv_val
= val
;
1189 ret
->ldctl_iscritical
= control
->ldctl_iscritical
;
1194 static inline LDAPControl
**controlarrayWtoU( LDAPControlW
**controlarray
)
1196 LDAPControl
**ret
= NULL
;
1201 size
= sizeof(*ret
) * (controlarraylenW( controlarray
) + 1);
1202 if ((ret
= malloc( size
)))
1204 LDAPControlW
**p
= controlarray
;
1205 LDAPControl
**q
= ret
;
1207 while (*p
) *q
++ = controlWtoU( *p
++ );
1214 static inline void controlfreeU( LDAPControl
*control
)
1218 free( control
->ldctl_oid
);
1219 free( control
->ldctl_value
.bv_val
);
1224 static inline void controlarrayfreeU( LDAPControl
**controlarray
)
1228 LDAPControl
**p
= controlarray
;
1229 while (*p
) controlfreeU( *p
++ );
1230 free( controlarray
);
1234 static inline DWORD
controlarraylenU( LDAPControl
**controlarray
)
1236 LDAPControl
**p
= controlarray
;
1238 return p
- controlarray
;
1241 static inline LDAPControlW
*controldupW( LDAPControlW
*control
)
1244 DWORD len
= control
->ldctl_value
.bv_len
;
1247 if (control
->ldctl_value
.bv_val
)
1249 if (!(val
= malloc( len
))) return NULL
;
1250 memcpy( val
, control
->ldctl_value
.bv_val
, len
);
1253 if (!(ret
= malloc( sizeof(*ret
) )))
1259 ret
->ldctl_oid
= wcsdup( control
->ldctl_oid
);
1260 ret
->ldctl_value
.bv_len
= len
;
1261 ret
->ldctl_value
.bv_val
= val
;
1262 ret
->ldctl_iscritical
= control
->ldctl_iscritical
;
1267 static inline LDAPControlW
**controlarraydupW( LDAPControlW
**controlarray
)
1269 LDAPControlW
**ret
= NULL
;
1274 size
= sizeof(*ret
) * (controlarraylenW( controlarray
) + 1);
1275 if ((ret
= malloc( size
)))
1277 LDAPControlW
**p
= controlarray
, **q
= ret
;
1279 while (*p
) *q
++ = controldupW( *p
++ );
1286 static inline LDAPControlA
**controlarrayWtoA( LDAPControlW
**controlarray
)
1288 LDAPControlA
**ret
= NULL
;
1293 size
= sizeof(*ret
) * (controlarraylenW( controlarray
) + 1);
1294 if ((ret
= malloc( size
)))
1296 LDAPControlW
**p
= controlarray
;
1297 LDAPControlA
**q
= ret
;
1299 while (*p
) *q
++ = controlWtoA( *p
++ );
1306 static inline WCHAR
*strUtoW( const char *str
)
1311 DWORD len
= MultiByteToWideChar( CP_UTF8
, 0, str
, -1, NULL
, 0 );
1312 if ((ret
= malloc( len
* sizeof(WCHAR
) ))) MultiByteToWideChar( CP_UTF8
, 0, str
, -1, ret
, len
);
1317 static inline DWORD
strarraylenU( char **strarray
)
1319 char **p
= strarray
;
1321 return p
- strarray
;
1324 static inline WCHAR
**strarrayUtoW( char **strarray
)
1331 size
= sizeof(*ret
) * (strarraylenU( strarray
) + 1);
1332 if ((ret
= malloc( size
)))
1334 char **p
= strarray
;
1337 while (*p
) *q
++ = strUtoW( *p
++ );
1344 static inline char **strarrayUtoU( char **strarray
)
1351 size
= sizeof(*ret
) * (strarraylenU( strarray
) + 1);
1352 if ((ret
= malloc( size
)))
1354 char **p
= strarray
, **q
= ret
;
1356 while (*p
) *q
++ = strdup( *p
++ );
1363 static inline LDAPControlW
*controlUtoW( const LDAPControl
*control
)
1366 DWORD len
= control
->ldctl_value
.bv_len
;
1369 if (control
->ldctl_value
.bv_val
)
1371 if (!(val
= malloc( len
))) return NULL
;
1372 memcpy( val
, control
->ldctl_value
.bv_val
, len
);
1375 if (!(ret
= malloc( sizeof(*ret
) )))
1381 ret
->ldctl_oid
= strUtoW( control
->ldctl_oid
);
1382 ret
->ldctl_value
.bv_len
= len
;
1383 ret
->ldctl_value
.bv_val
= val
;
1384 ret
->ldctl_iscritical
= control
->ldctl_iscritical
;
1389 static inline LDAPControlW
**controlarrayUtoW( LDAPControl
**controlarray
)
1391 LDAPControlW
**ret
= NULL
;
1396 size
= sizeof(*ret
) * (controlarraylenU( controlarray
) + 1);
1397 if ((ret
= malloc( size
)))
1399 LDAPControl
**p
= controlarray
;
1400 LDAPControlW
**q
= ret
;
1402 while (*p
) *q
++ = controlUtoW( *p
++ );
1409 static inline DWORD
sortkeyarraylenA( LDAPSortKeyA
**sortkeyarray
)
1411 LDAPSortKeyA
**p
= sortkeyarray
;
1413 return p
- sortkeyarray
;
1416 static inline LDAPSortKeyW
*sortkeyAtoW( const LDAPSortKeyA
*sortkey
)
1420 if ((ret
= malloc( sizeof(*ret
) )))
1422 ret
->sk_attrtype
= strAtoW( sortkey
->sk_attrtype
);
1423 ret
->sk_matchruleoid
= strAtoW( sortkey
->sk_matchruleoid
);
1424 ret
->sk_reverseorder
= sortkey
->sk_reverseorder
;
1429 static inline LDAPSortKeyW
**sortkeyarrayAtoW( LDAPSortKeyA
**sortkeyarray
)
1431 LDAPSortKeyW
**ret
= NULL
;
1436 size
= sizeof(*ret
) * (sortkeyarraylenA( sortkeyarray
) + 1);
1437 if ((ret
= malloc( size
)))
1439 LDAPSortKeyA
**p
= sortkeyarray
;
1440 LDAPSortKeyW
**q
= ret
;
1442 while (*p
) *q
++ = sortkeyAtoW( *p
++ );
1449 static inline void sortkeyfreeW( LDAPSortKeyW
*sortkey
)
1453 free( sortkey
->sk_attrtype
);
1454 free( sortkey
->sk_matchruleoid
);
1459 static inline void sortkeyarrayfreeW( LDAPSortKeyW
**sortkeyarray
)
1463 LDAPSortKeyW
**p
= sortkeyarray
;
1464 while (*p
) sortkeyfreeW( *p
++ );
1465 free( sortkeyarray
);
1469 static inline DWORD
sortkeyarraylenW( LDAPSortKeyW
**sortkeyarray
)
1471 LDAPSortKeyW
**p
= sortkeyarray
;
1473 return p
- sortkeyarray
;
1476 static inline LDAPSortKey
*sortkeyWtoU( const LDAPSortKeyW
*sortkey
)
1480 if ((ret
= malloc( sizeof(*ret
) )))
1482 ret
->attributeType
= strWtoU( sortkey
->sk_attrtype
);
1483 ret
->orderingRule
= strWtoU( sortkey
->sk_matchruleoid
);
1484 ret
->reverseOrder
= sortkey
->sk_reverseorder
;
1489 static inline LDAPSortKey
**sortkeyarrayWtoU( LDAPSortKeyW
**sortkeyarray
)
1491 LDAPSortKey
**ret
= NULL
;
1496 size
= sizeof(*ret
) * (sortkeyarraylenW( sortkeyarray
) + 1);
1497 if ((ret
= malloc( size
)))
1499 LDAPSortKeyW
**p
= sortkeyarray
;
1500 LDAPSortKey
**q
= ret
;
1502 while (*p
) *q
++ = sortkeyWtoU( *p
++ );
1509 static inline void sortkeyfreeU( LDAPSortKey
*sortkey
)
1513 free( sortkey
->attributeType
);
1514 free( sortkey
->orderingRule
);
1519 static inline void sortkeyarrayfreeU( LDAPSortKey
**sortkeyarray
)
1523 LDAPSortKey
**p
= sortkeyarray
;
1524 while (*p
) sortkeyfreeU( *p
++ );
1525 free( sortkeyarray
);
1529 static inline LDAPVLVInfo
*vlvinfoWtoU( const WLDAP32_LDAPVLVInfo
*info
)
1533 if ((ret
= malloc( sizeof(*ret
) )))
1535 ret
->ldvlv_version
= info
->ldvlv_version
;
1536 ret
->ldvlv_before_count
= info
->ldvlv_before_count
;
1537 ret
->ldvlv_after_count
= info
->ldvlv_after_count
;
1538 ret
->ldvlv_offset
= info
->ldvlv_offset
;
1539 ret
->ldvlv_count
= info
->ldvlv_count
;
1540 if (!(ret
->ldvlv_attrvalue
= bervalWtoU( info
->ldvlv_attrvalue
)))
1545 if (!(ret
->ldvlv_context
= bervalWtoU( info
->ldvlv_context
)))
1547 free( ret
->ldvlv_attrvalue
);
1551 ret
->ldvlv_extradata
= info
->ldvlv_extradata
;
1556 static inline void vlvinfofreeU( LDAPVLVInfo
*info
)
1558 free( info
->ldvlv_attrvalue
);
1559 free( info
->ldvlv_context
);