1 /* result.c - shell backend result reading function */
4 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
15 #include <ac/unistd.h>
21 read_and_send_results(
30 /* read in the result and send it along */
31 buf = (char *) ch_malloc( BUFSIZ );
37 if ( fgets( line, sizeof(line), fp ) == NULL ) {
38 if ( errno == EINTR ) continue;
40 Debug( LDAP_DEBUG_ANY, "shell: fgets failed: %s (%d)\n",
41 strerror(errno), errno, 0 );
45 Debug( LDAP_DEBUG_SHELL, "shell search reading line (%s)\n",
48 /* ignore lines beginning with # (LDIFv1 comments) */
53 /* ignore lines beginning with DEBUG: */
54 if ( strncasecmp( line, "DEBUG:", 6 ) == 0 ) {
59 while ( bp + len - buf > bsize ) {
60 size_t offset = bp - buf;
62 buf = (char *) ch_realloc( buf, bsize );
68 /* line marked the end of an entry or result */
69 if ( *line == '\n' ) {
70 if ( strncasecmp( buf, "RESULT", 6 ) == 0 ) {
74 if ( (rs->sr_entry = str2entry( buf )) == NULL ) {
75 Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n",
78 rs->sr_attrs = op->oq_search.rs_attrs;
79 send_search_entry( op, rs );
80 entry_free( rs->sr_entry );
86 (void) str2result( buf, &rs->sr_err, (char **)&rs->sr_matched, (char **)&rs->sr_text );
88 /* otherwise, front end will send this result */
89 if ( rs->sr_err != 0 || op->o_tag != LDAP_REQ_BIND ) {
90 send_ldap_result( op, rs );
106 for ( i = 0; be->be_suffix[i].bv_val != NULL; i++ ) {
107 fprintf( fp, "suffix: %s\n", be->be_suffix[i].bv_val );