Commit b0f347b4 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wldap32: Move support for extended functions to the Unix library.

parent e21c9596
......@@ -18,21 +18,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#ifdef HAVE_LDAP_H
#include <ldap.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winldap_private.h"
#include "wldap32.h"
#include "wine/debug.h"
#include "winldap_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
......@@ -66,33 +58,20 @@ ULONG CDECL ldap_close_extended_op( WLDAP32_LDAP *ld, ULONG msgid )
*
* See ldap_extended_operationW.
*/
ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, ULONG *message )
ULONG CDECL ldap_extended_operationA( WLDAP32_LDAP *ld, char *oid, struct WLDAP32_berval *data,
LDAPControlA **serverctrls, LDAPControlA **clientctrls, ULONG *message )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *oidW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
clientctrls, message );
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, message );
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
if (oid) {
oidW = strAtoW( oid );
if (!oidW) goto exit;
}
if (serverctrls) {
serverctrlsW = controlarrayAtoW( serverctrls );
if (!serverctrlsW) goto exit;
}
if (clientctrls) {
clientctrlsW = controlarrayAtoW( clientctrls );
if (!clientctrlsW) goto exit;
}
if (oid && !(oidW = strAtoW( oid ))) goto exit;
if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
ret = ldap_extended_operationW( ld, oidW, data, serverctrlsW, clientctrlsW, message );
......@@ -100,8 +79,6 @@ exit:
strfreeW( oidW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
#endif
return ret;
}
......@@ -130,43 +107,30 @@ exit:
* are optional and should be set to NULL if not used. Call
* ldap_close_extended_op to close the operation.
*/
ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, ULONG *message )
ULONG CDECL ldap_extended_operationW( WLDAP32_LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data,
LDAPControlW **serverctrls, LDAPControlW **clientctrls, ULONG *message )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *oidU = NULL;
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
struct bervalU *dataU = NULL;
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
clientctrls, message );
TRACE( "(%p, %s, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, message );
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
if (oid) {
oidU = strWtoU( oid );
if (!oidU) goto exit;
}
if (serverctrls) {
serverctrlsU = controlarrayWtoU( serverctrls );
if (!serverctrlsU) goto exit;
}
if (clientctrls) {
clientctrlsU = controlarrayWtoU( clientctrls );
if (!clientctrlsU) goto exit;
}
if (oid && !(oidU = strWtoU( oid ))) goto exit;
if (data && !(dataU = bervalWtoU( data ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_extended_operation( ld->ld, oid ? oidU : "", (struct berval *)data,
serverctrlsU, clientctrlsU, (int *)message ));
ret = map_error( ldap_funcs->ldap_extended_operation( ld->ld, oidU, dataU, serverctrlsU, clientctrlsU, message ) );
exit:
strfreeU( oidU );
bvfreeU( dataU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
#endif
return ret;
}
......@@ -175,41 +139,27 @@ exit:
*
* See ldap_extended_operation_sW.
*/
ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, PCHAR oid, struct WLDAP32_berval *data,
PLDAPControlA *serverctrls, PLDAPControlA *clientctrls, PCHAR *retoid,
struct WLDAP32_berval **retdata )
ULONG CDECL ldap_extended_operation_sA( WLDAP32_LDAP *ld, char *oid, struct WLDAP32_berval *data,
LDAPControlA **serverctrls, LDAPControlA **clientctrls, char **retoid, struct WLDAP32_berval **retdata )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
WCHAR *oidW = NULL, *retoidW = NULL;
LDAPControlW **serverctrlsW = NULL, **clientctrlsW = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls,
clientctrls, retoid, retdata );
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_a(oid), data, serverctrls, clientctrls, retoid, retdata );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (oid) {
oidW = strAtoW( oid );
if (!oidW) goto exit;
}
if (serverctrls) {
serverctrlsW = controlarrayAtoW( serverctrls );
if (!serverctrlsW) goto exit;
}
if (clientctrls) {
clientctrlsW = controlarrayAtoW( clientctrls );
if (!clientctrlsW) goto exit;
}
ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW,
&retoidW, retdata );
if (oid && !(oidW = strAtoW( oid ))) goto exit;
if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsW = controlarrayAtoW( clientctrls ))) goto exit;
if (retoid && retoidW) {
*retoid = strWtoA( retoidW );
if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
ret = ldap_extended_operation_sW( ld, oidW, data, serverctrlsW, clientctrlsW, &retoidW, retdata );
if (retoid && retoidW)
{
char *str = strWtoA( retoidW );
if (str) *retoid = str;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_memfreeW( retoidW );
}
......@@ -217,8 +167,6 @@ exit:
strfreeW( oidW );
controlarrayfreeW( serverctrlsW );
controlarrayfreeW( clientctrlsW );
#endif
return ret;
}
......@@ -246,49 +194,44 @@ exit:
* and retdata parameters are also optional. Set to NULL if not
* used. Free retoid and retdata after use with ldap_memfree.
*/
ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, PWCHAR oid, struct WLDAP32_berval *data,
PLDAPControlW *serverctrls, PLDAPControlW *clientctrls, PWCHAR *retoid,
struct WLDAP32_berval **retdata )
ULONG CDECL ldap_extended_operation_sW( WLDAP32_LDAP *ld, WCHAR *oid, struct WLDAP32_berval *data,
LDAPControlW **serverctrls, LDAPControlW **clientctrls, WCHAR **retoid, struct WLDAP32_berval **retdata )
{
ULONG ret = WLDAP32_LDAP_NOT_SUPPORTED;
#ifdef HAVE_LDAP
ULONG ret = WLDAP32_LDAP_NO_MEMORY;
char *oidU = NULL, *retoidU = NULL;
LDAPControl **serverctrlsU = NULL, **clientctrlsU = NULL;
LDAPControlU **serverctrlsU = NULL, **clientctrlsU = NULL;
struct bervalU *retdataU, *dataU = NULL;
ret = WLDAP32_LDAP_NO_MEMORY;
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls,
clientctrls, retoid, retdata );
TRACE( "(%p, %s, %p, %p, %p, %p, %p)\n", ld, debugstr_w(oid), data, serverctrls, clientctrls, retoid, retdata );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (oid) {
oidU = strWtoU( oid );
if (!oidU) goto exit;
}
if (serverctrls) {
serverctrlsU = controlarrayWtoU( serverctrls );
if (!serverctrlsU) goto exit;
}
if (clientctrls) {
clientctrlsU = controlarrayWtoU( clientctrls );
if (!clientctrlsU) goto exit;
if (oid && !(oidU = strWtoU( oid ))) goto exit;
if (data && !(dataU = bervalWtoU( data ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
ret = map_error( ldap_funcs->ldap_extended_operation_s( ld->ld, oidU, dataU, serverctrlsU, clientctrlsU,
&retoidU, &retdataU ) );
if (retoid && retoidU)
{
WCHAR *str = strUtoW( retoidU );
if (str) *retoid = str;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_funcs->ldap_memfree( retoidU );
}
ret = map_error( ldap_extended_operation_s( ld->ld, oid ? oidU : "", (struct berval *)data, serverctrlsU,
clientctrlsU, &retoidU, (struct berval **)retdata ));
if (retoid && retoidU) {
*retoid = strUtoW( retoidU );
if (!*retoid) ret = WLDAP32_LDAP_NO_MEMORY;
ldap_memfree( retoidU );
if (retdata && retdataU)
{
struct WLDAP32_berval *bv = bervalUtoW( retdataU );
if (bv) *retdata = bv;
else ret = WLDAP32_LDAP_NO_MEMORY;
ldap_funcs->ber_bvfree( retdataU );
}
exit:
strfreeU( oidU );
bvfreeU( dataU );
controlarrayfreeU( serverctrlsU );
controlarrayfreeU( clientctrlsU );
#endif
return ret;
}
......@@ -379,6 +379,21 @@ char ** CDECL wrap_ldap_explode_dn( const char *dn, int notypes )
return ldap_explode_dn( dn, notypes );
}
int CDECL wrap_ldap_extended_operation( void *ld, const char *oid, struct bervalU *data, LDAPControlU **serverctrls,
LDAPControlU **clientctrls, ULONG *msg )
{
int dummy;
return ldap_extended_operation( ld, oid ? oid : "", (struct berval *)data, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls, msg ? (int *)msg : &dummy );
}
int CDECL wrap_ldap_extended_operation_s( void *ld, const char *oid, struct bervalU *data, LDAPControlU **serverctrls,
LDAPControlU **clientctrls, char **retoid, struct bervalU **retdata )
{
return ldap_extended_operation_s( ld, oid ? oid : "", (struct berval *)data, (LDAPControl **)serverctrls,
(LDAPControl **)clientctrls, retoid, (struct berval **)retdata );
}
char * CDECL wrap_ldap_get_dn( void *ld, void *entry )
{
return ldap_get_dn( ld, entry );
......@@ -530,6 +545,8 @@ static const struct ldap_funcs funcs =
wrap_ldap_delete_ext_s,
wrap_ldap_dn2ufn,
wrap_ldap_explode_dn,
wrap_ldap_extended_operation,
wrap_ldap_extended_operation_s,
wrap_ldap_get_dn,
wrap_ldap_first_attribute,
wrap_ldap_first_entry,
......
......@@ -114,6 +114,10 @@ extern int CDECL wrap_ldap_delete_ext(void *, const char *, LDAPControlU **, LDA
extern int CDECL wrap_ldap_delete_ext_s(void *, const char *, LDAPControlU **, LDAPControlU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_dn2ufn(const char *) DECLSPEC_HIDDEN;
extern char ** CDECL wrap_ldap_explode_dn(const char *, int) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_extended_operation(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, ULONG *) DECLSPEC_HIDDEN;
extern int CDECL wrap_ldap_extended_operation_s(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_get_dn(void *, void *) DECLSPEC_HIDDEN;
extern char * CDECL wrap_ldap_first_attribute(void *, void *, void **) DECLSPEC_HIDDEN;
extern void * CDECL wrap_ldap_first_entry(void *, void *) DECLSPEC_HIDDEN;
......@@ -172,6 +176,10 @@ struct ldap_funcs
int (CDECL *ldap_delete_ext_s)(void *, const char *, LDAPControlU **, LDAPControlU **);
char * (CDECL *ldap_dn2ufn)(const char *);
char ** (CDECL *ldap_explode_dn)(const char *, int);
int (CDECL *ldap_extended_operation)(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, ULONG *);
int (CDECL *ldap_extended_operation_s)(void *, const char *, struct bervalU *, LDAPControlU **,
LDAPControlU **, char **, struct bervalU **);
char * (CDECL *ldap_get_dn)(void *, void *);
char * (CDECL *ldap_first_attribute)(void *, void *, void **);
void * (CDECL *ldap_first_entry)(void *, void *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment