]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/oc.c
declare oc_bvfind_undef()
[openldap] / servers / slapd / oc.c
index b31defeaef19610d784a8d705591721c062bae33..651041f93486f8ca10dad35905cf2bb151373e85 100644 (file)
@@ -23,7 +23,6 @@
 #include <ac/socket.h>
 
 #include "slap.h"
-#include "ldap_pvt.h"
 
 int is_object_subclass(
        ObjectClass *sup,
@@ -171,6 +170,47 @@ oc_bvfind( struct berval *ocname )
        return( NULL );
 }
 
+static LDAP_SLIST_HEAD(OCUList, slap_object_class) oc_undef_list
+       = LDAP_SLIST_HEAD_INITIALIZER(&oc_undef_list);
+
+ObjectClass *
+oc_bvfind_undef( struct berval *ocname )
+{
+       ObjectClass     *oc = oc_bvfind( ocname );
+
+       if ( oc ) {
+               return oc;
+       }
+
+       LDAP_SLIST_FOREACH( oc, &oc_undef_list, soc_next ) {
+               int     d = oc->soc_cname.bv_len - ocname->bv_len;
+
+               if ( d ) {
+                       continue;
+               }
+
+               if ( strcasecmp( oc->soc_cname.bv_val, ocname->bv_val ) == 0 ) {
+                       break;
+               }
+       }
+       
+       if ( oc ) {
+               return oc;
+       }
+       
+       oc = ch_malloc( sizeof( ObjectClass ) + ocname->bv_len + 1 );
+       memset( oc, 0, sizeof( ObjectClass ) );
+
+       oc->soc_cname.bv_len = ocname->bv_len;
+       oc->soc_cname.bv_val = (char *)&oc[ 1 ];
+       AC_MEMCPY( oc->soc_cname.bv_val, ocname->bv_val, ocname->bv_len );
+
+       LDAP_SLIST_NEXT( oc, soc_next ) = NULL;
+       LDAP_SLIST_INSERT_HEAD( &oc_undef_list, oc, soc_next );
+
+       return oc;
+}
+
 static int
 oc_create_required(
     ObjectClass                *soc,
@@ -338,6 +378,13 @@ oc_destroy( void )
                if (o->soc_allowed) ldap_memfree(o->soc_allowed);
                ldap_objectclass_free((LDAPObjectClass *)o);
        }
+       
+       while( !LDAP_SLIST_EMPTY(&oc_undef_list) ) {
+               o = LDAP_SLIST_FIRST(&oc_undef_list);
+               LDAP_SLIST_REMOVE_HEAD(&oc_undef_list, soc_next);
+
+               ch_free( (ObjectClass *)o );
+       }
 }
 
 static int