1 /* entry.c - monitor backend entry handling routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2006 The OpenLDAP Foundation.
6 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Pierangelo Masarati for inclusion
19 * in OpenLDAP Software.
25 #include "back-monitor.h"
34 monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;
37 int rc = SLAP_CB_CONTINUE;
41 assert( e->e_private != NULL );
43 mp = ( monitor_entry_t * )e->e_private;
46 struct monitor_callback_t *mc;
48 for ( mc = mp->mp_cb; mc; mc = mc->mc_next ) {
49 if ( mc->mc_update ) {
50 rc = mc->mc_update( op, rs, e, mc->mc_private );
51 if ( rc != SLAP_CB_CONTINUE ) {
58 if ( rc == SLAP_CB_CONTINUE && mp->mp_info && mp->mp_info->mss_update ) {
59 rc = mp->mp_info->mss_update( op, rs, e );
62 if ( rc == SLAP_CB_CONTINUE ) {
77 monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;
80 int rc = SLAP_CB_CONTINUE;
83 assert( e_parent != NULL );
84 assert( e_parent->e_private != NULL );
87 mp = ( monitor_entry_t * )e_parent->e_private;
89 if ( mp->mp_info && mp->mp_info->mss_create ) {
90 rc = mp->mp_info->mss_create( op, rs, ndn, e_parent, ep );
93 if ( rc == SLAP_CB_CONTINUE ) {
101 monitor_entry_modify(
107 monitor_info_t *mi = ( monitor_info_t * )op->o_bd->be_private;
110 int rc = SLAP_CB_CONTINUE;
112 assert( mi != NULL );
114 assert( e->e_private != NULL );
116 mp = ( monitor_entry_t * )e->e_private;
119 struct monitor_callback_t *mc;
121 for ( mc = mp->mp_cb; mc; mc = mc->mc_next ) {
122 if ( mc->mc_modify ) {
123 rc = mc->mc_modify( op, rs, e, mc->mc_private );
124 if ( rc != SLAP_CB_CONTINUE ) {
131 if ( rc == SLAP_CB_CONTINUE && mp->mp_info && mp->mp_info->mss_modify ) {
132 rc = mp->mp_info->mss_modify( op, rs, e );
135 if ( rc == SLAP_CB_CONTINUE ) {
143 monitor_entry_test_flags(
148 assert( mp != NULL );
150 return( ( mp->mp_flags & cond ) || ( mp->mp_info->mss_flags & cond ) );
154 monitor_entrypriv_create( void )
158 mp = ( monitor_entry_t * )ch_calloc( sizeof( monitor_entry_t ), 1 );
161 mp->mp_children = NULL;
163 mp->mp_flags = MONITOR_F_NONE;
166 ldap_pvt_thread_mutex_init( &mp->mp_mutex );
178 struct berval *create,
179 struct berval *modify
182 AttributeDescription *nad = NULL;
190 ptr = strchr( nat.bv_val, '=' );
191 nat.bv_len = ptr - nat.bv_val;
192 rc = slap_bv2ad( &nat, &nad, &text );
200 rdnNormalize( 0, NULL, NULL, rdn, &nrdn, NULL );
201 build_new_dn( &e->e_name, pdn, rdn, NULL );
202 build_new_dn( &e->e_nname, pndn, &nrdn, NULL );
203 ber_memfree( nrdn.bv_val );
204 nat.bv_val = ptr + 1;
205 nat.bv_len = rdn->bv_len - ( nat.bv_val - rdn->bv_val );
206 attr_merge_normalize_one( e, slap_schema.si_ad_objectClass,
207 &oc->soc_cname, NULL );
208 attr_merge_normalize_one( e, slap_schema.si_ad_structuralObjectClass,
209 &oc->soc_cname, NULL );
210 attr_merge_normalize_one( e, nad, &nat, NULL );
211 attr_merge_one( e, slap_schema.si_ad_creatorsName, &mi->mi_creatorsName,
212 &mi->mi_ncreatorsName );
213 attr_merge_one( e, slap_schema.si_ad_modifiersName, &mi->mi_creatorsName,
214 &mi->mi_ncreatorsName );
215 attr_merge_normalize_one( e, slap_schema.si_ad_createTimestamp,
216 create ? create : &mi->mi_startTime, NULL );
217 attr_merge_normalize_one( e, slap_schema.si_ad_modifyTimestamp,
218 modify ? modify : &mi->mi_startTime, NULL );