]> git.sur5r.net Git - openldap/commitdiff
Let at_find find the AttributeType that matches a given AttributeDescription.
authorJulio Sánchez Fernández <jsanchez@openldap.org>
Fri, 17 Sep 1999 15:48:23 +0000 (15:48 +0000)
committerJulio Sánchez Fernández <jsanchez@openldap.org>
Fri, 17 Sep 1999 15:48:23 +0000 (15:48 +0000)
Useful to deal with things like userCertificate;binary.

servers/slapd/attr.c

index 8a5f5358cb2f8d263937370fe0bdf455da94dbef..de6453b353a4b15505c20efd56921978656369a5 100644 (file)
@@ -386,11 +386,27 @@ at_find(
 )
 {
        struct aindexrec        *air = NULL;
+       char                    *p, *tmpname = NULL;
 
-       if ( (air = (struct aindexrec *) avl_find( attr_index, name,
+       /*
+        * The name may actually be an AttributeDescription, i.e. it may
+        * contain options.  Let's deal with it.
+        */
+       p = strchr( name, ';' );
+       if ( p ) {
+               tmpname = ch_malloc( p-name+1 );
+               strncpy( tmpname, name, p-name );
+               tmpname[p-name] = '\0';
+       } else
+               tmpname = (char *)name;
+       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 );
        }
+       if ( tmpname != name )
+               ldap_memfree( tmpname );
        return( NULL );
 }