/* log.c - deal with log subsystem */
/*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/*
- * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- *
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
*
* This work has beed deveolped for the OpenLDAP Foundation
struct monitorinfo *mi;
Entry *e;
int i;
- struct berval val, *bv[2] = { &val, NULL };
+ struct berval bv[2];
ldap_pvt_thread_mutex_init( &monitor_log_mutex );
mi = ( struct monitorinfo * )be->be_private;
- if ( monitor_cache_get( mi, monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn,
+ if ( monitor_cache_get( mi, &monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn,
&e ) ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
"monitor_subsys_log_init: "
"unable to get entry '%s'\n",
- monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn->bv_val ));
+ monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val ));
#else
Debug( LDAP_DEBUG_ANY,
"monitor_subsys_log_init: "
"unable to get entry '%s'\n%s%s",
- monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn->bv_val,
+ monitor_subsys[SLAPD_MONITOR_LOG].mss_ndn.bv_val,
"", "" );
#endif
return( -1 );
}
+ bv[1].bv_val = NULL;
+
/* initialize the debug level */
for ( i = 0; int_2_level[ i ].i != 0; i++ ) {
if ( int_2_level[ i ].i & ldap_syslog ) {
- val.bv_val = ( char * )int_2_level[ i ].s;
- val.bv_len = strlen( val.bv_val );
+ bv[0].bv_val = ( char * )int_2_level[ i ].s;
+ bv[0].bv_len = strlen( bv[0].bv_val );
attr_merge( e, monitor_ad_desc, bv );
}
#endif
/* check that the entry still obeys the schema */
- rc = entry_schema_check( e, save_attrs, &text, textbuf,
- sizeof( textbuf ) );
+ rc = entry_schema_check( be_monitor, e, save_attrs,
+ &text, textbuf, sizeof( textbuf ) );
if ( rc != LDAP_SUCCESS ) {
goto cleanup;
}
{
int i;
- for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int l;
const char *s;
ber_len_t len;
- l = loglevel2int( mod->sm_bvalues[i]->bv_val );
+ l = loglevel2int( mod->sm_bvalues[i].bv_val );
if ( !l ) {
return LDAP_CONSTRAINT_VIOLATION;
}
s = int2loglevel( l );
len = strlen( s );
- assert( len == mod->sm_bvalues[i]->bv_len );
+ assert( len == mod->sm_bvalues[i].bv_len );
- AC_MEMCPY( mod->sm_bvalues[i]->bv_val, s, len );
+ AC_MEMCPY( mod->sm_bvalues[i].bv_val, s, len );
*newlevel |= l;
}
return LDAP_INAPPROPRIATE_MATCHING;
}
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
int j;
const char *text = NULL;
- struct berval *asserted = NULL;
+ struct berval asserted;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
return rc;
}
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
- ber_bvfree( asserted );
+ free( asserted.bv_val );
return LDAP_TYPE_OR_VALUE_EXISTS;
}
}
- ber_bvfree( asserted );
+ free( asserted.bv_val );
}
}
/* no - add them */
if ( attr_merge( e, mod->sm_desc, mod->sm_bvalues ) != 0 ) {
- /* this should return result return of attr_merge */
+ /* this should return result of attr_merge */
return LDAP_OTHER;
}
}
/* find each value to delete */
- for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+ for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
int rc;
const char *text = NULL;
- struct berval *asserted = NULL;
+ struct berval asserted;
rc = value_normalize( mod->sm_desc,
SLAP_MR_EQUALITY,
- mod->sm_bvalues[i],
+ &mod->sm_bvalues[i],
&asserted,
&text );
if( rc != LDAP_SUCCESS ) return rc;
found = 0;
- for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
int match;
int rc = value_match( &match, mod->sm_desc, mr,
SLAP_MR_VALUE_SYNTAX_MATCH,
- a->a_vals[j], asserted, &text );
+ &a->a_vals[j], &asserted, &text );
if( rc == LDAP_SUCCESS && match != 0 ) {
continue;
found = 1;
/* delete it */
- ber_bvfree( a->a_vals[j] );
- for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+ free( a->a_vals[j].bv_val );
+ for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
a->a_vals[k - 1] = a->a_vals[k];
}
- a->a_vals[k - 1] = NULL;
+ a->a_vals[k - 1].bv_val = NULL;
break;
}
- ber_bvfree( asserted );
+ free( asserted.bv_val );
/* looked through them all w/o finding it */
if ( ! found ) {
}
/* if no values remain, delete the entire attribute */
- if ( a->a_vals[0] == NULL ) {
+ if ( a->a_vals[0].bv_val == NULL ) {
/* should already be zero */
*newlevel = 0;