]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/add.c
SLAPD compiles. Needs LDBM work to link.
[openldap] / servers / slapd / back-shell / add.c
1 /* add.c - shell backend add function */
2
3 #include "portable.h"
4
5 #include <stdio.h>
6
7 #include <ac/string.h>
8 #include <ac/socket.h>
9
10 #include "slap.h"
11 #include "shell.h"
12
13 extern pthread_mutex_t  entry2str_mutex;
14 extern char             *entry2str();
15
16 void
17 shell_back_add(
18     Backend     *be,
19     Connection  *conn,
20     Operation   *op,
21     Entry       *e
22 )
23 {
24         struct shellinfo        *si = (struct shellinfo *) be->be_private;
25         FILE                    *rfp, *wfp;
26         int                     len;
27
28         if ( si->si_add == NULL ) {
29                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
30                     "add not implemented" );
31                 return;
32         }
33
34         if ( (op->o_private = forkandexec( si->si_add, &rfp, &wfp )) == -1 ) {
35                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
36                     "could not fork/exec" );
37                 return;
38         }
39
40         /* write out the request to the add process */
41         fprintf( wfp, "ADD\n" );
42         fprintf( wfp, "msgid: %d\n", op->o_msgid );
43         print_suffixes( wfp, be );
44         pthread_mutex_lock( &entry2str_mutex );
45         fprintf( wfp, "%s", entry2str( e, &len, 0 ) );
46         pthread_mutex_unlock( &entry2str_mutex );
47         fclose( wfp );
48
49         /* read in the result and send it along */
50         read_and_send_results( be, conn, op, rfp, NULL, 0 );
51
52         fclose( rfp );
53 }