]> git.sur5r.net Git - openldap/commitdiff
Add ldap_*2name() in <include,libldap>/schema, use them in slapd/schema
authorHallvard Furuseth <hallvard@openldap.org>
Mon, 16 Aug 1999 02:59:11 +0000 (02:59 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 16 Aug 1999 02:59:11 +0000 (02:59 +0000)
include/ldap_schema.h
libraries/libldap/schema.c
servers/slapd/schema.c

index f1f9dae8317e08f59e7891cf644c02ac0ba2d3ab..64de1b08d6bcf2d0c87fed26a1288038df01b8b2 100644 (file)
@@ -86,6 +86,22 @@ typedef struct ldap_objectclass {
 #define LDAP_SCHEMA_STRUCTURAL                 1
 #define LDAP_SCHEMA_AUXILIARY                  2
 
+LDAP_F( LDAP_CONST char * )
+ldap_syntax2name LDAP_P((
+       LDAP_SYNTAX * syn ));
+
+LDAP_F( LDAP_CONST char * )
+ldap_matchingrule2name LDAP_P((
+       LDAP_MATCHING_RULE * mr ));
+
+LDAP_F( LDAP_CONST char * )
+ldap_attributetype2name LDAP_P((
+       LDAP_ATTRIBUTE_TYPE * at ));
+
+LDAP_F( LDAP_CONST char * )
+ldap_objectclass2name LDAP_P((
+       LDAP_OBJECT_CLASS * oc ));
+
 LDAP_F( void )
 ldap_syntax_free LDAP_P((
        LDAP_SYNTAX * syn ));
index e3ae6318f04076cc712190719b31c55ade5b9e61..33f8f2674a20f9e6a3f76e8a7d3a3aa39c9236e7 100644 (file)
 
 #include <ldap_schema.h>
 
+
+static LDAP_CONST char *
+choose_name( char *names[], LDAP_CONST char *fallback )
+{
+       return( (names != NULL && names[0] != NULL) ? names[0] : fallback );
+}
+
+LDAP_CONST char *
+ldap_syntax2name( LDAP_SYNTAX * syn )
+{
+       return( syn->syn_oid );
+}
+
+LDAP_CONST char *
+ldap_matchingrule2name( LDAP_MATCHING_RULE * mr )
+{
+       return( choose_name( mr->mr_names, mr->mr_oid ) );
+}
+
+LDAP_CONST char *
+ldap_attributetype2name( LDAP_ATTRIBUTE_TYPE * at )
+{
+       return( choose_name( at->at_names, at->at_oid ) );
+}
+
+LDAP_CONST char *
+ldap_objectclass2name( LDAP_OBJECT_CLASS * oc )
+{
+       return( choose_name( oc->oc_names, oc->oc_oid ) );
+}
+
+
 /*
  * When pretty printing the entities we will be appending to a buffer.
  * Since checking for overflow, realloc'ing and checking if no error
index 6abcacac99efcf263f0f04969dbbf18663b35881..ad022a60bbfa062a185d49523edc49e0a59850a2 100644 (file)
@@ -1190,24 +1190,21 @@ static void
 oc_print( ObjectClass *oc )
 {
        int     i;
+       const char *mid;
 
-       if ( oc->soc_names && oc->soc_names[0] ) {
-               printf( "objectclass %s\n", oc->soc_names[0] );
-       } else {
-               printf( "objectclass %s\n", oc->soc_oid );
-       }
+       printf( "objectclass %s\n", ldap_objectclass2name( &oc->soc_oclass ) );
        if ( oc->soc_required != NULL ) {
-               printf( "\trequires %s", oc->soc_required[0] );
-               for ( i = 1; oc->soc_required[i] != NULL; i++ ) {
-                       printf( ",%s", oc->soc_required[i] );
-               }
+               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 ) {
-               printf( "\tallows %s", oc->soc_allowed[0] );
-               for ( i = 1; oc->soc_allowed[i] != NULL; i++ ) {
-                       printf( ",%s", oc->soc_allowed[i] );
-               }
+               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" );
        }
 }