compare.c revision 1.1.1.2
1/* $NetBSD: compare.c,v 1.1.1.2 2010/03/08 02:14:20 lukem Exp $ */ 2 3/* OpenLDAP: pkg/ldap/servers/slapd/back-perl/compare.c,v 1.26.2.4 2009/01/22 00:01:09 kurt Exp */ 4/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 5 * 6 * Copyright 1999-2009 The OpenLDAP Foundation. 7 * Portions Copyright 1999 John C. Quillan. 8 * Portions Copyright 2002 myinternet Limited. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted only as authorized by the OpenLDAP 13 * Public License. 14 * 15 * A copy of this license is available in file LICENSE in the 16 * top-level directory of the distribution or, alternatively, at 17 * <http://www.OpenLDAP.org/license.html>. 18 */ 19 20#include "perl_back.h" 21#include "lutil.h" 22 23/********************************************************** 24 * 25 * Compare 26 * 27 **********************************************************/ 28 29int 30perl_back_compare( 31 Operation *op, 32 SlapReply *rs ) 33{ 34 int count; 35 char *avastr; 36 37 PerlBackend *perl_back = (PerlBackend *)op->o_bd->be_private; 38 39 avastr = ch_malloc( op->orc_ava->aa_desc->ad_cname.bv_len + 1 + 40 op->orc_ava->aa_value.bv_len + 1 ); 41 42 lutil_strcopy( lutil_strcopy( lutil_strcopy( avastr, 43 op->orc_ava->aa_desc->ad_cname.bv_val ), "=" ), 44 op->orc_ava->aa_value.bv_val ); 45 46#if defined(HAVE_WIN32_ASPERL) || defined(USE_ITHREADS) 47 PERL_SET_CONTEXT( PERL_INTERPRETER ); 48#endif 49 ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex ); 50 51 { 52 dSP; ENTER; SAVETMPS; 53 54 PUSHMARK(sp); 55 XPUSHs( perl_back->pb_obj_ref ); 56 XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , 0))); 57 XPUSHs(sv_2mortal(newSVpv( avastr , 0))); 58 PUTBACK; 59 60#ifdef PERL_IS_5_6 61 count = call_method("compare", G_SCALAR); 62#else 63 count = perl_call_method("compare", G_SCALAR); 64#endif 65 66 SPAGAIN; 67 68 if (count != 1) { 69 croak("Big trouble in back_compare\n"); 70 } 71 72 rs->sr_err = POPi; 73 74 PUTBACK; FREETMPS; LEAVE; 75 } 76 77 ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex ); 78 79 ch_free( avastr ); 80 81 send_ldap_result( op, rs ); 82 83 Debug( LDAP_DEBUG_ANY, "Perl COMPARE\n", 0, 0, 0 ); 84 85 return (0); 86} 87 88