2001-02-04 01:28:45 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
|
2009-02-28 00:07:55 +00:00
|
|
|
extern int buffer_stubborn_read(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
2001-02-04 01:28:45 +00:00
|
|
|
|
|
|
|
int buffer_feed(buffer* b) {
|
|
|
|
if (b->p==b->n) {
|
|
|
|
int w;
|
2009-02-28 00:07:55 +00:00
|
|
|
if ((w=buffer_stubborn_read(b->op,b->fd,b->x,b->a,b))<0)
|
2001-02-04 01:28:45 +00:00
|
|
|
return -1;
|
|
|
|
b->n=w;
|
|
|
|
b->p=0;
|
|
|
|
}
|
2001-02-05 20:28:33 +00:00
|
|
|
return (b->n-b->p);
|
2001-02-04 01:28:45 +00:00
|
|
|
}
|