]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/log.c
Cleanup and SIGTRAP
[openldap] / servers / slapd / back-monitor / log.c
index 6b072071b27ceb62f34dd9c0d6263ef8f5cc6a36..9e99fb1eede4dc21d54bc4c2369c0b92d30a6874 100644 (file)
@@ -1,34 +1,22 @@
 /* log.c - deal with log subsystem */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2001-2004 The OpenLDAP Foundation.
+ * Portions Copyright 2001-2003 Pierangelo Masarati.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/*
- * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
- * 
- * This work has beed deveolped for the OpenLDAP Foundation 
- * in the hope that it may be useful to the Open Source community, 
- * but WITHOUT ANY WARRANTY.
- * 
- * Permission is granted to anyone to use this software for any purpose
- * on any computer system, and to alter it and redistribute it, subject
- * to the following restrictions:
- * 
- * 1. The author and SysNet s.n.c. are not responsible for the consequences
- *    of use of this software, no matter how awful, even if they arise from
- *    flaws in it.
- * 
- * 2. The origin of this software must not be misrepresented, either by
- *    explicit claim or by omission.  Since few users ever read sources,
- *    credits should appear in the documentation.
- * 
- * 3. Altered versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.  Since few users
- *    ever read sources, credits should appear in the documentation.
- *    SysNet s.n.c. cannot be responsible for the consequences of the
- *    alterations.
- * 
- * 4. This notice may not be removed or altered.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by Pierangelo Masarati for inclusion
+ * in OpenLDAP Software.
  */
 
 #include "portable.h"
@@ -53,21 +41,21 @@ static struct {
        struct berval s;
        struct berval n;
 } int_2_level[] = {
-       { LDAP_DEBUG_TRACE,     BER_BVC("Trace"),       { 0, NULL } },
-       { LDAP_DEBUG_PACKETS,   BER_BVC("Packets"),     { 0, NULL } },
-       { LDAP_DEBUG_ARGS,      BER_BVC("Args"),        { 0, NULL } },
-       { LDAP_DEBUG_CONNS,     BER_BVC("Conns"),       { 0, NULL } },
-       { LDAP_DEBUG_BER,       BER_BVC("BER"), { 0, NULL } },
-       { LDAP_DEBUG_FILTER,    BER_BVC("Filter"),      { 0, NULL } },
-       { LDAP_DEBUG_CONFIG,    BER_BVC("Config"),      { 0, NULL } },  /* useless */
-       { LDAP_DEBUG_ACL,       BER_BVC("ACL"), { 0, NULL } },
-       { LDAP_DEBUG_STATS,     BER_BVC("Stats"),       { 0, NULL } },
-       { LDAP_DEBUG_STATS2,    BER_BVC("Stats2"),      { 0, NULL } },
-       { LDAP_DEBUG_SHELL,     BER_BVC("Shell"),       { 0, NULL } },
-       { LDAP_DEBUG_PARSE,     BER_BVC("Parse"),       { 0, NULL } },
-       { LDAP_DEBUG_CACHE,     BER_BVC("Cache"),       { 0, NULL } },
-       { LDAP_DEBUG_INDEX,     BER_BVC("Index"),       { 0, NULL } },
-       { 0,                    { 0, NULL },    { 0, NULL } }
+       { LDAP_DEBUG_TRACE,     BER_BVC("Trace"),       BER_BVNULL },
+       { LDAP_DEBUG_PACKETS,   BER_BVC("Packets"),     BER_BVNULL },
+       { LDAP_DEBUG_ARGS,      BER_BVC("Args"),        BER_BVNULL },
+       { LDAP_DEBUG_CONNS,     BER_BVC("Conns"),       BER_BVNULL },
+       { LDAP_DEBUG_BER,       BER_BVC("BER"), BER_BVNULL },
+       { LDAP_DEBUG_FILTER,    BER_BVC("Filter"),      BER_BVNULL },
+       { LDAP_DEBUG_CONFIG,    BER_BVC("Config"),      BER_BVNULL },   /* useless */
+       { LDAP_DEBUG_ACL,       BER_BVC("ACL"), BER_BVNULL },
+       { LDAP_DEBUG_STATS,     BER_BVC("Stats"),       BER_BVNULL },
+       { LDAP_DEBUG_STATS2,    BER_BVC("Stats2"),      BER_BVNULL },
+       { LDAP_DEBUG_SHELL,     BER_BVC("Shell"),       BER_BVNULL },
+       { LDAP_DEBUG_PARSE,     BER_BVC("Parse"),       BER_BVNULL },
+       { LDAP_DEBUG_CACHE,     BER_BVC("Cache"),       BER_BVNULL },
+       { LDAP_DEBUG_INDEX,     BER_BVC("Index"),       BER_BVNULL },
+       { 0,                    BER_BVNULL,     BER_BVNULL }
 };
 
 static int loglevel2int( struct berval *l );
@@ -91,7 +79,7 @@ monitor_subsys_log_init(
        struct berval           desc[] = {
                BER_BVC("This entry allows to set the log level runtime."),
                BER_BVC("Set the attribute 'managedInfo' to the desired log levels."),
-               { 0, NULL }
+               BER_BVNULL
        };
 
        ldap_pvt_thread_mutex_init( &monitor_log_mutex );
@@ -122,7 +110,7 @@ monitor_subsys_log_init(
                        int     rc;
 
                        rc = (*mi->mi_ad_managedInfo->ad_type->sat_equality->smr_normalize)(
-                                       0,
+                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
                                        mi->mi_ad_managedInfo->ad_type->sat_syntax,
                                        mi->mi_ad_managedInfo->ad_type->sat_equality,
                                        &int_2_level[ i ].s,
@@ -172,8 +160,7 @@ monitor_subsys_log_modify(
                 */
                if ( is_at_operational( mod->sm_desc->ad_type ) ) {
                        ( void ) attr_delete( &e->e_attrs, mod->sm_desc );
-                       rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
-                                       mod->sm_nvalues );
+                       rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
                        if ( rc != 0 ) {
                                rc = LDAP_OTHER;
                                break;
@@ -295,10 +282,10 @@ check_constraints( Modification *mod, int *newlevel )
 {
        int             i;
 
-       for ( i = 0; mod->sm_bvalues && mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+       for ( i = 0; mod->sm_values && mod->sm_values[i].bv_val != NULL; i++ ) {
                int             l;
                
-               l = loglevel2int( &mod->sm_bvalues[i] );
+               l = loglevel2int( &mod->sm_values[i] );
                if ( !l ) {
                        return LDAP_CONSTRAINT_VIOLATION;
                }
@@ -308,9 +295,9 @@ check_constraints( Modification *mod, int *newlevel )
                }
 
                assert( int_2_level[ l ].s.bv_len
-                               == mod->sm_bvalues[i].bv_len );
+                               == mod->sm_values[i].bv_len );
                
-               AC_MEMCPY( mod->sm_bvalues[i].bv_val,
+               AC_MEMCPY( mod->sm_values[i].bv_val,
                                int_2_level[ l ].s.bv_val,
                                int_2_level[ l ].s.bv_len );
 
@@ -344,7 +331,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
 
-               for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+               for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
                        int rc;
                        int j;
                        const char *text = NULL;
@@ -352,7 +339,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
 
                        rc = asserted_value_validate_normalize(
                                mod->sm_desc, mr, SLAP_MR_EQUALITY,
-                               &mod->sm_bvalues[i], &asserted, &text, NULL );
+                               &mod->sm_values[i], &asserted, &text, NULL );
 
                        if ( rc != LDAP_SUCCESS ) {
                                return rc;
@@ -361,8 +348,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
-                                       0,
-                                       &a->a_vals[j], &asserted, &text );
+                                       0, &a->a_vals[j], &asserted, &text );
 
                                if ( rc == LDAP_SUCCESS && match == 0 ) {
                                        free( asserted.bv_val );
@@ -375,7 +361,7 @@ add_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* no - add them */
-       rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues, mod->sm_nvalues );
+       rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
        if ( rc != LDAP_SUCCESS ) {
                /* this should return result of attr_mergeit */
                return rc;
@@ -399,7 +385,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        *newlevel &= ~nl;
 
        /* delete the entire attribute */
-       if ( mod->sm_bvalues == NULL ) {
+       if ( mod->sm_values == NULL ) {
                int rc = attr_delete( &e->e_attrs, mod->sm_desc );
 
                if ( rc ) {
@@ -423,7 +409,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
        }
 
        /* find each value to delete */
-       for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
+       for ( i = 0; mod->sm_values[i].bv_val != NULL; i++ ) {
                int rc;
                const char *text = NULL;
 
@@ -431,7 +417,7 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
 
                rc = asserted_value_validate_normalize(
                                mod->sm_desc, mr, SLAP_MR_EQUALITY,
-                               &mod->sm_bvalues[i], &asserted, &text, NULL );
+                               &mod->sm_values[i], &asserted, &text, NULL );
 
                if( rc != LDAP_SUCCESS ) return rc;
 
@@ -497,9 +483,8 @@ replace_values( Entry *e, Modification *mod, int *newlevel )
                return rc;
        }
 
-       if ( mod->sm_bvalues != NULL ) {
-               rc = attr_merge( e, mod->sm_desc, mod->sm_bvalues,
-                      mod->sm_nvalues );
+       if ( mod->sm_values != NULL ) {
+               rc = attr_merge( e, mod->sm_desc, mod->sm_values, mod->sm_nvalues );
                if ( rc != LDAP_SUCCESS ) {
                        return rc;
                }