3 * Copyright 1999, John C. Quillan, All rights reserved.
4 * Portions Copyright 2002, myinternet Limited. All rights reserved.
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
13 /* init.c - initialize shell backend */
18 #ifdef HAVE_WIN32_ASPERL
19 #include "asperl_undefs.h"
25 #include "perl_back.h"
28 static void perl_back_xs_init LDAP_P((PERL_BACK_XS_INIT_PARAMS));
29 EXT void boot_DynaLoader LDAP_P((PERL_BACK_BOOT_DYNALOADER_PARAMS));
31 PerlInterpreter *PERL_INTERPRETER = NULL;
32 ldap_pvt_thread_mutex_t perl_interpreter_mutex;
34 #ifdef SLAPD_PERL_DYNAMIC
36 int back_perl_LTX_init_module(int argc, char *argv[])
40 memset( &bi, '\0', sizeof(bi) );
42 bi.bi_init = perl_back_initialize;
48 #endif /* SLAPD_PERL_DYNAMIC */
51 /**********************************************************
55 **********************************************************/
62 char *embedding[] = { "", "-e", "0" };
64 Debug( LDAP_DEBUG_TRACE, "perl backend open\n", 0, 0, 0 );
66 if( PERL_INTERPRETER != NULL ) {
67 Debug( LDAP_DEBUG_ANY, "perl backend open: already opened\n",
72 PERL_INTERPRETER = perl_alloc();
73 perl_construct(PERL_INTERPRETER);
74 perl_parse(PERL_INTERPRETER, perl_back_xs_init, 3, embedding, (char **)NULL);
75 perl_run(PERL_INTERPRETER);
77 bi->bi_open = perl_back_open;
79 bi->bi_close = perl_back_close;
80 bi->bi_destroy = perl_back_destroy;
82 bi->bi_db_init = perl_back_db_init;
83 bi->bi_db_config = perl_back_db_config;
84 bi->bi_db_open = perl_back_db_open;
86 bi->bi_db_destroy = perl_back_db_destroy;
88 bi->bi_op_bind = perl_back_bind;
90 bi->bi_op_search = perl_back_search;
91 bi->bi_op_compare = perl_back_compare;
92 bi->bi_op_modify = perl_back_modify;
93 bi->bi_op_modrdn = perl_back_modrdn;
94 bi->bi_op_add = perl_back_add;
95 bi->bi_op_delete = perl_back_delete;
96 bi->bi_op_abandon = 0;
100 bi->bi_acl_group = 0;
101 bi->bi_acl_attribute = 0;
102 bi->bi_chk_referrals = 0;
104 bi->bi_connection_init = 0;
105 bi->bi_connection_destroy = 0;
115 ldap_pvt_thread_mutex_init( &perl_interpreter_mutex );
124 be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
125 memset( be->be_private, '\0', sizeof(PerlBackend));
127 ((PerlBackend *)be->be_private)->pb_filter_search_results = 0;
129 Debug( LDAP_DEBUG_TRACE, "perl backend db init\n", 0, 0, 0 );
142 PerlBackend *perl_back = (PerlBackend *) be->be_private;
144 ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
147 dSP; ENTER; SAVETMPS;
150 XPUSHs( perl_back->pb_obj_ref );
155 count = call_method("init", G_SCALAR);
157 count = perl_call_method("init", G_SCALAR);
163 croak("Big trouble in perl_back_db_open\n");
168 PUTBACK; FREETMPS; LEAVE;
171 ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
180 char *file = __FILE__;
182 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);