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 @@
#include "wine/debug.h"
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
......@@ -125,6 +126,77 @@ ULONG WLDAP32_ldap_count_references( WLDAP32_LDAP *ld, WLDAP32_LDAPMessage *res
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,
WLDAP32_BerElement** ptr )
{
......
......@@ -283,6 +283,8 @@ PCHAR ldap_dn2ufnA(PCHAR);
PWCHAR ldap_dn2ufnW(PWCHAR);
PCHAR ldap_err2stringA(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);
PWCHAR *ldap_explode_dnW(PWCHAR,ULONG);
ULONG ldap_extended_operationA(WLDAP32_LDAP*,PCHAR,struct WLDAP32_berval*,PLDAPControlA*,PLDAPControlA*,ULONG*);
......
......@@ -95,9 +95,9 @@
@ cdecl ldap_err2string(long) ldap_err2stringA
@ cdecl ldap_err2stringA(long)
@ cdecl ldap_err2stringW(long)
@ stub ldap_escape_filter_element
@ stub ldap_escape_filter_elementA
@ stub ldap_escape_filter_elementW
@ cdecl ldap_escape_filter_element(str long ptr long) ldap_escape_filter_elementA
@ cdecl ldap_escape_filter_elementA(str long ptr long)
@ cdecl ldap_escape_filter_elementW(wstr long ptr long)
@ cdecl ldap_explode_dn(str long) ldap_explode_dnA
@ cdecl ldap_explode_dnA(str long)
@ cdecl ldap_explode_dnW(wstr long)
......
......@@ -445,7 +445,7 @@ PCHAR ldap_err2stringA(ULONG);
PWCHAR ldap_err2stringW(ULONG);
#define ldap_err2string WINELIB_NAME_AW(ldap_err2string)
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)
PCHAR *ldap_explode_dnA(PCHAR,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