]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/oc.c
Remove lint
[openldap] / servers / slapd / oc.c
index ca7a0d45aa2cb8a7e3c913296ee9b07be807c608..3301a702bb9567b6d39104ff3e789793b3a49b83 100644 (file)
@@ -25,8 +25,14 @@ int is_object_subclass(
        if( sub == NULL || sup == NULL ) return 0;
 
 #if 1
+#ifdef NEW_LOGGING
+       LDAP_LOG ( OPERATION, ARGS, 
+               "is_object_subclass(%s,%s) %d\n",
+               sup->soc_oid, sub->soc_oid, sup == sub );
+#else
        Debug( LDAP_DEBUG_TRACE, "is_object_subclass(%s,%s) %d\n",
                sup->soc_oid, sub->soc_oid, sup == sub );
+#endif
 #endif
 
        if( sup == sub ) {
@@ -72,10 +78,10 @@ int is_entry_objectclass(
        if( attr == NULL ) {
                /* no objectClass attribute */
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "operation", LDAP_LEVEL_ERR, "is_entry_objectclass: "
-                       "dn(%s), oid (%s), no objectClass attribute.\n",
-                       e->e_dn == NULL ? "" : e->e_dn,
-                       oc->soc_oclass.oc_oid ));
+               LDAP_LOG( OPERATION, ERR, 
+                       "is_entry_objectclass: dn(%s), oid (%s), no objectClass "
+                       "attribute.\n", e->e_dn == NULL ? "" : e->e_dn,
+                       oc->soc_oclass.oc_oid, 0 );
 #else
                Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") "
                        "no objectClass attribute\n",
@@ -280,7 +286,7 @@ oc_add_sups(
                                && soc1->soc_kind != LDAP_SCHEMA_ABSTRACT )
                        {
                                *err = *sups1;
-                               return SLAP_SCHERR_CLASS_BAD_USAGE;
+                               return SLAP_SCHERR_CLASS_BAD_SUP;
                        }
 
                        if( soc->soc_flags & SLAP_OC_OPERATIONAL ) (*op)++;
@@ -354,7 +360,7 @@ oc_insert(
                {
                        *err = soc->soc_oid;
                        ldap_memfree(oir);
-                       return SLAP_SCHERR_DUP_CLASS;
+                       return SLAP_SCHERR_CLASS_DUP;
                }
 
                /* FIX: temporal consistency check */
@@ -378,7 +384,7 @@ oc_insert(
                        {
                                *err = *names;
                                ldap_memfree(oir);
-                               return SLAP_SCHERR_DUP_CLASS;
+                               return SLAP_SCHERR_CLASS_DUP;
                        }
 
                        /* FIX: temporal consistency check */
@@ -428,6 +434,13 @@ oc_add(
        soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) );
        AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) );
 
+       if( oc->oc_names != NULL ) {
+               soc->soc_cname.bv_val = soc->soc_names[0];
+       } else {
+               soc->soc_cname.bv_val = soc->soc_oid;
+       }
+       soc->soc_cname.bv_len = strlen( soc->soc_cname.bv_val );
+
        if( soc->soc_sup_oids == NULL &&
                soc->soc_kind == LDAP_SCHEMA_STRUCTURAL )
        {
@@ -446,42 +459,12 @@ oc_add(
        code = oc_create_allowed( soc, soc->soc_at_oids_may, &op, err );
        if ( code != 0 ) return code;
 
-       if( user && op ) return SLAP_SCHERR_CLASS_OPERATIONAL;
+       if( user && op ) return SLAP_SCHERR_CLASS_BAD_SUP;
 
        code = oc_insert(soc,err);
        return code;
 }
 
-#ifdef LDAP_DEBUG
-
-static void
-oc_print( ObjectClass *oc )
-{
-       int     i;
-       const char *mid;
-
-       printf( "objectclass %s\n", ldap_objectclass2name( &oc->soc_oclass ) );
-       if ( oc->soc_required != NULL ) {
-               mid = "\trequires ";
-               for ( i = 0; oc->soc_required[i] != NULL; i++, mid = "," )
-                       printf( "%s%s", mid,
-                               ldap_attributetype2name( &oc->soc_required[i]->sat_atype ) );
-               printf( "\n" );
-       }
-       if ( oc->soc_allowed != NULL ) {
-               mid = "\tallows ";
-               for ( i = 0; oc->soc_allowed[i] != NULL; i++, mid = "," )
-                       printf( "%s%s", mid,
-                               ldap_attributetype2name( &oc->soc_allowed[i]->sat_atype ) );
-               printf( "\n" );
-       }
-}
-
-#endif
-
-
-#if defined( SLAPD_SCHEMA_DN )
-
 int
 oc_schema_info( Entry *e )
 {
@@ -493,12 +476,12 @@ oc_schema_info( Entry *e )
        vals[1].bv_val = NULL;
 
        for ( oc = oc_list; oc; oc = oc->soc_next ) {
+               if( oc->soc_flags & SLAP_OC_HIDE ) continue;
+
                if ( ldap_objectclass2bv( &oc->soc_oclass, vals ) == NULL ) {
                        return -1;
                }
 
-               if( oc->soc_flags & SLAP_OC_HIDE ) continue;
-
 #if 0
                Debug( LDAP_DEBUG_TRACE, "Merging oc [%ld] %s\n",
               (long) vals[0].bv_len, vals[0].bv_val, 0 );
@@ -508,5 +491,3 @@ oc_schema_info( Entry *e )
        }
        return 0;
 }
-
-#endif