]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/modrdn.c
32d9433af6cce16181b32923ae9a5742422c2caa
[openldap] / servers / slapd / back-perl / modrdn.c
1 /*
2  *       Copyright 1999, John C. Quillan, All rights reserved.
3  *
4  *       Redistribution and use in source and binary forms are permitted only
5  *       as authorized by the OpenLDAP Public License.  A copy of this
6  *       license is available at http://www.OpenLDAP.org/license.html or
7  *       in file LICENSE in the top-level directory of the distribution.
8  */
9
10 #include "portable.h"
11
12 #include <stdio.h>
13 /*      #include <ac/types.h>
14         #include <ac/socket.h>
15 */
16
17 #include <EXTERN.h>
18 #include <perl.h>
19
20 #include "slap.h"
21 #include "perl_back.h"
22
23 int
24 perl_back_modrdn(
25         Backend *be,
26         Connection      *conn,
27         Operation       *op,
28         char    *dn,
29         char    *newrdn,
30         int             deleteoldrdn
31 )
32 {
33         int len;
34         int count;
35         int return_code;
36
37         PerlBackend *perl_back = (PerlBackend *) be->be_private;
38
39         pthread_mutex_lock( &perl_interpreter_mutex );  
40
41         {
42                 dSP; ENTER; SAVETMPS;
43
44                 PUSHMARK(sp) ;
45                 XPUSHs( perl_back->pb_obj_ref );
46                 XPUSHs(sv_2mortal(newSVpv( dn , 0 )));
47                 XPUSHs(sv_2mortal(newSVpv( newrdn , 0 )));
48                 XPUSHs(sv_2mortal(newSViv( deleteoldrdn )));
49                 PUTBACK ;
50
51                 count = perl_call_method("modrdn", G_SCALAR);
52
53                 SPAGAIN ;
54
55                 if (count != 1) {
56                         croak("Big trouble in back_search\n") ;
57                 }
58                                                          
59                 return_code = POPi;
60
61                 PUTBACK; FREETMPS; LEAVE ;
62         }
63
64         pthread_mutex_unlock( &perl_interpreter_mutex );
65
66         if( return_code != 0 ) {
67                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
68
69         } else {
70                 send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
71         }
72
73         Debug( LDAP_DEBUG_ANY, "Perl MODRDN\n", 0, 0, 0 );
74         return( 0 );
75 }
76
77