From b4d2a542b50212a2d368358d44a063959ed293bb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 27 Feb 2008 22:53:26 -0500 Subject: [PATCH] Using polled reading and don't allow actual LPR-ing in debug mode * Source/AppController.m: ([AppController readChannel:]): Use libssh2_poll_channel_read() to check and see if there's more to read as it's much faster ([AppController uploadAndPrint:]): If BLU_DEBUG, do not LPR anything, but rather touch a file --- Source/AppController.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/AppController.m b/Source/AppController.m index 4cac97a..2a8c952 100644 --- a/Source/AppController.m +++ b/Source/AppController.m @@ -75,12 +75,12 @@ do { memset(&buf, '\0', sizeof(buf)); - sleep(1); numbytes = libssh2_channel_read(channel, buf, sizeof(buf)); + sleep(1); #ifdef BLU_DEBUG NSLog(@"buf: %s", buf); #endif - } while (numbytes > 0); + } while (libssh2_poll_channel_read(channel, 0)); } /** @@ -103,7 +103,6 @@ [progress setHidden:NO]; [status setHidden:NO]; - NSString *printer = [[printersController selection] valueForKey:@"unixName"]; FILE *localFile; struct stat fileInfo; @@ -207,7 +206,13 @@ [self readChannel:channel]; // send the job to lpr - char *cmd = (char *)[[NSString stringWithFormat:@"lpr -m -P%@ __bu_print_drop__.pdf\r\n\0", printer] UTF8String]; + char *cmd; +#ifndef BLU_DEBUG + NSString *printer = [[printersController selection] valueForKey:@"unixName"]; + cmd = (char *)[[NSString stringWithFormat:@"lpr -m -P%@ __bu_print_drop__.pdf\r\n\0", printer] UTF8String]; +#else + cmd = "touch abc.def\r\n\0"; +#endif libssh2_channel_write(channel, cmd, sizeof(char) * strlen(cmd)); [self readChannel:channel]; -- 2.22.5