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