From: Luke Howard Date: Fri, 27 Feb 2004 10:00:45 +0000 (+0000) Subject: Allow paged results to be requested without interaction by specifying X-Git-Tag: OPENLDAP_REL_ENG_2_2_BP~397 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f4e0802d5dd9f4b05757529616dfeca44f3936c6;p=openldap Allow paged results to be requested without interaction by specifying /false after the page result size (/true is still the default) --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index c5357c95a0..1ddcddf82c 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -108,7 +108,7 @@ usage( void ) #endif fprintf( stderr, _(" [!]mv= (matched values filter)\n")); #ifdef LDAP_CONTROL_PAGEDRESULTS - fprintf( stderr, _(" [!]pr= (paged results)\n")); + fprintf( stderr, _(" [!]pr=[/true|false] (paged results/prompt)\n")); #endif #ifdef LDAP_CONTROL_SUBENTRIES fprintf( stderr, _(" [!]subentries[=true|false] (subentries)\n")); @@ -195,6 +195,7 @@ static int sync_slimit = -1; #ifdef LDAP_CONTROL_PAGEDRESULTS static int pagedResults = 0; +static int pagePrompt = 1; static ber_int_t pageSize = 0; static ber_int_t entriesLeft = 0; static ber_int_t morePagedResults = 1; @@ -304,6 +305,20 @@ handle_private_option( int i ) } if( cvalue != NULL ) { + char *promptp; + + promptp = strchr( cvalue, '/' ); + if ( promptp != NULL ) { + *promptp++ = '\0'; + if ( strcasecmp( promptp, "true" ) == 0 ) { + pagePrompt = 1; + } else if ( strcasecmp( promptp, "false" ) == 0) { + pagePrompt = 0; + } else { + fprintf( stderr, _("Invalid value for PagedResultsControl, %s/%s.\n"), cvalue, promptp); + exit( EXIT_FAILURE ); + } + } num = sscanf( cvalue, "%d", &tmp ); if ( num != 1 ) { fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), cvalue); @@ -805,30 +820,32 @@ getNextPage: /* Loop to get the next pages when * enter is pressed on the terminal. */ - if ( entriesLeft > 0 ) { - printf( _("Estimate entries: %d\n"), entriesLeft ); - } - printf( _("Press [size] Enter for the next {%d|size} entries.\n"), - (int)pageSize ); - i = 0; - moreEntries = getchar(); - while ( moreEntries != EOF && moreEntries != '\n' ) { - if ( i < (int)sizeof(buf) - 1 ) { - buf[i] = moreEntries; - i++; + if ( pagePrompt != 0 ) { + if ( entriesLeft > 0 ) { + printf( _("Estimate entries: %d\n"), entriesLeft ); } + printf( _("Press [size] Enter for the next {%d|size} entries.\n"), + (int)pageSize ); + i = 0; moreEntries = getchar(); - } - buf[i] = '\0'; - - if ( i > 0 && isdigit( (unsigned char)buf[0] ) ) { - int num = sscanf( buf, "%d", &tmpSize ); - if ( num != 1 ) { - fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), buf); - return EXIT_FAILURE; + while ( moreEntries != EOF && moreEntries != '\n' ) { + if ( i < (int)sizeof(buf) - 1 ) { + buf[i] = moreEntries; + i++; + } + moreEntries = getchar(); + } + buf[i] = '\0'; + if ( i > 0 && isdigit( (unsigned char)buf[0] ) ) { + int num = sscanf( buf, "%d", &tmpSize ); + if ( num != 1 ) { + fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), buf); + return EXIT_FAILURE; + + } + pageSize = (ber_int_t)tmpSize; } - pageSize = (ber_int_t)tmpSize; } goto getNextPage;