]> git.sur5r.net Git - openldap/blob - servers/slapd/back-relay/init.c
minor naming cleanup; improvements to DN mapping layer; major docs update
[openldap] / servers / slapd / back-relay / init.c
1 /* init.c - initialize relay backend */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 2004-2005 The OpenLDAP Foundation.
5  * Portions Copyright 2004 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 the 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 #include "portable.h"
22
23 #include <stdio.h>
24
25 #include "slap.h"
26 #include "back-relay.h"
27
28 int
29 relay_back_initialize( BackendInfo *bi )
30 {
31         bi->bi_init = 0;
32         bi->bi_open = 0;
33         bi->bi_config = 0;
34         bi->bi_close = 0;
35         bi->bi_destroy = 0;
36
37         bi->bi_db_init = relay_back_db_init;
38         bi->bi_db_config = relay_back_db_config;
39         bi->bi_db_open = relay_back_db_open;
40 #if 0
41         bi->bi_db_close =relay_back_db_close;
42 #endif
43         bi->bi_db_destroy = relay_back_db_destroy;
44
45         bi->bi_op_bind = relay_back_op_bind;
46         bi->bi_op_unbind = relay_back_op_unbind;
47         bi->bi_op_search = relay_back_op_search;
48         bi->bi_op_compare = relay_back_op_compare;
49         bi->bi_op_modify = relay_back_op_modify;
50         bi->bi_op_modrdn = relay_back_op_modrdn;
51         bi->bi_op_add = relay_back_op_add;
52         bi->bi_op_delete = relay_back_op_delete;
53         bi->bi_op_abandon = relay_back_op_abandon;
54         bi->bi_op_cancel = relay_back_op_cancel;
55         bi->bi_extended = relay_back_op_extended;
56         bi->bi_entry_release_rw = relay_back_entry_release_rw;
57         bi->bi_entry_get_rw = relay_back_entry_get_rw;
58 #if 0   /* see comment in op.c */
59         bi->bi_chk_referrals = relay_back_chk_referrals;
60 #endif
61         bi->bi_operational = relay_back_operational;
62         bi->bi_has_subordinates = relay_back_has_subordinates;
63
64         bi->bi_connection_init = relay_back_connection_init;
65         bi->bi_connection_destroy = relay_back_connection_destroy;
66
67         return 0;
68 }
69
70 int
71 relay_back_db_init( Backend *be )
72 {
73         relay_back_info         *ri;
74
75         be->be_private = NULL;
76
77         ri = (relay_back_info *)ch_calloc( 1, sizeof( relay_back_info ) );
78         if ( ri == NULL ) {
79                 return -1;
80         }
81
82         ri->ri_bd = NULL;
83         BER_BVZERO( &ri->ri_realsuffix );
84         ri->ri_massage = 0;
85
86         be->be_private = (void *)ri;
87
88         return 0;
89 }
90
91 int
92 relay_back_db_open( Backend *be )
93 {
94         relay_back_info         *ri = (relay_back_info *)be->be_private;
95
96         assert( ri != NULL );
97
98         if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
99                 ri->ri_bd = select_backend( &ri->ri_realsuffix, 0, 1 );
100                 /* must be there: it was during config! */
101                 assert( ri->ri_bd );
102
103                 /* FIXME: (somehow) copy supported controls ? */
104         }
105
106         return 0;
107 }
108
109 int
110 relay_back_db_close( Backend *be )
111 {
112         return 0;
113 }
114
115 int
116 relay_back_db_destroy( Backend *be )
117 {
118         relay_back_info         *ri = (relay_back_info *)be->be_private;
119
120         if ( ri ) {
121                 if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
122                         ch_free( ri->ri_realsuffix.bv_val );
123                 }
124                 ch_free( ri );
125         }
126
127         return 0;
128 }
129
130 #if SLAPD_RELAY == SLAPD_MOD_DYNAMIC
131
132 /* conditionally define the init_module() function */
133 SLAP_BACKEND_INIT_MODULE( relay )
134
135 #endif /* SLAPD_RELAY == SLAPD_MOD_DYNAMIC */
136