]> git.sur5r.net Git - openldap/blob - servers/slapd/back-relay/init.c
add back-relay (doesn't work yet)
[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 2003-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 <ac/string.h>
26 #include <ac/socket.h>
27
28 #include "slap.h"
29 #include "back-relay.h"
30
31 #ifdef SLAPD_RELAY_DYNAMIC
32
33 int
34 init_module( int argc, char *argv[] ) {
35         BackendInfo     bi;
36
37         memset( &bi, '\0', sizeof( bi ) );
38         bi.bi_type = "relay";
39         bi.bi_init = relay_back_initialize;
40
41         backend_add(&bi);
42         return 0;
43 }
44
45 #endif /* SLAPD_RELAY_DYNAMIC */
46
47 int
48 relay_back_initialize( BackendInfo *bi )
49 {
50         bi->bi_init = 0;
51         bi->bi_open = 0;
52         bi->bi_config = 0;
53         bi->bi_close = 0;
54         bi->bi_destroy = 0;
55
56         bi->bi_db_init = relay_back_db_init;
57         bi->bi_db_config = relay_back_db_config;
58         bi->bi_db_open = relay_back_db_open;
59         bi->bi_db_close = 0 /* relay_back_db_close */ ;
60         bi->bi_db_destroy = relay_back_db_destroy;
61
62         bi->bi_op_bind = relay_back_op_bind;
63         bi->bi_op_unbind = relay_back_op_unbind;
64         bi->bi_op_search = relay_back_op_search;
65         bi->bi_op_compare = relay_back_op_compare;
66         bi->bi_op_modify = relay_back_op_modify;
67         bi->bi_op_modrdn = relay_back_op_modrdn;
68         bi->bi_op_add = relay_back_op_add;
69         bi->bi_op_delete = relay_back_op_delete;
70         bi->bi_op_abandon = relay_back_op_abandon;
71         bi->bi_op_cancel = relay_back_op_cancel;
72         bi->bi_extended = relay_back_op_extended;
73         bi->bi_entry_release_rw = relay_back_entry_release_rw;
74         bi->bi_entry_get_rw = relay_back_entry_get_rw;
75         bi->bi_chk_referrals = relay_back_chk_referrals;
76         bi->bi_operational = relay_back_operational;
77         bi->bi_has_subordinates = relay_back_has_subordinates;
78
79         bi->bi_connection_init = relay_back_connection_init;
80         bi->bi_connection_destroy = relay_back_connection_destroy;
81
82         return 0;
83 }
84
85 int
86 relay_back_db_init( Backend *be )
87 {
88         relay_back_info         *ri;
89
90         ri = (relay_back_info *)ch_calloc( 1, sizeof( relay_back_info ) );
91         if ( ri == NULL ) {
92                 return -1;
93         }
94
95         ri->ri_bd = NULL;
96
97         be->be_private = (void *)ri;
98
99         return 0;
100 }
101
102 int
103 relay_back_db_open( Backend *be )
104 {
105         relay_back_info         *ri = (relay_back_info *)be->be_private;
106
107         assert( ri != NULL );
108
109 #if 0
110         be->bd_info = ri->ri_bd->bd_info;
111
112         if ( !ri->ri_do_not_massage ) {
113                 char    *argv[ 4 ];
114
115                 argv[ 0 ] = "suffixmassage";
116                 argv[ 1 ] = be->be_suffix[0].bv_val;
117                 argv[ 2 ] = ri->ri_bd->be_suffix[0].bv_val;
118                 argv[ 3 ] = NULL;
119
120                 if ( be->be_config( be, "back-relay", 1, 3, argv ) ) {
121                         return 1;
122                 }
123         }
124 #endif
125
126         return 0;
127 }
128
129 int
130 relay_back_db_close( Backend *be )
131 {
132         return 0;
133 }
134
135 int
136 relay_back_db_destroy( Backend *be )
137 {
138         relay_back_info         *ri = (relay_back_info *)be->be_private;
139
140         if ( ri ) {
141                 ch_free( ri );
142         }
143
144         return 0;
145 }