]> git.sur5r.net Git - openldap/commitdiff
SLAP_NVALUES: test003 now passes (with help of a substr mr hack)
authorKurt Zeilenga <kurt@openldap.org>
Sat, 1 Mar 2003 00:14:32 +0000 (00:14 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 1 Mar 2003 00:14:32 +0000 (00:14 +0000)
servers/slapd/Makefile.in
servers/slapd/dn.c
servers/slapd/filter.c
servers/slapd/globals.c [new file with mode: 0644]
servers/slapd/main.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c
servers/slapd/tools/Makefile.in
servers/slapd/tools/slapcommon.c
servers/slapd/value.c

index 75087a41171eaa34572e0ac1e09390492073a114..0aee934d0601bcb2308b25c3154f84feadebb507 100644 (file)
@@ -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 \
index 2b76efc5865bf68111fd588939b5a85941e21abe..647468d92bffc5ba5804596c44278e2870f6b271 100644 (file)
@@ -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(
index 137102b940ce8441a0df61085993b5fd3c8a0b4f..9c07d2d6acf4e102897893f578b185a5c4182c13 100644 (file)
@@ -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 (file)
index 0000000..68eda09
--- /dev/null
@@ -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, "" };
+
index f627ad1ad958261407b507895b78abd6486d304d..5c4cc1fd09e99b561e2be3346c56b7914b4a5c61 100644 (file)
@@ -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 ) { \
index 93605a4708aa66bd35a285293ab14a512011b673..d2c5dbae10a5cad3f8ad07d3f23a173eb87106ed 100644 (file)
@@ -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, 
index 5cd2e04560b1cd64007ea367c29e7e09b5c53160..e4dcb06b3b938d6aa7479677502c5ae5d398113d 100644 (file)
@@ -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
 
 
 #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' )",
index 70eaff2304068f592eb544e68a301492a0cdf4da..e33a31a83ee23d5ce5cba5b3e1a4449ff776391f 100644 (file)
@@ -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 \
index 23fc0bf64c2c460cdfa90b69d31b7cb0108a0a39..2443284c972c6333dedf0694af819b1575426dd6 100644 (file)
@@ -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",
index 83ec803257317ec46768e31110d75641a0699f5c..82fead26c65c39d1f71ef2f4c567ed531c03c675 100644 (file)
@@ -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 ) {