Commit 1bccd288 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

Add helpers for converting (arrays of) LDAPSortKey, LDAPAPIInfo, and

LDAPAPIFeatureInfo structures into different encodings.
parent ae7a646f
...@@ -43,6 +43,44 @@ typedef enum { ...@@ -43,6 +43,44 @@ typedef enum {
WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED = 0x61 WLDAP32_LDAP_REFERRAL_LIMIT_EXCEEDED = 0x61
} LDAP_RETCODE; } LDAP_RETCODE;
#define LDAP_OPT_THREAD_FN_PTRS 0x05
#define LDAP_OPT_REBIND_FN 0x06
#define LDAP_OPT_REBIND_ARG 0x07
#define LDAP_OPT_SSL 0x0a
#define LDAP_OPT_IO_FN_PTRS 0x0b
#define LDAP_OPT_CACHE_FN_PTRS 0x0d
#define LDAP_OPT_CACHE_STRATEGY 0x0e
#define LDAP_OPT_CACHE_ENABLE 0x0f
#define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10
#define LDAP_OPT_VERSION 0x11
#define LDAP_OPT_SERVER_ERROR 0x33
#define LDAP_OPT_SERVER_EXT_ERROR 0x34
#define LDAP_OPT_PING_KEEP_ALIVE 0x36
#define LDAP_OPT_PING_WAIT_TIME 0x37
#define LDAP_OPT_PING_LIMIT 0x38
#define LDAP_OPT_DNSDOMAIN_NAME 0x3b
#define LDAP_OPT_GETDSNAME_FLAGS 0x3d
#define LDAP_OPT_HOST_REACHABLE 0x3e
#define LDAP_OPT_PROMPT_CREDENTIALS 0x3f
#define LDAP_OPT_TCP_KEEPALIVE 0x40
#define LDAP_OPT_FAST_CONCURRENT_BIND 0x41
#define LDAP_OPT_SEND_TIMEOUT 0x42
#define LDAP_OPT_REFERRAL_CALLBACK 0x70
#define LDAP_OPT_CLIENT_CERTIFICATE 0x80
#define LDAP_OPT_SERVER_CERTIFICATE 0x81
#define LDAP_OPT_AUTO_RECONNECT 0x91
#define LDAP_OPT_SSPI_FLAGS 0x92
#define LDAP_OPT_SSL_INFO 0x93
#define LDAP_OPT_REF_DEREF_CONN_PER_MSG 0x94
#define LDAP_OPT_TLS LDAP_OPT_SSL
#define LDAP_OPT_TLS_INFO LDAP_OPT_SSL_INFO
#define LDAP_OPT_SIGN 0x95
#define LDAP_OPT_ENCRYPT 0x96
#define LDAP_OPT_SASL_METHOD 0x97
#define LDAP_OPT_AREC_EXCLUSIVE 0x98
#define LDAP_OPT_SECURITY_CONTEXT 0x99
#define LDAP_OPT_ROOTDSE_CACHE 0x9a
typedef struct ldap typedef struct ldap
{ {
struct struct
...@@ -116,6 +154,54 @@ typedef struct ldapcontrolW ...@@ -116,6 +154,54 @@ typedef struct ldapcontrolW
BOOLEAN ldctl_iscritical; BOOLEAN ldctl_iscritical;
} LDAPControlW, *PLDAPControlW; } LDAPControlW, *PLDAPControlW;
typedef struct ldapsortkeyA
{
PCHAR sk_attrtype;
PCHAR sk_matchruleoid;
BOOLEAN sk_reverseorder;
} LDAPSortKeyA, *PLDAPSortKeyA;
typedef struct ldapsortkeyW
{
PWCHAR sk_attrtype;
PWCHAR sk_matchruleoid;
BOOLEAN sk_reverseorder;
} LDAPSortKeyW, *PLDAPSortKeyW;
typedef struct ldapapiinfoA
{
int ldapai_info_version;
int ldapai_api_version;
int ldapai_protocol_version;
char **ldapai_extensions;
char *ldapai_vendor_name;
int ldapai_vendor_version;
} LDAPAPIInfoA;
typedef struct ldapapiinfoW
{
int ldapai_info_version;
int ldapai_api_version;
int ldapai_protocol_version;
PWCHAR *ldapai_extensions;
PWCHAR ldapai_vendor_name;
int ldapai_vendor_version;
} LDAPAPIInfoW;
typedef struct ldap_apifeature_infoA
{
int ldapaif_info_version;
char *ldapaif_name;
int ldapaif_version;
} LDAPAPIFeatureInfoA;
typedef struct ldap_apifeature_infoW
{
int ldapaif_info_version;
PWCHAR ldapaif_name;
int ldapaif_version;
} LDAPAPIFeatureInfoW;
ULONG ldap_bindA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG); ULONG ldap_bindA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);
ULONG ldap_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR,ULONG); ULONG ldap_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR,ULONG);
ULONG ldap_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG); ULONG ldap_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);
...@@ -136,6 +222,8 @@ PCHAR *ldap_explode_dnA(PCHAR,ULONG); ...@@ -136,6 +222,8 @@ PCHAR *ldap_explode_dnA(PCHAR,ULONG);
PWCHAR *ldap_explode_dnW(PWCHAR,ULONG); PWCHAR *ldap_explode_dnW(PWCHAR,ULONG);
PCHAR ldap_get_dnA(WLDAP32_LDAP*,WLDAP32_LDAPMessage*); PCHAR ldap_get_dnA(WLDAP32_LDAP*,WLDAP32_LDAPMessage*);
PWCHAR ldap_get_dnW(WLDAP32_LDAP*,WLDAP32_LDAPMessage*); PWCHAR ldap_get_dnW(WLDAP32_LDAP*,WLDAP32_LDAPMessage*);
ULONG ldap_get_optionA(WLDAP32_LDAP*,int,void*);
ULONG ldap_get_optionW(WLDAP32_LDAP*,int,void*);
WLDAP32_LDAP *ldap_initA(const PCHAR,ULONG); WLDAP32_LDAP *ldap_initA(const PCHAR,ULONG);
WLDAP32_LDAP *ldap_initW(const PWCHAR,ULONG); WLDAP32_LDAP *ldap_initW(const PWCHAR,ULONG);
void ldap_memfreeA(PCHAR); void ldap_memfreeA(PCHAR);
...@@ -164,6 +252,8 @@ ULONG ldap_search_stA(WLDAP32_LDAP*,const PCHAR,ULONG,const PCHAR,PCHAR[],ULONG, ...@@ -164,6 +252,8 @@ ULONG ldap_search_stA(WLDAP32_LDAP*,const PCHAR,ULONG,const PCHAR,PCHAR[],ULONG,
struct l_timeval*,WLDAP32_LDAPMessage**); struct l_timeval*,WLDAP32_LDAPMessage**);
ULONG ldap_search_stW(WLDAP32_LDAP*,const PWCHAR,ULONG,const PWCHAR,PWCHAR[],ULONG, ULONG ldap_search_stW(WLDAP32_LDAP*,const PWCHAR,ULONG,const PWCHAR,PWCHAR[],ULONG,
struct l_timeval*,WLDAP32_LDAPMessage**); struct l_timeval*,WLDAP32_LDAPMessage**);
ULONG ldap_set_optionA(WLDAP32_LDAP*,int,void*);
ULONG ldap_set_optionW(WLDAP32_LDAP*,int,void*);
ULONG ldap_simple_bindA(WLDAP32_LDAP*,PCHAR,PCHAR); ULONG ldap_simple_bindA(WLDAP32_LDAP*,PCHAR,PCHAR);
ULONG ldap_simple_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR); ULONG ldap_simple_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR);
ULONG ldap_simple_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR); ULONG ldap_simple_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR);
......
...@@ -444,4 +444,304 @@ static inline void controlarrayfreeU( LDAPControl **controlarray ) ...@@ -444,4 +444,304 @@ static inline void controlarrayfreeU( LDAPControl **controlarray )
} }
} }
static inline LDAPSortKeyW *sortkeyAtoW( LDAPSortKeyA *sortkey )
{
LDAPSortKeyW *sortkeyW;
sortkeyW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyW) );
if (sortkeyW)
{
sortkeyW->sk_attrtype = strAtoW( sortkey->sk_attrtype );
sortkeyW->sk_matchruleoid = strAtoW( sortkey->sk_matchruleoid );
sortkeyW->sk_reverseorder = sortkey->sk_reverseorder;
}
return sortkeyW;
}
static inline LDAPSortKeyA *sortkeyWtoA( LDAPSortKeyW *sortkey )
{
LDAPSortKeyA *sortkeyA;
sortkeyA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKeyA) );
if (sortkeyA)
{
sortkeyA->sk_attrtype = strWtoA( sortkey->sk_attrtype );
sortkeyA->sk_matchruleoid = strWtoA( sortkey->sk_matchruleoid );
sortkeyA->sk_reverseorder = sortkey->sk_reverseorder;
}
return sortkeyA;
}
static inline LDAPSortKey *sortkeyWtoU( LDAPSortKeyW *sortkey )
{
LDAPSortKey *sortkeyU;
sortkeyU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPSortKey) );
if (sortkeyU)
{
sortkeyU->attributeType = strWtoU( sortkey->sk_attrtype );
sortkeyU->orderingRule = strWtoU( sortkey->sk_matchruleoid );
sortkeyU->reverseOrder = sortkey->sk_reverseorder;
}
return sortkeyU;
}
static inline void sortkeyfreeA( LDAPSortKeyA *sortkey )
{
if (sortkey)
{
strfreeA( sortkey->sk_attrtype );
strfreeA( sortkey->sk_matchruleoid );
HeapFree( GetProcessHeap(), 0, sortkey );
}
}
static inline void sortkeyfreeW( LDAPSortKeyW *sortkey )
{
if (sortkey)
{
strfreeW( sortkey->sk_attrtype );
strfreeW( sortkey->sk_matchruleoid );
HeapFree( GetProcessHeap(), 0, sortkey );
}
}
static inline void sortkeyfreeU( LDAPSortKey *sortkey )
{
if (sortkey)
{
strfreeU( sortkey->attributeType );
strfreeU( sortkey->orderingRule );
HeapFree( GetProcessHeap(), 0, sortkey );
}
}
static inline DWORD sortkeyarraylenA( LDAPSortKeyA **sortkeyarray )
{
LDAPSortKeyA **p = sortkeyarray;
while (*p) p++;
return p - sortkeyarray;
}
static inline DWORD sortkeyarraylenW( LDAPSortKeyW **sortkeyarray )
{
LDAPSortKeyW **p = sortkeyarray;
while (*p) p++;
return p - sortkeyarray;
}
static inline LDAPSortKeyW **sortkeyarrayAtoW( LDAPSortKeyA **sortkeyarray )
{
LDAPSortKeyW **sortkeyarrayW = NULL;
DWORD size;
if (sortkeyarray)
{
size = sizeof(LDAPSortKeyW*) * (sortkeyarraylenA( sortkeyarray ) + 1);
sortkeyarrayW = HeapAlloc( GetProcessHeap(), 0, size );
if (sortkeyarrayW)
{
LDAPSortKeyA **p = sortkeyarray;
LDAPSortKeyW **q = sortkeyarrayW;
while (*p) *q++ = sortkeyAtoW( *p++ );
*q = NULL;
}
}
return sortkeyarrayW;
}
static inline LDAPSortKey **sortkeyarrayWtoU( LDAPSortKeyW **sortkeyarray )
{
LDAPSortKey **sortkeyarrayU = NULL;
DWORD size;
if (sortkeyarray)
{
size = sizeof(LDAPSortKey*) * (sortkeyarraylenW( sortkeyarray ) + 1);
sortkeyarrayU = HeapAlloc( GetProcessHeap(), 0, size );
if (sortkeyarrayU)
{
LDAPSortKeyW **p = sortkeyarray;
LDAPSortKey **q = sortkeyarrayU;
while (*p) *q++ = sortkeyWtoU( *p++ );
*q = NULL;
}
}
return sortkeyarrayU;
}
static inline void sortkeyarrayfreeW( LDAPSortKeyW **sortkeyarray )
{
if (sortkeyarray)
{
LDAPSortKeyW **p = sortkeyarray;
while (*p) sortkeyfreeW( *p++ );
HeapFree( GetProcessHeap(), 0, sortkeyarray );
}
}
static inline void sortkeyarrayfreeU( LDAPSortKey **sortkeyarray )
{
if (sortkeyarray)
{
LDAPSortKey **p = sortkeyarray;
while (*p) sortkeyfreeU( *p++ );
HeapFree( GetProcessHeap(), 0, sortkeyarray );
}
}
static inline LDAPAPIInfoW *infoAtoW( LDAPAPIInfoA *info )
{
LDAPAPIInfoW *infoW;
infoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoW) );
if (infoW)
{
memcpy( infoW, info, sizeof(LDAPAPIInfoA) );
infoW->ldapai_extensions = strarrayAtoW( info->ldapai_extensions );
infoW->ldapai_vendor_name = strAtoW( info->ldapai_vendor_name );
}
return infoW;
}
static inline LDAPAPIInfoA *infoWtoA( LDAPAPIInfoW *info )
{
LDAPAPIInfoA *infoA;
infoA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoA) );
if (infoA)
{
memcpy( infoA, info, sizeof(LDAPAPIInfoW) );
infoA->ldapai_extensions = strarrayWtoA( info->ldapai_extensions );
infoA->ldapai_vendor_name = strWtoA( info->ldapai_vendor_name );
}
return infoA;
}
static inline LDAPAPIInfoW *infoUtoW( LDAPAPIInfo *info )
{
LDAPAPIInfoW *infoW;
infoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfoW) );
if (infoW)
{
memcpy( infoW, info, sizeof(LDAPAPIInfo) );
infoW->ldapai_extensions = strarrayUtoW( info->ldapai_extensions );
infoW->ldapai_vendor_name = strUtoW( info->ldapai_vendor_name );
}
return infoW;
}
static inline LDAPAPIInfo *infoWtoU( LDAPAPIInfoW *info )
{
LDAPAPIInfo *infoU;
infoU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIInfo) );
if (infoU)
{
memcpy( infoU, info, sizeof(LDAPAPIInfoW) );
infoU->ldapai_extensions = strarrayWtoU( info->ldapai_extensions );
infoU->ldapai_vendor_name = strWtoU( info->ldapai_vendor_name );
}
return infoU;
}
static inline void infofreeW( LDAPAPIInfoW *info )
{
if (info)
{
strarrayfreeW( info->ldapai_extensions );
strfreeW( info->ldapai_vendor_name );
HeapFree( GetProcessHeap(), 0, info );
}
}
static inline void infofreeU( LDAPAPIInfo *info )
{
if (info)
{
strarrayfreeU( info->ldapai_extensions );
strfreeU( info->ldapai_vendor_name );
HeapFree( GetProcessHeap(), 0, info );
}
}
static inline LDAPAPIFeatureInfoW *featureinfoAtoW( LDAPAPIFeatureInfoA *featureinfo )
{
LDAPAPIFeatureInfoW *featureinfoW;
featureinfoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoW) );
if (featureinfoW)
{
featureinfoW->ldapaif_info_version = featureinfo->ldapaif_info_version;
featureinfoW->ldapaif_name = strAtoW( featureinfo->ldapaif_name );
featureinfoW->ldapaif_version = featureinfo->ldapaif_version;
}
return featureinfoW;
}
static inline LDAPAPIFeatureInfoA *featureinfoWtoA( LDAPAPIFeatureInfoW *featureinfo )
{
LDAPAPIFeatureInfoA *featureinfoA;
featureinfoA = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoA) );
if (featureinfoA)
{
featureinfoA->ldapaif_info_version = featureinfo->ldapaif_info_version;
featureinfoA->ldapaif_name = strWtoA( featureinfo->ldapaif_name );
featureinfoA->ldapaif_version = featureinfo->ldapaif_version;
}
return featureinfoA;
}
static inline LDAPAPIFeatureInfoW *featureinfoUtoW( LDAPAPIFeatureInfo *featureinfo )
{
LDAPAPIFeatureInfoW *featureinfoW;
featureinfoW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfoW) );
if (featureinfoW)
{
featureinfoW->ldapaif_info_version = featureinfo->ldapaif_info_version;
featureinfoW->ldapaif_name = strUtoW( featureinfo->ldapaif_name );
featureinfoW->ldapaif_version = featureinfo->ldapaif_version;
}
return featureinfoW;
}
static inline LDAPAPIFeatureInfo *featureinfoWtoU( LDAPAPIFeatureInfoW *featureinfo )
{
LDAPAPIFeatureInfo *featureinfoU;
featureinfoU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPAPIFeatureInfo) );
if (featureinfoU)
{
featureinfoU->ldapaif_info_version = featureinfo->ldapaif_info_version;
featureinfoU->ldapaif_name = strWtoU( featureinfo->ldapaif_name );
featureinfoU->ldapaif_version = featureinfo->ldapaif_version;
}
return featureinfoU;
}
static inline void featureinfofreeW( LDAPAPIFeatureInfoW *featureinfo )
{
if (featureinfo)
{
strfreeW( featureinfo->ldapaif_name );
HeapFree( GetProcessHeap(), 0, featureinfo );
}
}
static inline void featureinfofreeU( LDAPAPIFeatureInfo *featureinfo )
{
if (featureinfo)
{
strfreeU( featureinfo->ldapaif_name );
HeapFree( GetProcessHeap(), 0, featureinfo );
}
}
#endif /* HAVE_LDAP */ #endif /* HAVE_LDAP */
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