1 /* result.c - shell backend result reading function */
4 * Copyright 1998-2002 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(
37 /* read in the result and send it along */
38 buf = (char *) ch_malloc( BUFSIZ );
44 if ( fgets( line, sizeof(line), fp ) == NULL ) {
45 if ( errno == EINTR ) continue;
47 Debug( LDAP_DEBUG_ANY, "shell: fgets failed: %s (%d)\n",
48 strerror(errno), errno, 0 );
52 Debug( LDAP_DEBUG_SHELL, "shell search reading line (%s)\n",
55 /* ignore lines beginning with # (LDIFv1 comments) */
60 /* ignore lines beginning with DEBUG: */
61 if ( strncasecmp( line, "DEBUG:", 6 ) == 0 ) {
66 while ( bp + len - buf > bsize ) {
67 size_t offset = bp - buf;
69 buf = (char *) ch_realloc( buf, bsize );
75 /* line marked the end of an entry or result */
76 if ( *line == '\n' ) {
77 if ( strncasecmp( buf, "RESULT", 6 ) == 0 ) {
81 if ( (e = str2entry( buf )) == NULL ) {
82 Debug( LDAP_DEBUG_ANY, "str2entry(%s) failed\n",
85 send_search_entry( be, conn, op, e,
86 attrs, attrsonly, NULL );
93 (void) str2result( buf, &err, &matched, &info );
95 /* otherwise, front end will send this result */
96 if ( err != 0 || op->o_tag != LDAP_REQ_BIND ) {
97 send_ldap_result( conn, op, err, matched, info, NULL, NULL );
113 for ( i = 0; be->be_suffix[i] != NULL; i++ ) {
114 fprintf( fp, "suffix: %s\n", be->be_suffix[i]->bv_val );