3 * Copyright 1999, John C. Quillan, All rights reserved.
5 * Redistribution and use in source and binary forms are permitted only
6 * as authorized by the OpenLDAP Public License. A copy of this
7 * license is available at http://www.OpenLDAP.org/license.html or
8 * in file LICENSE in the top-level directory of the distribution.
12 /* init.c - initialize shell backend */
15 /* #include <ac/types.h>
16 #include <ac/socket.h>
23 #include "perl_back.h"
26 /**********************************************************
30 **********************************************************/
41 PerlBackend *perl_back = (PerlBackend *) be->be_private;
42 char eval_str[EVAL_BUF_SIZE];
48 if ( strcasecmp( argv[0], "perlModule" ) == 0 ) {
50 Debug( LDAP_DEBUG_ANY,
51 "%s.pm: line %d: missing module in \"perlModule <module>\" line\n",
56 strncpy(eval_str, argv[1], EVAL_BUF_SIZE );
58 perl_require_pv( strcat( eval_str, ".pm" ));
60 if (SvTRUE(GvSV(errgv))) {
61 fprintf(stderr , "Error %s\n", SvPV(GvSV(errgv), na)) ;
66 XPUSHs(sv_2mortal(newSVpv(argv[1], 0)));
69 count = perl_call_method("new", G_SCALAR);
74 croak("Big trouble in config\n") ;
77 perl_back->pb_obj_ref = newSVsv(POPs);
79 PUTBACK; FREETMPS; LEAVE ;
82 } else if ( strcasecmp( argv[0], "perlModulePath" ) == 0 ) {
85 "%s: line %d: missing module in \"PerlModulePath <module>\" line\n",
90 sprintf( eval_str, "push @INC, '%s';", argv[1] );
91 loc_sv = perl_eval_pv( eval_str, 0 );
95 * Pass it to Perl module if defined
99 dSP ; ENTER ; SAVETMPS;
102 XPUSHs( perl_back->pb_obj_ref );
104 /* Put all arguments on the perl stack */
105 for( args = 0; args < argc; args++ ) {
106 XPUSHs(sv_2mortal(newSVpv(argv[args], 0)));
111 count = perl_call_method("config", G_SCALAR);
116 croak("Big trouble in config\n") ;
121 PUTBACK ; FREETMPS ; LEAVE ;
125 /* if the module rejected it then we should reject it */
126 if ( return_code != 0 ) {
128 "Unknown perl backeng config: %s\n", argv[0]);
129 exit( EXIT_FAILURE );