From: Luke Howard Date: Tue, 21 Jan 2003 10:12:08 +0000 (+0000) Subject: Added slapi_attr_get_flags() and slapi_attr_flag_is_set() API for X-Git-Tag: NO_SLAP_OP_BLOCKS~567 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f1fdb34fbe0592fdbbe173542acd21a1e5d80a38;p=openldap Added slapi_attr_get_flags() and slapi_attr_flag_is_set() API for Sun ONE harmonisation. --- diff --git a/servers/slapd/slapi/slapi.h b/servers/slapd/slapi/slapi.h index 7feb0c4585..b0d23fd55f 100644 --- a/servers/slapd/slapi/slapi.h +++ b/servers/slapd/slapi/slapi.h @@ -36,6 +36,17 @@ LDAP_END_DECL LDAP_BEGIN_DECL +/* + * Attribute flags returned by slapi_attr_get_flags() + */ +#define SLAPI_ATTR_FLAG_SINGLE 0x0001 +#define SLAPI_ATTR_FLAG_OPATTR 0x0002 +#define SLAPI_ATTR_FLAG_READONLY 0x0004 +#define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY +#define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 +#define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 +#define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 + /* * Plugin types universally supported by SLAPI * implementations diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 348afa39de..ca2361d694 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1329,3 +1329,45 @@ int slapi_is_connection_ssl( Slapi_PBlock *pb, int *isSSL ) return -1; #endif /* defined(LDAP_SLAPI) */ } + +int slapi_attr_get_flags( Slapi_Attr *attr, unsigned long *flags ) +{ +#if defined( LDAP_SLAPI ) + AttributeType *at; + + if ( attr == NULL ) + return LDAP_PARAM_ERROR; + + at = attr->a_desc->ad_type; + + *flags = SLAPI_ATTR_FLAG_STD_ATTR; + + if ( is_at_single_value( at ) ) + *flags |= SLAPI_ATTR_FLAG_SINGLE; + if ( is_at_operational( at ) ) + *flags |= SLAPI_ATTR_FLAG_OPATTR; + if ( is_at_obsolete( at ) ) + *flags |= SLAPI_ATTR_FLAG_OBSOLETE; + if ( is_at_collective( at ) ) + *flags |= SLAPI_ATTR_FLAG_COLLECTIVE; + if ( is_at_no_user_mod( at ) ) + *flags |= SLAPI_ATTR_FLAG_NOUSERMOD; + + return LDAP_SUCCESS; +#else + return -1; +#endif /* defined(LDAP_SLAPI) */ +} + +int slapi_attr_flag_is_set( Slapi_Attr *attr, unsigned long flag ) +{ +#if defined( LDAP_SLAPI ) + unsigned long flags; + + if ( slapi_attr_get_flags( attr, &flags ) != 0 ) + return 0; + return (flags & flag) ? 1 : 0; +#else + return 0; +#endif /* defined(LDAP_SLAPI) */ +} diff --git a/servers/slapd/slapi/slapi_utils.h b/servers/slapd/slapi/slapi_utils.h index 6adcd18845..a14a301ae3 100644 --- a/servers/slapd/slapi/slapi_utils.h +++ b/servers/slapd/slapi/slapi_utils.h @@ -54,6 +54,8 @@ Slapi_Entry *slapi_entry_dup( Slapi_Entry *e ); Slapi_Entry *slapi_entry_alloc(); void slapi_entry_free( Slapi_Entry *e ); int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ); +int slapi_attr_get_flags( Slapi_Attr *attr, unsigned long *flags ); +int slapi_attr_flag_is_set( Slapi_Attr *attr, unsigned long flag ); char *slapi_ch_malloc( unsigned long size ); void slapi_ch_free( void **ptr ); char *slapi_ch_calloc( unsigned long nelem, unsigned long size );