]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/compare.c
Import op -> slap_op , conn -> slap_conn change from rel eng 1.1.
[openldap] / servers / slapd / back-shell / compare.c
1 /* compare.c - shell backend compare 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 int
14 shell_back_compare(
15     Backend     *be,
16     Connection  *conn,
17     Operation   *op,
18     char        *dn,
19     Ava         *ava
20 )
21 {
22         struct shellinfo        *si = (struct shellinfo *) be->be_private;
23         FILE                    *rfp, *wfp;
24
25         if ( si->si_compare == NULL ) {
26                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
27                     "compare not implemented" );
28                 return( -1 );
29         }
30
31         if ( (op->o_private = forkandexec( si->si_compare, &rfp, &wfp ))
32             == -1 ) {
33                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
34                     "could not fork/exec" );
35                 return( -1 );
36         }
37
38         /* write out the request to the compare process */
39         fprintf( wfp, "COMPARE\n" );
40         fprintf( wfp, "msgid: %ld\n", op->o_msgid );
41         print_suffixes( wfp, be );
42         fprintf( wfp, "dn: %s\n", dn );
43         fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );
44         fclose( wfp );
45
46         /* read in the result and send it along */
47         read_and_send_results( be, conn, op, rfp, NULL, 0 );
48
49         fclose( rfp );
50         return( 0 );
51 }