mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-12 07:13:41 -05:00
Add ldap_*2name() in <include,libldap>/schema, use them in slapd/schema
This commit is contained in:
parent
e5e91d94aa
commit
6147119dc8
3 changed files with 58 additions and 13 deletions
|
|
@ -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 ));
|
||||
|
|
|
|||
|
|
@ -20,6 +20,38 @@
|
|||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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" );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue