mirror of https://github.com/ipxe/ipxe.git
Line buffer API changed a while ago
parent
1f24ba73c4
commit
01b3dd4fc3
|
@ -14,16 +14,19 @@ void linebuf_test ( void ) {
|
||||||
struct line_buffer linebuf;
|
struct line_buffer linebuf;
|
||||||
const char *data = data1;
|
const char *data = data1;
|
||||||
size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ );
|
size_t len = ( sizeof ( data1 ) - 1 /* be mean; strip the NUL */ );
|
||||||
|
ssize_t frag_len;
|
||||||
char *line;
|
char *line;
|
||||||
int rc;
|
|
||||||
|
|
||||||
memset ( &linebuf, 0, sizeof ( linebuf ) );
|
memset ( &linebuf, 0, sizeof ( linebuf ) );
|
||||||
while ( len ) {
|
while ( len ) {
|
||||||
if ( ( rc = line_buffer ( &linebuf, &data, &len ) ) != 0 ) {
|
frag_len = line_buffer ( &linebuf, data, len );
|
||||||
|
if ( frag_len < 0 ) {
|
||||||
printf ( "line_buffer() failed: %s\n",
|
printf ( "line_buffer() failed: %s\n",
|
||||||
strerror ( rc ) );
|
strerror ( frag_len ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
data += frag_len;
|
||||||
|
len -= frag_len;
|
||||||
if ( ( line = buffered_line ( &linebuf ) ) )
|
if ( ( line = buffered_line ( &linebuf ) ) )
|
||||||
printf ( "\"%s\"\n", line );
|
printf ( "\"%s\"\n", line );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue