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