diff options
author | Michael Brown <mcb30@etherboot.org> | 2007-01-12 18:09:14 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2007-01-12 18:09:14 +0000 |
commit | 83b7933f8a80e688579218450c4dbacc55c61309 (patch) | |
tree | 6f5dc0ee8c6e96d81d4641253a540617634c75d1 /src/tests | |
parent | ad22cccc0931a7275e497e1c625fe83e79d61d4e (diff) | |
download | ipxe-83b7933f8a80e688579218450c4dbacc55c61309.zip ipxe-83b7933f8a80e688579218450c4dbacc55c61309.tar.gz ipxe-83b7933f8a80e688579218450c4dbacc55c61309.tar.bz2 |
Damn it; my lovely resilient scheme falls down when you have a protocol
that switches from line-oriented to byte-oriented partway through, such as
HTTP.
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/linebuf_test.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/tests/linebuf_test.c b/src/tests/linebuf_test.c index 9ddbb75..31ce808 100644 --- a/src/tests/linebuf_test.c +++ b/src/tests/linebuf_test.c @@ -5,8 +5,8 @@ static const char data1[] = "Hello world\r\n" -"This is a particularly mean set of lines\n" -"with a mixture of terminators\r\r\n" +"This is a reasonably nice set of lines\n" +"with not many different terminators\r\n\r\n" "There should be exactly one blank line above\n" "and this line should never appear at all since it has no terminator"; @@ -14,13 +14,18 @@ void linebuf_test ( void ) { struct line_buffer linebuf; const char *data = data1; size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ ); - size_t buffered; + char *line; + int rc; memset ( &linebuf, 0, sizeof ( linebuf ) ); - while ( ( buffered = line_buffer ( &linebuf, data, len ) ) != len ) { - printf ( "\"%s\"\n", buffered_line ( &linebuf ) ); - data += buffered; - len -= buffered; + while ( len ) { + if ( ( rc = line_buffer ( &linebuf, &data, &len ) ) != 0 ) { + printf ( "line_buffer() failed: %s\n", + strerror ( rc ) ); + return; + } + if ( ( line = buffered_line ( &linebuf ) ) ) + printf ( "\"%s\"\n", line ); } empty_line_buffer ( &linebuf ); |