]> git.sur5r.net Git - openldap/blob - servers/slapd/back-relay/init.c
declare oc_bvfind_undef()
[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 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         bi->bi_db_close = 0 /* relay_back_db_close */ ;
41         bi->bi_db_destroy = relay_back_db_destroy;
42
43         bi->bi_op_bind = relay_back_op_bind;
44         bi->bi_op_unbind = relay_back_op_unbind;
45         bi->bi_op_search = relay_back_op_search;
46         bi->bi_op_compare = relay_back_op_compare;
47         bi->bi_op_modify = relay_back_op_modify;
48         bi->bi_op_modrdn = relay_back_op_modrdn;
49         bi->bi_op_add = relay_back_op_add;
50         bi->bi_op_delete = relay_back_op_delete;
51         bi->bi_op_abandon = relay_back_op_abandon;
52         bi->bi_op_cancel = relay_back_op_cancel;
53         bi->bi_extended = relay_back_op_extended;
54         bi->bi_entry_release_rw = relay_back_entry_release_rw;
55         bi->bi_entry_get_rw = relay_back_entry_get_rw;
56         bi->bi_chk_referrals = relay_back_chk_referrals;
57         bi->bi_operational = relay_back_operational;
58         bi->bi_has_subordinates = relay_back_has_subordinates;
59
60         bi->bi_connection_init = relay_back_connection_init;
61         bi->bi_connection_destroy = relay_back_connection_destroy;
62
63         return 0;
64 }
65
66 int
67 relay_back_db_init( Backend *be )
68 {
69         relay_back_info         *ri;
70
71         be->be_private = NULL;
72
73         ri = (relay_back_info *)ch_calloc( 1, sizeof( relay_back_info ) );
74         if ( ri == NULL ) {
75                 return -1;
76         }
77
78         ri->ri_bd = NULL;
79         BER_BVZERO( &ri->ri_realsuffix );
80         ri->ri_massage = 0;
81
82         be->be_private = (void *)ri;
83
84         return 0;
85 }
86
87 int
88 relay_back_db_open( Backend *be )
89 {
90         relay_back_info         *ri = (relay_back_info *)be->be_private;
91
92         assert( ri != NULL );
93
94         if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
95                 ri->ri_bd = select_backend( &ri->ri_realsuffix, 0, 1 );
96                 /* must be there: it was during config! */
97                 assert( ri->ri_bd );
98
99                 /* FIXME: (somehow) copy supported controls ? */
100         }
101
102         return 0;
103 }
104
105 int
106 relay_back_db_close( Backend *be )
107 {
108         return 0;
109 }
110
111 int
112 relay_back_db_destroy( Backend *be )
113 {
114         relay_back_info         *ri = (relay_back_info *)be->be_private;
115
116         if ( ri ) {
117                 if ( !BER_BVISNULL( &ri->ri_realsuffix ) ) {
118                         ch_free( ri->ri_realsuffix.bv_val );
119                 }
120                 ch_free( ri );
121         }
122
123         return 0;
124 }
125
126 #if SLAPD_RELAY == SLAPD_MOD_DYNAMIC
127
128 /* conditionally define the init_module() function */
129 SLAP_BACKEND_INIT_MODULE( relay )
130
131 #endif /* SLAPD_RELAY == SLAPD_MOD_DYNAMIC */
132