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