]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/modrdn.c
2990c89e8da65838e5dc313e1fc9f6725db928f4
[openldap] / servers / slapd / back-perl / modrdn.c
1 /* $OpenLDAP$ */
2 /*
3  *       Copyright 1999, John C. Quillan, All rights reserved.
4  *       Portions Copyright 2002, myinternet pty ltd. All rights reserved.
5  *
6  *       Redistribution and use in source and binary forms are permitted only
7  *       as authorized by the OpenLDAP Public License.  A copy of this
8  *       license is available at http://www.OpenLDAP.org/license.html or
9  *       in file LICENSE in the top-level directory of the distribution.
10  */
11
12 /*
13  * LDAP v3 newSuperior support.
14  *
15  * Copyright 1999, Juan C. Gomez, All rights reserved.
16  * This software is not subject to any license of Silicon Graphics 
17  * Inc. or Purdue University.
18  *
19  * Redistribution and use in source and binary forms are permitted
20  * without restriction or fee of any kind as long as this notice
21  * is preserved.
22  *
23  */
24
25 #include "portable.h"
26
27 #include <stdio.h>
28 /*      #include <ac/types.h>
29         #include <ac/socket.h>
30 */
31
32 #include <EXTERN.h>
33 #include <perl.h>
34
35 #include "slap.h"
36 #include "perl_back.h"
37
38 int
39 perl_back_modrdn(
40         Backend *be,
41         Connection      *conn,
42         Operation       *op,
43         struct berval   *dn,
44         struct berval   *ndn,
45         struct berval   *newrdn,
46         struct berval   *nnewrdn,
47         int             deleteoldrdn,
48         struct berval   *newSuperior,
49         struct berval   *nnewSuperior
50 )
51 {
52         int len;
53         int count;
54         int return_code;
55
56         PerlBackend *perl_back = (PerlBackend *) be->be_private;
57
58         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
59
60         {
61                 dSP; ENTER; SAVETMPS;
62                 
63                 PUSHMARK(sp) ;
64                 XPUSHs( perl_back->pb_obj_ref );
65                 XPUSHs(sv_2mortal(newSVpv( dn->bv_val , 0 )));
66                 XPUSHs(sv_2mortal(newSVpv( newrdn->bv_val , 0 )));
67                 XPUSHs(sv_2mortal(newSViv( deleteoldrdn )));
68                 if ( newSuperior != NULL ) {
69                         XPUSHs(sv_2mortal(newSVpv( newSuperior->bv_val , 0 )));
70                 }
71                 PUTBACK ;
72
73 #ifdef PERL_IS_5_6
74                 count = call_method("modrdn", G_SCALAR);
75 #else
76                 count = perl_call_method("modrdn", G_SCALAR);
77 #endif
78
79                 SPAGAIN ;
80
81                 if (count != 1) {
82                         croak("Big trouble in back_modrdn\n") ;
83                 }
84                                                          
85                 return_code = POPi;
86
87                 PUTBACK; FREETMPS; LEAVE ;
88         }
89
90         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
91         
92         send_ldap_result( conn, op, return_code,
93                 NULL, NULL, NULL, NULL );
94
95         Debug( LDAP_DEBUG_ANY, "Perl MODRDN\n", 0, 0, 0 );
96         return( 0 );
97 }