]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/add.c
8f41042c6e61fedf795249d1b1a91495ec3c80ae
[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 "portable.h"
17
18 #include <stdio.h>
19
20 #include "slap.h"
21 #ifdef HAVE_WIN32_ASPERL
22 #include "asperl_undefs.h"
23 #endif
24
25 #include <EXTERN.h>
26 #include <perl.h>
27
28 #include "perl_back.h"
29
30 int
31 perl_back_add(
32         Operation       *op,
33         SlapReply       *rs )
34 {
35         PerlBackend *perl_back = (PerlBackend *) op->o_bd->be_private;
36         int len;
37         int count;
38
39         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );
40         ldap_pvt_thread_mutex_lock( &entry2str_mutex );
41
42         {
43                 dSP; ENTER; SAVETMPS;
44
45                 PUSHMARK(sp);
46                 XPUSHs( perl_back->pb_obj_ref );
47                 XPUSHs(sv_2mortal(newSVpv( entry2str( op->ora_e, &len ), 0 )));
48
49                 PUTBACK;
50
51 #ifdef PERL_IS_5_6
52                 count = call_method("add", G_SCALAR);
53 #else
54                 count = perl_call_method("add", G_SCALAR);
55 #endif
56
57                 SPAGAIN;
58
59                 if (count != 1) {
60                         croak("Big trouble in back_add\n");
61                 }
62                                                          
63                 rs->sr_err = POPi;
64
65                 PUTBACK; FREETMPS; LEAVE;
66         }
67
68         ldap_pvt_thread_mutex_unlock( &entry2str_mutex );
69         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );        
70
71         send_ldap_result( op, rs );
72
73         Debug( LDAP_DEBUG_ANY, "Perl ADD\n", 0, 0, 0 );
74         return( 0 );
75 }