]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/entry.c
fix typo in rww; general cleanup
[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-2004 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         struct monitorinfo      *mi =
34                 (struct monitorinfo *)op->o_bd->be_private;
35         struct monitorentrypriv *mp;
36         int                     rc = 0;
37
38         assert( mi != NULL );
39         assert( e != NULL );
40         assert( e->e_private != NULL );
41
42         mp = ( struct monitorentrypriv * )e->e_private;
43
44         if ( mp->mp_info && mp->mp_info->mss_update ) {
45                 rc = ( *mp->mp_info->mss_update )( op, e );
46         }
47
48         if ( rc == 0 && mp->mp_update ) {
49                 rc = ( *mp->mp_update )( op, e );
50         }
51
52         return rc;
53 }
54
55 int
56 monitor_entry_create(
57         Operation               *op,
58         struct berval           *ndn,
59         Entry                   *e_parent,
60         Entry                   **ep
61 )
62 {
63         struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
64         struct monitorentrypriv *mp;
65
66         assert( mi != NULL );
67         assert( e_parent != NULL );
68         assert( e_parent->e_private != NULL );
69         assert( ep != NULL );
70
71         mp = ( struct monitorentrypriv * )e_parent->e_private;
72
73         if ( mp->mp_info && mp->mp_info->mss_create ) {
74                 return ( *mp->mp_info->mss_create )( op, ndn, e_parent, ep );
75         }
76         
77         return( 0 );
78 }
79
80 int
81 monitor_entry_modify(
82         Operation               *op,
83         Entry                   *e
84 )
85 {
86         struct monitorinfo *mi = (struct monitorinfo *)op->o_bd->be_private;
87         struct monitorentrypriv *mp;
88
89         assert( mi != NULL );
90         assert( e != NULL );
91         assert( e->e_private != NULL );
92
93         mp = ( struct monitorentrypriv * )e->e_private;
94
95         if ( mp->mp_info && mp->mp_info->mss_modify ) {
96                 return ( *mp->mp_info->mss_modify )( op, e );
97         }
98
99         return( 0 );
100 }
101
102 int
103 monitor_entry_test_flags(
104         struct monitorentrypriv *mp,
105         int                     cond
106 )
107 {
108         assert( mp != NULL );
109
110         return( ( mp->mp_flags & cond ) || ( mp->mp_info->mss_flags & cond ) );
111 }
112
113 struct monitorentrypriv *
114 monitor_entrypriv_create( void )
115 {
116         struct monitorentrypriv *mp;
117
118         mp = ( struct monitorentrypriv * )ch_calloc( sizeof( struct monitorentrypriv ), 1 );
119
120         mp->mp_next = NULL;
121         mp->mp_children = NULL;
122         mp->mp_info = NULL;
123         mp->mp_flags = MONITOR_F_NONE;
124         mp->mp_update = NULL;
125         mp->mp_private = NULL;
126
127         return mp;
128 }