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;
45 if ( mp->mp_info && mp->mp_info->mss_update ) {
46 rc = mp->mp_info->mss_update( op, rs, e );
49 if ( rc == SLAP_CB_CONTINUE && mp->mp_cb ) {
50 struct monitor_callback_t *mc;
52 for ( mc = mp->mp_cb; mc; mc = mc->mc_next ) {
53 if ( mc->mc_update ) {
54 rc = mc->mc_update( op, rs, e, mc->mc_private );
55 if ( rc != SLAP_CB_CONTINUE ) {
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;
118 if ( mp->mp_info && mp->mp_info->mss_modify ) {
119 rc = mp->mp_info->mss_modify( op, rs, e );
122 if ( rc == SLAP_CB_CONTINUE && mp->mp_cb ) {
123 struct monitor_callback_t *mc;
125 for ( mc = mp->mp_cb; mc; mc = mc->mc_next ) {
126 if ( mc->mc_modify ) {
127 rc = mc->mc_modify( op, rs, e, mc->mc_private );
128 if ( rc != SLAP_CB_CONTINUE ) {
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;
176 struct berval *create,
177 struct berval *modify
180 AttributeDescription *nad = NULL;
188 ptr = strchr( nat.bv_val, '=' );
189 nat.bv_len = ptr - nat.bv_val;
190 rc = slap_bv2ad( &nat, &nad, &text );
194 e = ch_calloc( 1, sizeof( Entry ));
198 rdnNormalize( 0, NULL, NULL, rdn, &nrdn, NULL );
199 build_new_dn( &e->e_name, pdn, rdn, NULL );
200 build_new_dn( &e->e_nname, pndn, &nrdn, NULL );
201 nat.bv_val = ptr + 1;
202 nat.bv_len = rdn->bv_len - ( nat.bv_val - rdn->bv_val );
203 attr_merge_normalize_one( e, slap_schema.si_ad_objectClass,
204 &oc->soc_cname, NULL );
205 attr_merge_normalize_one( e, slap_schema.si_ad_structuralObjectClass,
206 &oc->soc_cname, NULL );
207 attr_merge_normalize_one( e, nad, &nat, NULL );
208 attr_merge_one( e, slap_schema.si_ad_creatorsName, &mi->mi_creatorsName,
209 &mi->mi_ncreatorsName );
210 attr_merge_one( e, slap_schema.si_ad_modifiersName, &mi->mi_creatorsName,
211 &mi->mi_ncreatorsName );
212 attr_merge_normalize_one( e, slap_schema.si_ad_createTimestamp,
213 create ? create : &mi->mi_startTime, NULL );
214 attr_merge_normalize_one( e, slap_schema.si_ad_modifyTimestamp,
215 modify ? modify : &mi->mi_startTime, NULL );