]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_init.c
Fix cursor initialization, scope IDs
[openldap] / servers / slapd / schema_init.c
index 6e6e1a3c509063723122c2ab4f58490d489b0702..d1e4068a23fcfdec981b9872af0ec0ace50c88ac 100644 (file)
@@ -28,6 +28,8 @@
 #define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
 #define HASH_Final(d,c)                        lutil_HASHFinal(d,c)
 
+#define SLAP_NVALUES 1
+
 #ifdef SLAP_NVALUES
 /* TO BE DELETED */
 #define SLAP_MR_DN_FOLD (0)
 #define caseExactNormalize                                                     UTF8StringNormalize
 #define caseIgnoreNormalize                                                    UTF8StringNormalize
 
-#define integerNormalize                                                       NULL
 #define integerFirstComponentNormalize                         NULL
 #define objectIdentifierNormalize                                      NULL
 #define objectIdentifierFirstComponentNormalize                NULL
-#define generalizedTimeNormalize                                       NULL
-#define bitStringNormalize                                                     NULL
 
 #define distinguishedNameNormalize     dnNormalize
 #define distinguishedNameMatch         dnMatch
 #define distinguishedNameIndexer       octetStringIndexer
 #define distinguishedNameFilter                octetStringFilter
 
+#define integerOrderingMatch                   integerMatch
+#define integerFirstComponentMatch             NULL
+#define integerIndexer                         octetStringIndexer
+#define integerFilter                          octetStringFilter
+
+#define generalizedTimeMatch                   caseIgnoreIA5Match
+#define generalizedTimeOrderingMatch   caseIgnoreIA5Match
+
 #define uniqueMemberMatch                      dnMatch /* FIXME! */
 
 #define objectIdentifierMatch  octetStringMatch
 #define bitStringIndexer               octetStringIndexer
 #define bitStringFilter                        octetStringFilter
 
-#define integerMatch NULL
-#define integerOrderingMatch NULL
-#define integerIndexer NULL
-#define integerFilter NULL
-
-#define generalizedTimeMatch   NULL
-#define generalizedTimeOrderingMatch   NULL
-
 #define caseIgnoreMatch                octetStringMatch
 #define caseIgnoreOrderingMatch                octetStringOrderingMatch
 #define caseIgnoreIndexer      octetStringIndexer
 #define objectIdentifierFirstComponentNormalize                NULL
 #define generalizedTimeNormalize                                       NULL
 #define uniqueMemberNormalize                                          NULL
-#define bitStringNormalize                                                     NULL
 #define telephoneNumberNormalize                                       NULL
 
 
@@ -757,7 +755,7 @@ UTF8StringNormalize(
 
        flags = SLAP_MR_ASSOCIATED(mr, slap_schema.si_mr_caseExactMatch )
                ? LDAP_UTF8_NOCASEFOLD : LDAP_UTF8_CASEFOLD;
-       flags |= ( use & SLAP_MR_EQUALITY_APPROX == SLAP_MR_EQUALITY_APPROX )
+       flags |= ( ( use & SLAP_MR_EQUALITY_APPROX ) == SLAP_MR_EQUALITY_APPROX )
                ? LDAP_UTF8_APPROX : 0;
 
        val = UTF8bvnormalize( val, &tmp, flags );
@@ -2112,8 +2110,6 @@ oidValidate(
        return LDAP_INVALID_SYNTAX;
 }
 
-#ifndef SLAP_NVALUES
-
 static int
 integerMatch(
        int *matchp,
@@ -2132,18 +2128,20 @@ integerMatch(
        /* Skip leading space/sign/zeroes, and get the sign of the *value number */
        v = value->bv_val;
        vlen = value->bv_len;
+
+#ifndef SLAP_NVALUES
        if( mr == slap_schema.si_mr_integerFirstComponentMatch ) {
                char *tmp = memchr( v, '$', vlen );
-               if( tmp )
-                       vlen = tmp - v;
-               while( vlen && ASCII_SPACE( v[vlen-1] ))
-                       vlen--;
+               if( tmp ) vlen = tmp - v;
+               while( vlen && ASCII_SPACE( v[vlen-1] )) vlen--;
+       }
+#endif
+
+       for( ; vlen && ( *v < '1' || '9' < *v ); v++, vlen-- ) { /* ANSI 2.2.1 */
+               if( *v == '-' ) vsign = -1;
        }
-       for( ; vlen && ( *v < '1' || '9' < *v ); v++, vlen-- ) /* ANSI 2.2.1 */
-               if( *v == '-' )
-                       vsign = -1;
-       if( vlen == 0 )
-               vsign = 0;
+
+       if( vlen == 0 ) vsign = 0;
 
        /* Do the same with the *assertedValue number */
        asserted = (struct berval *) assertedValue;
@@ -2168,7 +2166,6 @@ integerMatch(
        return LDAP_SUCCESS;
 }
        
-#endif
 static int
 integerValidate(
        Syntax *syntax,
@@ -2180,6 +2177,7 @@ integerValidate(
 
        if(( val->bv_val[0] == '+' ) || ( val->bv_val[0] == '-' )) {
                if( val->bv_len < 2 ) return LDAP_INVALID_SYNTAX;
+
        } else if( !ASCII_DIGIT(val->bv_val[0]) ) {
                return LDAP_INVALID_SYNTAX;
        }
@@ -2191,12 +2189,20 @@ integerValidate(
        return LDAP_SUCCESS;
 }
 
-#ifndef SLAP_NVALUES
 static int
+#ifdef SLAP_NVALUES
+integerNormalize(
+       slap_mask_t use,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *val,
+       struct berval *normalized )
+#else
 xintegerNormalize(
        Syntax *syntax,
        struct berval *val,
        struct berval *normalized )
+#endif
 {
        char *p;
        int negative=0;
@@ -2232,13 +2238,11 @@ xintegerNormalize(
        if( len == 0 ) {
                normalized->bv_val = ch_strdup("0");
                normalized->bv_len = 1;
-       }
-       else {
+
+       else {
                normalized->bv_len = len+negative;
                normalized->bv_val = ch_malloc( normalized->bv_len + 1 );
-               if( negative ) {
-                       normalized->bv_val[0] = '-';
-               }
+               if( negative ) normalized->bv_val[0] = '-';
                AC_MEMCPY( normalized->bv_val + negative, p, len );
                normalized->bv_val[len+negative] = '\0';
        }
@@ -2246,6 +2250,8 @@ xintegerNormalize(
        return LDAP_SUCCESS;
 }
 
+#ifndef SLAP_NVALUES
+
 /* Index generation function */
 static int integerIndexer(
        slap_mask_t use,
@@ -2437,8 +2443,8 @@ IA5StringValidate(
        return LDAP_SUCCESS;
 }
 
-#ifdef SLAP_NVALUES
 static int
+#ifdef SLAP_NVALUES
 IA5StringNormalize(
        slap_mask_t use,
        Syntax *syntax,
@@ -2446,7 +2452,6 @@ IA5StringNormalize(
        struct berval *val,
        struct berval *normalized )
 #else
-static int
 xIA5StringNormalize(
        Syntax *syntax,
        struct berval *val,
@@ -4496,13 +4501,20 @@ generalizedTimeValidate(
        return check_time_syntax(in, 0, parts);
 }
 
-#ifndef SLAP_NVALUES
-
 static int
+#ifdef SLAP_NVALUES
+generalizedTimeNormalize(
+       slap_mask_t usage,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *val,
+       struct berval *normalized )
+#else
 xgeneralizedTimeNormalize(
        Syntax *syntax,
        struct berval *val,
        struct berval *normalized )
+#endif
 {
        int parts[9], rc;
 
@@ -4524,7 +4536,6 @@ xgeneralizedTimeNormalize(
        return LDAP_SUCCESS;
 }
 
-#endif
 static int
 nisNetgroupTripleValidate(
        Syntax *syntax,
@@ -4960,7 +4971,7 @@ static slap_mrule_defs_rec mrule_defs[] = {
                "SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
                SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
                NULL,
-               bitStringNormalize, bitStringMatch,
+               NULL, bitStringMatch,
                bitStringIndexer, bitStringFilter,
                NULL},