From: Andrew M. <fit...@us...> - 2006-02-24 21:47:12
|
Update of /cvsroot/radmind/radmind-assistant/rte In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11775 Modified Files: RXAuthRW.m Log Message: Support for reading twhich output. Index: RXAuthRW.m =================================================================== RCS file: /cvsroot/radmind/radmind-assistant/rte/RXAuthRW.m,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** RXAuthRW.m 7 Mar 2005 14:53:46 -0000 1.17 --- RXAuthRW.m 24 Feb 2006 21:47:04 -0000 1.18 *************** *** 42,45 **** --- 42,46 ---- #define TWRITE 1 #define FSDIFF 2 + #define TWHICH 3 extern int errno; *************** *** 145,148 **** --- 146,150 ---- case TWRITE: + case TWHICH: [ _rteController writeFinishedFromThreadWithID: [ self threadID ]]; break; *************** *** 169,172 **** --- 171,175 ---- NSArray *av; NSMutableArray *transcriptLines = nil; + NSMutableString *twhichOutput = nil; NSString *path = nil; *************** *** 259,272 **** } ! if ( action == FSDIFF ) { if (( rfp = fdopen( rfd[ 0 ], "r" )) == NULL ) { NSLog( @"fdopen %d failed: %s\n", rfd[ 0 ], strerror( errno )); return( -1 ); } ! FD_ZERO( &readmask ); ! if ( transcriptLines == nil ) { transcriptLines = [[ NSMutableArray alloc ] init ]; ! } for ( ;; ) { --- 262,280 ---- } ! if ( action == FSDIFF || action == TWHICH ) { if (( rfp = fdopen( rfd[ 0 ], "r" )) == NULL ) { NSLog( @"fdopen %d failed: %s\n", rfd[ 0 ], strerror( errno )); return( -1 ); } ! setbuf( rfp, NULL ); ! FD_ZERO( &readmask ); ! ! if ( transcriptLines == nil && action == FSDIFF ) { transcriptLines = [[ NSMutableArray alloc ] init ]; ! } else if ( twhichOutput == nil && action == TWHICH ) { ! twhichOutput = [[ NSMutableString alloc ] ! initWithCapacity: MAXPATHLEN ]; ! } for ( ;; ) { *************** *** 278,295 **** } ! if ( FD_ISSET( rfd[ 0 ], &readmask )) { ! if ( fgets( buf, ( MAXPATHLEN * 2 ), rfp ) == NULL ) break; ! [ transcriptLines addObject: [ NSMutableDictionary dictionaryForLine: ! [ NSString stringWithUTF8String: buf ]]]; ! ! if ( [ transcriptLines count ] % 100 == 0 ) { ! /* sending mutable objects between threads is risky */ ! [ rxt addLines: [ NSArray arrayWithArray: transcriptLines ] ! fromThreadWithID: [ self threadID ]]; ! [ transcriptLines removeAllObjects ]; ! } ! } } ! if ( [ transcriptLines count ] ) { [ rxt addLines: [ NSArray arrayWithArray: transcriptLines ] fromThreadWithID: [ self threadID ]]; --- 286,315 ---- } ! if ( ! FD_ISSET( rfd[ 0 ], &readmask )) { ! break; ! } ! ! if ( fgets( buf, ( MAXPATHLEN * 2 ), rfp ) == NULL ) { ! if ( ferror( rfp )) { ! NSLog( @"fgets: %s", strerror( errno )); ! clearerr( rfp ); ! } ! break; ! } ! if ( action == FSDIFF ) { ! [ transcriptLines addObject: [ NSMutableDictionary dictionaryForLine: ! [ NSString stringWithUTF8String: buf ]]]; ! ! if ( [ transcriptLines count ] % 100 == 0 ) { ! /* sending mutable objects between threads is risky */ ! [ rxt addLines: [ NSArray arrayWithArray: transcriptLines ] ! fromThreadWithID: [ self threadID ]]; ! [ transcriptLines removeAllObjects ]; ! } ! } else if ( action == TWHICH ) { ! [ twhichOutput appendFormat: @"%s", buf ]; ! } } ! if ( action == FSDIFF && [ transcriptLines count ] ) { [ rxt addLines: [ NSArray arrayWithArray: transcriptLines ] fromThreadWithID: [ self threadID ]]; *************** *** 301,306 **** if (( rr = read( efd[ 0 ], buf, ( MAXPATHLEN * 2 ))) <= 0 ) break; buf[ rr ] = '\0'; ! [ rxt readError: buf fromThreadWithID: [ self threadID ]]; ! memset( buf, '\0', strlen( buf )); } if ( rr < 0 ) { --- 321,352 ---- if (( rr = read( efd[ 0 ], buf, ( MAXPATHLEN * 2 ))) <= 0 ) break; buf[ rr ] = '\0'; ! ! #ifdef notdef ! /* getpass(3) puts the prompt on stderr if /dev/tty isn't available */ ! if ( command == LCREATE && strcmp( "password:", buf ) == 0 ) { ! NSString *pass = [ rxt retrievePassword ]; ! const unsigned char *c_pass = [ pass UTF8String ]; ! ! if ( pass && ( strlen( c_pass ) > 0 )) { ! if ( write( wfd[ 1 ], c_pass, strlen( c_pass )) != strlen( c_pass )) { ! [ rxt readError: "wrote wrong number of bytes" ! fromThreadWithID: [ self threadID ]]; ! break; ! } ! } ! if ( write( wfd[ 1 ], "\n", strlen( "\n" )) != strlen( "\n" )) { ! [ rxt readError: "wrote wrong number of bytes" ! fromThreadWithID: [ self threadID ]]; ! break; ! } ! ! /* XXX logging */ ! } else { ! [ rxt readError: buf fromThreadWithID: [ self threadID ]]; ! memset( buf, '\0', strlen( buf )); ! } ! #endif notdef ! [ rxt readError: buf fromThreadWithID: [ self threadID ]]; ! memset( buf, '\0', strlen( buf )); } if ( rr < 0 ) { *************** *** 314,322 **** pid = wait( &status ); ! if ( action == TREAD ) { path = [ av objectAtIndex: 5 ]; [ rxt readTranscriptCopyAtPath: path threadID: [ self threadID ]]; ! } else if ( action == FSDIFF ) { [ rxt addLines: transcriptLines fromThreadWithID: [ self threadID ]]; } --- 360,380 ---- pid = wait( &status ); ! switch ( action ) { ! case TREAD: path = [ av objectAtIndex: 5 ]; [ rxt readTranscriptCopyAtPath: path threadID: [ self threadID ]]; ! break; ! ! case FSDIFF: [ rxt addLines: transcriptLines fromThreadWithID: [ self threadID ]]; + break; + + case TWHICH: + [ rxt displayTwhichOutput: [ NSString stringWithString: twhichOutput ] + fromThreadWithID: [ self threadID ]]; + break; + + default: + break; } *************** *** 325,328 **** --- 383,390 ---- } + if ( twhichOutput != nil ) { + [ twhichOutput release ]; + } + return( WEXITSTATUS( status )); } |