]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/delete.c
9bc51264686ff80073eae10ff08a0acd760d4aa3
[openldap] / servers / slapd / back-perl / delete.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1999-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  *       Copyright 1999, John C. Quillan, All rights reserved.
8  *       Portions Copyright 2002, myinternet Limited. All rights reserved.
9  *
10  *       Redistribution and use in source and binary forms are permitted only
11  *       as authorized by the OpenLDAP Public License.  A copy of this
12  *       license is available at http://www.OpenLDAP.org/license.html or
13  *       in file LICENSE in the top-level directory of the distribution.
14  */
15
16 #include <EXTERN.h>
17 #include <perl.h>
18 #undef _ /* #defined used by both Perl and ac/localize.h */
19
20 #ifdef HAVE_WIN32_ASPERL
21 #include "asperl_undefs.h"
22 #endif
23
24 #include "portable.h"
25
26 #include <stdio.h>
27
28 #include "slap.h"
29
30 #include "perl_back.h"
31
32 int
33 perl_back_delete(
34         Operation       *op,
35         SlapReply       *rs )
36 {
37         PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
38         int count;
39
40         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
41
42         {
43                 dSP; ENTER; SAVETMPS;
44
45                 PUSHMARK(sp);
46                 XPUSHs( perl_back->pb_obj_ref );
47                 XPUSHs(sv_2mortal(newSVpv( op->o_req_dn.bv_val , 0 )));
48
49                 PUTBACK;
50
51 #ifdef PERL_IS_5_6
52                 count = call_method("delete", G_SCALAR);
53 #else
54                 count = perl_call_method("delete", G_SCALAR);
55 #endif
56
57                 SPAGAIN;
58
59                 if (count != 1) {
60                         croak("Big trouble in perl-back_delete\n");
61                 }
62
63                 rs->sr_err = POPi;
64
65                 PUTBACK; FREETMPS; LEAVE;
66         }
67
68         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
69
70         send_ldap_result( op, rs );
71
72         Debug( LDAP_DEBUG_ANY, "Perl DELETE\n", 0, 0, 0 );
73         return( 0 );
74 }