2 * Copyright 1999, John C. Quillan, All rights reserved.
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.
11 /* init.c - initialize shell backend */
14 /* #include <ac/types.h>
15 #include <ac/socket.h>
22 #include "perl_back.h"
25 /**********************************************************
29 **********************************************************/
40 PerlBackend *perl_back = (PerlBackend *) be->be_private;
41 char eval_str[EVAL_BUF_SIZE];
47 if ( strcasecmp( argv[0], "perlModule" ) == 0 ) {
49 Debug( LDAP_DEBUG_ANY,
50 "%s.pm: line %d: missing module in \"perlModule <module>\" line\n",
55 strncpy(eval_str, argv[1], EVAL_BUF_SIZE );
57 perl_require_pv( strcat( eval_str, ".pm" ));
59 if (SvTRUE(GvSV(errgv))) {
60 fprintf(stderr , "Error %s\n", SvPV(GvSV(errgv), na)) ;
65 XPUSHs(sv_2mortal(newSVpv(argv[1], 0)));
68 count = perl_call_method("new", G_SCALAR);
73 croak("Big trouble in config\n") ;
76 perl_back->pb_obj_ref = newSVsv(POPs);
78 PUTBACK; FREETMPS; LEAVE ;
81 } else if ( strcasecmp( argv[0], "perlModulePath" ) == 0 ) {
84 "%s: line %d: missing module in \"PerlModulePath <module>\" line\n",
89 sprintf( eval_str, "push @INC, '%s';", argv[1] );
90 loc_sv = perl_eval_pv( eval_str, 0 );
94 * Pass it to Perl module if defined
98 dSP ; ENTER ; SAVETMPS;
101 XPUSHs( perl_back->pb_obj_ref );
103 /* Put all arguments on the perl stack */
104 for( args = 0; args < argc; args++ ) {
105 XPUSHs(sv_2mortal(newSVpv(argv[args], 0)));
110 count = perl_call_method("config", G_SCALAR);
115 croak("Big trouble in config\n") ;
120 PUTBACK ; FREETMPS ; LEAVE ;
124 /* if the module rejected it then we should reject it */
125 if ( return_code != 0 ) {
127 "Unknown perl backeng config: %s\n", argv[0]);