]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/init.c
4717b6f199fcabcb80a45b91b185079b6278e9c1
[openldap] / servers / slapd / back-perl / init.c
1 /*
2  *       Copyright 1999, John C. Quillan, All rights reserved.
3  *
4  *       Redistribution and use in source and binary forms are permitted only
5  *       as authorized by the OpenLDAP Public License.  A copy of this
6  *       license is available at http://www.OpenLDAP.org/license.html or
7  *       in file LICENSE in the top-level directory of the distribution.
8  */
9
10 #include "portable.h"
11  /* init.c - initialize shell backend */
12         
13 #include <stdio.h>
14 /* #include <ac/types.h>
15         #include <ac/socket.h>
16 */
17
18
19
20 #include <EXTERN.h>
21 #include <perl.h>
22
23 #include "slap.h"
24 #include "perl_back.h"
25
26
27
28 PerlInterpreter *perl_interpreter = NULL;
29 ldap_pvt_thread_mutex_t perl_interpreter_mutex;
30
31
32 /**********************************************************
33  *
34  * Init
35  *
36  **********************************************************/
37
38 int
39 perl_back_initialize(
40         BackendInfo     *bi
41 )
42 {
43         char *embedding[] = { "", "-e", "0" };
44
45         Debug( LDAP_DEBUG_TRACE, "perl backend open\n", 0, 0, 0 );
46
47         if( perl_interpreter != NULL ) {
48                 Debug( LDAP_DEBUG_ANY, "perl backend open: already opened\n",
49                         0, 0, 0 );
50                 return 1;
51         }
52         
53         perl_interpreter = perl_alloc();
54         perl_construct(perl_interpreter);
55         perl_parse(perl_interpreter, NULL, 3, embedding, (char **)NULL);
56         perl_run(perl_interpreter);
57
58         bi->bi_open = perl_back_open;
59         bi->bi_config = 0;
60         bi->bi_close = perl_back_close;
61         bi->bi_destroy = perl_back_destroy;
62
63         bi->bi_db_init = perl_back_db_init;
64         bi->bi_db_config = perl_back_db_config;
65         bi->bi_db_open = 0;
66         bi->bi_db_close = 0;
67         bi->bi_db_destroy = perl_back_db_destroy;
68
69         bi->bi_op_bind = perl_back_bind;
70         bi->bi_op_unbind = perl_back_unbind;
71         bi->bi_op_search = perl_back_search;
72         bi->bi_op_compare = perl_back_compare;
73         bi->bi_op_modify = perl_back_modify;
74         bi->bi_op_modrdn = perl_back_modrdn;
75         bi->bi_op_add = perl_back_add;
76         bi->bi_op_delete = perl_back_delete;
77         bi->bi_op_abandon = 0;
78
79 #ifdef SLAPD_ACLGROUPS
80         bi->bi_acl_group = 0;
81 #endif
82
83         bi->bi_connection_init = 0;
84         bi->bi_connection_destroy = 0;
85
86         return 0;
87 }
88                 
89 int
90 perl_back_open(
91         BackendInfo     *bi
92 )
93 {
94         ldap_pvt_thread_mutex_init( &perl_interpreter_mutex );
95         return 0;
96 }
97
98 int
99 perl_back_db_init(
100         Backend *be
101 )
102 {
103         be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
104         memset( be->be_private, 0, sizeof(PerlBackend));
105
106         Debug( LDAP_DEBUG_TRACE, "perl backend db init\n", 0, 0, 0 );
107
108         return 0;
109 }
110