From: Kurt Zeilenga Date: Sat, 1 Mar 2003 00:14:32 +0000 (+0000) Subject: SLAP_NVALUES: test003 now passes (with help of a substr mr hack) X-Git-Tag: NO_SLAP_OP_BLOCKS~239 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=16c9e81c802a342e784742cfd456eaca0e4c3a94;p=openldap SLAP_NVALUES: test003 now passes (with help of a substr mr hack) --- diff --git a/servers/slapd/Makefile.in b/servers/slapd/Makefile.in index 75087a4117..0aee934d06 100644 --- a/servers/slapd/Makefile.in +++ b/servers/slapd/Makefile.in @@ -9,8 +9,9 @@ XSRCS=version.c NT_SRCS = nt_svc.c NT_OBJS = nt_svc.o ../../libraries/liblutil/slapdmsg.res -SRCS = main.c daemon.c connection.c search.c filter.c add.c cr.c \ - attr.c entry.c config.c backend.c result.c operation.c \ +SRCS = main.c globals.c config.c daemon.c \ + connection.c search.c filter.c add.c cr.c \ + attr.c entry.c backend.c result.c operation.c \ dn.c compare.c modify.c delete.c modrdn.c ch_malloc.c \ value.c ava.c bind.c unbind.c abandon.c filterentry.c \ phonetic.c acl.c str2filter.c aclparse.c init.c user.c \ @@ -22,8 +23,9 @@ SRCS = main.c daemon.c connection.c search.c filter.c add.c cr.c \ limits.c backglue.c operational.c matchedValues.c cancel.c \ $(@PLAT@_SRCS) -OBJS = main.o daemon.o connection.o search.o filter.o add.o cr.o \ - attr.o entry.o config.o backend.o result.o operation.o \ +OBJS = main.o globals.o config.o daemon.o \ + connection.o search.o filter.o add.o cr.o \ + attr.o entry.o backend.o result.o operation.o \ dn.o compare.o modify.o delete.o modrdn.o ch_malloc.o \ value.o ava.o bind.o unbind.o abandon.o filterentry.o \ phonetic.o acl.o str2filter.o aclparse.o init.o user.o \ diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 2b76efc586..647468d92b 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -20,8 +20,6 @@ #include "lutil.h" -const struct berval slap_empty_bv = { 0, "" }; - /* * The DN syntax-related functions take advantage of the dn representation * handling functions ldap_str2dn/ldap_dn2str. The latter are not schema- @@ -361,34 +359,20 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) return LDAP_SUCCESS; } -/* - * dn normalize routine - */ int +#ifdef SLAP_NVALUES dnNormalize( - Syntax *syntax, - struct berval *val, - struct berval **normalized ) -{ - struct berval *out; - int rc; - - assert( normalized && *normalized == NULL ); - - out = ch_malloc( sizeof( struct berval ) ); - rc = dnNormalize2( syntax, val, out ); - if ( rc != LDAP_SUCCESS ) - free( out ); - else - *normalized = out; - return rc; -} - -int -dnNormalize2( - Syntax *syntax, - struct berval *val, - struct berval *out ) + slap_mask_t use, + Syntax *syntax, + MatchingRule *mr, + struct berval *val, + struct berval *out ) +#else +dnNormalize( + Syntax *syntax, + struct berval *val, + struct berval *out ) +#endif { assert( val ); assert( out ); @@ -437,6 +421,7 @@ dnNormalize2( return LDAP_SUCCESS; } +#if 0 /* * dn "pretty"ing routine */ @@ -459,6 +444,7 @@ dnPretty( *pretty = out; return rc; } +#endif int dnPretty2( diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 137102b940..9c07d2d6ac 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -415,9 +415,9 @@ get_substring_filter( } #ifdef SLAP_NVALUES - /* validate using equality matching rule validator! */ + /* validate/normalize using equality matching rule validator! */ rc = asserted_value_validate_normalize( - f->f_sub_desc, f->f_sub_desc->ad_type->sat_substr, + f->f_sub_desc, f->f_sub_desc->ad_type->sat_equality, usage, &value, &bv, text ); if( rc != LDAP_SUCCESS ) { goto return_error; @@ -1434,9 +1434,9 @@ get_substring_vrFilter( } #ifdef SLAP_NVALUES - /* validate using equality matching rule validator! */ + /* validate/normalize using equality matching rule validator! */ rc = asserted_value_validate_normalize( - vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_substr, + vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_equality, usage, &value, &bv, text ); if( rc != LDAP_SUCCESS ) { goto return_error; diff --git a/servers/slapd/globals.c b/servers/slapd/globals.c new file mode 100644 index 0000000000..68eda098a1 --- /dev/null +++ b/servers/slapd/globals.c @@ -0,0 +1,20 @@ +/* globals.c - various global variables */ +/* $OpenLDAP$ */ +/* + * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ + +#include "portable.h" + +#include "slap.h" + +/* + * global variables, in general, should be declared in the file + * primarily responsible for its management. Configurable globals + * belong in config.c. variables declared here have no other + * sensible home. + */ + +const struct berval slap_empty_bv = { 0, "" }; + diff --git a/servers/slapd/main.c b/servers/slapd/main.c index f627ad1ad9..5c4cc1fd09 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -32,10 +32,11 @@ static RETSIGTYPE wait4child( int sig ); #define MAIN_RETURN(x) return static struct sockaddr_in bind_addr; -void CommenceStartupProcessing( LPCTSTR serverName, - void(*stopper)(int)); -void ReportSlapdShutdownComplete( void ); -void *getRegParam( char *svc, char *value ); +/* FIXME: no externs should appear in a .c, should be in a .h instead */ +extern void CommenceStartupProcessing( LPCTSTR serverName, + void(*stopper)(int)); +extern void ReportSlapdShutdownComplete( void ); +extern void *getRegParam( char *svc, char *value ); #define SERVICE_EXIT( e, n ) do { \ if ( is_NT_Service ) { \ diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 93605a4708..d2c5dbae10 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -393,15 +393,21 @@ LDAP_SLAPD_F (int) dnValidate LDAP_P(( Syntax *syntax, struct berval *val )); +#ifdef SLAP_NVALUES LDAP_SLAPD_F (int) dnNormalize LDAP_P(( + slap_mask_t use, Syntax *syntax, + MatchingRule *mr, struct berval *val, - struct berval **normalized )); - -LDAP_SLAPD_F (int) dnNormalize2 LDAP_P(( + struct berval *normalized )); +#define dnNormalize2(s,v,n) dnNormalize(0,(s),NULL,(v),(n)) +#else +LDAP_SLAPD_F (int) dnNormalize LDAP_P(( Syntax *syntax, struct berval *val, struct berval *normalized )); +#define dnNormalize2(s,v,n) dnNormalize((s),(v),(n)) +#endif LDAP_SLAPD_F (int) dnPretty LDAP_P(( Syntax *syntax, diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 5cd2e04560..e4dcb06b3b 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -42,6 +42,7 @@ #define xintegerNormalize NULL #define xnumericStringNormalize NULL #define xnameUIDNormalize NULL +#define xdnNormalize NULL /* (new) normalization routines */ #define caseExactIA5Normalize IA5StringNormalize @@ -49,7 +50,6 @@ #define caseExactNormalize UTF8StringNormalize #define caseIgnoreNormalize UTF8StringNormalize -#define distinguishedNameNormalize NULL #define integerNormalize NULL #define integerFirstComponentNormalize NULL #define numericStringNormalize NULL @@ -60,6 +60,7 @@ #define bitStringNormalize NULL #define telephoneNumberNormalize NULL +#define distinguishedNameNormalize dnNormalize #define distinguishedNameMatch dnMatch #define distinguishedNameIndexer octetStringIndexer #define distinguishedNameFilter octetStringFilter @@ -89,7 +90,7 @@ #define caseIgnoreIndexer octetStringIndexer #define caseIgnoreFilter octetStringFilter -#define caseIgnoreSubstringsMatch NULL +#define caseIgnoreSubstringsMatch SubstringsMatch #define caseIgnoreSubstringsIndexer NULL #define caseIgnoreSubstringsFilter NULL @@ -156,6 +157,8 @@ #ifndef SLAP_NVALUES +#define xdnNormalize dnNormalize + /* (new) normalization routines */ #define caseExactNormalize NULL #define caseExactIA5Normalize NULL @@ -2491,7 +2494,12 @@ caseExactIA5Match( } static int -caseExactIA5SubstringsMatch( +caseExactIA5SubstringsMatch +#else +static int +SubstringsMatch +#endif +( int *matchp, slap_mask_t flags, Syntax *syntax, @@ -2614,6 +2622,8 @@ done: return LDAP_SUCCESS; } +#ifndef SLAP_NVALUES + /* Index generation function */ static int caseExactIA5Indexer( slap_mask_t use, @@ -4582,7 +4592,7 @@ static slap_syntax_defs_rec syntax_defs[] = { {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )", 0, countryStringValidate, xIA5StringNormalize, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )", - 0, dnValidate, dnNormalize2, dnPretty2}, + 0, dnValidate, xdnNormalize, dnPretty2}, {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )", 0, NULL, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )", diff --git a/servers/slapd/tools/Makefile.in b/servers/slapd/tools/Makefile.in index 70eaff2304..e33a31a83e 100644 --- a/servers/slapd/tools/Makefile.in +++ b/servers/slapd/tools/Makefile.in @@ -37,7 +37,7 @@ PROGRAMS=slapadd slapcat slapindex slappasswd SRCS = mimic.c slapcommon.c \ slapadd.c slapcat.c slapindex.c slappasswd.c -SLAPD_OBJS = ../config.o ../ch_malloc.o ../cr.o ../backend.o \ +SLAPD_OBJS = ../globals.o ../config.o ../ch_malloc.o ../cr.o ../backend.o \ ../module.o ../aclparse.o ../filterentry.o ../schema.o \ ../schema_check.o ../schema_init.o ../schema_prep.o \ ../schemaparse.o ../ad.o ../at.o ../mr.o ../oc.o \ diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index 23fc0bf64c..2443284c97 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -230,17 +230,17 @@ slap_tool_init( } if( base.bv_val != NULL ) { - struct berval *nbase = NULL; + struct berval nbase; - rc = dnNormalize( NULL, &base, &nbase ); + rc = dnNormalize2( NULL, &base, &nbase ); if( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n", progname, base.bv_val ); exit( EXIT_FAILURE ); } - be = select_backend( nbase, 0, 0 ); - ber_bvfree( nbase ); + be = select_backend( &nbase, 0, 0 ); + ber_bvfree( nbase.bv_val ); if( be == NULL ) { fprintf( stderr, "%s: slap_init no backend for \"%s\"\n", diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 83ec803257..82fead26c6 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -147,9 +147,6 @@ int asserted_value_validate_normalize( return LDAP_INAPPROPRIATE_MATCHING; } - assert( mr->smr_syntax ); - assert( mr->smr_syntax->ssyn_validate ); - rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in ); if( rc != LDAP_SUCCESS ) {