]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/log.c
Add search no-op support.
[openldap] / servers / slapd / back-monitor / log.c
index 1789ff0c9bf1fd4a86167a310d5d4aca1e50b26b..fe5a0819327fae89b8e79fb13aef7c89488113cc 100644 (file)
@@ -1,12 +1,9 @@
 /* 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 
@@ -89,34 +86,36 @@ monitor_subsys_log_init(
        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 );
                }
@@ -207,8 +206,8 @@ monitor_subsys_log_modify(
 #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;
                }
@@ -271,21 +270,21 @@ check_constraints( Modification *mod, int *newlevel )
 {
        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;
        }
@@ -314,7 +313,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        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;
@@ -322,7 +321,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
 
                        rc = value_normalize( mod->sm_desc,
                                        SLAP_MR_EQUALITY,
-                                       mod->sm_bvalues[i],
+                                       &mod->sm_bvalues[i],
                                        &asserted,
                                        &text );
 
@@ -330,11 +329,11 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                                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 ) {
                                        free( asserted.bv_val );
@@ -348,7 +347,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
 
        /* 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;
        }
 
@@ -394,7 +393,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* 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;
 
@@ -402,18 +401,18 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
 
                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;
@@ -423,11 +422,11 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
                        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;
                }
@@ -441,7 +440,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* 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;