]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/add.c
Changes from HEAD for beta
[openldap] / servers / slapd / back-perl / add.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_add(
34         Operation       *op,
35         SlapReply       *rs )
36 {
37         PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
38         int len;
39         int count;
40
41         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
42         ldap_pvt_thread_mutex_lock( &entry2str_mutex );
43
44         {
45                 dSP; ENTER; SAVETMPS;
46
47                 PUSHMARK(sp);
48                 XPUSHs( perl_back->pb_obj_ref );
49                 XPUSHs(sv_2mortal(newSVpv( entry2str( op->ora_e, &len ), 0 )));
50
51                 PUTBACK;
52
53 #ifdef PERL_IS_5_6
54                 count = call_method("add", G_SCALAR);
55 #else
56                 count = perl_call_method("add", G_SCALAR);
57 #endif
58
59                 SPAGAIN;
60
61                 if (count != 1) {
62                         croak("Big trouble in back_add\n");
63                 }
64                                                          
65                 rs->sr_err = POPi;
66
67                 PUTBACK; FREETMPS; LEAVE;
68         }
69
70         ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
71         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
72
73         send_ldap_result( op, rs );
74
75         Debug( LDAP_DEBUG_ANY, "Perl ADD\n", 0, 0, 0 );
76         return( 0 );
77 }