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