2001-02-04 01:28:45 +00:00
|
|
|
#include "byte.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
|
2009-02-28 00:07:55 +00:00
|
|
|
extern int buffer_stubborn(ssize_t (*op)(),int fd,const char* buf, size_t len,void* cookie);
|
2001-02-04 01:28:45 +00:00
|
|
|
|
2006-11-07 17:56:05 +00:00
|
|
|
int buffer_put(buffer* b,const char* buf,size_t len) {
|
2001-11-25 22:37:38 +00:00
|
|
|
if (len>b->a-b->p) { /* doesn't fit */
|
2001-02-04 01:28:45 +00:00
|
|
|
if (buffer_flush(b)==-1) return -1;
|
2001-11-25 22:37:38 +00:00
|
|
|
if (len>b->a) {
|
2009-02-28 00:07:55 +00:00
|
|
|
if (buffer_stubborn(b->op,b->fd,buf,len,b)<0) return -1;
|
2001-02-04 01:28:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
byte_copy(b->x+b->p, len, buf);
|
|
|
|
b->p+=len;
|
|
|
|
return 0;
|
|
|
|
}
|