]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/at.c
Extend value_match to extract an asserted value from a full value
[openldap] / servers / slapd / at.c
index 4ad381d9ffaef74806cf4de54a145fc21b2eea28..5c3cad15c5667774beca4a5a53645227f2d5bb0a 100644 (file)
@@ -74,23 +74,12 @@ at_find(
     const char         *name
 )
 {
-       struct aindexrec        *air;
-       char                    *tmpname;
-
-       {
-               tmpname = (char *)name;
-       }
+       struct aindexrec *air;
 
-       if ( (air = (struct aindexrec *) avl_find( attr_index, tmpname,
-            (AVL_CMP) attr_index_name_cmp )) != NULL ) {
-               if ( tmpname != name )
-                       ldap_memfree( tmpname );
-               return( air->air_at );
-       }
+       air = (struct aindexrec *) avl_find( attr_index, name,
+            (AVL_CMP) attr_index_name_cmp );
 
-       if ( tmpname != name )
-               ldap_memfree( tmpname );
-       return( NULL );
+       return air != NULL ? air->air_at : NULL;
 }
 
 int
@@ -106,7 +95,7 @@ at_append_to_list(
        list = *listp;
        if ( !list ) {
                size = 2;
-               list = calloc(size, sizeof(AttributeType *));
+               list = ch_calloc(size, sizeof(AttributeType *));
                if ( !list ) {
                        return -1;
                }
@@ -118,7 +107,7 @@ at_append_to_list(
                        list1++;
                }
                size += 2;
-               list1 = realloc(list, size*sizeof(AttributeType *));
+               list1 = ch_realloc(list, size*sizeof(AttributeType *));
                if ( !list1 ) {
                        return -1;
                }
@@ -155,7 +144,7 @@ at_delete_from_list(
        }
        list[i] = NULL;
        /* Tell the runtime this can be shrinked */
-       list1 = realloc(list, (i+1)*sizeof(AttributeType **));
+       list1 = ch_realloc(list, (i+1)*sizeof(AttributeType **));
        if ( !list1 ) {
                return -1;
        }
@@ -239,7 +228,7 @@ at_insert(
 
 int
 at_add(
-    LDAP_ATTRIBUTE_TYPE        *at,
+    LDAPAttributeType  *at,
     const char         **err
 )
 {
@@ -250,15 +239,28 @@ at_add(
        char                    *cname;
 
        if ( at->at_names && at->at_names[0] ) {
+               int i;
+
+               for( i=0; at->at_names[i]; i++ ) {
+                       if( !slap_valid_descr( at->at_names[i] ) ) {
+                               return SLAP_SCHERR_BAD_DESCR;
+                       }
+               }
+
                cname = at->at_names[0];
+
        } else if ( at->at_oid ) {
                cname = at->at_oid;
        } else {
-               cname = "";
                return SLAP_SCHERR_ATTR_INCOMPLETE;
        }
+
+       if ( at->at_collective ) {
+               return SLAP_SCHERR_NOT_SUPPORTED;
+       }
+
        sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
-       memcpy( &sat->sat_atype, at, sizeof(LDAP_ATTRIBUTE_TYPE));
+       AC_MEMCPY( &sat->sat_atype, at, sizeof(LDAPAttributeType));
 
        sat->sat_cname = cname;
 
@@ -286,6 +288,7 @@ at_add(
        if ( sat->sat_sup ) {
                sat->sat_syntax = sat->sat_sup->sat_syntax;
                sat->sat_equality = sat->sat_sup->sat_equality;
+               sat->sat_approx = sat->sat_sup->sat_approx;
                sat->sat_ordering = sat->sat_sup->sat_ordering;
                sat->sat_substr = sat->sat_sup->sat_substr;
        }
@@ -306,6 +309,7 @@ at_add(
        if ( sat->sat_equality_oid ) {
                if ( (mr = mr_find(sat->sat_equality_oid)) ) {
                        sat->sat_equality = mr;
+                       sat->sat_approx = mr->smr_associated;
                } else {
                        *err = sat->sat_equality_oid;
                        return SLAP_SCHERR_MR_NOT_FOUND;