|
|
@ -2,11 +2,18 @@
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
|
|
|
|
|
|
|
|
int buffer_get(buffer* b,char* x,unsigned long int len) {
|
|
|
|
int buffer_get(buffer* b,char* x,unsigned long int len) {
|
|
|
|
|
|
|
|
unsigned long done;
|
|
|
|
int blen;
|
|
|
|
int blen;
|
|
|
|
if ((blen=buffer_feed(b))<0) return blen;
|
|
|
|
done=0;
|
|
|
|
if ((unsigned long int) blen>=len)
|
|
|
|
while (len) {
|
|
|
|
blen=len;
|
|
|
|
if ((blen=buffer_feed(b))<=0) return blen;
|
|
|
|
byte_copy(x,blen,b->x+b->p);
|
|
|
|
if ((unsigned long int) blen>=len)
|
|
|
|
b->p+=blen;
|
|
|
|
blen=len;
|
|
|
|
return blen;
|
|
|
|
byte_copy(x,blen,b->x+b->p);
|
|
|
|
|
|
|
|
b->p+=blen;
|
|
|
|
|
|
|
|
len-=blen;
|
|
|
|
|
|
|
|
x+=blen;
|
|
|
|
|
|
|
|
done+=blen;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|