]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/init.c
0665262b757aab3975851298fc27b9c82f5288f0
[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         return 0;
64 }
65
66 int
67 ldap_back_db_init(
68     Backend     *be
69 )
70 {
71         struct ldapinfo *li;
72
73         li = (struct ldapinfo *) ch_calloc( 1, sizeof(struct ldapinfo) );
74         ldap_pvt_thread_mutex_init( &li->conn_mutex );
75
76         be->be_private = li;
77
78         return li == NULL;
79 }
80
81 int
82 ldap_back_db_destroy(
83     Backend     *be
84 )
85 {
86         struct ldapinfo *li;
87
88         if (be->be_private) {
89                 li = (struct ldapinfo *)be->be_private;
90                 if (li->host) {
91                         free(li->host);
92                         li->host = NULL;
93                 }
94                 ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
95         }
96
97         free( be->be_private );
98         return 0;
99 }