22static ssize_t buffer_0_read(
int fd,
char *buf,
size_t len)
25 return read(fd,buf,len);
30 return (ssize_t)
read(fd,buf,len);
35 return (ssize_t) write(fd,buf,len);
77static int oneread(ssize_t (*op)(),
int fd,
char *buf,
size_t len)
83 if (r == -1)
if (errno == EINTR)
continue;
88static int getthis(
buffer *s,
char *buf,
size_t len)
90 if (len > s->
p) len = s->
p;
101 if (s->
p)
return s->
p;
102 r = oneread(s->
op,s->
fd,s->
x,s->
n);
103 if (r <= 0)
return r;
114 if (s->
p > 0)
return getthis(s,buf,len);
115 if (s->
n <= len)
return oneread(s->
op,s->
fd,buf,s->
n);
117 if (r <= 0)
return r;
118 return getthis(s,buf,len);
125 if (s->
p > 0)
return getthis(s,buf,len);
126 if (s->
n <= len)
return oneread(s->
op,s->
fd,buf,len);
128 if (r <= 0)
return r;
129 return getthis(s,buf,len);
143static int allwrite(ssize_t (*op)(),
int fd,
const char *buf,
size_t len)
150 if (errno == EINTR)
continue;
168 return allwrite(s->
op,s->
fd,s->
x,p);
175 while (len > (n = s->
n - s->
p)) {
176 byte_copy(s->
x + s->
p,n,buf); s->
p += n; buf += n; len -= n;
190 if (len > n - s->
p) {
195 if (n > len) n = len;
196 if (allwrite(s->
op,s->
fd,buf,n) == -1)
return -1;
210 return allwrite(s->
op,s->
fd,buf,len);
int read(int _str, void *_buf, int _b)
char buffer_2_space[BUFFER_OUTSIZE]
char buffer_0_small[BUFFER_SMALL]
int buffer_putalign(buffer *s, const char *buf, size_t len)
int buffer_get(buffer *s, char *buf, size_t len)
ssize_t buffer_unixread(int fd, char *buf, size_t len)
int buffer_putsflush(buffer *s, const char *buf)
void buffer_init(buffer *s, ssize_t(*op)(), int fd, char *buf, size_t len)
char buffer_2_small[BUFFER_SMALL]
int buffer_putflush(buffer *s, const char *buf, size_t len)
int buffer_copy(buffer *bout, buffer *bin)
char buffer_1_space[BUFFER_OUTSIZE]
int buffer_puts(buffer *s, const char *buf)
char buffer_0_space[BUFFER_INSIZE]
char buffer_1_small[BUFFER_SMALL]
int buffer_flush(buffer *s)
int buffer_bget(buffer *s, char *buf, size_t len)
void buffer_seek(buffer *s, size_t len)
ssize_t buffer_unixwrite(int fd, char *buf, size_t len)
int buffer_put(buffer *s, const char *buf, size_t len)
int buffer_feed(buffer *s)
int buffer_putsalign(buffer *s, const char *buf)
char * buffer_peek(buffer *s)
#define BUFFER_INIT(op, fd, buf, len)
#define buffer_SEEK(s, len)
void byte_copy(void *, unsigned int, const void *)
void byte_copyr(void *, unsigned int, const void *)
unsigned int str_len(const char *)