From e61d7dec5c96bef217ee39bbf6bae004dd6e957a Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 11 Mar 2005 16:28:37 +0000 Subject: [PATCH] piping to 'less' for long data git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@211 9efc2488-bf62-4759-914b-345cdb29e865 --- src/srfsh/srfsh.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index 126ff2a..1707992 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -1,9 +1,9 @@ #include "srfsh.h" - int main( int argc, char* argv[] ) { + /* --------------------------------------------- */ if( argc < 2 ) { @@ -331,6 +331,11 @@ int send_request( char* server, printf("\nReceived no data from server\n"); + signal(SIGPIPE, SIG_IGN); + + FILE* less = popen( "less -EX", "w"); + if( less == NULL ) { less = stdout; } + while(omsg) { if(omsg->result_content) { @@ -340,16 +345,16 @@ int send_request( char* server, if( pretty_print ) { char* content = json_printer( omsg->result_content ); - printf( "\nReceived Data: %s\n",content ); + fprintf( less, "\nReceived Data: %s\n",content ); free(content); } else { - printf( "\nReceived Data: %s\n", + fprintf( less, "\nReceived Data: %s\n", json_object_to_json_string(omsg->result_content)); } } else { - printf( "\nReceived Exception:\nName: %s\nStatus: " + fprintf( less, "\nReceived Exception:\nName: %s\nStatus: " "%s\nStatusCode %d\n", omsg->status_name, omsg->status_text, omsg->status_code ); } @@ -357,20 +362,23 @@ int send_request( char* server, omsg = osrf_app_session_request_recv( session, req_id, 5 ); } + double end = get_timestamp_millis(); - printf("\n------------------------------------\n"); + fprintf( less, "\n------------------------------------\n"); if( osrf_app_session_request_complete( session, req_id )) - printf("Request Completed Successfully\n"); + fprintf(less, "Request Completed Successfully\n"); - printf("Request Time in seconds: %.3f\n", end - start ); - printf("------------------------------------\n"); + fprintf(less, "Request Time in seconds: %.3f\n", end - start ); + fprintf(less, "------------------------------------\n"); osrf_app_session_request_finish( session, req_id ); osrf_app_session_disconnect( session ); osrf_app_session_destroy( session ); + pclose(less); + return 1; -- 2.11.0