2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2012 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"
20 /**********************************************************
24 **********************************************************/
30 PerlBackend *perl_back = (PerlBackend *)op->o_bd->be_private;
37 PERL_SET_CONTEXT( PERL_INTERPRETER );
38 ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
44 XPUSHs( perl_back->pb_obj_ref );
45 XPUSHs(sv_2mortal(newSVpv( op->o_req_ndn.bv_val , op->o_req_ndn.bv_len)));
46 XPUSHs(sv_2mortal(newSViv( op->ors_scope )));
47 XPUSHs(sv_2mortal(newSViv( op->ors_deref )));
48 XPUSHs(sv_2mortal(newSViv( op->ors_slimit )));
49 XPUSHs(sv_2mortal(newSViv( op->ors_tlimit )));
50 XPUSHs(sv_2mortal(newSVpv( op->ors_filterstr.bv_val , op->ors_filterstr.bv_len)));
51 XPUSHs(sv_2mortal(newSViv( op->ors_attrsonly )));
53 for ( an = op->ors_attrs; an && an->an_name.bv_val; an++ ) {
54 XPUSHs(sv_2mortal(newSVpv( an->an_name.bv_val , an->an_name.bv_len)));
58 count = call_method("search", G_ARRAY );
63 croak("Big trouble in back_search\n") ;
68 for ( i = 1; i < count; i++ ) {
72 if ( (e = str2entry( buf )) == NULL ) {
73 Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n", buf, 0, 0 );
78 if (perl_back->pb_filter_search_results)
79 send_entry = (test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE);
85 rs->sr_attrs = op->ors_attrs;
86 rs->sr_flags = REP_ENTRY_MODIFIABLE;
87 rs->sr_err = LDAP_SUCCESS;
88 rs->sr_err = send_search_entry( op, rs );
92 if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
103 * We grab the return code last because the stack comes
104 * from perl in reverse order.
106 * ex perl: return ( 0, $res_1, $res_2 );
108 * ex stack: <$res_2> <$res_1> <0>
114 PUTBACK; FREETMPS; LEAVE;
117 ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
119 send_ldap_result( op, rs );