v2: Fix compilation without LDAP.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/wldap32/page.c | 64 ++++++++++++++++++++++++++++++++-- dlls/wldap32/winldap_private.h | 13 +++++++ 2 files changed, 74 insertions(+), 3 deletions(-)
diff --git a/dlls/wldap32/page.c b/dlls/wldap32/page.c index 7cf7d93245..f9b3de77b3 100644 --- a/dlls/wldap32/page.c +++ b/dlls/wldap32/page.c @@ -277,11 +277,69 @@ PLDAPSearch CDECL ldap_search_init_pageA( WLDAP32_LDAP *ld, PCHAR dn, ULONG scop return NULL; }
-PLDAPSearch CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR dn, ULONG scope, +PLDAPSearch CDECL ldap_search_init_pageW( WLDAP32_LDAP *ld, PWCHAR base, ULONG scope, PWCHAR filter, PWCHAR attrs[], ULONG attrsonly, PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG timelimit, ULONG sizelimit, PLDAPSortKeyW *sortkeys ) { - FIXME( "(%p, %s, 0x%08x, %s, %p, 0x%08x)\n", ld, debugstr_w(dn), - scope, debugstr_w(filter), attrs, attrsonly ); +#ifdef HAVE_LDAP + LDAPSearch *search; + DWORD i, len; + + TRACE( "(%p, %s, 0x%08x, %s, %p, 0x%08x, %p, %p, 0x%08x, 0x%08x, %p)\n", + ld, debugstr_w(base), scope, debugstr_w(filter), attrs, attrsonly, + serverctrls, clientctrls, timelimit, sizelimit, sortkeys ); + + search = heap_alloc_zero( sizeof(*search) ); + if (!search) + { + ld->ld_errno = WLDAP32_LDAP_NO_MEMORY; + return NULL; + } + + if (base) + { + search->base = strWtoU( base ); + if (!search->base) goto fail; + } + if (filter) + { + search->filter = strWtoU( filter ); + if (!search->filter) goto fail; + } + if (attrs) + { + search->attrs = strarrayWtoU( attrs ); + if (!search->attrs) goto fail; + } + + len = serverctrls ? controlarraylenW( serverctrls ) : 0; + search->serverctrls = heap_alloc( sizeof(LDAPControl *) * (len + 2) ); + if (!search->serverctrls) goto fail; + search->serverctrls[0] = NULL; /* reserve 0 for page control */ + for (i = 0; i < len; i++) + { + search->serverctrls[i + 1] = controlWtoU( serverctrls[i] ); + if (!search->serverctrls[i + 1]) goto fail; + } + search->serverctrls[len + 1] = NULL; + + if (clientctrls) + { + search->clientctrls = controlarrayWtoU( clientctrls ); + if (!search->clientctrls) goto fail; + } + + search->scope = scope; + search->attrsonly = attrsonly; + search->timeout.tv_sec = timelimit; + search->timeout.tv_usec = 0; + search->sizelimit = sizelimit; + search->cookie = NULL; + + return search; + +fail: + ldap_search_abandon_page( ld, search ); +#endif return NULL; } diff --git a/dlls/wldap32/winldap_private.h b/dlls/wldap32/winldap_private.h index 30c12a909c..442b4a884a 100644 --- a/dlls/wldap32/winldap_private.h +++ b/dlls/wldap32/winldap_private.h @@ -234,7 +234,20 @@ typedef struct WLDAP32_ldapvlvinfo VOID *ldvlv_extradata; } WLDAP32_LDAPVLVInfo, *WLDAP32_PLDAPVLVInfo;
+#ifdef HAVE_LDAP +typedef struct ldapsearch +{ + char *base, *filter, **attrs; + ULONG scope, attrsonly; + LDAPControl **serverctrls; + LDAPControl **clientctrls; + struct timeval timeout; + ULONG sizelimit; + struct berval *cookie; +} LDAPSearch, *PLDAPSearch; +#else typedef struct ldapsearch LDAPSearch, *PLDAPSearch; +#endif
typedef struct ldapsortkeyA {
Dmitry Timoshkov dmitry@baikal.ru wrote:
v2: Fix compilation without LDAP.
Please ignore this version, it mixes libldap/wldap32 management for the LDAPControl array elements which leads to free/HeapFree mismatches on array destruction spotted by valgrind.