}
if ( hasSubordinates == LDAP_COMPARE_TRUE ) {
- hs.bv_val = "TRUE";
- hs.bv_len = sizeof( "TRUE" ) - 1;
+ hs = slap_true_bv;
} else if ( hasSubordinates == LDAP_COMPARE_FALSE ) {
- hs.bv_val = "FALSE";
- hs.bv_len = sizeof( "FALSE" ) - 1;
+ hs = slap_false_bv;
} else {
return LDAP_OTHER;
const struct berval slap_empty_bv = BER_BVC("");
const struct berval slap_unknown_bv = BER_BVC("unknown");
+/* normalized boolean values */
+const struct berval slap_true_bv = BER_BVC("TRUE");
+const struct berval slap_false_bv = BER_BVC("FALSE");
+
slap_operational_hasSubordinate( int hs )
{
Attribute *a;
- char *val;
- ber_len_t len;
+ struct berval val;
if ( hs ) {
- val = "TRUE";
- len = sizeof( "TRUE" ) - 1;
+ val = slap_true_bv;
} else {
- val = "FALSE";
- len = sizeof( "FALSE" ) - 1;
-
+ val = slap_false_bv;
}
a = ch_malloc( sizeof( Attribute ) );
a->a_desc = slap_schema.si_ad_hasSubordinates;
a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
- ber_str2bv( val, len, 1, a->a_vals );
+ ber_dupbv( &a->a_vals[0], &val );
a->a_vals[1].bv_val = NULL;
a->a_nvals = a->a_vals;
LDAP_SLAPD_V( const struct berval ) slap_empty_bv;
LDAP_SLAPD_V( const struct berval ) slap_unknown_bv;
+LDAP_SLAPD_V( const struct berval ) slap_true_bv;
+LDAP_SLAPD_V( const struct berval ) slap_false_bv;
/*
* index.c
*/
if( in->bv_len == 4 ) {
- if( !memcmp( in->bv_val, "TRUE", 4 ) ) {
+ if( bvmatch( in, &slap_true_bv ) ) {
return LDAP_SUCCESS;
}
} else if( in->bv_len == 5 ) {
- if( !memcmp( in->bv_val, "FALSE", 5 ) ) {
+ if( bvmatch( in, &slap_false_bv ) ) {
return LDAP_SUCCESS;
}
}