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

Implement ldap_escape_filter_element*.

parent fa1dca30
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "wine/debug.h" #include "wine/debug.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -125,6 +126,77 @@ ULONG WLDAP32_ldap_count_references( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res ...@@ -125,6 +126,77 @@ ULONG WLDAP32_ldap_count_references( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res
return ret; return ret;
} }
static ULONG get_escape_size( PCHAR src, ULONG srclen )
{
ULONG i, size = 0;
if (src)
{
for (i = 0; i < srclen; i++)
{
if ((src[i] >= '0' && src[i] <= '9') ||
(src[i] >= 'A' && src[i] <= 'Z') ||
(src[i] >= 'a' && src[i] <= 'z'))
size++;
else
size += 3;
}
}
return size + 1;
}
static void escape_filter_element( PCHAR src, ULONG srclen, PCHAR dst )
{
ULONG i;
char fmt[] = "\\%02X";
char *d = dst;
for (i = 0; i < srclen; i++)
{
if ((src[i] >= '0' && src[i] <= '9') ||
(src[i] >= 'A' && src[i] <= 'Z') ||
(src[i] >= 'a' && src[i] <= 'z'))
*d++ = src[i];
else
{
sprintf( d, fmt, (unsigned char)src[i] );
d += 3;
}
}
*++d = 0;
}
ULONG ldap_escape_filter_elementA( PCHAR src, ULONG srclen, PCHAR dst, ULONG dstlen )
{
ULONG len;
TRACE( "(%p, 0x%08lx, %p, 0x%08lx)\n", src, srclen, dst, dstlen );
len = get_escape_size( src, srclen );
if (!dst) return len;
if (!src || dstlen < len)
return WLDAP32_LDAP_PARAM_ERROR;
else
{
escape_filter_element( src, srclen, dst );
return LDAP_SUCCESS;
}
}
ULONG ldap_escape_filter_elementW( PCHAR src, ULONG srclen, PWCHAR dst, ULONG dstlen )
{
ULONG len;
TRACE( "(%p, 0x%08lx, %p, 0x%08lx)\n", src, srclen, dst, dstlen );
len = get_escape_size( src, srclen );
if (!dst) return len;
/* no matter what you throw at it, this is what native returns */
return WLDAP32_LDAP_PARAM_ERROR;
}
PCHAR ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry, PCHAR ldap_first_attributeA( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *entry,
WLDAP32_BerElement** ptr ) WLDAP32_BerElement** ptr )
{ {
......
...@@ -283,6 +283,8 @@ PCHAR ldap_dn2ufnA(PCHAR); ...@@ -283,6 +283,8 @@ PCHAR ldap_dn2ufnA(PCHAR);
PWCHAR ldap_dn2ufnW(PWCHAR); PWCHAR ldap_dn2ufnW(PWCHAR);
PCHAR ldap_err2stringA(ULONG); PCHAR ldap_err2stringA(ULONG);
PWCHAR ldap_err2stringW(ULONG); PWCHAR ldap_err2stringW(ULONG);
ULONG ldap_escape_filter_elementA(PCHAR,ULONG,PCHAR,ULONG);
ULONG ldap_escape_filter_elementW(PCHAR,ULONG,PWCHAR,ULONG);
PCHAR *ldap_explode_dnA(PCHAR,ULONG); PCHAR *ldap_explode_dnA(PCHAR,ULONG);
PWCHAR *ldap_explode_dnW(PWCHAR,ULONG); PWCHAR *ldap_explode_dnW(PWCHAR,ULONG);
ULONG ldap_extended_operationA(WLDAP32_LDAP*,PCHAR,struct WLDAP32_berval*,PLDAPControlA*,PLDAPControlA*,ULONG*); ULONG ldap_extended_operationA(WLDAP32_LDAP*,PCHAR,struct WLDAP32_berval*,PLDAPControlA*,PLDAPControlA*,ULONG*);
......
...@@ -95,9 +95,9 @@ ...@@ -95,9 +95,9 @@
@ cdecl ldap_err2string(long) ldap_err2stringA @ cdecl ldap_err2string(long) ldap_err2stringA
@ cdecl ldap_err2stringA(long) @ cdecl ldap_err2stringA(long)
@ cdecl ldap_err2stringW(long) @ cdecl ldap_err2stringW(long)
@ stub ldap_escape_filter_element @ cdecl ldap_escape_filter_element(str long ptr long) ldap_escape_filter_elementA
@ stub ldap_escape_filter_elementA @ cdecl ldap_escape_filter_elementA(str long ptr long)
@ stub ldap_escape_filter_elementW @ cdecl ldap_escape_filter_elementW(wstr long ptr long)
@ cdecl ldap_explode_dn(str long) ldap_explode_dnA @ cdecl ldap_explode_dn(str long) ldap_explode_dnA
@ cdecl ldap_explode_dnA(str long) @ cdecl ldap_explode_dnA(str long)
@ cdecl ldap_explode_dnW(wstr long) @ cdecl ldap_explode_dnW(wstr long)
......
...@@ -445,7 +445,7 @@ PCHAR ldap_err2stringA(ULONG); ...@@ -445,7 +445,7 @@ PCHAR ldap_err2stringA(ULONG);
PWCHAR ldap_err2stringW(ULONG); PWCHAR ldap_err2stringW(ULONG);
#define ldap_err2string WINELIB_NAME_AW(ldap_err2string) #define ldap_err2string WINELIB_NAME_AW(ldap_err2string)
ULONG ldap_escape_filter_elementA(PCHAR,ULONG,PCHAR,ULONG); ULONG ldap_escape_filter_elementA(PCHAR,ULONG,PCHAR,ULONG);
ULONG ldap_escape_filter_elementW(PWCHAR,ULONG,PWCHAR,ULONG); ULONG ldap_escape_filter_elementW(PCHAR,ULONG,PWCHAR,ULONG);
#define ldap_escape_filter_element WINELIB_NAME_AW(ldap_escape_filter_element) #define ldap_escape_filter_element WINELIB_NAME_AW(ldap_escape_filter_element)
PCHAR *ldap_explode_dnA(PCHAR,ULONG); PCHAR *ldap_explode_dnA(PCHAR,ULONG);
PWCHAR *ldap_explode_dnW(PWCHAR,ULONG); PWCHAR *ldap_explode_dnW(PWCHAR,ULONG);
......
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