C-Kermit INPUT /NOWRAP Command

One thing that INPUT was never able to do well was read and save the complete incoming data stream. That's because, while waiting for its target, the buffer might overflow wrap around. Yet there was not a way to tell it to stop when its buffer fills up and let me save it. In C-Kermit 8.0.212 Dev.07 (1 Dec 2005) I added a /NOWRAP switch that does this. If the buffer fills up before any other completion criterion is met, INPUT (or MINPUT) returns failure, but with \v(instatus) set to 6 (the next available instatus value). Thus a program that wants to read and save (say) an email message from a POP server, which could be any length at all, and which terminates with <CRLF>.<CRLF> could do this:

set flag off
while open connection {
    input /nowrap 10 \13\10.\13\10 # Wait for <CRLF>.<CRLF>
    if success {
	frwrite /string \%o {\freplace(\v(input),\13\10.\13\10,\13\10)}
	set flag on
	break
    } else if ( == \v(instatus) 6 || == \v(instatus) 1 ) {
	frwrite /string \%o {\v(input)}
	continue
    }
    break
}
if flag (handle success)

Note carefully the braces around the FWRITE text; without them, trailing spaces would be lost. Also note that the IF condition that checks \v(instatus) could be written more simply as:

} else if match \v(instatus) [16] {

Previously the only way to INPUT an entire data stream without losing anything (assuming it was ordinary lines of text that were not "too long"), was line-by-line (as in this example where we want to copy everything up to the next "$" prompt to a file):

while open connection {
    input /clear 10 \13\10
    if fail break
    if eq "\v(input)" "\13\10$\32" break
    fwrite /string \%o {\freplace(\v(input),\13\10,\10)}
}

The new code is 3 times faster using the default INPUT buffer length of 4K. Raising it to 16K makes it 3.6 times faster (not worth it). Changing the POP3 script to use INPUT /NOWRAP makes it about twice as fast (it does more; it has to do all the byte-stuffing and unstuffing).

The POP script that prompted the addition of INPUT /NOWRAP is in production and can be seen HERE. C-Kermit makes an excellent POP client because of:

For reference, here is a current list of INPUT status codes:

\v(instatus) Meaning
0 Success
1 Timed out
2 User interrupted from keyboard
3 Internal error
4 I/O error or connection lost
5 Internet Kermit Service active, INPUT disabled
6 Buffer full and /NOWRAP specified

fdc@columbia.edu, 3 Dec 2005.

[ C-Kermit Daily Builds ]   [ C-Kermit Home ]   [ Kermit Home ]


C-Kermit Daily Source Code / The Kermit Project / Columbia University / kermit@columbia.edu