3 * Copyright 1999-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright 1999, John C. Quillan, All rights reserved.
8 * Portions Copyright 2002, myinternet Limited. All rights reserved.
10 * Redistribution and use in source and binary forms are permitted only
11 * as authorized by the OpenLDAP Public License. A copy of this
12 * license is available at http://www.OpenLDAP.org/license.html or
13 * in file LICENSE in the top-level directory of the distribution.
18 #undef _ /* #defined by both Perl and ac/localize.h */
20 #ifdef HAVE_WIN32_ASPERL
21 #include "asperl_undefs.h"
30 #include "perl_back.h"
33 static void perl_back_xs_init LDAP_P((PERL_BACK_XS_INIT_PARAMS));
34 EXT void boot_DynaLoader LDAP_P((PERL_BACK_BOOT_DYNALOADER_PARAMS));
36 PerlInterpreter *PERL_INTERPRETER = NULL;
37 ldap_pvt_thread_mutex_t perl_interpreter_mutex;
39 #ifdef SLAPD_PERL_DYNAMIC
41 int init_module(int argc, char *argv[])
45 memset( &bi, '\0', sizeof(bi) );
47 bi.bi_init = perl_back_initialize;
53 #endif /* SLAPD_PERL_DYNAMIC */
56 /**********************************************************
60 **********************************************************/
67 char *embedding[] = { "", "-e", "0" };
69 Debug( LDAP_DEBUG_TRACE, "perl backend open\n", 0, 0, 0 );
71 if( PERL_INTERPRETER != NULL ) {
72 Debug( LDAP_DEBUG_ANY, "perl backend open: already opened\n",
77 PERL_INTERPRETER = perl_alloc();
78 perl_construct(PERL_INTERPRETER);
79 perl_parse(PERL_INTERPRETER, perl_back_xs_init, 3, embedding, (char **)NULL);
80 perl_run(PERL_INTERPRETER);
82 bi->bi_open = perl_back_open;
84 bi->bi_close = perl_back_close;
85 bi->bi_destroy = perl_back_destroy;
87 bi->bi_db_init = perl_back_db_init;
88 bi->bi_db_config = perl_back_db_config;
89 bi->bi_db_open = perl_back_db_open;
91 bi->bi_db_destroy = perl_back_db_destroy;
93 bi->bi_op_bind = perl_back_bind;
95 bi->bi_op_search = perl_back_search;
96 bi->bi_op_compare = perl_back_compare;
97 bi->bi_op_modify = perl_back_modify;
98 bi->bi_op_modrdn = perl_back_modrdn;
99 bi->bi_op_add = perl_back_add;
100 bi->bi_op_delete = perl_back_delete;
101 bi->bi_op_abandon = 0;
105 bi->bi_chk_referrals = 0;
107 bi->bi_connection_init = 0;
108 bi->bi_connection_destroy = 0;
118 ldap_pvt_thread_mutex_init( &perl_interpreter_mutex );
127 be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
128 memset( be->be_private, '\0', sizeof(PerlBackend));
130 ((PerlBackend *)be->be_private)->pb_filter_search_results = 0;
132 Debug( LDAP_DEBUG_TRACE, "perl backend db init\n", 0, 0, 0 );
145 PerlBackend *perl_back = (PerlBackend *) be->be_private;
147 ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
150 dSP; ENTER; SAVETMPS;
153 XPUSHs( perl_back->pb_obj_ref );
158 count = call_method("init", G_SCALAR);
160 count = perl_call_method("init", G_SCALAR);
166 croak("Big trouble in perl_back_db_open\n");
171 PUTBACK; FREETMPS; LEAVE;
174 ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
181 perl_back_xs_init(PERL_BACK_XS_INIT_PARAMS)
183 char *file = __FILE__;
185 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);