1 /* $OpenLDAP: pkg/ldap/servers/slapd/back-perl/config.c,v 1.22.2.3 2008/02/11 23:26:47 kurt Exp $ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2008 The OpenLDAP Foundation.
5 * Portions Copyright 1999 John C. Quillan.
6 * Portions Copyright 2002 myinternet Limited.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 #include "perl_back.h"
21 /**********************************************************
25 **********************************************************/
36 PerlBackend
*perl_back
= (PerlBackend
*) be
->be_private
;
37 char eval_str
[EVAL_BUF_SIZE
];
43 if ( strcasecmp( argv
[0], "perlModule" ) == 0 ) {
45 Debug( LDAP_DEBUG_ANY
,
46 "%s.pm: line %d: missing module in \"perlModule <module>\" line\n",
52 snprintf( eval_str
, EVAL_BUF_SIZE
, "use %s;", argv
[1] );
53 eval_pv( eval_str
, 0 );
58 fprintf(stderr
, "Error %s\n", SvPV(ERRSV
, n_a
)) ;
61 snprintf( eval_str
, EVAL_BUF_SIZE
, "%s.pm", argv
[1] );
62 perl_require_pv( eval_str
);
64 if (SvTRUE(GvSV(errgv
))) {
65 fprintf(stderr
, "Error %s\n", SvPV(GvSV(errgv
), na
)) ;
67 #endif /* PERL_IS_5_6 */
71 XPUSHs(sv_2mortal(newSVpv(argv
[1], 0)));
75 count
= call_method("new", G_SCALAR
);
77 count
= perl_call_method("new", G_SCALAR
);
83 croak("Big trouble in config\n") ;
86 perl_back
->pb_obj_ref
= newSVsv(POPs
);
88 PUTBACK
; FREETMPS
; LEAVE
;
91 } else if ( strcasecmp( argv
[0], "perlModulePath" ) == 0 ) {
94 "%s: line %d: missing module in \"PerlModulePath <module>\" line\n",
99 snprintf( eval_str
, EVAL_BUF_SIZE
, "push @INC, '%s';", argv
[1] );
101 loc_sv
= eval_pv( eval_str
, 0 );
103 loc_sv
= perl_eval_pv( eval_str
, 0 );
106 /* XXX loc_sv return value is ignored. */
108 } else if ( strcasecmp( argv
[0], "filterSearchResults" ) == 0 ) {
109 perl_back
->pb_filter_search_results
= 1;
111 return_code
= SLAP_CONF_UNKNOWN
;
113 * Pass it to Perl module if defined
117 dSP
; ENTER
; SAVETMPS
;
120 XPUSHs( perl_back
->pb_obj_ref
);
122 /* Put all arguments on the perl stack */
123 for( args
= 0; args
< argc
; args
++ ) {
124 XPUSHs(sv_2mortal(newSVpv(argv
[args
], 0)));
130 count
= call_method("config", G_SCALAR
);
132 count
= perl_call_method("config", G_SCALAR
);
138 croak("Big trouble in config\n") ;
143 PUTBACK
; FREETMPS
; LEAVE
;