]> git.sur5r.net Git - openldap/blob - servers/slapd/back-perl/modrdn.c
5fa8bca1231fd552ad7ec091a74e58685a138537
[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 /*
11  * LDAP v3 newSuperior support.
12  *
13  * Copyright 1999, Juan C. Gomez, All rights reserved.
14  * This software is not subject to any license of Silicon Graphics 
15  * Inc. or Purdue University.
16  *
17  * Redistribution and use in source and binary forms are permitted
18  * without restriction or fee of any kind as long as this notice
19  * is preserved.
20  *
21  */
22
23 #include "portable.h"
24
25 #include <stdio.h>
26 /*      #include <ac/types.h>
27         #include <ac/socket.h>
28 */
29
30 #include <EXTERN.h>
31 #include <perl.h>
32
33 #include "slap.h"
34 #include "perl_back.h"
35
36 int
37 perl_back_modrdn(
38         Backend *be,
39         Connection      *conn,
40         Operation       *op,
41         char    *dn,
42         char    *newrdn,
43         int             deleteoldrdn,
44         char    *newSuperior
45 )
46 {
47         int len;
48         int count;
49         int return_code;
50
51         PerlBackend *perl_back = (PerlBackend *) be->be_private;
52
53         ldap_pvt_thread_mutex_lock( &perl_interpreter_mutex );  
54
55         {
56                 dSP; ENTER; SAVETMPS;
57                 
58                 PUSHMARK(sp) ;
59                 XPUSHs( perl_back->pb_obj_ref );
60                 XPUSHs(sv_2mortal(newSVpv( dn , 0 )));
61                 XPUSHs(sv_2mortal(newSVpv( newrdn , 0 )));
62                 XPUSHs(sv_2mortal(newSViv( deleteoldrdn )));
63                 if ( newSuperior != NULL ) {
64                         XPUSHs(sv_2mortal(newSVpv( newSuperior , 0 )));
65                 }
66                 PUTBACK ;
67
68                 count = perl_call_method("modrdn", G_SCALAR);
69
70                 SPAGAIN ;
71
72                 if (count != 1) {
73                         croak("Big trouble in back_search\n") ;
74                 }
75                                                          
76                 return_code = POPi;
77
78                 PUTBACK; FREETMPS; LEAVE ;
79         }
80
81         ldap_pvt_thread_mutex_unlock( &perl_interpreter_mutex );
82         
83         if( return_code != 0 ) {
84                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
85                         NULL, NULL, NULL, NULL );
86
87         } else {
88                 send_ldap_result( conn, op, LDAP_SUCCESS,
89                         NULL, NULL, NULL, NULL );
90         }
91
92         Debug( LDAP_DEBUG_ANY, "Perl MODRDN\n", 0, 0, 0 );
93         return( 0 );
94 }
95
96