1/* init.c - initialize sock backend */
2/* $OpenLDAP$ */
3/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 2007-2011 The OpenLDAP Foundation.
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 Brian Candler for inclusion
18 * in OpenLDAP Software.
19 */
20
21#include "portable.h"
22
23#include <stdio.h>
24
25#include <ac/socket.h>
26
27#include "slap.h"
28#include "back-sock.h"
29
30int
31sock_back_initialize(
32    BackendInfo	*bi
33)
34{
35	bi->bi_open = 0;
36	bi->bi_config = 0;
37	bi->bi_close = 0;
38	bi->bi_destroy = 0;
39
40	bi->bi_db_init = sock_back_db_init;
41	bi->bi_db_config = 0;
42	bi->bi_db_open = 0;
43	bi->bi_db_close = 0;
44	bi->bi_db_destroy = sock_back_db_destroy;
45
46	bi->bi_op_bind = sock_back_bind;
47	bi->bi_op_unbind = sock_back_unbind;
48	bi->bi_op_search = sock_back_search;
49	bi->bi_op_compare = sock_back_compare;
50	bi->bi_op_modify = sock_back_modify;
51	bi->bi_op_modrdn = sock_back_modrdn;
52	bi->bi_op_add = sock_back_add;
53	bi->bi_op_delete = sock_back_delete;
54	bi->bi_op_abandon = 0;
55
56	bi->bi_extended = 0;
57
58	bi->bi_chk_referrals = 0;
59
60	bi->bi_connection_init = 0;
61	bi->bi_connection_destroy = 0;
62
63	return sock_back_init_cf( bi );
64}
65
66int
67sock_back_db_init(
68    Backend	*be,
69	struct config_reply_s *cr
70)
71{
72	struct sockinfo	*si;
73
74	si = (struct sockinfo *) ch_calloc( 1, sizeof(struct sockinfo) );
75
76	be->be_private = si;
77	be->be_cf_ocs = be->bd_info->bi_cf_ocs;
78
79	return si == NULL;
80}
81
82int
83sock_back_db_destroy(
84    Backend	*be,
85	struct config_reply_s *cr
86)
87{
88	free( be->be_private );
89	return 0;
90}
91
92#if SLAPD_SOCK == SLAPD_MOD_DYNAMIC
93
94/* conditionally define the init_module() function */
95SLAP_BACKEND_INIT_MODULE( sock )
96
97#endif /* SLAPD_SOCK == SLAPD_MOD_DYNAMIC */
98