--- /dev/null
+# Microsoft Developer Studio Project File - Name="ucgendat" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ucgendat - Win32 Single Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "ucgendat.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "ucgendat.mak" CFG="ucgendat - Win32 Single Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "ucgendat - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "ucgendat - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "ucgendat - Win32 Single Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "ucgendat - Win32 Single Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "ucgendat - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\Release"
+# PROP Intermediate_Dir "..\..\Release\ucgendat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 oldap32.lib olber32.lib sasl.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\Release"
+
+!ELSEIF "$(CFG)" == "ucgendat - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ucgendat_"
+# PROP BASE Intermediate_Dir "ucgendat_"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\Debug"
+# PROP Intermediate_Dir "..\..\Debug\ucgendat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 oldap32.lib olber32.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\Debug"
+
+!ELSEIF "$(CFG)" == "ucgendat - Win32 Single Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ucgendat_"
+# PROP BASE Intermediate_Dir "ucgendat_"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "..\..\SDebug"
+# PROP Intermediate_Dir "..\..\SDebug\ucgendat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 oldap32.lib olber32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\Debug"
+# ADD LINK32 oldap32.lib olber32.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\SDebug"
+
+!ELSEIF "$(CFG)" == "ucgendat - Win32 Single Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ucgendat0"
+# PROP BASE Intermediate_Dir "ucgendat0"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "..\..\SRelease"
+# PROP Intermediate_Dir "..\..\SRelease\ucgendat"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 oldap32.lib olber32.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\Release"
+# ADD LINK32 oldap32.lib olber32.lib sasl.lib libsasl.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\SRelease"
+
+!ENDIF
+
+# Begin Target
+
+# Name "ucgendat - Win32 Release"
+# Name "ucgendat - Win32 Debug"
+# Name "ucgendat - Win32 Single Debug"
+# Name "ucgendat - Win32 Single Release"
+# Begin Source File
+
+SOURCE=.\ucdata\ucgendat.c
+# End Source File
+# End Target
+# End Project
#include "slap.h"
#include "ldap_pvt.h"
+#include "ldap_pvt_uc.h"
#include "lutil_md5.h"
/* recycled validatation routines */
#define objectIdentifierMatch numericStringMatch
#define integerMatch numericStringMatch
#define telephoneNumberMatch numericStringMatch
-#define telephoneNumberSubstringsMatch caseIgnoreIA5SubstringsMatch
+#define telephoneNumberSubstringsMatch caseIgnoreSubstringsMatch
#define generalizedTimeMatch numericStringMatch
#define generalizedTimeOrderingMatch numericStringMatch
#define uniqueMemberMatch dnMatch
return LDAP_SUCCESS;
}
-#if 0
-static int
-UTF8casecmp(
- struct berval *right,
- struct berval *left )
-{
- ber_len_t r, l;
- int rlen, llen;
- ldap_unicode_t ru, lu;
- ldap_unicode_t ruu, luu;
-
- for( r=0, l=0;
- r < right->bv_len && l < left->bv_len;
- r+=rlen, l+=llen )
- {
- /*
- * XXYYZ: we convert to ucs4 even though -llunicode
- * expects ucs2 in an unsigned long
- */
- ru = ldap_utf8_to_ucs4( &right->bv_val[r] );
- if( ru == LDAP_UCS4_INVALID ) {
- return 1;
- }
-
- lu = ldap_utf8_to_ucs4( &left->bv_val[l] );
- if( lu == LDAP_UCS4_INVALID ) {
- return -1;
- }
-
- ruu = uctoupper( ru );
- luu = uctoupper( lu );
-
- if( ruu > luu ) {
- return 1;
- } else if( luu > ruu ) {
- return -1;
- }
-
- rlen = LDAP_UTF8_CHARLEN( &right->bv_val[r] );
- llen = LDAP_UTF8_CHARLEN( &left->bv_val[l] );
- }
-
- if( r < right->bv_len ) {
- /* less left */
- return -1;
- }
-
- if( l < left->bv_len ) {
- /* less right */
- return 1;
- }
-
- return 0;
-}
-#endif
-
static int
UTF8StringValidate(
Syntax *syntax,
return LDAP_SUCCESS;
}
+#define UNICODE2LEN(n) ((n)*sizeof(ldap_unicode_t))
+#define LEN2UNICODE(n) ((n)/sizeof(ldap_unicode_t))
+
+#define SLAP_INDEX_SUBSTR_UMINLEN UNICODE2LEN(SLAP_INDEX_SUBSTR_MINLEN)
+#define SLAP_INDEX_SUBSTR_UMAXLEN UNICODE2LEN(SLAP_INDEX_SUBSTR_MAXLEN)
+#define SLAP_INDEX_SUBSTR_USTEP UNICODE2LEN(SLAP_INDEX_SUBSTR_STEP)
+
static int
UTF8StringNormalize(
Syntax *syntax,
struct berval *val,
struct berval **normalized )
{
+ ber_len_t bcount;
+ ber_len_t ucount;
+ int len, space;
+ char *u;
struct berval *newval;
- char *p, *q, *s;
+ ldap_unicode_t *uc;
- newval = ch_malloc( sizeof( struct berval ) );
+ if( !val->bv_len ) return LDAP_INVALID_SYNTAX;
- p = val->bv_val;
+ u = val->bv_val;
+ ucount = 0;
+ space = 1;
- /* Ignore initial whitespace */
- while ( ldap_utf8_isspace( p ) ) {
- LDAP_UTF8_INCR( p );
- }
+ for( bcount = val->bv_len; bcount > 0; bcount-=len, u+=len ) {
+ /* get the length indicated by the first byte */
+ len = LDAP_UTF8_CHARLEN( u );
- if( *p == '\0' ) {
- ch_free( newval );
- return LDAP_INVALID_SYNTAX;
- }
+ /* should not be zero */
+ if( len == 0 ) return LDAP_INVALID_SYNTAX;
- newval->bv_val = ch_strdup( p );
- p = q = newval->bv_val;
- s = NULL;
+ if( ldap_utf8_isspace( u ) ) {
+ if( space ) continue;
+ } else {
+ space=1;
+ }
- while ( *p ) {
- int len;
+ ucount++;
+ }
- if ( ldap_utf8_isspace( p ) ) {
- len = LDAP_UTF8_COPY(q,p);
- s=q;
- p+=len;
- q+=len;
+ if( ucount <= 1 ) {
+ return LDAP_INVALID_SYNTAX;
+ }
- /* Ignore the extra whitespace */
- while ( ldap_utf8_isspace( p ) ) {
- LDAP_UTF8_INCR( p );
- }
- } else {
- len = LDAP_UTF8_COPY(q,p);
- s=NULL;
- p+=len;
- q+=len;
- }
+ if( space ) {
+ ucount--;
}
- assert( *newval->bv_val );
- assert( newval->bv_val < p );
- assert( p >= q );
+ newval = ch_malloc( sizeof( struct berval ) );
+ newval->bv_val = ch_malloc( UNICODE2LEN(ucount+1) );
+ uc = (ldap_unicode_t *) newval->bv_val;
- /* cannot start with a space */
- assert( !ldap_utf8_isspace(newval->bv_val) );
+ u = val->bv_val;
+ ucount = 0;
+ space = 1;
- /*
- * If the string ended in space, backup the pointer one
- * position. One is enough because the above loop collapsed
- * all whitespace to a single space.
- */
+ for( bcount = val->bv_len; bcount > 0; bcount-=len, u+=len ) {
+ /* get the length indicated by the first byte */
+ len = LDAP_UTF8_CHARLEN( u );
- if ( s != NULL ) {
- q = s;
- }
+ /* should not be zero */
+ if( len == 0 ) return LDAP_INVALID_SYNTAX;
- /* cannot end with a space */
- assert( !ldap_utf8_isspace( LDAP_UTF8_PREV(q) ) );
+ if( ldap_utf8_isspace( u ) ) {
+ if( space ) continue;
+ } else {
+ space=1;
+ }
- /* null terminate */
- *q = '\0';
+ uc[ucount++] = ldap_utf8_to_unicode( u );
+ }
- newval->bv_len = q - newval->bv_val;
- *normalized = newval;
+ if( space ) ucount--;
+ uc[ucount] = 0;
+ newval->bv_len = UNICODE2LEN(ucount);
return LDAP_SUCCESS;
}
int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
if( match == 0 ) {
- match = strncmp( value->bv_val,
- ((struct berval *) assertedValue)->bv_val,
- value->bv_len );
+ match = ucstrncmp( (ldap_unicode_t *) value->bv_val,
+ (ldap_unicode_t *) ((struct berval *) assertedValue)->bv_val,
+ LEN2UNICODE(value->bv_len) );
}
*matchp = match;
goto done;
}
- match = strncmp( sub->sa_initial->bv_val, left.bv_val,
- sub->sa_initial->bv_len );
+ match = ucstrncmp(
+ (ldap_unicode_t *) sub->sa_initial->bv_val,
+ (ldap_unicode_t *) left.bv_val,
+ LEN2UNICODE(sub->sa_initial->bv_len) );
if( match != 0 ) {
goto done;
goto done;
}
- match = strncmp( sub->sa_final->bv_val,
- &left.bv_val[left.bv_len - sub->sa_final->bv_len],
- sub->sa_final->bv_len );
+ match = ucstrncmp(
+ (ldap_unicode_t *) sub->sa_final->bv_val,
+ (ldap_unicode_t *) &left.bv_val[left.bv_len - sub->sa_final->bv_len],
+ LEN2UNICODE(sub->sa_final->bv_len) );
if( match != 0 ) {
goto done;
continue;
}
- p = strchr( left.bv_val, *sub->sa_any[i]->bv_val );
+ p = (char *) ucstrnchr(
+ (ldap_unicode_t *) left.bv_val,
+ LEN2UNICODE(left.bv_len),
+ ((ldap_unicode_t *) sub->sa_any[i]->bv_val)[0] );
+
if( p == NULL ) {
match = 1;
goto done;
}
- match = strncmp( left.bv_val,
- sub->sa_any[i]->bv_val,
- sub->sa_any[i]->bv_len );
+ match = ucstrncmp(
+ (ldap_unicode_t *) left.bv_val,
+ (ldap_unicode_t *) sub->sa_any[i]->bv_val,
+ LEN2UNICODE(sub->sa_any[i]->bv_len) );
if( match != 0 ) {
- left.bv_val++;
- left.bv_len--;
+ left.bv_val += UNICODE2LEN(1);
+ left.bv_len -= UNICODE2LEN(1);
goto retry;
}
nkeys=0;
for( i=0; values[i] != NULL; i++ ) {
/* count number of indices to generate */
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+ if( values[i]->bv_len < SLAP_INDEX_SUBSTR_UMINLEN ) {
continue;
}
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
- ( SLAP_INDEX_SUBSTR_MINLEN - 1);
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_ANY ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
- ( SLAP_INDEX_SUBSTR_MINLEN - 1);
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
}
struct berval *value;
value = values[i];
- if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+ if( value->bv_len < SLAP_INDEX_SUBSTR_UMINLEN ) continue;
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
- ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
+ ( value->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
- max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
+ max = value->bv_len -
+ ( SLAP_INDEX_SUBSTR_UMAXLEN - UNICODE2LEN(1));
- for( j=0; j<max; j++ ) {
+ for( j=0; j<max; j+=UNICODE2LEN(1) ) {
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
lutil_MD5Update( &MD5context,
prefix->bv_val, prefix->bv_len );
}
-
lutil_MD5Update( &MD5context,
&pre, sizeof( pre ) );
lutil_MD5Update( &MD5context,
lutil_MD5Update( &MD5context,
mr->smr_oid, mlen );
lutil_MD5Update( &MD5context,
- &value->bv_val[j],
- SLAP_INDEX_SUBSTR_MAXLEN );
+ &value->bv_val[j], SLAP_INDEX_SUBSTR_UMAXLEN );
lutil_MD5Final( MD5digest, &MD5context );
keys[nkeys++] = ber_bvdup( &digest );
}
}
- max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ max = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
- for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
+ for( j=SLAP_INDEX_SUBSTR_UMINLEN; j<=max; j+=UNICODE2LEN(1) ) {
char pre;
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
struct berval digest;
if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
- sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
nkeys++;
}
if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
ber_len_t i;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
- if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
/* don't bother accounting for stepping */
- nkeys += sa->sa_any[i]->bv_len -
+ nkeys += LEN2UNICODE(sa->sa_any[i]->bv_len) -
( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
- sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
nkeys++;
}
nkeys = 0;
if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
- sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
value = sa->sa_initial;
- klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
ber_len_t i, j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
- klen = SLAP_INDEX_SUBSTR_MAXLEN;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
- if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_UMAXLEN ) {
continue;
}
value = sa->sa_any[i];
for(j=0;
- j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
- j += SLAP_INDEX_SUBSTR_STEP )
+ j <= value->bv_len - SLAP_INDEX_SUBSTR_UMAXLEN;
+ j += SLAP_INDEX_SUBSTR_USTEP )
{
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
lutil_MD5Update( &MD5context,
mr->smr_oid, mlen );
lutil_MD5Update( &MD5context,
- &value->bv_val[j], klen );
+ &value->bv_val[j], klen );
lutil_MD5Final( MD5digest, &MD5context );
keys[nkeys++] = ber_bvdup( &digest );
}
if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
- sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
value = sa->sa_final;
- klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
struct berval *value,
void *assertedValue )
{
-#if 0
- *matchp = UTF8casecmp( value, (struct berval *) assertedValue );
-#else
int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
if( match == 0 ) {
- match = strncasecmp( value->bv_val,
- ((struct berval *) assertedValue)->bv_val,
- value->bv_len );
+ match = ucstrncasecmp(
+ (ldap_unicode_t *) value->bv_val,
+ (ldap_unicode_t *) ((struct berval *) assertedValue)->bv_val,
+ LEN2UNICODE(value->bv_len) );
}
*matchp = match;
-#endif
return LDAP_SUCCESS;
}
goto done;
}
- match = strncasecmp( sub->sa_initial->bv_val, left.bv_val,
- sub->sa_initial->bv_len );
+ match = ucstrncasecmp(
+ (ldap_unicode_t *) sub->sa_initial->bv_val,
+ (ldap_unicode_t *) left.bv_val,
+ LEN2UNICODE(sub->sa_initial->bv_len) );
if( match != 0 ) {
goto done;
goto done;
}
- match = strncasecmp( sub->sa_final->bv_val,
- &left.bv_val[left.bv_len - sub->sa_final->bv_len],
- sub->sa_final->bv_len );
+ match = ucstrncasecmp(
+ (ldap_unicode_t *) sub->sa_final->bv_val,
+ (ldap_unicode_t *) &left.bv_val[left.bv_len - sub->sa_final->bv_len],
+ LEN2UNICODE(sub->sa_final->bv_len) );
if( match != 0 ) {
goto done;
continue;
}
- p = strcasechr( left.bv_val, *sub->sa_any[i]->bv_val );
+ p = (char *) ucstrncasechr(
+ (ldap_unicode_t *) left.bv_val,
+ LEN2UNICODE(left.bv_len),
+ ((ldap_unicode_t *) sub->sa_any[i]->bv_val)[0] );
if( p == NULL ) {
match = 1;
goto done;
}
- match = strncasecmp( left.bv_val,
- sub->sa_any[i]->bv_val,
- sub->sa_any[i]->bv_len );
+ match = ucstrncasecmp(
+ (ldap_unicode_t *) left.bv_val,
+ (ldap_unicode_t *) sub->sa_any[i]->bv_val,
+ LEN2UNICODE(sub->sa_any[i]->bv_len) );
if( match != 0 ) {
- left.bv_val++;
- left.bv_len--;
+ left.bv_val += UNICODE2LEN(1);
+ left.bv_len -= UNICODE2LEN(1);
goto retry;
}
for( i=0; values[i] != NULL; i++ ) {
struct berval *value = ber_bvdup( values[i] );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
lutil_MD5Final( MD5digest, &MD5context );
ber_bvfree( value );
-
keys[i] = ber_bvdup( &digest );
}
mlen = strlen( mr->smr_oid );
value = ber_bvdup( (struct berval *) assertValue );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
keys = ch_malloc( sizeof( struct berval * ) * 2 );
nkeys=0;
for( i=0; values[i] != NULL; i++ ) {
/* count number of indices to generate */
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) {
+ if( values[i]->bv_len < SLAP_INDEX_SUBSTR_UMINLEN ) {
continue;
}
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_ANY ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
- if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
} else {
- nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
+ nkeys += LEN2UNICODE(values[i]->bv_len) -
+ ( SLAP_INDEX_SUBSTR_MINLEN - 1 );
}
}
}
int j,max;
struct berval *value;
- if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+ if( values[i]->bv_len < SLAP_INDEX_SUBSTR_UMINLEN ) continue;
value = ber_bvdup( values[i] );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
- ( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
+ ( value->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
- max = value->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1);
+ max = value->bv_len -
+ ( SLAP_INDEX_SUBSTR_UMAXLEN - UNICODE2LEN(1));
- for( j=0; j<max; j++ ) {
+ for( j=0; j<max; j+=UNICODE2LEN(1) ) {
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
lutil_MD5Update( &MD5context,
prefix->bv_val, prefix->bv_len );
}
-
lutil_MD5Update( &MD5context,
&pre, sizeof( pre ) );
lutil_MD5Update( &MD5context,
mr->smr_oid, mlen );
lutil_MD5Update( &MD5context,
&value->bv_val[j],
- SLAP_INDEX_SUBSTR_MAXLEN );
+ SLAP_INDEX_SUBSTR_UMAXLEN );
lutil_MD5Final( MD5digest, &MD5context );
keys[nkeys++] = ber_bvdup( &digest );
}
}
- max = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ max = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
- for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
+ for( j=SLAP_INDEX_SUBSTR_UMINLEN; j<=max; j+=UNICODE2LEN(1) ) {
char pre;
if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
struct berval digest;
if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
- sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
nkeys++;
}
if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
ber_len_t i;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
- if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_UMAXLEN ) {
/* don't bother accounting for stepping */
- nkeys += sa->sa_any[i]->bv_len -
+ nkeys += LEN2UNICODE(sa->sa_any[i]->bv_len) -
( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
}
if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
- sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
nkeys++;
}
nkeys = 0;
if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
- sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
value = ber_bvdup( sa->sa_initial );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
- klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
ber_len_t i, j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
- klen = SLAP_INDEX_SUBSTR_MAXLEN;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
- if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_MAXLEN ) {
+ if( sa->sa_any[i]->bv_len < SLAP_INDEX_SUBSTR_UMAXLEN ) {
continue;
}
value = ber_bvdup( sa->sa_any[i] );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
for(j=0;
- j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
- j += SLAP_INDEX_SUBSTR_STEP )
+ j <= value->bv_len - SLAP_INDEX_SUBSTR_UMAXLEN;
+ j += SLAP_INDEX_SUBSTR_USTEP )
{
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
}
if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
- sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
+ sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_UMINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
value = ber_bvdup( sa->sa_final );
- ldap_pvt_str2upper( value->bv_val );
+ ucstr2upper( (ldap_unicode_t *) value->bv_val,
+ LEN2UNICODE(value->bv_len) );
- klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
- ? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
+ klen = SLAP_INDEX_SUBSTR_UMAXLEN < value->bv_len
+ ? SLAP_INDEX_SUBSTR_UMAXLEN : value->bv_len;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
lutil_MD5Update( &MD5context,
prefix->bv_val, prefix->bv_len );
}
-
lutil_MD5Update( &MD5context,
&pre, sizeof( pre ) );
lutil_MD5Update( &MD5context,
lutil_MD5Update( &MD5context,
prefix->bv_val, prefix->bv_len );
}
-
lutil_MD5Update( &MD5context,
&pre, sizeof( pre ) );
lutil_MD5Update( &MD5context,