david/ipxe
Archived
1
0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/tests/linebuf_test.c
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00

36 lines
910 B
C

#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <ipxe/linebuf.h>
static const char data1[] =
"Hello world\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";
void linebuf_test ( void ) {
struct line_buffer linebuf;
const char *data = data1;
size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ );
ssize_t frag_len;
char *line;
memset ( &linebuf, 0, sizeof ( linebuf ) );
while ( len ) {
frag_len = line_buffer ( &linebuf, data, len );
if ( frag_len < 0 ) {
printf ( "line_buffer() failed: %s\n",
strerror ( frag_len ) );
return;
}
data += frag_len;
len -= frag_len;
if ( ( line = buffered_line ( &linebuf ) ) )
printf ( "\"%s\"\n", line );
}
empty_line_buffer ( &linebuf );
}