From eebc51b9bf75d0ea89ea433ffcdd2aa59f4c43d5 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 29 Apr 2003 18:13:10 +0000 Subject: [PATCH] remove dnPretty rename dnPretty2 to dnPretty --- servers/slapd/back-ldap/suffixmassage.c | 2 +- servers/slapd/back-meta/cache-remove.c | 2 +- servers/slapd/back-monitor/init.c | 2 +- servers/slapd/dn.c | 25 --- servers/slapd/filter.c | 222 ++---------------------- servers/slapd/proto-slap.h | 7 +- servers/slapd/referral.c | 6 +- servers/slapd/schema_init.c | 2 +- servers/slapd/slapi/slapi_utils.c | 2 +- 9 files changed, 27 insertions(+), 243 deletions(-) diff --git a/servers/slapd/back-ldap/suffixmassage.c b/servers/slapd/back-ldap/suffixmassage.c index be739828e8..b6a02e6777 100644 --- a/servers/slapd/back-ldap/suffixmassage.c +++ b/servers/slapd/back-ldap/suffixmassage.c @@ -122,7 +122,7 @@ ldap_back_dn_massage( /* DN from remote server may be in arbitrary form. * Pretty it so we can parse reliably. */ - dnPretty2( NULL, dn, &pretty, NULL ); + dnPretty( NULL, dn, &pretty, NULL ); if (pretty.bv_val) dn = &pretty; } diff --git a/servers/slapd/back-meta/cache-remove.c b/servers/slapd/back-meta/cache-remove.c index 25c97dc563..06d448166a 100644 --- a/servers/slapd/back-meta/cache-remove.c +++ b/servers/slapd/back-meta/cache-remove.c @@ -134,7 +134,7 @@ remove_func ( } if (count == 1) { #if 0 /* ??? pdn is not used anywhere */ - dnPretty2(NULL, &entry->e_nname, &pdn); + dnPretty(NULL, &entry->e_nname, &pdn); #endif info->freed += size; #ifdef NEW_LOGGING diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 8e9b3933e3..cd4d7811fe 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -603,7 +603,7 @@ monitor_back_db_open( dn.bv_val = ch_calloc( sizeof( char ), dn.bv_len + 1 ); strcpy( dn.bv_val, "cn=" ); strcat( dn.bv_val, monitor_subsys[ i ].mss_name ); - rc = dnPretty2( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL ); + rc = dnPretty( NULL, &dn, &monitor_subsys[ i ].mss_rdn, NULL ); free( dn.bv_val ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index b02680096c..3930ea666b 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -398,33 +398,8 @@ dnNormalize( return LDAP_SUCCESS; } -#if 0 -/* - * dn "pretty"ing routine - */ int dnPretty( - Syntax *syntax, - struct berval *val, - struct berval **pretty) -{ - struct berval *out; - int rc; - - assert( pretty && *pretty == NULL ); - - out = ch_malloc( sizeof( struct berval ) ); - rc = dnPretty2( syntax, val, out ); - if ( rc != LDAP_SUCCESS ) - free( out ); - else - *pretty = out; - return rc; -} -#endif - -int -dnPretty2( Syntax *syntax, struct berval *val, struct berval *out, diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 38f99a7f61..af5051c283 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -252,20 +252,22 @@ get_filter( assert( f.f_not != NULL ); if ( f.f_not->f_choice == SLAPD_FILTER_COMPUTED ) { - if ( f.f_not->f_result == LDAP_COMPARE_TRUE ) { - op->o_tmpfree( f.f_not, op->o_tmpmemctx ); - f.f_not = NULL; - f.f_choice = SLAPD_FILTER_COMPUTED; + f.f_choice = SLAPD_FILTER_COMPUTED; + f.f_result = f.f_not->f_result; + op->o_tmpfree( f.f_not, op->o_tmpmemctx ); + f.f_not = NULL; + + switch( f.f_result ) { + case LDAP_COMPARE_TRUE: f.f_result = LDAP_COMPARE_FALSE; - } else if ( f.f_not->f_result == LDAP_COMPARE_FALSE ) { - op->o_tmpfree( f.f_not, op->o_tmpmemctx ); - f.f_not = NULL; - f.f_choice = SLAPD_FILTER_COMPUTED; + break; + case LDAP_COMPARE_FALSE: f.f_result = LDAP_COMPARE_TRUE; + break; + default: + /* (!Undefined) is Undefined */ } - /* Leave UNDEFINED alone */ } - break; case LDAP_FILTER_EXT: @@ -836,7 +838,8 @@ filter2bv_x( Operation *op, Filter *f, struct berval *fstr ) break; default: - ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr, op->o_tmpmemctx ); + ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, + 1, fstr, op->o_tmpmemctx ); break; } } @@ -1207,7 +1210,8 @@ vrFilter2bv( Operation *op, ValuesReturnFilter *vrf, struct berval *fstr ) ber_len_t len; if ( vrf == NULL ) { - ber_str2bv_x( "No filter!", sizeof("No filter!")-1, 1, fstr, op->o_tmpmemctx ); + ber_str2bv_x( "No filter!", sizeof("No filter!")-1, + 1, fstr, op->o_tmpmemctx ); return; } @@ -1404,198 +1408,8 @@ simple_vrFilter2bv( Operation *op, ValuesReturnFilter *vrf, struct berval *fstr break; default: - ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, 1, fstr, op->o_tmpmemctx ); + ber_str2bv_x( "(?=unknown)", sizeof("(?=unknown)")-1, + 1, fstr, op->o_tmpmemctx ); break; } } - -#if 0 /* unused */ -static int -get_substring_vrFilter( - Operation *op, - BerElement *ber, - ValuesReturnFilter *vrf, - const char **text ) -{ - ber_tag_t tag; - ber_len_t len; - ber_tag_t rc; - struct berval value; - char *last; - struct berval bv; - *text = "error decoding filter"; - -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, ENTRY, - "get_substring_filter: conn %d begin\n", op->o_connid, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); -#endif - if ( ber_scanf( ber, "{m" /*}*/, &bv ) == LBER_ERROR ) { - return SLAPD_DISCONNECT; - } - - vrf->vrf_sub = ch_calloc( 1, sizeof(SubstringsAssertion) ); - vrf->vrf_sub_desc = NULL; - rc = slap_bv2ad( &bv, &vrf->vrf_sub_desc, text ); - - if( rc != LDAP_SUCCESS ) { - text = NULL; - ch_free( vrf->vrf_sub ); - vrf->vrf_choice = SLAPD_FILTER_COMPUTED; - vrf->vrf_result = SLAPD_COMPARE_UNDEFINED; - return LDAP_SUCCESS; - } - - vrf->vrf_sub_initial.bv_val = NULL; - vrf->vrf_sub_any = NULL; - vrf->vrf_sub_final.bv_val = NULL; - - for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; - tag = ber_next_element( ber, &len, last ) ) - { - unsigned usage; - - rc = ber_scanf( ber, "m", &value ); - if ( rc == LBER_ERROR ) { - rc = SLAPD_DISCONNECT; - goto return_error; - } - - if ( value.bv_val == NULL || value.bv_len == 0 ) { - rc = LDAP_INVALID_SYNTAX; - goto return_error; - } - - switch ( tag ) { - case LDAP_SUBSTRING_INITIAL: - usage = SLAP_MR_SUBSTR_INITIAL; - break; - - case LDAP_SUBSTRING_ANY: - usage = SLAP_MR_SUBSTR_ANY; - break; - - case LDAP_SUBSTRING_FINAL: - usage = SLAP_MR_SUBSTR_FINAL; - break; - - default: - rc = LDAP_PROTOCOL_ERROR; - -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, ERR, - "get_filter_substring: conn %d unknown substring choice=%ld\n", - op->o_connid, (long)tag, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, - " unknown substring choice=%ld\n", - (long) tag, 0, 0 ); -#endif - goto return_error; - } - - /* validate/normalize using equality matching rule validator! */ - rc = asserted_value_validate_normalize( - vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_equality, - usage, &value, &bv, text ); - if( rc != LDAP_SUCCESS ) { - goto return_error; - } - - value = bv; - - rc = LDAP_PROTOCOL_ERROR; - - switch ( tag ) { - case LDAP_SUBSTRING_INITIAL: -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, DETAIL1, - "get_substring_filter: conn %d INITIAL\n", - op->o_connid, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); -#endif - - if ( vrf->vrf_sub_initial.bv_val != NULL - || vrf->vrf_sub_any != NULL - || vrf->vrf_sub_final.bv_val != NULL ) - { - free( value.bv_val ); - goto return_error; - } - - vrf->vrf_sub_initial = value; - break; - - case LDAP_SUBSTRING_ANY: -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, DETAIL1, - "get_substring_filter: conn %d ANY\n", op->o_connid, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); -#endif - - if ( vrf->vrf_sub_final.bv_val != NULL ) { - free( value.bv_val ); - goto return_error; - } - - ber_bvarray_add( &vrf->vrf_sub_any, &value ); - break; - - case LDAP_SUBSTRING_FINAL: -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, DETAIL1, - "get_substring_filter: conn %d FINAL\n", op->o_connid, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); -#endif - - if ( vrf->vrf_sub_final.bv_val != NULL ) { - free( value.bv_val ); - goto return_error; - } - - vrf->vrf_sub_final = value; - break; - - default: -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, INFO, - "get_substring_filter: conn %d unknown substring type %ld\n", - op->o_connid, (long)tag, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, - " unknown substring type=%ld\n", - (long) tag, 0, 0 ); -#endif - - free( value.bv_val ); - -return_error: -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, INFO, - "get_substring_filter: conn %d error %ld\n", - op->o_connid, (long)rc, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, " error=%ld\n", - (long) rc, 0, 0 ); -#endif - free( vrf->vrf_sub_initial.bv_val ); - ber_bvarray_free( vrf->vrf_sub_any ); - free( vrf->vrf_sub_final.bv_val ); - ch_free( vrf->vrf_sub ); - return rc; - } - } - -#ifdef NEW_LOGGING - LDAP_LOG( FILTER, ENTRY, - "get_substring_filter: conn %d exit\n", op->o_connid, 0, 0 ); -#else - Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); -#endif - return( LDAP_SUCCESS ); -} -#endif /* unused */ diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 621c936ec9..9aeccbfc39 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -376,12 +376,7 @@ LDAP_SLAPD_F (int) dnValidate LDAP_P(( LDAP_SLAPD_F (slap_mr_normalize_func) dnNormalize; #define dnNormalize2(s,v,n,x) dnNormalize(0,(s),NULL,(v),(n),(x)) -LDAP_SLAPD_F (int) dnPretty LDAP_P(( - Syntax *syntax, - struct berval *val, - struct berval **pretty )); - -LDAP_SLAPD_F (slap_syntax_transform_func) dnPretty2; +LDAP_SLAPD_F (slap_syntax_transform_func) dnPretty; LDAP_SLAPD_F (int) dnPrettyNormal LDAP_P(( Syntax *syntax, diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 503e1f4558..85fd39b426 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -44,7 +44,7 @@ static char * referral_dn_muck( bvin.bv_val = (char *)refDN; bvin.bv_len = strlen( refDN ); - rc = dnPretty2( NULL, &bvin, &nrefDN, NULL ); + rc = dnPretty( NULL, &bvin, &nrefDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid refDN */ return NULL; @@ -59,7 +59,7 @@ static char * referral_dn_muck( return nrefDN.bv_len ? nrefDN.bv_val : ch_strdup( baseDN->bv_val ); } - rc = dnPretty2( NULL, targetDN, &ntargetDN, NULL ); + rc = dnPretty( NULL, targetDN, &ntargetDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid targetDN */ ch_free( nrefDN.bv_val ); @@ -67,7 +67,7 @@ static char * referral_dn_muck( } if( nrefDN.bv_len ) { - rc = dnPretty2( NULL, baseDN, &nbaseDN, NULL ); + rc = dnPretty( NULL, baseDN, &nbaseDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid baseDN */ ch_free( nrefDN.bv_val ); diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index e77c883f60..f75c3b6f75 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -2601,7 +2601,7 @@ static slap_syntax_defs_rec syntax_defs[] = { {"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )", 0, countryStringValidate, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )", - 0, dnValidate, dnPretty2}, + 0, dnValidate, dnPretty}, {"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )", 0, NULL, NULL}, {"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )", diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index aae1b24e8a..156e585b61 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -857,7 +857,7 @@ slapi_dn_normalize( char *dn ) bdn.bv_val = dn; bdn.bv_len = strlen( dn ); - if ( dnPretty2( NULL, &bdn, &pdn, NULL ) != LDAP_SUCCESS ) { + if ( dnPretty( NULL, &bdn, &pdn, NULL ) != LDAP_SUCCESS ) { return NULL; } -- 2.39.5