2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-23 19:51:46 +00:00

Line buffer API changed a while ago

This commit is contained in:
Michael Brown 2007-07-03 21:21:50 +01:00
parent 1f24ba73c4
commit 01b3dd4fc3

View File

@ -14,16 +14,19 @@ 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;
int rc;
memset ( &linebuf, 0, sizeof ( linebuf ) );
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",
strerror ( rc ) );
strerror ( frag_len ) );
return;
}
data += frag_len;
len -= frag_len;
if ( ( line = buffered_line ( &linebuf ) ) )
printf ( "\"%s\"\n", line );
}