]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/init.c
e625d50e687420912bf857df0e111231b6b8dd1c
[openldap] / servers / slapd / back-ldap / init.c
1 /* init.c - initialize ldap backend */
2
3 /*
4  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
5  * 
6  * Permission is granted to anyone to use this software for any purpose
7  * on any computer system, and to alter it and redistribute it, subject
8  * to the following restrictions:
9  * 
10  * 1. The author is not responsible for the consequences of use of this
11  *    software, no matter how awful, even if they arise from flaws in it.
12  * 
13  * 2. The origin of this software must not be misrepresented, either by
14  *    explicit claim or by omission.  Since few users ever read sources,
15  *    credits should appear in the documentation.
16  * 
17  * 3. Altered versions must be plainly marked as such, and must not be
18  *    misrepresented as being the original software.  Since few users
19  *    ever read sources, credits should appear in the documentation.
20  * 
21  * 4. This notice may not be removed or altered.
22  */
23
24 #include "portable.h"
25
26 #include <stdio.h>
27
28 #include <ac/socket.h>
29
30 #include "slap.h"
31 #include "back-ldap.h"
32
33 int
34 ldap_back_initialize(
35     BackendInfo *bi
36 )
37 {
38         bi->bi_open = 0;
39         bi->bi_config = 0;
40         bi->bi_close = 0;
41         bi->bi_destroy = 0;
42
43         bi->bi_db_init = ldap_back_db_init;
44         bi->bi_db_config = ldap_back_db_config;
45         bi->bi_db_open = 0;
46         bi->bi_db_close = 0;
47         bi->bi_db_destroy = ldap_back_db_destroy;
48
49         bi->bi_op_bind = ldap_back_bind;
50         bi->bi_op_unbind = ldap_back_unbind;
51         bi->bi_op_search = ldap_back_search;
52         bi->bi_op_compare = ldap_back_compare;
53         bi->bi_op_modify = ldap_back_modify;
54         bi->bi_op_modrdn = ldap_back_modrdn;
55         bi->bi_op_add = ldap_back_add;
56         bi->bi_op_delete = ldap_back_delete;
57         bi->bi_op_abandon = 0;
58
59 #ifdef SLAPD_ACLGROUPS
60         bi->bi_acl_group = 0;
61 #endif
62
63         bi->bi_connection_init = 0;
64         bi->bi_connection_destroy = 0;
65
66         return 0;
67 }
68
69 int
70 ldap_back_db_init(
71     Backend     *be
72 )
73 {
74         struct ldapinfo *li;
75
76         li = (struct ldapinfo *) ch_calloc( 1, sizeof(struct ldapinfo) );
77         ldap_pvt_thread_mutex_init( &li->conn_mutex );
78
79         be->be_private = li;
80
81         return li == NULL;
82 }
83
84 int
85 ldap_back_db_destroy(
86     Backend     *be
87 )
88 {
89         struct ldapinfo *li;
90
91         if (be->be_private) {
92                 li = (struct ldapinfo *)be->be_private;
93                 if (li->host) {
94                         free(li->host);
95                         li->host = NULL;
96                 }
97                 ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
98         }
99
100         free( be->be_private );
101         return 0;
102 }