Add helpers for converting (arrays of) LDAPMod structures into

different encodings.
This commit is contained in:
Hans Leidekker 2005-08-10 13:00:21 +00:00 committed by Alexandre Julliard
parent 6b1670c7cb
commit 009485b4b8
2 changed files with 166 additions and 0 deletions

View File

@ -108,6 +108,24 @@ typedef struct ldap
ULONG ld_options;
} WLDAP32_LDAP, *WLDAP32_PLDAP;
typedef struct ldapmodA {
ULONG mod_op;
PCHAR mod_type;
union {
PCHAR *modv_strvals;
struct berval **modv_bvals;
} mod_vals;
} LDAPModA, *PLDAPModA;
typedef struct ldapmodW {
ULONG mod_op;
PWCHAR mod_type;
union {
PWCHAR *modv_strvals;
struct berval **modv_bvals;
} mod_vals;
} LDAPModW, *PLDAPModW;
typedef struct l_timeval
{
LONG tv_sec;
@ -134,6 +152,16 @@ typedef struct ldapmsg
BOOLEAN ConnectionReferenced;
} WLDAP32_LDAPMessage, *WLDAP32_PLDAPMessage;
#define LAPI_MAJOR_VER1 1
#define LAPI_MINOR_VER1 1
typedef struct ldap_version_info
{
ULONG lv_size;
ULONG lv_major;
ULONG lv_minor;
} LDAP_VERSION_INFO, *PLDAP_VERSION_INFO;
typedef struct WLDAP32_berval
{
ULONG bv_len;
@ -154,6 +182,8 @@ typedef struct ldapcontrolW
BOOLEAN ldctl_iscritical;
} LDAPControlW, *PLDAPControlW;
typedef struct ldapsearch LDAPSearch, *PLDAPSearch;
typedef struct ldapsortkeyA
{
PCHAR sk_attrtype;
@ -202,6 +232,14 @@ typedef struct ldap_apifeature_infoW
int ldapaif_version;
} LDAPAPIFeatureInfoW;
ULONG ldap_addA(WLDAP32_LDAP*,PCHAR,LDAPModA*[]);
ULONG ldap_addW(WLDAP32_LDAP*,PWCHAR,LDAPModW*[]);
ULONG ldap_add_extA(WLDAP32_LDAP*,PCHAR,LDAPModA*[],PLDAPControlA*,PLDAPControlA*,ULONG*);
ULONG ldap_add_extW(WLDAP32_LDAP*,PWCHAR,LDAPModW*[],PLDAPControlW*,PLDAPControlW*,ULONG*);
ULONG ldap_add_ext_sA(WLDAP32_LDAP*,PCHAR,LDAPModA*[],PLDAPControlA*,PLDAPControlA*);
ULONG ldap_add_ext_sW(WLDAP32_LDAP*,PWCHAR,LDAPModW*[],PLDAPControlW*,PLDAPControlW*);
ULONG ldap_add_sA(WLDAP32_LDAP*,PCHAR,LDAPModA*[]);
ULONG ldap_add_sW(WLDAP32_LDAP*,PWCHAR,LDAPModW*[]);
ULONG ldap_bindA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);
ULONG ldap_bindW(WLDAP32_LDAP*,PWCHAR,PWCHAR,ULONG);
ULONG ldap_bind_sA(WLDAP32_LDAP*,PCHAR,PCHAR,ULONG);

View File

@ -226,6 +226,134 @@ static inline void strarrayfreeU( char **strarray )
#ifdef HAVE_LDAP
static inline LDAPModW *modAtoW( LDAPModA *mod )
{
LDAPModW *modW;
modW = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPModW) );
if (modW)
{
modW->mod_op = mod->mod_op;
modW->mod_type = strAtoW( mod->mod_type );
if (mod->mod_op & LDAP_MOD_BVALUES)
modW->mod_vals.modv_bvals = mod->mod_vals.modv_bvals;
else
modW->mod_vals.modv_strvals = strarrayAtoW( mod->mod_vals.modv_strvals );
}
return modW;
}
static inline LDAPMod *modWtoU( LDAPModW *mod )
{
LDAPMod *modU;
modU = HeapAlloc( GetProcessHeap(), 0, sizeof(LDAPMod) );
if (modU)
{
modU->mod_op = mod->mod_op;
modU->mod_type = strWtoU( mod->mod_type );
if (mod->mod_op & LDAP_MOD_BVALUES)
modU->mod_vals.modv_bvals = mod->mod_vals.modv_bvals;
else
modU->mod_vals.modv_strvals = strarrayWtoU( mod->mod_vals.modv_strvals );
}
return modU;
}
static inline void modfreeW( LDAPModW *mod )
{
if (!(mod->mod_op & LDAP_MOD_BVALUES))
strarrayfreeW( mod->mod_vals.modv_strvals );
HeapFree( GetProcessHeap(), 0, mod );
}
static inline void modfreeU( LDAPMod *mod )
{
if (!(mod->mod_op & LDAP_MOD_BVALUES))
strarrayfreeU( mod->mod_vals.modv_strvals );
HeapFree( GetProcessHeap(), 0, mod );
}
static inline DWORD modarraylenA( LDAPModA **modarray )
{
LDAPModA **p = modarray;
while (*p) p++;
return p - modarray;
}
static inline DWORD modarraylenW( LDAPModW **modarray )
{
LDAPModW **p = modarray;
while (*p) p++;
return p - modarray;
}
static inline LDAPModW **modarrayAtoW( LDAPModA **modarray )
{
LDAPModW **modarrayW = NULL;
DWORD size;
if (modarray)
{
size = sizeof(LDAPModW*) * (modarraylenA( modarray ) + 1);
modarrayW = HeapAlloc( GetProcessHeap(), 0, size );
if (modarrayW)
{
LDAPModA **p = modarray;
LDAPModW **q = modarrayW;
while (*p) *q++ = modAtoW( *p++ );
*q = NULL;
}
}
return modarrayW;
}
static inline LDAPMod **modarrayWtoU( LDAPModW **modarray )
{
LDAPMod **modarrayU = NULL;
DWORD size;
if (modarray)
{
size = sizeof(LDAPMod*) * (modarraylenW( modarray ) + 1);
modarrayU = HeapAlloc( GetProcessHeap(), 0, size );
if (modarrayU)
{
LDAPModW **p = modarray;
LDAPMod **q = modarrayU;
while (*p) *q++ = modWtoU( *p++ );
*q = NULL;
}
}
return modarrayU;
}
static inline void modarrayfreeW( LDAPModW **modarray )
{
if (modarray)
{
LDAPModW **p = modarray;
while (*p) modfreeW( *p++ );
HeapFree( GetProcessHeap(), 0, modarray );
}
}
static inline void modarrayfreeU( LDAPMod **modarray )
{
if (modarray)
{
LDAPMod **p = modarray;
while (*p) modfreeU( *p++ );
HeapFree( GetProcessHeap(), 0, modarray );
}
}
static inline LDAPControlW *controlAtoW( LDAPControlA *control )
{
LDAPControlW *controlW;