]> git.sur5r.net Git - openldap/blob - servers/slapd/back-monitor/proto-back-monitor.h
fix typo in rww; general cleanup
[openldap] / servers / slapd / back-monitor / proto-back-monitor.h
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2001-2004 The OpenLDAP Foundation.
5  * Portions Copyright 2001-2003 Pierangelo Masarati.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Pierangelo Masarati for inclusion
18  * in OpenLDAP Software.
19  */
20
21 #ifndef _PROTO_BACK_MONITOR
22 #define _PROTO_BACK_MONITOR
23
24 #include <ldap_cdefs.h>
25
26 #include "external.h"
27
28 LDAP_BEGIN_DECL
29
30 /*
31  * backends
32  */
33 int monitor_subsys_backend_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
34
35 /*
36  * cache
37  */
38 extern int monitor_cache_cmp LDAP_P(( const void *c1, const void *c2 ));
39 extern int monitor_cache_dup LDAP_P(( void *c1, void *c2 ));
40 extern int monitor_cache_add LDAP_P(( struct monitorinfo *mi, Entry *e ));
41 extern int monitor_cache_get LDAP_P(( struct monitorinfo *mi, struct berval *ndn, Entry **ep ));
42 extern int monitor_cache_dn2entry LDAP_P(( Operation *op, struct berval *ndn, Entry **ep, Entry **matched ));
43 extern int monitor_cache_lock LDAP_P(( Entry *e ));
44 extern int monitor_cache_release LDAP_P(( struct monitorinfo *mi, Entry *e ));
45
46 /*
47  * connections
48  */
49 int monitor_subsys_conn_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
50 int monitor_subsys_conn_update LDAP_P(( Operation *op, Entry *e ));
51 int monitor_subsys_conn_create LDAP_P(( Operation *op, struct berval *ndn,
52                         Entry *e_parent, Entry **ep ));
53
54 /*
55  * databases 
56  */
57 int monitor_subsys_database_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
58 int monitor_subsys_database_modify LDAP_P(( Operation *op, Entry *e ));
59
60 /*
61  * entry
62  */
63 extern int monitor_entry_update LDAP_P(( Operation *op, Entry *e ));
64 extern int monitor_entry_create LDAP_P(( Operation *op, struct berval *ndn,
65                 Entry *e_parent, Entry **ep ));
66 extern int monitor_entry_modify LDAP_P(( Operation *op, Entry *e ));
67 int monitor_entry_test_flags LDAP_P(( struct monitorentrypriv *mp, int cond ));
68 extern struct monitorentrypriv * monitor_entrypriv_create LDAP_P(( void ));
69
70 /*
71  * init
72  */
73 extern int monitor_back_register_subsys LDAP_P(( monitorsubsys *ms ));
74 extern monitorsubsys * monitor_back_get_subsys LDAP_P(( const char *name ));
75 extern monitorsubsys * monitor_back_get_subsys_by_dn LDAP_P(( struct berval *ndn, int sub ));
76
77 /*
78  * listener
79  */
80 int monitor_subsys_listener_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
81
82 /*
83  * log
84  */
85 int monitor_subsys_log_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
86 int monitor_subsys_log_modify LDAP_P(( Operation *op, Entry *e ));
87
88 /*
89  * operations
90  */
91 int monitor_subsys_ops_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
92 int monitor_subsys_ops_update LDAP_P(( Operation *op, Entry *e ));
93
94 /*
95  * overlay
96  */
97 int monitor_subsys_overlay_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
98
99 /*
100  * sent
101  */
102 int monitor_subsys_sent_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
103 int monitor_subsys_sent_update LDAP_P(( Operation *op, Entry *e ));
104
105 /*
106  * threads
107  */
108 int monitor_subsys_thread_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
109 int monitor_subsys_thread_update LDAP_P(( Operation *op, Entry *e ));
110
111 /*
112  * time
113  */
114 int monitor_subsys_time_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
115 int monitor_subsys_time_update LDAP_P(( Operation *op, Entry *e ));
116
117 /*
118  * waiters
119  */
120 int monitor_subsys_rww_init LDAP_P(( BackendDB *be, monitorsubsys *ms ));
121 int monitor_subsys_rww_update LDAP_P(( Operation *op, Entry *e ));
122
123 /* NOTE: this macro assumes that bv has been allocated
124  * by ber_* malloc functions or is { 0L, NULL } */
125 #if defined(HAVE_BIGNUM)
126 #define UI2BV(bv,ui) \
127         do { \
128                 char            *val; \
129                 ber_len_t       len; \
130                 val = BN_bn2dec(ui); \
131                 if (val) { \
132                         len = strlen(val); \
133                         if ( len > (bv)->bv_len ) { \
134                                 (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \
135                         } \
136                         AC_MEMCPY((bv)->bv_val, val, len + 1); \
137                         (bv)->bv_len = len; \
138                         OPENSSL_free(val); \
139                 } else { \
140                         ber_memfree( (bv)->bv_val ); \
141                         BER_BVZERO( (bv) ); \
142                 } \
143         } while ( 0 )
144 #elif defined(HAVE_GMP)
145 /* NOTE: according to the documentation, the result 
146  * of mpz_sizeinbase() can exceed the length of the
147  * string representation of the number by 1
148  */
149 #define UI2BV(bv,ui) \
150         do { \
151                 ber_len_t       len = mpz_sizeinbase( (ui), 10 ); \
152                 if ( len > (bv)->bv_len ) { \
153                         (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \
154                 } \
155                 (void)mpz_get_str( (bv)->bv_val, 10, (ui) ); \
156                 if ( (bv)->bv_val[ len - 1 ] == '\0' ) { \
157                         len--; \
158                 } \
159                 (bv)->bv_len = len; \
160         } while ( 0 )
161 #else /* ! HAVE_BIGNUM && ! HAVE_GMP */
162 #define UI2BV(bv,ui) \
163         do { \
164                 char            buf[] = "+9223372036854775807L"; \
165                 ber_len_t       len; \
166                 snprintf( buf, sizeof( buf ), "%lu", (ui) ); \
167                 len = strlen( buf ); \
168                 if ( len > (bv)->bv_len ) { \
169                         (bv)->bv_val = ber_memrealloc( (bv)->bv_val, len + 1 ); \
170                 } \
171                 AC_MEMCPY( (bv)->bv_val, buf, len + 1 ); \
172         } while ( 0 )
173 #endif /* ! HAVE_GMP */
174
175 LDAP_END_DECL
176
177 #endif /* _PROTO_BACK_MONITOR */
178