#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 ));
#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
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" );
}
}