]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/mr.c
Extend value_match to extract an asserted value from a full value
[openldap] / servers / slapd / mr.c
index 28b543fdd6a91da0e33dd25677ff2543832f25a0..5fa82b52319f819c0b8fadef8623372869cd30f6 100644 (file)
@@ -36,7 +36,7 @@ mr_index_cmp(
 
 static int
 mr_index_name_cmp(
-    char               *name,
+    char               *name,
     struct mindexrec   *mir
 )
 {
@@ -49,7 +49,7 @@ mr_find( const char *mrname )
        struct mindexrec        *mir = NULL;
 
        if ( (mir = (struct mindexrec *) avl_find( mr_index, mrname,
-            (AVL_CMP) mr_index_name_cmp )) != NULL ) {
+           (AVL_CMP) mr_index_name_cmp )) != NULL ) {
                return( mir->mir_mr );
        }
        return( NULL );
@@ -125,7 +125,7 @@ mr_add(
        int             code;
 
        smr = (MatchingRule *) ch_calloc( 1, sizeof(MatchingRule) );
-       memcpy( &smr->smr_mrule, mr, sizeof(LDAPMatchingRule));
+       AC_MEMCPY( &smr->smr_mrule, mr, sizeof(LDAPMatchingRule));
 
        smr->smr_usage = usage;
        smr->smr_convert = convert;
@@ -168,25 +168,51 @@ register_matching_rule(
        const char      *err;
 
        if( usage == SLAP_MR_NONE ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "register_matching_rule: %s not usable\n", desc ));
+#else
                Debug( LDAP_DEBUG_ANY, "register_matching_rule: not usable %s\n",
                    desc, 0, 0 );
+#endif
+
                return -1;
        }
 
        if( associated != NULL ) {
                amr = mr_find( associated );
 
-               Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate "
-                       "associated matching rule %s for %s\n",
-                       associated, desc, 0 );
+#if 0
+               /* ignore for now */
+
+               if( amr == NULL ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                                  "register_matching_rule: could not locate associated matching rule %s for %s\n",
+                                  associated, desc ));
+#else
+                       Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate "
+                               "associated matching rule %s for %s\n",
+                               associated, desc, 0 );
+#endif
+
+                       return -1;
+               }
+#endif
 
-               return -1;
        }
 
        mr = ldap_str2matchingrule( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL);
        if ( !mr ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "register_matching_rule: %s before %s in %s.\n",
+                          ldap_scherr2str(code), err, desc ));
+#else
                Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s before %s in %s\n",
                    ldap_scherr2str(code), err, desc );
+#endif
+
                return( -1 );
        }
 
@@ -197,8 +223,15 @@ register_matching_rule(
        ldap_memfree( mr );
 
        if ( code ) {
-               Debug( LDAP_DEBUG_ANY, "Error in register_syntax: %s for %s in %s\n",
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
+                          "register_matching_rule: %s for %s in %s.\n",
+                          scherr2str(code), err, desc ));
+#else
+               Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s for %s in %s\n",
                    scherr2str(code), err, desc );
+#endif
+
                return( -1 );
        }
 
@@ -220,6 +253,11 @@ int mr_schema_info( Entry *e )
        vals[1] = NULL;
 
        for ( mr = mr_list; mr; mr = mr->smr_next ) {
+               if ( ! mr->smr_match ) {
+                       /* skip rules without matching functions */
+                       continue;
+               }
+
                val.bv_val = ldap_matchingrule2str( &mr->smr_mrule );
 
                if ( val.bv_val == NULL ) {