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.
21 #ifdef HAVE_WIN32_ASPERL
22 #include "asperl_undefs.h"
28 #include "perl_back.h"
31 /**********************************************************
35 **********************************************************/
46 PerlBackend *perl_back = (PerlBackend *) be->be_private;
47 char eval_str[EVAL_BUF_SIZE];
53 if ( strcasecmp( argv[0], "perlModule" ) == 0 ) {
55 Debug( LDAP_DEBUG_ANY,
56 "%s.pm: line %d: missing module in \"perlModule <module>\" line\n",
62 snprintf( eval_str, EVAL_BUF_SIZE, "use %s;", argv[1] );
63 eval_pv( eval_str, 0 );
68 fprintf(stderr , "Error %s\n", SvPV(ERRSV, n_a)) ;
71 snprintf( eval_str, EVAL_BUF_SIZE, "%s.pm", argv[1] );
72 perl_require_pv( eval_str );
74 if (SvTRUE(GvSV(errgv))) {
75 fprintf(stderr , "Error %s\n", SvPV(GvSV(errgv), na)) ;
77 #endif /* PERL_IS_5_6 */
81 XPUSHs(sv_2mortal(newSVpv(argv[1], 0)));
85 count = call_method("new", G_SCALAR);
87 count = perl_call_method("new", G_SCALAR);
93 croak("Big trouble in config\n") ;
96 perl_back->pb_obj_ref = newSVsv(POPs);
98 PUTBACK; FREETMPS; LEAVE ;
101 } else if ( strcasecmp( argv[0], "perlModulePath" ) == 0 ) {
104 "%s: line %d: missing module in \"PerlModulePath <module>\" line\n",
109 snprintf( eval_str, EVAL_BUF_SIZE, "push @INC, '%s';", argv[1] );
111 loc_sv = eval_pv( eval_str, 0 );
113 loc_sv = perl_eval_pv( eval_str, 0 );
116 /* XXX loc_sv return value is ignored. */
118 } else if ( strcasecmp( argv[0], "filterSearchResults" ) == 0 ) {
119 perl_back->pb_filter_search_results = 1;
122 * Pass it to Perl module if defined
126 dSP ; ENTER ; SAVETMPS;
129 XPUSHs( perl_back->pb_obj_ref );
131 /* Put all arguments on the perl stack */
132 for( args = 0; args < argc; args++ ) {
133 XPUSHs(sv_2mortal(newSVpv(argv[args], 0)));
139 count = call_method("config", G_SCALAR);
141 count = perl_call_method("config", G_SCALAR);
147 croak("Big trouble in config\n") ;
152 PUTBACK ; FREETMPS ; LEAVE ;
156 /* if the module rejected it then we should reject it */
157 if ( return_code != 0 ) {
159 "Unknown perl backend config: %s\n", argv[0]);
160 exit( EXIT_FAILURE );