]> git.sur5r.net Git - openldap/blob - servers/slapd/back-shell/compare.c
Const'ification
[openldap] / servers / slapd / back-shell / compare.c
1 /* compare.c - shell backend compare function */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/string.h>
13 #include <ac/socket.h>
14
15 #include "slap.h"
16 #include "shell.h"
17
18 int
19 shell_back_compare(
20     Backend     *be,
21     Connection  *conn,
22     Operation   *op,
23     const char  *dn,
24     const char  *ndn,
25     Ava         *ava
26 )
27 {
28         struct shellinfo        *si = (struct shellinfo *) be->be_private;
29         FILE                    *rfp, *wfp;
30
31         if ( si->si_compare == NULL ) {
32                 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
33                     "compare not implemented", NULL, NULL );
34                 return( -1 );
35         }
36
37         if ( (op->o_private = (void *) forkandexec( si->si_compare, &rfp, &wfp ))
38             == (void *) -1 ) {
39                 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
40                     "could not fork/exec", NULL, NULL );
41                 return( -1 );
42         }
43
44         /* write out the request to the compare process */
45         fprintf( wfp, "COMPARE\n" );
46         fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
47         print_suffixes( wfp, be );
48         fprintf( wfp, "dn: %s\n", dn );
49         fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );
50         fclose( wfp );
51
52         /* read in the result and send it along */
53         read_and_send_results( be, conn, op, rfp, NULL, 0 );
54
55         fclose( rfp );
56         return( 0 );
57 }