From: Kurt Zeilenga Date: Sat, 21 Jul 2001 23:13:04 +0000 (+0000) Subject: Make some additional UTF8 public X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1219 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=978e417699699579fb0b858ad485f36399220c4d;p=openldap Make some additional UTF8 public Remove lint --- diff --git a/include/ac/string.h b/include/ac/string.h index 8aad76eab9..5d7cf3d7a1 100644 --- a/include/ac/string.h +++ b/include/ac/string.h @@ -44,8 +44,8 @@ #endif /* use ldap_pvt_strtok instead of strtok or strtok_r! */ -LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, const char *delim, - char **pos )); +LDAP_F(char *) ldap_pvt_strtok LDAP_P(( char *str, + const char *delim, char **pos )); #ifndef HAVE_STRDUP /* strdup() is missing, declare our own version */ diff --git a/include/ldap_features.h.in b/include/ldap_features.h.in index 7da00ded86..d77029c3fe 100644 --- a/include/ldap_features.h.in +++ b/include/ldap_features.h.in @@ -24,6 +24,8 @@ #undef LDAP_VENDOR_VERSION_PATCH /* +** WORK IN PROGRESS! +** ** OpenLDAP reentrancy/thread-safeness should be dynamically ** checked using ldap_get_option(). ** diff --git a/include/ldap_features.nt b/include/ldap_features.nt index 9fcde6cd97..eeec2d1b58 100644 --- a/include/ldap_features.nt +++ b/include/ldap_features.nt @@ -21,6 +21,8 @@ #define LDAP_VENDOR_VERSION_PATCH X /* +** WORK IN PROGRESS! +** ** OpenLDAP reentrancy/thread-safeness should be dynamically ** checked using ldap_get_option(). ** diff --git a/include/ldap_pvt_uc.h b/include/ldap_pvt_uc.h index 4a7c27c918..f8ed9baf1c 100644 --- a/include/ldap_pvt_uc.h +++ b/include/ldap_pvt_uc.h @@ -12,6 +12,7 @@ /* * ldap_pvt_uc.h - Header for Unicode functions. * These are meant to be used by the OpenLDAP distribution only. + * These should be named ldap_pvt_....() */ #ifndef _LDAP_PVT_UC_H @@ -32,18 +33,10 @@ LDAP_BEGIN_DECL * UTF-8 (in utf-8.c) */ -typedef ber_int_t ldap_ucs4_t; -#define LDAP_UCS4_INVALID (0x80000000U) - typedef short ldap_ucs2_t; /* UCDATA uses UCS-2 passed in an unsigned long */ typedef unsigned long ldap_unicode_t; - -/* conversion routines */ -LDAP_F( ldap_ucs4_t ) ldap_utf8_to_ucs4( const char * p ); -LDAP_F( int ) ldap_ucs4_to_utf8( ldap_ucs4_t c, char *buf ); - #define ldap_utf8_to_unicode( p ) ldap_utf8_to_ucs4((p)) #define ldap_unicode_to_utf8( c, buf ) ldap_ucs4_to_ucs4((c),(buf)) diff --git a/include/ldap_schema.h b/include/ldap_schema.h index 5551b28dba..c8722d5251 100644 --- a/include/ldap_schema.h +++ b/include/ldap_schema.h @@ -12,6 +12,7 @@ /* * ldap-schema.h - Header for basic schema handling functions that can be * used by both clients and servers. + * these routines should be renamed ldap_x_... */ #ifndef _LDAP_SCHEMA_H diff --git a/include/ldap_utf8.h b/include/ldap_utf8.h index c65756353b..c5cc61e109 100644 --- a/include/ldap_utf8.h +++ b/include/ldap_utf8.h @@ -29,36 +29,45 @@ #ifndef _LDAP_UTF8_H #define _LDAP_UTF8_H -LDAP_BEGIN_DECL +#include /* get ber_*_t */ /* * UTF-8 Utility Routines */ +LDAP_BEGIN_DECL + #define LDAP_UCS4_INVALID (0x80000000U) +typedef ber_int_t ldap_ucs4_t; + /* LDAP_MAX_UTF8_LEN is 3 or 6 depending on size of wchar_t */ #define LDAP_MAX_UTF8_LEN ( sizeof(wchar_t) * 3/2 ) +/* Unicode conversion routines */ +LDAP_F( ldap_ucs4_t ) ldap_x_utf8_to_ucs4( LDAP_CONST char * p ); +LDAP_F( int ) ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf ); + + /* * Wide Char / UTF-8 Conversion Routines */ /* UTF-8 character to Wide Char */ LDAP_F(int) -ldap_x_utf8_to_wc ( wchar_t *wchar, const char *utf8char ); +ldap_x_utf8_to_wc LDAP_P(( wchar_t *wchar, LDAP_CONST char *utf8char )); /* UTF-8 string to Wide Char string */ LDAP_F(int) -ldap_x_utf8s_to_wcs ( wchar_t *wcstr, const char *utf8str, size_t count ); +ldap_x_utf8s_to_wcs LDAP_P(( wchar_t *wcstr, LDAP_CONST char *utf8str, size_t count )); /* Wide Char to UTF-8 character */ LDAP_F(int) -ldap_x_wc_to_utf8 ( char *utf8char, wchar_t wchar, size_t count ); +ldap_x_wc_to_utf8 LDAP_P(( char *utf8char, wchar_t wchar, size_t count )); /* Wide Char string to UTF-8 string */ LDAP_F(int) -ldap_x_wcs_to_utf8s ( char *utf8str, const wchar_t *wcstr, size_t count ); +ldap_x_wcs_to_utf8s LDAP_P(( char *utf8str, LDAP_CONST wchar_t *wcstr, size_t count )); /* * MultiByte Char / UTF-8 Conversion Routines @@ -66,23 +75,23 @@ ldap_x_wcs_to_utf8s ( char *utf8str, const wchar_t *wcstr, size_t count ); /* UTF-8 character to MultiByte character */ LDAP_F(int) -ldap_x_utf8_to_mb ( char *mbchar, const char *utf8char, - int (*f_wctomb)(char *mbchar, wchar_t wchar) ); +ldap_x_utf8_to_mb LDAP_P(( char *mbchar, LDAP_CONST char *utf8char, + int (*f_wctomb)(char *mbchar, wchar_t wchar) )); /* UTF-8 string to MultiByte string */ LDAP_F(int) -ldap_x_utf8s_to_mbs ( char *mbstr, const char *utf8str, size_t count, - size_t (*f_wcstombs)(char *mbstr, const wchar_t *wcstr, size_t count) ); +ldap_x_utf8s_to_mbs LDAP_P(( char *mbstr, LDAP_CONST char *utf8str, size_t count, + size_t (*f_wcstombs)(char *mbstr, LDAP_CONST wchar_t *wcstr, size_t count) )); /* MultiByte character to UTF-8 character */ LDAP_F(int) -ldap_x_mb_to_utf8 ( char *utf8char, const char *mbchar, size_t mbsize, - int (*f_mbtowc)(wchar_t *wchar, const char *mbchar, size_t count) ); +ldap_x_mb_to_utf8 LDAP_P(( char *utf8char, LDAP_CONST char *mbchar, size_t mbsize, + int (*f_mbtowc)(wchar_t *wchar, LDAP_CONST char *mbchar, size_t count) )); /* MultiByte string to UTF-8 string */ LDAP_F(int) -ldap_x_mbs_to_utf8s ( char *utf8str, const char *mbstr, size_t count, - size_t (*f_mbstowcs)(wchar_t *wcstr, const char *mbstr, size_t count) ); +ldap_x_mbs_to_utf8s LDAP_P(( char *utf8str, LDAP_CONST char *mbstr, size_t count, + size_t (*f_mbstowcs)(wchar_t *wcstr, LDAP_CONST char *mbstr, size_t count) )); LDAP_END_DECL diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c index c2721064f4..13f0f2508d 100644 --- a/libraries/liblber/bprint.c +++ b/libraries/liblber/bprint.c @@ -305,7 +305,7 @@ ber_log_dump( int inout ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( !ber_log_check( errlvl, loglvl )) { return 0; @@ -324,7 +324,7 @@ ber_dump( ber_len_t len; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( inout == 1 ) { len = ber_pvt_ber_remaining(ber); diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c index 2d864abae2..1e0132d732 100644 --- a/libraries/liblber/decode.c +++ b/libraries/liblber/decode.c @@ -42,7 +42,7 @@ ber_get_tag( BerElement *ber ) unsigned int i; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 ) { return LBER_DEFAULT; @@ -85,7 +85,7 @@ ber_skip_tag( BerElement *ber, ber_len_t *len ) assert( ber != NULL ); assert( len != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); /* * Any ber element looks like this: tag length contents. @@ -175,7 +175,7 @@ ber_getnint( assert( ber != NULL ); assert( num != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); /* * The tag and length have already been stripped off. We should @@ -221,7 +221,7 @@ ber_get_int( ber_len_t len; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) { return LBER_DEFAULT; @@ -252,7 +252,7 @@ ber_get_stringb( ber_tag_t tag; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { return LBER_DEFAULT; @@ -282,7 +282,7 @@ ber_get_stringa( BerElement *ber, char **buf ) assert( ber != NULL ); assert( buf != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { *buf = NULL; @@ -312,7 +312,7 @@ ber_get_stringal( BerElement *ber, struct berval **bv ) assert( ber != NULL ); assert( bv != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) { *bv = NULL; @@ -363,7 +363,7 @@ ber_get_bitstringa( assert( buf != NULL ); assert( blen != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT ) { *buf = NULL; @@ -398,7 +398,7 @@ ber_get_null( BerElement *ber ) ber_tag_t tag; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT ) { return LBER_DEFAULT; @@ -422,7 +422,7 @@ ber_get_boolean( assert( ber != NULL ); assert( boolval != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); rc = ber_get_int( ber, &longbool ); *boolval = longbool; @@ -465,7 +465,7 @@ ber_next_element( assert( len != NULL ); assert( last != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( ber->ber_ptr == last ) { return LBER_DEFAULT; @@ -497,7 +497,7 @@ ber_scanf ( BerElement *ber, assert( ber != NULL ); assert( fmt != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); fmt_reset = fmt; diff --git a/libraries/liblber/encode.c b/libraries/liblber/encode.c index 59ef8ad677..08fc871e5b 100644 --- a/libraries/liblber/encode.c +++ b/libraries/liblber/encode.c @@ -73,7 +73,7 @@ ber_put_tag( unsigned char nettag[sizeof(ber_tag_t)]; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); taglen = ber_calc_taglen( tag ); @@ -125,7 +125,7 @@ ber_put_len( BerElement *ber, ber_len_t len, int nosos ) unsigned char netlen[sizeof(ber_len_t)]; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); /* * short len if it's less than 128 - one byte giving the len, @@ -184,7 +184,7 @@ ber_put_int_or_enum( unsigned char netnum[sizeof(ber_uint_t)]; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); sign = (num < 0); unum = num; /* Bit fiddling should be done with unsigned values */ @@ -244,7 +244,7 @@ ber_put_enum( ber_tag_t tag ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_ENUMERATED; @@ -260,7 +260,7 @@ ber_put_int( ber_tag_t tag ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_INTEGER; @@ -282,7 +282,7 @@ ber_put_ostring( assert( ber != NULL ); assert( str != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_OCTETSTRING; @@ -309,7 +309,7 @@ ber_put_berval( ber_tag_t tag ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if( bv == NULL || bv->bv_len == 0 ) { return ber_put_ostring( ber, "", (ber_len_t) 0, tag ); @@ -327,7 +327,7 @@ ber_put_string( assert( ber != NULL ); assert( str != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); return ber_put_ostring( ber, str, strlen( str ), tag ); } @@ -345,7 +345,7 @@ ber_put_bitstring( assert( ber != NULL ); assert( str != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_BITSTRING; @@ -379,7 +379,7 @@ ber_put_null( BerElement *ber, ber_tag_t tag ) ber_len_t taglen; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_NULL; @@ -407,7 +407,7 @@ ber_put_boolean( unsigned char falseval = 0; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) tag = LBER_BOOLEAN; @@ -439,7 +439,7 @@ ber_start_seqorset( Seqorset *new; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); new = (Seqorset *) LBER_CALLOC( 1, sizeof(Seqorset) ); @@ -468,7 +468,7 @@ int ber_start_seq( BerElement *ber, ber_tag_t tag ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_SEQUENCE; @@ -481,7 +481,7 @@ int ber_start_set( BerElement *ber, ber_tag_t tag ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( tag == LBER_DEFAULT ) { tag = LBER_SET; @@ -502,7 +502,7 @@ ber_put_seqorset( BerElement *ber ) Seqorset **sos = &ber->ber_sos; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); /* * If this is the toplevel sequence or set, we need to actually @@ -655,7 +655,7 @@ int ber_put_seq( BerElement *ber ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); return ber_put_seqorset( ber ); } @@ -664,7 +664,7 @@ int ber_put_set( BerElement *ber ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); return ber_put_seqorset( ber ); } @@ -686,7 +686,7 @@ ber_printf( BerElement *ber, LDAP_CONST char *fmt, ... ) assert( ber != NULL ); assert( fmt != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); va_start( ap, fmt ); diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index 023110f8c8..e5aae6d46e 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -34,7 +34,7 @@ #include "lber-int.h" -#define EXBUFSIZ 1024 +#define LBER_EXBUFSIZ 1024 static ber_slen_t BerRead( @@ -75,7 +75,7 @@ ber_read( assert( ber != NULL ); assert( buf != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); nleft = ber_pvt_ber_remaining( ber ); actuallen = nleft < len ? nleft : len; @@ -97,7 +97,7 @@ ber_write( assert( ber != NULL ); assert( buf != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( nosos || ber->ber_sos == NULL ) { if ( ber->ber_ptr + len > ber->ber_end ) { @@ -131,12 +131,12 @@ ber_realloc( BerElement *ber, ber_len_t len ) assert( ber != NULL ); assert( len > 0 ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); total = ber_pvt_ber_total( ber ); - have = total / EXBUFSIZ; - need = (len < EXBUFSIZ ? 1 : (len + (EXBUFSIZ - 1)) / EXBUFSIZ); - total = have * EXBUFSIZ + need * EXBUFSIZ; + have = total / LBER_EXBUFSIZ; + need = len < LBER_EXBUFSIZ ? 1 : (len + (LBER_EXBUFSIZ - 1)) / LBER_EXBUFSIZ; + total = have * LBER_EXBUFSIZ + need * LBER_EXBUFSIZ; oldbuf = ber->ber_buf; @@ -181,7 +181,7 @@ ber_free( BerElement *ber, int freebuf ) return; } - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( freebuf ) { Seqorset *s, *next; @@ -210,7 +210,7 @@ ber_flush( Sockbuf *sb, BerElement *ber, int freeit ) assert( ber != NULL ); assert( SOCKBUF_VALID( sb ) ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( ber->ber_rwptr == NULL ) { ber->ber_rwptr = ber->ber_buf; @@ -269,7 +269,7 @@ ber_alloc_t( int options ) ber->ber_options = options; ber->ber_debug = ber_int_debug; - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); return ber; } @@ -291,7 +291,7 @@ ber_dup( BerElement *ber ) BerElement *new; assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( (new = ber_alloc_t( ber->ber_options )) == NULL ) { return NULL; @@ -299,7 +299,7 @@ ber_dup( BerElement *ber ) *new = *ber; - assert( BER_VALID( new ) ); + assert( LBER_VALID( new ) ); return( new ); } @@ -318,7 +318,7 @@ ber_init_w_nullc( BerElement *ber, int options ) ber->ber_options = (char) options; ber->ber_debug = ber_int_debug; - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); } /* New C-API ber_init() */ @@ -410,7 +410,7 @@ void ber_reset( BerElement *ber, int was_writing ) { assert( ber != NULL ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if ( was_writing ) { ber->ber_end = ber->ber_ptr; @@ -440,7 +440,7 @@ ber_get_next( assert( ber != NULL ); assert( SOCKBUF_VALID( sb ) ); - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); #ifdef NEW_LOGGING LDAP_LOG(( "liblber", LDAP_LEVEL_ENTRY, "ber_get_next: enter\n" )); diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h index 39d86a9e32..bf03644868 100644 --- a/libraries/liblber/lber-int.h +++ b/libraries/liblber/lber-int.h @@ -72,7 +72,7 @@ struct berelement { struct seqorset *ber_sos; char *ber_rwptr; }; -#define BER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT) +#define LBER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT) #define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr) #define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf) @@ -92,8 +92,6 @@ struct sockbuf { #define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF ) -#define READBUFSIZ 8192 - struct seqorset { BerElement *sos_ber; ber_len_t sos_clen; diff --git a/libraries/liblber/memory.c b/libraries/liblber/memory.c index 90720fa792..309fbeab77 100644 --- a/libraries/liblber/memory.c +++ b/libraries/liblber/memory.c @@ -53,9 +53,9 @@ struct ber_mem_hdr { }; /* Pattern at top of allocated space */ -#define BER_MEM_JUNK 0xdeaddadaU +#define LLBER_MEM_JUNK 0xdeaddadaU -static const struct ber_mem_hdr ber_int_mem_hdr = { BER_MEM_JUNK, 0, 0 }; +static const struct ber_mem_hdr ber_int_mem_hdr = { LBER_MEM_JUNK, 0, 0 }; /* Note sequence and ber_int_options.lbu_meminuse are counters, but are not * thread safe. If you want to use these values for multithreaded applications, @@ -140,7 +140,7 @@ ber_memfree( void *p ) #ifdef LDAP_MEMORY_DEBUG struct ber_mem_hdr *mh = (struct ber_mem_hdr *) ((char *)p - sizeof(struct ber_mem_hdr)); - assert( mh->bm_top == BER_MEM_JUNK); + assert( mh->bm_top == LBER_MEM_JUNK); assert( testdatatop( mh)); assert( testend( (char *)&mh[1] + mh->bm_length) ); ber_int_options.lbo_meminuse -= mh->bm_length; @@ -204,7 +204,7 @@ ber_memalloc( ber_len_t s ) struct ber_mem_hdr *mh = malloc(s + sizeof(struct ber_mem_hdr) + sizeof( ber_int_t)); if( mh == NULL ) return NULL; - mh->bm_top = BER_MEM_JUNK; + mh->bm_top = LBER_MEM_JUNK; mh->bm_length = s; setdatatop( mh); setend( (char *)&mh[1] + mh->bm_length ); @@ -256,7 +256,7 @@ ber_memcalloc( ber_len_t n, ber_len_t s ) (n * s) + sizeof(struct ber_mem_hdr) + sizeof(ber_int_t) ); if( mh == NULL ) return NULL; - mh->bm_top = BER_MEM_JUNK; + mh->bm_top = LBER_MEM_JUNK; mh->bm_length = n*s; setdatatop( mh); setend( (char *)&mh[1] + mh->bm_length ); @@ -310,7 +310,7 @@ ber_memrealloc( void* p, ber_len_t s ) ber_int_t oldlen; struct ber_mem_hdr *mh = (struct ber_mem_hdr *) ((char *)p - sizeof(struct ber_mem_hdr)); - assert( mh->bm_top == BER_MEM_JUNK); + assert( mh->bm_top == LBER_MEM_JUNK); assert( testdatatop( mh)); assert( testend( (char *)&mh[1] + mh->bm_length) ); oldlen = mh->bm_length; @@ -329,7 +329,7 @@ ber_memrealloc( void* p, ber_len_t s ) memset( (char *)&mh[1] + oldlen, 0xff, s - oldlen); } - assert( mh->bm_top == BER_MEM_JUNK); + assert( mh->bm_top == LBER_MEM_JUNK); assert( testdatatop( mh)); ber_int_options.lbo_meminuse += s - oldlen; diff --git a/libraries/liblber/nt_err.c b/libraries/liblber/nt_err.c index 45de02c8be..e5f64691d1 100644 --- a/libraries/liblber/nt_err.c +++ b/libraries/liblber/nt_err.c @@ -11,78 +11,77 @@ #include #endif /* HAVE_WINSOCK(2) */ -#undef __RETSTR -#define __RETSTR( x ) case x: return #x; +#define LBER_RETSTR( x ) case x: return #x; char *ber_pvt_wsa_err2string( int err ) { switch( err ) { - __RETSTR( WSAEINTR ) - __RETSTR( WSAEBADF ) - __RETSTR( WSAEACCES ) - __RETSTR( WSAEFAULT ) - __RETSTR( WSAEINVAL ) - __RETSTR( WSAEMFILE ) - __RETSTR( WSAEWOULDBLOCK ) - __RETSTR( WSAEINPROGRESS ) - __RETSTR( WSAEALREADY ) - __RETSTR( WSAENOTSOCK ) - __RETSTR( WSAEDESTADDRREQ ) - __RETSTR( WSAEMSGSIZE ) - __RETSTR( WSAEPROTOTYPE ) - __RETSTR( WSAENOPROTOOPT ) - __RETSTR( WSAEPROTONOSUPPORT ) - __RETSTR( WSAESOCKTNOSUPPORT ) - __RETSTR( WSAEOPNOTSUPP ) - __RETSTR( WSAEPFNOSUPPORT ) - __RETSTR( WSAEAFNOSUPPORT ) - __RETSTR( WSAEADDRINUSE ) - __RETSTR( WSAEADDRNOTAVAIL ) - __RETSTR( WSAENETDOWN ) - __RETSTR( WSAENETUNREACH ) - __RETSTR( WSAENETRESET ) - __RETSTR( WSAECONNABORTED ) - __RETSTR( WSAECONNRESET ) - __RETSTR( WSAENOBUFS ) - __RETSTR( WSAEISCONN ) - __RETSTR( WSAENOTCONN ) - __RETSTR( WSAESHUTDOWN ) - __RETSTR( WSAETOOMANYREFS ) - __RETSTR( WSAETIMEDOUT ) - __RETSTR( WSAECONNREFUSED ) - __RETSTR( WSAELOOP ) - __RETSTR( WSAENAMETOOLONG ) - __RETSTR( WSAEHOSTDOWN ) - __RETSTR( WSAEHOSTUNREACH ) - __RETSTR( WSAENOTEMPTY ) - __RETSTR( WSAEPROCLIM ) - __RETSTR( WSAEUSERS ) - __RETSTR( WSAEDQUOT ) - __RETSTR( WSAESTALE ) - __RETSTR( WSAEREMOTE ) - __RETSTR( WSASYSNOTREADY ) - __RETSTR( WSAVERNOTSUPPORTED ) - __RETSTR( WSANOTINITIALISED ) - __RETSTR( WSAEDISCON ) + LBER_RETSTR( WSAEINTR ) + LBER_RETSTR( WSAEBADF ) + LBER_RETSTR( WSAEACCES ) + LBER_RETSTR( WSAEFAULT ) + LBER_RETSTR( WSAEINVAL ) + LBER_RETSTR( WSAEMFILE ) + LBER_RETSTR( WSAEWOULDBLOCK ) + LBER_RETSTR( WSAEINPROGRESS ) + LBER_RETSTR( WSAEALREADY ) + LBER_RETSTR( WSAENOTSOCK ) + LBER_RETSTR( WSAEDESTADDRREQ ) + LBER_RETSTR( WSAEMSGSIZE ) + LBER_RETSTR( WSAEPROTOTYPE ) + LBER_RETSTR( WSAENOPROTOOPT ) + LBER_RETSTR( WSAEPROTONOSUPPORT ) + LBER_RETSTR( WSAESOCKTNOSUPPORT ) + LBER_RETSTR( WSAEOPNOTSUPP ) + LBER_RETSTR( WSAEPFNOSUPPORT ) + LBER_RETSTR( WSAEAFNOSUPPORT ) + LBER_RETSTR( WSAEADDRINUSE ) + LBER_RETSTR( WSAEADDRNOTAVAIL ) + LBER_RETSTR( WSAENETDOWN ) + LBER_RETSTR( WSAENETUNREACH ) + LBER_RETSTR( WSAENETRESET ) + LBER_RETSTR( WSAECONNABORTED ) + LBER_RETSTR( WSAECONNRESET ) + LBER_RETSTR( WSAENOBUFS ) + LBER_RETSTR( WSAEISCONN ) + LBER_RETSTR( WSAENOTCONN ) + LBER_RETSTR( WSAESHUTDOWN ) + LBER_RETSTR( WSAETOOMANYREFS ) + LBER_RETSTR( WSAETIMEDOUT ) + LBER_RETSTR( WSAECONNREFUSED ) + LBER_RETSTR( WSAELOOP ) + LBER_RETSTR( WSAENAMETOOLONG ) + LBER_RETSTR( WSAEHOSTDOWN ) + LBER_RETSTR( WSAEHOSTUNREACH ) + LBER_RETSTR( WSAENOTEMPTY ) + LBER_RETSTR( WSAEPROCLIM ) + LBER_RETSTR( WSAEUSERS ) + LBER_RETSTR( WSAEDQUOT ) + LBER_RETSTR( WSAESTALE ) + LBER_RETSTR( WSAEREMOTE ) + LBER_RETSTR( WSASYSNOTREADY ) + LBER_RETSTR( WSAVERNOTSUPPORTED ) + LBER_RETSTR( WSANOTINITIALISED ) + LBER_RETSTR( WSAEDISCON ) #ifdef HAVE_WINSOCK2 - __RETSTR( WSAENOMORE ) - __RETSTR( WSAECANCELLED ) - __RETSTR( WSAEINVALIDPROCTABLE ) - __RETSTR( WSAEINVALIDPROVIDER ) - __RETSTR( WSASYSCALLFAILURE ) - __RETSTR( WSASERVICE_NOT_FOUND ) - __RETSTR( WSATYPE_NOT_FOUND ) - __RETSTR( WSA_E_NO_MORE ) - __RETSTR( WSA_E_CANCELLED ) - __RETSTR( WSAEREFUSED ) + LBER_RETSTR( WSAENOMORE ) + LBER_RETSTR( WSAECANCELLED ) + LBER_RETSTR( WSAEINVALIDPROCTABLE ) + LBER_RETSTR( WSAEINVALIDPROVIDER ) + LBER_RETSTR( WSASYSCALLFAILURE ) + LBER_RETSTR( WSASERVICE_NOT_FOUND ) + LBER_RETSTR( WSATYPE_NOT_FOUND ) + LBER_RETSTR( WSA_E_NO_MORE ) + LBER_RETSTR( WSA_E_CANCELLED ) + LBER_RETSTR( WSAEREFUSED ) #endif // HAVE_WINSOCK2 - __RETSTR( WSAHOST_NOT_FOUND ) - __RETSTR( WSATRY_AGAIN ) - __RETSTR( WSANO_RECOVERY ) - __RETSTR( WSANO_DATA ) + LBER_RETSTR( WSAHOST_NOT_FOUND ) + LBER_RETSTR( WSATRY_AGAIN ) + LBER_RETSTR( WSANO_RECOVERY ) + LBER_RETSTR( WSANO_DATA ) } return "unknown WSA error"; } \ No newline at end of file diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index d234e98081..64e7fcc466 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -24,8 +24,8 @@ ber_get_option( int option, void *outvalue) { - LDAP_CONST BerElement *ber; - LDAP_CONST Sockbuf *sb; + const BerElement *ber; + const Sockbuf *sb; ber_int_options.lbo_valid = LBER_INITIALIZED; @@ -67,27 +67,27 @@ ber_get_option( switch(option) { case LBER_OPT_BER_OPTIONS: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); * (int *) outvalue = ber->ber_options; return LBER_OPT_SUCCESS; case LBER_OPT_BER_DEBUG: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); * (int *) outvalue = ber->ber_debug; return LBER_OPT_SUCCESS; case LBER_OPT_BER_REMAINING_BYTES: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); *((ber_len_t *) outvalue) = ber_pvt_ber_remaining(ber); return LBER_OPT_SUCCESS; case LBER_OPT_BER_TOTAL_BYTES: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); *((ber_len_t *) outvalue) = ber_pvt_ber_total(ber); return LBER_OPT_SUCCESS; case LBER_OPT_BER_BYTES_TO_WRITE: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); *((ber_len_t *) outvalue) = ber_pvt_ber_write(ber); return LBER_OPT_SUCCESS; @@ -185,27 +185,27 @@ ber_set_option( switch(option) { case LBER_OPT_BER_OPTIONS: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); ber->ber_options = * (const int *) invalue; return LBER_OPT_SUCCESS; case LBER_OPT_BER_DEBUG: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); ber->ber_debug = * (const int *) invalue; return LBER_OPT_SUCCESS; case LBER_OPT_BER_REMAINING_BYTES: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); ber->ber_end = &ber->ber_ptr[* (const ber_len_t *) invalue]; return LBER_OPT_SUCCESS; case LBER_OPT_BER_TOTAL_BYTES: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); ber->ber_end = &ber->ber_buf[* (const ber_len_t *) invalue]; return LBER_OPT_SUCCESS; case LBER_OPT_BER_BYTES_TO_WRITE: - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); ber->ber_ptr = &ber->ber_buf[* (const ber_len_t *) invalue]; return LBER_OPT_SUCCESS; diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index b4d7c4194b..154c355fcc 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -33,9 +33,15 @@ #include "lber-int.h" -#define MIN_BUFF_SIZE 4096 -#define MAX_BUFF_SIZE 65536 -#define DEFAULT_READAHEAD 16384 +#ifndef LBER_MIN_BUFF_SIZE +#define LBER_MIN_BUFF_SIZE 4096 +#endif +#ifndef LBER_MAX_BUFF_SIZE +#define LBER_MAX_BUFF_SIZE 65536 +#endif +#ifndef LBER_DEFAULT_READAHEAD +#define LBER_DEFAULT_READAHEAD 16384 +#endif Sockbuf * ber_sockbuf_alloc( void ) @@ -108,7 +114,7 @@ ber_sockbuf_ctrl( Sockbuf *sb, int opt, void *arg ) /* Drain the data source to enable possible errors (e.g. * TLS) to be propagated to the upper layers */ - char buf[MIN_BUFF_SIZE]; + char buf[LBER_MIN_BUFF_SIZE]; do { ret = ber_int_sb_read( sb, buf, sizeof( buf ) ); @@ -243,8 +249,8 @@ ber_pvt_sb_grow_buffer( Sockbuf_Buf *buf, ber_len_t minsize ) assert( buf != NULL ); - for ( pw = MIN_BUFF_SIZE; pw < minsize; pw <<= 1 ) { - if (pw > MAX_BUFF_SIZE) return -1; + for ( pw = LBER_MIN_BUFF_SIZE; pw < minsize; pw <<= 1 ) { + if (pw > LBER_MAX_BUFF_SIZE) return -1; } if ( buf->buf_size < pw ) { @@ -596,7 +602,7 @@ sb_rdahead_setup( Sockbuf_IO_Desc *sbiod, void *arg ) ber_pvt_sb_buf_init( p ); if ( arg == NULL ) { - ber_pvt_sb_grow_buffer( p, DEFAULT_READAHEAD ); + ber_pvt_sb_grow_buffer( p, LBER_DEFAULT_READAHEAD ); } else { ber_pvt_sb_grow_buffer( p, *((int *)arg) ); } @@ -859,4 +865,3 @@ Sockbuf_IO ber_sockbuf_io_debug = { sb_debug_write, /* sbi_write */ NULL /* sbi_close */ }; - diff --git a/libraries/libldap/libldap.dsp b/libraries/libldap/libldap.dsp index 2dc86645ed..d4e46e37c3 100644 --- a/libraries/libldap/libldap.dsp +++ b/libraries/libldap/libldap.dsp @@ -263,10 +263,18 @@ SOURCE=..\..\include\ldap_pvt.h # End Source File # Begin Source File +SOURCE=..\..\include\ldap_pvt_uc.h +# End Source File +# Begin Source File + SOURCE=..\..\include\ldap_schema.h # End Source File # Begin Source File +SOURCE=..\..\include\ldap_utf8.h +# End Source File +# Begin Source File + SOURCE=.\messages.c # End Source File # Begin Source File @@ -363,6 +371,10 @@ SOURCE=.\url.c # End Source File # Begin Source File +SOURCE=".\utf-8-conv.c" +# End Source File +# Begin Source File + SOURCE=".\utf-8.c" # End Source File # Begin Source File diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index c8804e04e9..869769e65c 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -368,7 +368,7 @@ try_read1msg( } ber = lc->lconn_ber; - assert( BER_VALID (ber) ); + assert( LBER_VALID (ber) ); /* get the next message */ errno = 0; diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index 8945d95733..2d47636b7c 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -97,7 +97,7 @@ ldap_sasl_bind( return ld->ld_errno; } - assert( BER_VALID( ber ) ); + assert( LBER_VALID( ber ) ); if( mechanism == LDAP_SASL_SIMPLE ) { /* simple bind */ diff --git a/libraries/libldap/utf-8.c b/libraries/libldap/utf-8.c index 9ff563a27d..6b2ac969e1 100644 --- a/libraries/libldap/utf-8.c +++ b/libraries/libldap/utf-8.c @@ -25,11 +25,13 @@ #include #include +#include "ldap_utf8.h" + #include "ldap-int.h" #include "ldap_defaults.h" -#undef ISASCII -#define ISASCII(uc) ((uc) < 0x80) +#undef LDAP_IS_ASCII +#define LDAP_IS_ASCII(uc) ((uc) < 0x80) /* * Basic UTF-8 routines @@ -107,7 +109,7 @@ int ldap_utf8_charlen( const char * p ) } /* conv UTF-8 to UCS-4, useful for comparisons */ -ldap_ucs4_t ldap_utf8_to_ucs4( const char * p ) +ldap_ucs4_t ldap_x_utf8_to_ucs4( const char * p ) { const unsigned char *c = p; ldap_ucs4_t ch; @@ -134,7 +136,7 @@ ldap_ucs4_t ldap_utf8_to_ucs4( const char * p ) } /* conv UCS-4 to UTF-8, not used */ -int ldap_ucs4_to_utf8( ldap_ucs4_t c, char *buf ) +int ldap_x_ucs4_to_utf8( ldap_ucs4_t c, char *buf ) { int len=0; unsigned char* p = buf; @@ -270,14 +272,14 @@ int ldap_utf8_copy( char* dst, const char *src ) int ldap_utf8_isascii( const char * p ) { unsigned c = * (const unsigned char *) p; - return ISASCII(c); + return LDAP_IS_ASCII(c); } int ldap_utf8_isdigit( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return c >= '0' && c <= '9'; } @@ -286,7 +288,7 @@ int ldap_utf8_isxdigit( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'F' ) @@ -297,7 +299,7 @@ int ldap_utf8_isspace( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; switch(c) { case ' ': @@ -321,7 +323,7 @@ int ldap_utf8_isalpha( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return ( c >= 'A' && c <= 'Z' ) || ( c >= 'a' && c <= 'z' ); @@ -331,7 +333,7 @@ int ldap_utf8_isalnum( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'Z' ) @@ -342,7 +344,7 @@ int ldap_utf8_islower( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return ( c >= 'a' && c <= 'z' ); } @@ -351,7 +353,7 @@ int ldap_utf8_isupper( const char * p ) { unsigned c = * (const unsigned char *) p; - if(!ISASCII(c)) return 0; + if(!LDAP_IS_ASCII(c)) return 0; return ( c >= 'A' && c <= 'Z' ); } @@ -366,7 +368,7 @@ int ldap_utf8_isupper( const char * p ) char * (ldap_utf8_strchr)( const char *str, const char *chr ) { for( ; *str != '\0'; LDAP_UTF8_INCR(str) ) { - if( ldap_utf8_to_ucs4( str ) == ldap_utf8_to_ucs4( chr ) ) { + if( ldap_x_utf8_to_ucs4( str ) == ldap_x_utf8_to_ucs4( chr ) ) { return (char *) str; } } @@ -382,7 +384,7 @@ ber_len_t (ldap_utf8_strcspn)( const char *str, const char *set ) for( cstr = str; *cstr != '\0'; LDAP_UTF8_INCR(cstr) ) { for( cset = set; *cset != '\0'; LDAP_UTF8_INCR(cset) ) { - if( ldap_utf8_to_ucs4( cstr ) == ldap_utf8_to_ucs4( cset ) ) { + if( ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset ) ) { return cstr - str; } } @@ -403,7 +405,7 @@ ber_len_t (ldap_utf8_strspn)( const char *str, const char *set ) return cstr - str; } - if( ldap_utf8_to_ucs4( cstr ) == ldap_utf8_to_ucs4( cset ) ) { + if( ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset ) ) { break; } } @@ -419,7 +421,7 @@ char *(ldap_utf8_strpbrk)( const char *str, const char *set ) const char *cset; for( cset = set; *cset != '\0'; LDAP_UTF8_INCR(cset) ) { - if( ldap_utf8_to_ucs4( str ) == ldap_utf8_to_ucs4( cset ) ) { + if( ldap_x_utf8_to_ucs4( str ) == ldap_x_utf8_to_ucs4( cset ) ) { return (char *) str; } } diff --git a/libraries/liblunicode/liblunicode.dsp b/libraries/liblunicode/liblunicode.dsp index 50540aff99..e495cabb03 100644 --- a/libraries/liblunicode/liblunicode.dsp +++ b/libraries/liblunicode/liblunicode.dsp @@ -132,6 +132,10 @@ SOURCE=..\..\include\ldap_pvt_uc.h # End Source File # Begin Source File +SOURCE=..\..\include\ldap_utf8.h +# End Source File +# Begin Source File + SOURCE=.\ucdata\ucdata.c # End Source File # Begin Source File diff --git a/libraries/liblunicode/ucstr.c b/libraries/liblunicode/ucstr.c index bfd33d379c..31cbb0e988 100644 --- a/libraries/liblunicode/ucstr.c +++ b/libraries/liblunicode/ucstr.c @@ -1,5 +1,7 @@ #include "portable.h" +#include + #include #include @@ -183,7 +185,7 @@ char * UTF8normalize( return NULL; } } - outpos += ldap_ucs4_to_utf8( ucsout[j], &out[outpos] ); + outpos += ldap_x_ucs4_to_utf8( ucsout[j], &out[outpos] ); } if ( i == len ) { @@ -243,7 +245,7 @@ int UTF8normcmp( /* convert and normalize 1st string */ for ( i = 0, ulen = 0; i < l1; i += len, ulen++ ) { - ucs[ulen] = ldap_utf8_to_ucs4( s1 + i ); + ucs[ulen] = ldap_x_utf8_to_ucs4( s1 + i ); if ( ucs[ulen] == LDAP_UCS4_INVALID ) { free( ucs ); return -1; /* what to do??? */ @@ -255,7 +257,7 @@ int UTF8normcmp( /* convert and normalize 2nd string */ for ( i = 0, ulen = 0; i < l2; i += len, ulen++ ) { - ucs[ulen] = ldap_utf8_to_ucs4( s2 + i ); + ucs[ulen] = ldap_x_utf8_to_ucs4( s2 + i ); if ( ucs[ulen] == LDAP_UCS4_INVALID ) { free( ucsout1 ); free( ucs ); diff --git a/libraries/liblunicode/ure/ure.c b/libraries/liblunicode/ure/ure.c index 54c70791dc..90cea61407 100644 --- a/libraries/liblunicode/ure/ure.c +++ b/libraries/liblunicode/ure/ure.c @@ -1866,8 +1866,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out) */ if (0x10000 <= rp->min_code && rp->min_code <= 0x10ffff) { - h = ((rp->min_code - 0x10000) >> 10) + 0xd800; - l = ((rp->min_code - 0x10000) & 1023) + 0xdc00; + h = (ucs2_t) (((rp->min_code - 0x10000) >> 10) + 0xd800); + l = (ucs2_t) (((rp->min_code - 0x10000) & 1023) + 0xdc00); fprintf(out, "\\x%04hX\\x%04hX", h, l); } else fprintf(out, "\\x%04lX", rp->min_code & 0xffff); @@ -1875,8 +1875,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out) putc('-', out); if (rp->max_code >= 0x10000 && rp->max_code <= 0x10ffff) { - h = ((rp->max_code - 0x10000) >> 10) + 0xd800; - l = ((rp->max_code - 0x10000) & 1023) + 0xdc00; + h = (ucs2_t) (((rp->max_code - 0x10000) >> 10) + 0xd800); + l = (ucs2_t) (((rp->max_code - 0x10000) & 1023) + 0xdc00); fprintf(out, "\\x%04hX\\x%04hX", h, l); } else fprintf(out, "\\x%04lX", rp->max_code & 0xffff); @@ -1906,8 +1906,8 @@ ure_write_dfa(ure_dfa_t dfa, FILE *out) /* * Take care of UTF16 characters. */ - h = ((sym->sym.chr - 0x10000) >> 10) + 0xd800; - l = ((sym->sym.chr - 0x10000) & 1023) + 0xdc00; + h = (ucs2_t) (((sym->sym.chr - 0x10000) >> 10) + 0xd800); + l = (ucs2_t) (((sym->sym.chr - 0x10000) & 1023) + 0xdc00); fprintf(out, "\\x%04hX\\x%04hX ", h, l); } else fprintf(out, "\\x%04lX ", sym->sym.chr & 0xffff); diff --git a/servers/slapd/libslapd.dsp b/servers/slapd/libslapd.dsp index 8b84ecf6a1..7251ceffb8 100644 --- a/servers/slapd/libslapd.dsp +++ b/servers/slapd/libslapd.dsp @@ -184,10 +184,6 @@ SOURCE=.\config.c # End Source File # Begin Source File -SOURCE=.\configinfo.c -# End Source File -# Begin Source File - SOURCE=.\connection.c # End Source File # Begin Source File @@ -248,7 +244,7 @@ SOURCE=.\modrdn.c # End Source File # Begin Source File -SOURCE=.\monitor.c +SOURCE=.\mods.c # End Source File # Begin Source File diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 82587ed7b2..4c742291f9 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -16,6 +16,8 @@ #include "slap.h" #include "ldap_pvt.h" +#include "ldap_utf8.h" + #include "lutil_hash.h" /* We should replace MD5 with a faster hash */ #define HASH_BYTES LUTIL_HASH_BYTES @@ -498,6 +500,97 @@ booleanMatch( return LDAP_SUCCESS; } +/* case insensitive UTF8 strncmp with offset for second string */ +static int +UTF8oncasecmp( + struct berval *right, + struct berval *left, + ber_len_t len, + ber_len_t offset ) +{ + ber_len_t r, l; + ber_len_t rlen, llen; + ber_len_t rslen, lslen; + ldap_unicode_t ru, lu; + ldap_unicode_t ruu, luu; + + rslen = len < right->bv_len ? len : right->bv_len; + lslen = len + offset < left->bv_len ? len : left->bv_len; + + for( r = 0, l = offset; + r < rslen && l < lslen; + r+=rlen, l+=llen ) + { + /* + * XXYYZ: we convert to ucs4 even though -llunicode + * expects ucs2 in an unsigned long + */ + ru = ldap_x_utf8_to_ucs4( &right->bv_val[r] ); + if( ru == LDAP_UCS4_INVALID ) { + return 1; + } + + lu = ldap_x_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 < rslen ) { + /* less left */ + return -1; + } + + if( l < lslen ) { + /* less right */ + return 1; + } + + return 0; +} + +static char *UTF8casechr( const char *str, const char *c ) +{ + char *p, *lower, *upper; + ldap_ucs4_t tch, ch = ldap_x_utf8_to_ucs4(c); + + tch = uctolower ( ch ); + for( p = (char *) str; *p != '\0'; LDAP_UTF8_INCR(p) ) { + if( ldap_x_utf8_to_ucs4( p ) == tch ) { + break; + } + } + lower = *p != '\0' ? p : NULL; + + tch = uctoupper ( ch ); + for( p = (char *) str; *p != '\0'; LDAP_UTF8_INCR(p) ) { + if( ldap_x_utf8_to_ucs4( p ) == tch ) { + break; + } + } + upper = *p != '\0' ? p : NULL; + + if( lower && upper ) { + return lower < upper ? lower : upper; + } else if ( lower ) { + return lower; + } else { + return upper; + } +} + static int UTF8StringValidate( Syntax *syntax, diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index 3038bf6b69..b195a9bb71 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -169,11 +169,13 @@ void connection2anonymous( Connection *c ) Connection * connection_first( ber_socket_t *b ) { assert(0); + return NULL; } Connection * connection_next( Connection *c, ber_socket_t *b ) { assert(0); + return NULL; } void connection_done( Connection *c ) @@ -184,6 +186,7 @@ void connection_done( Connection *c ) const char * connection_state2str( int state ) { assert(0); + return NULL; } void replog( Backend *be, Operation *op, char *dn, void *change) @@ -199,5 +202,6 @@ void slap_mods_free( Modifications *ml ) int add_replica_info( Backend *be, const char *host ) { assert(0); + return 0; }