Added slapi_entry_attr_get_charptr() API

This commit is contained in:
Luke Howard 2003-01-22 09:35:48 +00:00
parent 2107a4c1b3
commit 921d62c2ae
2 changed files with 30 additions and 0 deletions

View file

@ -285,6 +285,35 @@ slapi_entry_attr_find(
#endif /* !defined(LDAP_SLAPI) */
}
char *
slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type )
{
#ifdef LDAP_SLAPI
AttributeDescription *ad = NULL;
const char *text;
int rc;
Attribute *attr;
rc = slap_str2ad( type, &ad, &text );
if ( rc != LDAP_SUCCESS ) {
return NULL;
}
attr = attr_find( e->e_attrs, ad );
if ( attr == NULL ) {
return NULL;
}
if ( attr->a_vals != NULL && attr->a_vals[0].bv_val != NULL ) {
return slapi_ch_strdup( attr->a_vals[0].bv_val );
}
return NULL;
#else
return -1;
#endif
}
/*
* FIXME -- The caller must free the allocated memory.
* In Netscape they do not have to.

View file

@ -47,6 +47,7 @@ Slapi_Entry *slapi_str2entry( char *s, int flags );
char *slapi_entry2str( Slapi_Entry *e, int *len );
int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals );
int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr );
char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type );
int slapi_entry_attr_delete( Slapi_Entry *e, char *type );
char *slapi_entry_get_dn( Slapi_Entry *e );
int slapi_x_entry_get_id( Slapi_Entry *e );