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.
14 /* #include <ac/types.h>
15 #include <ac/socket.h>
22 #include "perl_back.h"
24 /**********************************************************
28 **********************************************************/
41 const char *filterstr,
49 char *matched = NULL, *info = NULL;
50 PerlBackend *perl_back = (PerlBackend *)be->be_private;
56 ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
62 XPUSHs( perl_back->pb_obj_ref );
63 XPUSHs(sv_2mortal(newSVpv( filterstr , 0)));
64 XPUSHs(sv_2mortal(newSViv( sizelimit )));
65 XPUSHs(sv_2mortal(newSViv( timelimit )));
66 XPUSHs(sv_2mortal(newSViv( attrsonly )));
68 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
69 XPUSHs(sv_2mortal(newSVpv( attrs[i] , 0)));
73 count = perl_call_method("search", G_ARRAY );
78 croak("Big trouble in back_search\n") ;
83 for ( i = 1; i < count; i++ ) {
87 if ( (e = str2entry( buf )) == NULL ) {
88 Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n", buf, 0, 0 );
91 send_search_entry( be, conn, op,
92 e, attrs, attrsonly, NULL );
100 * We grab the return code last because the stack comes
101 * from perl in reverse order.
103 * ex perl: return ( 0, $res_1, $res_2 );
105 * ex stack: <$res_2> <$res_1> <0>
112 PUTBACK; FREETMPS; LEAVE;
115 ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
117 if( return_code != 0 ) {
118 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
119 NULL, NULL, NULL, NULL );
122 send_ldap_result( conn, op, LDAP_SUCCESS,
123 NULL, NULL, NULL, NULL );