*/
/* location of the default slapd config file */
#define SLAPD_DEFAULT_CONFIGFILE LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.conf"
+#define SLAPD_DEFAULT_UCDATA LDAP_DATADIR LDAP_DIRSEP "ucdata"
/* default max deref depth for aliases */
#define SLAPD_DEFAULT_MAXDEREFDEPTH 15
/* default sizelimit on number of entries from a search */
*/
typedef ber_int_t ldap_ucs4_t;
+#define LDAP_UCS4_INVALID (0x80000000U)
+
typedef short ldap_ucs2_t;
-typedef ldap_ucs2_t ldap_unicode_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))
/* returns the number of bytes in the UTF-8 string */
LDAP_F (ber_len_t) ldap_utf8_bytes( const char * );
#undef ISASCII
#define ISASCII(uc) ((uc) < 0x100)
-#undef UCS4_INVALID
-#define UCS4_INVALID 0x80000000U
/*
* Basic UTF-8 routines
len = LDAP_UTF8_CHARLEN(p);
- if( len == 0 ) return UCS4_INVALID;
+ if( len == 0 ) return LDAP_UCS4_INVALID;
ch = c[0] & mask[len];
for(i=1; i < len; i++) {
if ((c[i] & 0xc0) != 0x80) {
- return UCS4_INVALID;
+ return LDAP_UCS4_INVALID;
}
ch <<= 6;
XXDIR = $(srcdir)/*/
XXHEADERS = ucdata.h ure.h
+
XXSRCS = ucdata.c ucgendat.c ure.c urestubs.c
SRCS =
OBJS = ucdata.o ure.o urestubs.o
ucgendat: $(LIBRARY) ucgendat.o
$(LTLINK) $(LDFLAGS) -o $@ ucgendat.o $(LIBS)
+ ./ucgendat $(srcdir)/UnicodeData.txt
+
+install-local: $(PROGRAMS) FORCE
+ -$(MKDIR) $(DESTDIR)$(datadir)/ucdata
+ @for i $(DATFILES); do \
+ $(INSTALL) $(INSTALLFLAGS) -m 644 $$i $(DESTDIR)$(datadir)/ucdata \
+ done
.links :
@for i in $(XXSRCS) $(XXHEADERS); do \
$(XXSRCS) : .links
clean-local: FORCE
- @$(RM) .links
+ @$(RM) *.dat .links
depend-common: .links
XLDFLAGS = $(MODULES_LDFLAGS) $(SLAPD_MODULES)
# $(LTHREAD_LIBS) must be last
-XLIBS = libbackends.a -lavl -lldbm -lldif -llutil -lldap_r -llber
+XLIBS = libbackends.a -lavl -lldbm -lldif -llutil -llunicode -lldap_r -llber
XXLIBS = $(LDBM_LIBS) $(SLAPD_LIBS) \
$(SECURITY_LIBS) \
$(LDIF_LIBS) $(LUTIL_LIBS)
int global_idletimeout = 0;
char *global_host = NULL;
char *global_realm = NULL;
+char *global_ucdata_path = NULL;
char *ldap_srvtab = "";
char *default_passwd_hash;
return 1;
}
+ /* set UCDATA path */
+ } else if ( strcasecmp( cargv[0], "ucdata-path" ) == 0 ) {
+ if ( cargc < 2 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: missing path in \"ucdata-path <path>\" line\n",
+ fname, lineno, 0 );
+ return( 1 );
+ }
+
+ if ( global_ucdata_path != NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: already set ucdata-path!\n",
+ fname, lineno, 0 );
+ return 1;
+
+ } else {
+ global_ucdata_path = ch_strdup( cargv[1] );
+ }
+
/* set time limit */
} else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
if ( cargc < 2 ) {
LDAP_SLAPD_F (int) global_schemacheck;
LDAP_SLAPD_F (char) *global_host;
LDAP_SLAPD_F (char) *global_realm;
+LDAP_SLAPD_F (char) *global_ucdata_path;
LDAP_SLAPD_F (char) *default_passwd_hash;
LDAP_SLAPD_F (int) lber_debug;
LDAP_SLAPD_F (int) ldap_syslog;
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,
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 ) {
}
*matchp = match;
+#endif
return LDAP_SUCCESS;
}
#include "slap.h"
#include "ldap_pvt.h"
+#include "../libraries/liblunicode/ucdata.h"
int schema_init_done = 0;
/* we should only be called once after schema_init() was called */
assert( schema_init_done == 1 );
+ ucdata_load( global_ucdata_path ? global_ucdata_path :
+ SLAPD_DEFAULT_UCDATA, UCDATA_CASE|UCDATA_CTYPE|UCDATA_NUM );
+
for( i=0; oc_map[i].ssom_name; i++ ) {
ObjectClass ** ocp = (ObjectClass **)
&(((char *) &slap_schema)[oc_map[i].ssom_offset]);
#define slap_syntax_is_ber(s) slap_syntax_is_flag((s),SLAP_SYNTAX_BER)
#define slap_syntax_is_hidden(s) slap_syntax_is_flag((s),SLAP_SYNTAX_HIDE)
-/* XXX -> UCS-2 Converter */
+/* X -> Y Converter */
typedef int slap_mr_convert_func LDAP_P((
struct berval * in,
struct berval ** out ));
XDEFS = $(MODULES_CPPFLAGS)
XLDFLAGS = $(MODULES_LDFLAGS) $(SLAPD_MODULES)
-XLIBS = -lavl -lldif -lldbm -llutil -lldap_r -llber
+XLIBS = -lavl -lldif -lldbm -llutil -llunicode -lldap_r -llber
XXLIBS = $(SLAPD_LIBS) \
$(LDBM_LIBS) $(SECURITY_LIBS) \
$(LDIF_LIBS) $(LUTIL_LIBS)
test-ldbm: FORCE
@-$(LN_S) $(srcdir)/data .
@-$(LN_S) $(top_srcdir)/servers/slapd/schema .
+ @-$(LN_S) ../libraries/liblunicode/ucdata .
@if test "$(BUILD_LDBM)" = "yes" ; then \
echo "Initiating LDAP tests for LDBM..." ; \
$(MKDIR) test-db test-repl || true; \
test-passwd: FORCE
@-$(LN_S) $(srcdir)/data .
@-$(LN_S) $(top_srcdir)/servers/slapd/schema .
+ @-$(LN_S) ../libraries/liblunicode/ucdata .
@echo "Initiating LDAP tests..."
@-$(MKDIR) test-db test-repl || true
@$(srcdir)/scripts/passwd-search $(srcdir) passwd
test-nis-schema-ldbm:
@-$(LN_S) $(srcdir)/data .
@-$(LN_S) $(top_srcdir)/servers/slapd/schema .
+ @-$(LN_S) ../libraries/liblunicode/ucdata .
@echo "Initiating LDAP server with NIS schema & ldbm backend..."; \
$(MKDIR) test-db test-repl ; \
$(srcdir)/scripts/startup_nis_ldap_server.sh $(srcdir) ldbm
-$(RM) -r test-db/[!C]* test-repl/[!C]* *leak *gmon *core
veryclean-local: FORCE
- @-$(RM) data schema
+ @-$(RM) data schema ucdata
-$(RM) -r test-db test-repl
#
# master slapd config -- for testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# DNS SRV slapd config -- for testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# master slapd config -- for testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# master slapd config -- for testing
#
+ucdata-path ./ucdata
include ../servers/slapd/schema/others_nis.at.conf
include ../servers/slapd/schema/others_nis.oc.conf
include ../servers/slapd/schema/nis.at.conf
#
# master slapd config -- for testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# master slapd config -- for testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# slave slapd config -- for default referral testing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# master slapd config -- for testing of replication
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
#
# master slapd config -- for testing of replication
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema
# stand-alone slapd config -- for testing
# with indexing
#
+ucdata-path ./ucdata
#include ./data/slapd.at.conf
#include ./data/slapd.oc.conf
include ./schema/core.schema