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.
17 #ifdef HAVE_WIN32_ASPERL
18 #include "asperl_undefs.h"
24 #include "perl_back.h"
27 /**********************************************************
31 **********************************************************/
42 PerlBackend *perl_back = (PerlBackend *) be->be_private;
43 char eval_str[EVAL_BUF_SIZE];
49 if ( strcasecmp( argv[0], "perlModule" ) == 0 ) {
51 Debug( LDAP_DEBUG_ANY,
52 "%s.pm: line %d: missing module in \"perlModule <module>\" line\n",
58 snprintf( eval_str, EVAL_BUF_SIZE, "use %s;", argv[1] );
59 eval_pv( eval_str, 0 );
64 fprintf(stderr , "Error %s\n", SvPV(ERRSV, n_a)) ;
67 snprintf( eval_str, EVAL_BUF_SIZE, "%s.pm", argv[1] );
68 perl_require_pv( eval_str );
70 if (SvTRUE(GvSV(errgv))) {
71 fprintf(stderr , "Error %s\n", SvPV(GvSV(errgv), na)) ;
73 #endif /* PERL_IS_5_6 */
77 XPUSHs(sv_2mortal(newSVpv(argv[1], 0)));
81 count = call_method("new", G_SCALAR);
83 count = perl_call_method("new", G_SCALAR);
89 croak("Big trouble in config\n") ;
92 perl_back->pb_obj_ref = newSVsv(POPs);
94 PUTBACK; FREETMPS; LEAVE ;
97 } else if ( strcasecmp( argv[0], "perlModulePath" ) == 0 ) {
100 "%s: line %d: missing module in \"PerlModulePath <module>\" line\n",
105 snprintf( eval_str, EVAL_BUF_SIZE, "push @INC, '%s';", argv[1] );
107 loc_sv = eval_pv( eval_str, 0 );
109 loc_sv = perl_eval_pv( eval_str, 0 );
112 /* XXX loc_sv return value is ignored. */
114 } else if ( strcasecmp( argv[0], "filterSearchResults" ) == 0 ) {
115 perl_back->pb_filter_search_results = 1;
118 * Pass it to Perl module if defined
122 dSP ; ENTER ; SAVETMPS;
125 XPUSHs( perl_back->pb_obj_ref );
127 /* Put all arguments on the perl stack */
128 for( args = 0; args < argc; args++ ) {
129 XPUSHs(sv_2mortal(newSVpv(argv[args], 0)));
135 count = call_method("config", G_SCALAR);
137 count = perl_call_method("config", G_SCALAR);
143 croak("Big trouble in config\n") ;
148 PUTBACK ; FREETMPS ; LEAVE ;
152 /* if the module rejected it then we should reject it */
153 if ( return_code != 0 ) {
155 "Unknown perl backend config: %s\n", argv[0]);
156 exit( EXIT_FAILURE );