/* oc.c - object class routines */
/* $OpenLDAP$ */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "ldap_pvt.h"
int is_object_subclass(
- ObjectClass *sub,
- ObjectClass *sup )
+ ObjectClass *sup,
+ ObjectClass *sub )
{
int i;
if( sub == NULL || sup == NULL ) return 0;
-#if 0
+#if 1
Debug( LDAP_DEBUG_TRACE, "is_object_subclass(%s,%s) %d\n",
- sub->soc_oid, sup->soc_oid, sup == sub );
+ sup->soc_oid, sub->soc_oid, sup == sub );
#endif
if( sup == sub ) {
return 1;
}
- if( sup->soc_sups == NULL ) {
+ if( sub->soc_sups == NULL ) {
return 0;
}
- for( i=0; sup->soc_sups[i] != NULL; i++ ) {
- if( is_object_subclass( sub, sup->soc_sups[i] ) ) {
+ for( i=0; sub->soc_sups[i] != NULL; i++ ) {
+ if( is_object_subclass( sup, sub->soc_sups[i] ) ) {
return 1;
}
}
int is_entry_objectclass(
Entry* e,
- ObjectClass *oc )
+ ObjectClass *oc,
+ int set_flags )
{
Attribute *attr;
struct berval *bv;
return 0;
}
+ if( set_flags && ( e->e_ocflags & SLAP_OC__END )) {
+ return (e->e_ocflags & oc->soc_flags);
+ }
+
/*
* find objectClass attribute
*/
for( bv=attr->a_vals; bv->bv_val; bv++ ) {
ObjectClass *objectClass = oc_bvfind( bv );
- if( objectClass == oc ) {
+ if ( objectClass == oc && !set_flags ) {
return 1;
}
+
+ if ( objectClass != NULL ) {
+ e->e_ocflags |= objectClass->soc_flags;
+ }
}
+ e->e_ocflags |= SLAP_OC__END; /* We've finished this */
- return 0;
-
+ return (e->e_ocflags & oc->soc_flags);
}
}
}
+ if ( !OID_LEADCHAR( oc->oc_oid[0] )) {
+ /* Expand OID macros */
+ char *oid = oidm_find( oc->oc_oid );
+ if ( !oid ) {
+ *err = oc->oc_oid;
+ return SLAP_SCHERR_OIDM;
+ }
+ if ( oid != oc->oc_oid ) {
+ ldap_memfree( oc->oc_oid );
+ oc->oc_oid = oid;
+ }
+ }
+
soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) );
AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) );