]> git.sur5r.net Git - openldap/commitdiff
use global bervals for TRUE/FALSE
authorPierangelo Masarati <ando@openldap.org>
Wed, 16 Apr 2003 19:49:00 +0000 (19:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 16 Apr 2003 19:49:00 +0000 (19:49 +0000)
servers/slapd/filterentry.c
servers/slapd/globals.c
servers/slapd/operational.c
servers/slapd/proto-slap.h
servers/slapd/schema_init.c

index 386ea48a15c8155f768beead60fa3606237dd545..49927c407a717c80c39dd614978493727369a645 100644 (file)
@@ -467,12 +467,10 @@ test_ava_filter(
                }
 
                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;
index 7c3442ec0148cb6033c76c50c8692a6e3abd191a..6176244710e32527874e8b39d4f7c21431655533 100644 (file)
@@ -22,3 +22,7 @@
 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");
+
index bc842049ed0844b09664bbc242eda1f67bae072d..d03d4f3e16dedb1a7d85e3378c6df41be6f783c0 100644 (file)
@@ -43,24 +43,20 @@ Attribute *
 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;
index ce50890671002a66fed63e3d2642e5f1f76efc0b..fb4cceb8057266ca39aac7302e4d27329d67105f 100644 (file)
@@ -510,6 +510,8 @@ LDAP_SLAPD_F (int) test_filter LDAP_P(( Operation *op, Entry *e, Filter *f ));
 
 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
index e023f39dc2353f5f1ce2eb9ccfc952b0c671df44..dcb0ec32c81ae2163c92f4d6f5d4dbc98c02980e 100644 (file)
@@ -822,11 +822,11 @@ booleanValidate(
         */
 
        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;
                }
        }