From 756d35cb6ec9306bf3455ab1001d506044ae6591 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 8 Apr 2003 23:30:58 +0000 Subject: [PATCH] improve (and cleanup) value normalization --- servers/slapd/back-monitor/back-monitor.h | 1 - servers/slapd/back-monitor/backend.c | 22 ++----------- servers/slapd/back-monitor/database.c | 4 +-- servers/slapd/back-monitor/init.c | 7 +--- servers/slapd/back-monitor/listener.c | 40 +++-------------------- servers/slapd/back-monitor/log.c | 23 +++++++------ servers/slapd/back-monitor/rww.c | 20 ++---------- servers/slapd/back-monitor/thread.c | 4 +-- 8 files changed, 27 insertions(+), 94 deletions(-) diff --git a/servers/slapd/back-monitor/back-monitor.h b/servers/slapd/back-monitor/back-monitor.h index 3037e8655e..a16f8fb7d9 100644 --- a/servers/slapd/back-monitor/back-monitor.h +++ b/servers/slapd/back-monitor/back-monitor.h @@ -203,7 +203,6 @@ struct monitorsubsys { extern struct monitorsubsys monitor_subsys[]; extern AttributeDescription *monitor_ad_desc; -extern slap_mr_normalize_func *monitor_ad_normalize; extern BackendDB *be_monitor; /* diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index aab3ff7b26..573eaad4f0 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -76,8 +76,7 @@ monitor_subsys_backend_init( for ( i = nBackendInfo; i--; ) { char buf[1024]; BackendInfo *bi; - struct berval bv, nbv; - int rc; + struct berval bv; bi = &backendInfo[i]; @@ -110,23 +109,8 @@ monitor_subsys_backend_init( bv.bv_val = bi->bi_type; bv.bv_len = strlen( bv.bv_val ); - nbv.bv_val = NULL; - if ( monitor_ad_normalize ) { - rc = monitor_ad_normalize( - 0, - monitor_ad_desc->ad_type->sat_syntax, - monitor_ad_desc->ad_type->sat_equality, - &bv, &nbv ); - if ( rc ) { - return( -1 ); - } - } - - attr_merge_one( e, monitor_ad_desc, &bv, - nbv.bv_val ? &nbv : NULL ); - attr_merge_one( e_backend, monitor_ad_desc, &bv, - nbv.bv_val ? &nbv : NULL ); - ch_free( nbv.bv_val ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); + attr_merge_normalize_one( e_backend, monitor_ad_desc, &bv ); if ( bi->bi_controls ) { int j; diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 9fde6ca711..b4ce5de9ae 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -152,7 +152,7 @@ monitor_subsys_database_init( j, monitor_subsys[SLAPD_MONITOR_BACKEND].mss_dn.bv_val ); bv.bv_val = buf; bv.bv_len = strlen( buf ); - attr_mergeit_one( e, ad_seeAlso, &bv ); + attr_merge_normalize_one( e, ad_seeAlso, &bv ); break; } } @@ -239,7 +239,7 @@ monitor_back_add_plugin( Backend *be, Entry *e_database ) bv.bv_val = buf; bv.bv_len = strlen( buf ); - attr_mergeit_one( e_database, monitor_ad_desc, &bv ); + attr_merge_normalize_one( e_database, monitor_ad_desc, &bv ); i++; diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index a929562301..fdcb40cfd4 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -44,7 +44,6 @@ * used by many functions to add description to entries */ AttributeDescription *monitor_ad_desc = NULL; -slap_mr_normalize_func *monitor_ad_normalize = NULL; BackendDB *be_monitor = NULL; /* @@ -301,10 +300,6 @@ monitor_back_db_init( return( -1 ); } - if ( monitor_ad_desc->ad_type->sat_equality ) { - monitor_ad_normalize = monitor_ad_desc->ad_type->sat_equality->smr_normalize; - } - /* * Create all the subsystem specific entries */ @@ -429,7 +424,7 @@ monitor_back_db_init( } else { bv.bv_len = strlen( Versionstr ); } - if ( attr_merge_one( e, monitor_ad_desc, &bv, NULL ) ) { + if ( attr_merge_normalize_one( e, monitor_ad_desc, &bv ) ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, CRIT, "unable to add description to '%s' entry\n", diff --git a/servers/slapd/back-monitor/listener.c b/servers/slapd/back-monitor/listener.c index b862fcd0f8..2224ec1de7 100644 --- a/servers/slapd/back-monitor/listener.c +++ b/servers/slapd/back-monitor/listener.c @@ -122,54 +122,22 @@ monitor_subsys_listener_init( #ifdef HAVE_TLS if ( l[i]->sl_is_tls ) { - struct berval bv, nbv; + struct berval bv; bv.bv_val = "TLS"; bv.bv_len = sizeof("TLS")-1; - nbv.bv_val = NULL; - if ( monitor_ad_normalize ) { - int rc; - - rc = monitor_ad_normalize( - 0, - monitor_ad_desc->ad_type->sat_syntax, - monitor_ad_desc->ad_type->sat_equality, - &bv, &nbv ); - if ( rc ) { - return( -1 ); - } - } - - attr_merge_one( e, monitor_ad_desc, &bv, - nbv.bv_val ? &nbv : NULL ); - ch_free( nbv.bv_val ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); } #endif /* HAVE_TLS */ #ifdef LDAP_CONNECTIONLESS if ( l[i]->sl_is_udp ) { - struct berval bv, nbv; + struct berval bv; bv.bv_val = "UDP"; bv.bv_len = sizeof("UDP")-1; - nbv.bv_val = NULL; - if ( monitor_ad_normalize ) { - int rc; - - rc = monitor_ad_normalize( - 0, - monitor_ad_desc->ad_type->sat_syntax, - monitor_ad_desc->ad_type->sat_equality, - &bv, &nbv ); - if ( rc ) { - return( -1 ); - } - } - - attr_merge_one( e, monitor_ad_desc, &bv, - nbv.bv_val ? &nbv : NULL ); - ch_free( nbv.bv_val ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); } #endif /* HAVE_TLS */ diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 8bc0dd0d18..5ebcba76fb 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -116,10 +116,10 @@ monitor_subsys_log_init( /* initialize the debug level(s) */ for ( i = 0; int_2_level[ i ].i != 0; i++ ) { - if ( monitor_ad_normalize ) { + if ( monitor_ad_desc->ad_type->sat_equality->smr_normalize ) { int rc; - rc = monitor_ad_normalize( + rc = (*monitor_ad_desc->ad_type->sat_equality->smr_normalize)( 0, monitor_ad_desc->ad_type->sat_syntax, monitor_ad_desc->ad_type->sat_equality, @@ -167,7 +167,8 @@ monitor_subsys_log_modify( */ if ( is_at_operational( mod->sm_desc->ad_type ) ) { ( void ) attr_delete( &e->e_attrs, mod->sm_desc ); - rc = attr_mergeit( e, mod->sm_desc, mod->sm_bvalues ); + rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, + mod->sm_nvalues ); if ( rc != 0 ) { rc = LDAP_OTHER; break; @@ -374,10 +375,10 @@ add_values( Entry *e, Modification *mod, int *newlevel ) } /* no - add them */ - if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues, - mod->sm_nvalues ) != 0 ) { + rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues ); + if ( rc != LDAP_SUCCESS ) { /* this should return result of attr_mergeit */ - return LDAP_OTHER; + return rc; } return LDAP_SUCCESS; @@ -499,10 +500,12 @@ replace_values( Entry *e, Modification *mod, int *newlevel ) return rc; } - if ( mod->sm_bvalues != NULL && - attr_merge( e, mod->sm_desc, mod->sm_bvalues, - mod->sm_nvalues ) != 0 ) { - return LDAP_OTHER; + if ( mod->sm_bvalues != NULL ) { + rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, + mod->sm_nvalues ); + if ( rc != LDAP_SUCCESS ) { + return rc; + } } return LDAP_SUCCESS; diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index 5c2e88f530..cc1a383d1b 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -115,28 +115,12 @@ monitor_subsys_readw_update_internal( } if ( b == NULL || b[0].bv_val == NULL ) { - struct berval bv, nbv; + struct berval bv; bv.bv_val = buf; bv.bv_len = strlen( buf ); - nbv.bv_val = NULL; - if ( monitor_ad_normalize ) { - int rc; - - rc = monitor_ad_normalize( - 0, - monitor_ad_desc->ad_type->sat_syntax, - monitor_ad_desc->ad_type->sat_equality, - &bv, &nbv ); - if ( rc ) { - return( -1 ); - } - } - - attr_merge_one( e, monitor_ad_desc, &bv, - nbv.bv_val ? &nbv : NULL ); - ch_free( nbv.bv_val ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); } return( 0 ); diff --git a/servers/slapd/back-monitor/thread.c b/servers/slapd/back-monitor/thread.c index 7853a9faf1..16dd56b129 100644 --- a/servers/slapd/back-monitor/thread.c +++ b/servers/slapd/back-monitor/thread.c @@ -75,7 +75,7 @@ monitor_subsys_thread_init( bv.bv_val = buf; bv.bv_len = strlen( bv.bv_val ); - attr_merge_one( e, monitor_ad_desc, &bv, NULL ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); monitor_cache_release( mi, e ); @@ -112,7 +112,7 @@ monitor_subsys_thread_update( bv.bv_val = buf; bv.bv_len = strlen( buf ); - attr_merge_one( e, monitor_ad_desc, &bv, NULL ); + attr_merge_normalize_one( e, monitor_ad_desc, &bv ); } return( 0 ); -- 2.39.5