]> git.sur5r.net Git - openldap/commitdiff
Bring UCdata infrastructure.
authorKurt Zeilenga <kurt@openldap.org>
Sun, 3 Sep 2000 23:48:35 +0000 (23:48 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 3 Sep 2000 23:48:35 +0000 (23:48 +0000)
22 files changed:
include/ldap_defaults.h
include/ldap_pvt.h
libraries/libldap/utf-8.c
libraries/liblunicode/Makefile.in
servers/slapd/Makefile.in
servers/slapd/config.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/slap.h
servers/slapd/tools/Makefile.in
tests/Makefile.in
tests/data/slapd-acl.conf
tests/data/slapd-dnssrv.conf
tests/data/slapd-master.conf
tests/data/slapd-nis-master.conf
tests/data/slapd-passwd.conf
tests/data/slapd-pw.conf
tests/data/slapd-ref-slave.conf
tests/data/slapd-repl-master.conf
tests/data/slapd-repl-slave.conf
tests/data/slapd.conf

index c02734465da177d3effdb6001a7018f6e50718ff..811865f1d1bb957809bc986f39e6be84e247c355 100644 (file)
@@ -200,6 +200,7 @@ Please try again later.\r\n"
  */
        /* 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 */
index 042cdd18d938b248e49d733f520cc572cf7deea6..2596e29f0236e2ac6bbca25dd3f4fb20441836c2 100644 (file)
@@ -177,8 +177,19 @@ LDAP_F (int) ldap_pvt_tls_set_option LDAP_P(( struct ldapoptions *lo, int option
  */
 
 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 * );
index 07243b786dc47beec48f23a6141428a52e3e0ae4..1523b7b4a47baf17982a5131d002ed5bc56cec8f 100644 (file)
@@ -30,8 +30,6 @@
 
 #undef ISASCII
 #define ISASCII(uc)    ((uc) < 0x100)
-#undef UCS4_INVALID
-#define UCS4_INVALID   0x80000000U
 
 /*
  * Basic UTF-8 routines
@@ -119,13 +117,13 @@ ldap_ucs4_t ldap_utf8_to_ucs4( const char * p )
 
        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;
index 4f8b891b2815606851dc3bdb72554f3f2a20271d..815a16eeaaeafaabb6f5d9cbfe8e7207955ce83f 100644 (file)
@@ -8,6 +8,7 @@ LIBRARY = liblunicode.a
 
 XXDIR = $(srcdir)/*/
 XXHEADERS = ucdata.h ure.h
+
 XXSRCS = ucdata.c ucgendat.c ure.c urestubs.c
 SRCS   = 
 OBJS   = ucdata.o ure.o urestubs.o
@@ -20,6 +21,13 @@ LDAP_LIBDIR= ../../libraries
 
 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 \
@@ -31,6 +39,6 @@ ucgendat: $(LIBRARY) ucgendat.o
 $(XXSRCS) : .links
 
 clean-local: FORCE
-       @$(RM) .links
+       @$(RM) *.dat .links
 
 depend-common: .links
index 1c3b14747d0b22177718d1959fa89301ade96b9a..eb54e1542e97839ddd67d274e6e9aaec6089c3a2 100644 (file)
@@ -41,7 +41,7 @@ XDEFS = $(MODULES_CPPFLAGS)
 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)
index 69cd36c6f3aa7b65857e841c0cd0877671435ed4..903932def8d0899e4c49fc6e3293b431f6505000 100644 (file)
@@ -34,6 +34,7 @@ int           global_lastmod = ON;
 int            global_idletimeout = 0;
 char   *global_host = NULL;
 char   *global_realm = NULL;
+char   *global_ucdata_path = NULL;
 char           *ldap_srvtab = "";
 char           *default_passwd_hash;
 
@@ -283,6 +284,25 @@ read_config( const char *fname )
                                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 ) {
index 5789dc79254b8a1e95e2090a3bbbad55fd75862b..c324adf29682428e24ebf9276b5db62af15f0b00 100644 (file)
@@ -769,6 +769,7 @@ LDAP_SLAPD_F (int)          global_idletimeout;
 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;
index 1a8071ff6553e9b744d7b4116df43076acebd906..cac0f0b0a337f04d8d7bee66d89a69c5ae4015a8 100644 (file)
@@ -343,6 +343,62 @@ booleanMatch(
        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,
@@ -1019,6 +1075,9 @@ caseIgnoreMatch(
        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 ) {
@@ -1028,6 +1087,7 @@ caseIgnoreMatch(
        }
 
        *matchp = match;
+#endif
        return LDAP_SUCCESS;
 }
 
index 0574dcde1802fe87d0fc7a2e6c9cb2d8f01ef6cd..12b0af963ffa0d6f049d0d637cd4b646b2df2044 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "slap.h"
 #include "ldap_pvt.h"
+#include "../libraries/liblunicode/ucdata.h"
 
 int schema_init_done = 0;
 
@@ -218,6 +219,9 @@ schema_prep( void )
        /* 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]);
index 6d196c4511fa28b35efa94385202e02a00b2f012..76bf82d2ff28a23c755f8e8290fb82913305c941 100644 (file)
@@ -256,7 +256,7 @@ typedef struct slap_syntax {
 #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 ));
index 227ffd0bea0633ea64a9d78c3766d131f6714de0..777e666a93ab57c1dc6fc41571ed2b88f7ba4e67 100644 (file)
@@ -25,7 +25,7 @@ SLAPD_MODULES = @SLAPD_MODULES_LIST@
 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)
index 5d250a2d5aad0418070f10798b7894c7d66ca61d..ff5467d677a37b9c860a294fdd452fff1ede7422 100644 (file)
@@ -13,6 +13,7 @@ ldbm: test-ldbm
 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; \
@@ -25,6 +26,7 @@ passwd: test-passwd
 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
@@ -33,6 +35,7 @@ test-nis-schema:        test-nis-schema-ldbm
 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
@@ -41,6 +44,6 @@ clean-local:  FORCE
        -$(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
 
index 58992bfb7143400daae7a707e02e310b851b5298..bf0bbd659f4a67ff3e8aa0fb7906edcf35f1a306 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index bdd60db8109997f5d476b0d04962de0190bf73c6..e66e58e3b7a2075851a321161836e36f12a2dc13 100644 (file)
@@ -2,6 +2,7 @@
 #
 # DNS SRV slapd config -- for testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index f3d7e044b101ed1af73184cc06216602a921ec8f..7c0cc687dc901ec5879e672f26b0acea334609aa 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index 0aebb564d0d1bb6b41f8adfd7be785e200ddfb15..db1e2c2bb3a2595ecf4cd7923373660c0d7b7775 100644 (file)
@@ -2,6 +2,7 @@
 #
 # 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
index 78279e4f5da3379259009199a4054c83cea911e5..a231233f384baf57f76d0ad1a46b1844f7cc61fc 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index 2b1681c989834cd221512adb48ff04a295469854..1fd26b599241b8f4857607946f9c6d614d641a25 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index 714e4e097ec27127c5837ba2174fb50d7c77668c..f804e4d2e0350c850534e0c489f85db08485b4b2 100644 (file)
@@ -2,6 +2,7 @@
 #
 # slave slapd config -- for default referral testing
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index 57098f378673837bf77cbe6c55847289ae0aa796..6df433a5029b8324473f563f749142ce4e442416 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing of replication
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index ee7fea837b26b262889f7d85915247cdec6274e4..84919f7b879a2da634748008acc81b4d0aea5aa0 100644 (file)
@@ -2,6 +2,7 @@
 #
 # master slapd config -- for testing of replication
 #
+ucdata-path    ./ucdata
 #include               ./data/slapd.at.conf
 #include               ./data/slapd.oc.conf
 include ./schema/core.schema
index 413b16ec671842f3794cbe01dafb95af9963144f..a15e2b7cb0b0a46bf56d7b36c4b9eaf4cd2be6df 100644 (file)
@@ -3,6 +3,7 @@
 # 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