#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 */
#undef LDAP_VENDOR_VERSION_PATCH
/*
+** WORK IN PROGRESS!
+**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
#define LDAP_VENDOR_VERSION_PATCH X
/*
+** WORK IN PROGRESS!
+**
** OpenLDAP reentrancy/thread-safeness should be dynamically
** checked using ldap_get_option().
**
/*
* 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
* 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))
/*
* 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
#ifndef _LDAP_UTF8_H
#define _LDAP_UTF8_H
-LDAP_BEGIN_DECL
+#include <lber_types.h> /* 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
/* 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
int inout )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( !ber_log_check( errlvl, loglvl )) {
return 0;
ber_len_t len;
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( inout == 1 ) {
len = ber_pvt_ber_remaining(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;
assert( ber != NULL );
assert( len != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
/*
* Any ber element looks like this: tag length contents.
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
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;
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;
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;
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;
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;
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;
assert( ber != NULL );
assert( boolval != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
rc = ber_get_int( ber, &longbool );
*boolval = longbool;
assert( len != NULL );
assert( last != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( ber->ber_ptr == last ) {
return LBER_DEFAULT;
assert( ber != NULL );
assert( fmt != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
fmt_reset = fmt;
unsigned char nettag[sizeof(ber_tag_t)];
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
taglen = ber_calc_taglen( tag );
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,
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 */
ber_tag_t tag )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT ) {
tag = LBER_ENUMERATED;
ber_tag_t tag )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT ) {
tag = LBER_INTEGER;
assert( ber != NULL );
assert( str != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT ) {
tag = LBER_OCTETSTRING;
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 );
assert( ber != NULL );
assert( str != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
return ber_put_ostring( ber, str, strlen( str ), tag );
}
assert( ber != NULL );
assert( str != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT ) {
tag = LBER_BITSTRING;
ber_len_t taglen;
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT ) {
tag = LBER_NULL;
unsigned char falseval = 0;
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( tag == LBER_DEFAULT )
tag = LBER_BOOLEAN;
Seqorset *new;
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
new = (Seqorset *) LBER_CALLOC( 1, sizeof(Seqorset) );
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;
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;
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
ber_put_seq( BerElement *ber )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
return ber_put_seqorset( ber );
}
ber_put_set( BerElement *ber )
{
assert( ber != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
return ber_put_seqorset( ber );
}
assert( ber != NULL );
assert( fmt != NULL );
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
va_start( ap, fmt );
#include "lber-int.h"
-#define EXBUFSIZ 1024
+#define LBER_EXBUFSIZ 1024
static ber_slen_t
BerRead(
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;
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 ) {
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;
return;
}
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if ( freebuf ) {
Seqorset *s, *next;
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;
ber->ber_options = options;
ber->ber_debug = ber_int_debug;
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
return 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;
*new = *ber;
- assert( BER_VALID( new ) );
+ assert( LBER_VALID( new ) );
return( new );
}
ber->ber_options = (char) options;
ber->ber_debug = ber_int_debug;
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
}
/* New C-API ber_init() */
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;
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" ));
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)
#define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
-#define READBUFSIZ 8192
-
struct seqorset {
BerElement *sos_ber;
ber_len_t sos_clen;
};
/* 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,
#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;
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 );
(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 );
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;
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;
#include <winsock.h>
#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
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;
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;
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;
#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 )
/* 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 ) );
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 ) {
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) );
}
sb_debug_write, /* sbi_write */
NULL /* sbi_close */
};
-
# 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
# 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
}
ber = lc->lconn_ber;
- assert( BER_VALID (ber) );
+ assert( LBER_VALID (ber) );
/* get the next message */
errno = 0;
return ld->ld_errno;
}
- assert( BER_VALID( ber ) );
+ assert( LBER_VALID( ber ) );
if( mechanism == LDAP_SASL_SIMPLE ) {
/* simple bind */
#include <ac/string.h>
#include <ac/time.h>
+#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
}
/* 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;
}
/* 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;
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';
}
{
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' )
{
unsigned c = * (const unsigned char *) p;
- if(!ISASCII(c)) return 0;
+ if(!LDAP_IS_ASCII(c)) return 0;
switch(c) {
case ' ':
{
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' );
{
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' )
{
unsigned c = * (const unsigned char *) p;
- if(!ISASCII(c)) return 0;
+ if(!LDAP_IS_ASCII(c)) return 0;
return ( c >= 'a' && c <= 'z' );
}
{
unsigned c = * (const unsigned char *) p;
- if(!ISASCII(c)) return 0;
+ if(!LDAP_IS_ASCII(c)) return 0;
return ( c >= 'A' && c <= 'Z' );
}
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;
}
}
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;
}
}
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;
}
}
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;
}
}
# 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
#include "portable.h"
+#include <ldap_utf8.h>
+
#include <ldap_pvt_uc.h>
#include <ac/ctype.h>
return NULL;
}
}
- outpos += ldap_ucs4_to_utf8( ucsout[j], &out[outpos] );
+ outpos += ldap_x_ucs4_to_utf8( ucsout[j], &out[outpos] );
}
if ( i == len ) {
/* 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??? */
/* 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 );
*/
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);
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);
/*
* 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);
# End Source File
# Begin Source File
-SOURCE=.\configinfo.c
-# End Source File
-# Begin Source File
-
SOURCE=.\connection.c
# End Source File
# Begin Source File
# End Source File
# Begin Source File
-SOURCE=.\monitor.c
+SOURCE=.\mods.c
# End Source File
# Begin Source File
#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
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,
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 )
const char * connection_state2str( int state )
{
assert(0);
+ return NULL;
}
void replog( Backend *be, Operation *op, char *dn, void *change)
int add_replica_info( Backend *be, const char *host )
{
assert(0);
+ return 0;
}