]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/entry.c
honor disclose
[openldap] / servers / slapd / back-monitor / entry.c
1 /* entry.c - monitor backend entry handling routines */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2001-2005 The OpenLDAP Foundation.
6  * Portions Copyright 2001-2003 Pierangelo Masarati.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
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>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was initially developed by Pierangelo Masarati for inclusion
19  * in OpenLDAP Software.
20  */
21
22 #include "portable.h"
23
24 #include <slap.h>
25 #include "back-monitor.h"
26
27 int
28 monitor_entry_update(
29         Operation               *op,
30         Entry                   *e
31 )
32 {
33         monitor_info_t  *mi = ( monitor_info_t * )op->o_bd->be_private;
34         monitor_entry_t *mp;
35         int                     rc = 0;
36
37         assert( mi != NULL );
38         assert( e != NULL );
39         assert( e->e_private != NULL );
40
41         mp = ( monitor_entry_t * )e->e_private;
42
43         if ( mp->mp_info && mp->mp_info->mss_update ) {
44                 rc = ( *mp->mp_info->mss_update )( op, e );
45         }
46
47         if ( rc == 0 && mp->mp_cb ) {
48                 struct monitor_callback_t       *mc;
49
50                 for ( mc = mp->mp_cb; mc; mc = mc->mc_next ) {
51                         rc = ( *mc->mc_update )( op, e, mc->mc_private );
52                         if ( rc != 0 ) {
53                                 break;
54                         }
55                 }
56         }
57
58         return rc;
59 }
60
61 int
62 monitor_entry_create(
63         Operation               *op,
64         struct berval           *ndn,
65         Entry                   *e_parent,
66         Entry                   **ep
67 )
68 {
69         monitor_info_t  *mi = ( monitor_info_t * )op->o_bd->be_private;
70         monitor_entry_t *mp;
71
72         assert( mi != NULL );
73         assert( e_parent != NULL );
74         assert( e_parent->e_private != NULL );
75         assert( ep != NULL );
76
77         mp = ( monitor_entry_t * )e_parent->e_private;
78
79         if ( mp->mp_info && mp->mp_info->mss_create ) {
80                 return ( *mp->mp_info->mss_create )( op, ndn, e_parent, ep );
81         }
82         
83         return( 0 );
84 }
85
86 int
87 monitor_entry_modify(
88         Operation               *op,
89         Entry                   *e
90 )
91 {
92         monitor_info_t  *mi = ( monitor_info_t * )op->o_bd->be_private;
93         monitor_entry_t *mp;
94
95         assert( mi != NULL );
96         assert( e != NULL );
97         assert( e->e_private != NULL );
98
99         mp = ( monitor_entry_t * )e->e_private;
100
101         if ( mp->mp_info && mp->mp_info->mss_modify ) {
102                 return ( *mp->mp_info->mss_modify )( op, e );
103         }
104
105         return( 0 );
106 }
107
108 int
109 monitor_entry_test_flags(
110         monitor_entry_t         *mp,
111         int                     cond
112 )
113 {
114         assert( mp != NULL );
115
116         return( ( mp->mp_flags & cond ) || ( mp->mp_info->mss_flags & cond ) );
117 }
118
119 monitor_entry_t *
120 monitor_entrypriv_create( void )
121 {
122         monitor_entry_t *mp;
123
124         mp = ( monitor_entry_t * )ch_calloc( sizeof( monitor_entry_t ), 1 );
125
126         mp->mp_next = NULL;
127         mp->mp_children = NULL;
128         mp->mp_info = NULL;
129         mp->mp_flags = MONITOR_F_NONE;
130         mp->mp_cb = NULL;
131
132         return mp;
133 }