Commit cee040a3 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Bring UCdata infrastructure.

parent b9929921
......@@ -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 */
......
......@@ -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 * );
......
......@@ -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;
......
......@@ -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
......@@ -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)
......
......@@ -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 ) {
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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]);
......
......@@ -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 ));
......
......@@ -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)
......
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment