xref: /netbsd-src/external/bsd/openldap/dist/servers/slapd/back-perl/delete.c (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1 /*	$NetBSD: delete.c,v 1.1.1.2 2010/03/08 02:14:20 lukem Exp $	*/
2 
3 /* OpenLDAP: pkg/ldap/servers/slapd/back-perl/delete.c,v 1.20.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 
22 int
23 perl_back_delete(
24 	Operation	*op,
25 	SlapReply	*rs )
26 {
27 	PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
28 	int count;
29 
30 #if defined(HAVE_WIN32_ASPERL) || defined(USE_ITHREADS)
31 	PERL_SET_CONTEXT( PERL_INTERPRETER );
32 #endif
33 	ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
34 
35 	{
36 		dSP; ENTER; SAVETMPS;
37 
38 		PUSHMARK(sp);
39 		XPUSHs( perl_back->pb_obj_ref );
40 		XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , 0 )));
41 
42 		PUTBACK;
43 
44 #ifdef PERL_IS_5_6
45 		count = call_method("delete", G_SCALAR);
46 #else
47 		count = perl_call_method("delete", G_SCALAR);
48 #endif
49 
50 		SPAGAIN;
51 
52 		if (count != 1) {
53 			croak("Big trouble in perl-back_delete\n");
54 		}
55 
56 		rs->sr_err = POPi;
57 
58 		PUTBACK; FREETMPS; LEAVE;
59 	}
60 
61 	ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
62 
63 	send_ldap_result( op, rs );
64 
65 	Debug( LDAP_DEBUG_ANY, "Perl DELETE\n", 0, 0, 0 );
66 	return( 0 );
67 }
68