You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
442 B
C

#include "byte.h"
#include "buffer.h"
ssize_t buffer_get(buffer* b,char* x,size_t len) {
ssize_t done;
ssize_t blen;
done=0;
if ((ssize_t)len < 0) len=(ssize_t)(((size_t)-1)>>1);
while (len) {
if ((blen=buffer_feed(b))<=0) return blen;
if (blen>=(ssize_t)len)
blen=(ssize_t)len;
byte_copy(x,(size_t)blen,b->x+b->p);
b->p+=(size_t)blen;
len-=(size_t)blen;
x+=blen;
done+=blen;
}
return done;
}