]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/delete.c
Add copyright notices
[openldap] / servers / slapd / back-shell / delete.c
1 /* delete.c - shell backend delete function */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/string.h>
13 #include <ac/socket.h>
14
15 #include "slap.h"
16 #include "shell.h"
17
18 int
19 shell_back_delete(
20     Backend     *be,
21     Connection  *conn,
22     Operation   *op,
23     char        *dn,
24     char        *ndn
25 )
26 {
27         struct shellinfo        *si = (struct shellinfo *) be->be_private;
28         FILE                    *rfp, *wfp;
29
30         if ( si->si_delete == NULL ) {
31                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
32                     "delete not implemented", NULL, NULL );
33                 return( -1 );
34         }
35
36         if ( (op->o_private = (void *) forkandexec( si->si_delete, &rfp, &wfp ))
37             == (void *) -1 ) {
38                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
39                     "could not fork/exec", NULL, NULL );
40                 return( -1 );
41         }
42
43         /* write out the request to the delete process */
44         fprintf( wfp, "DELETE\n" );
45         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
46         print_suffixes( wfp, be );
47         fprintf( wfp, "dn: %s\n", dn );
48         fclose( wfp );
49
50         /* read in the results and send them along */
51         read_and_send_results( be, conn, op, rfp, NULL, 0 );
52         fclose( rfp );
53         return( 0 );
54 }