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.
29 lines
535 B
C
29 lines
535 B
C
#include "stralloc.h"
|
|
#include "buffer.h"
|
|
|
|
static ssize_t strallocwrite(int fd,char* buf,size_t len,void* myself) {
|
|
buffer* b=myself;
|
|
stralloc* sa=b->cookie;
|
|
sa->len+=len;
|
|
if (stralloc_readyplus(sa,1024)==0) return 0;
|
|
b->x=sa->s+sa->len;
|
|
b->p=0;
|
|
b->a=1024;
|
|
(void)fd;
|
|
(void)buf;
|
|
return (ssize_t)len;
|
|
}
|
|
|
|
int buffer_tosa(buffer* b,stralloc* sa) {
|
|
if (stralloc_ready(sa,1024)==0) return -1;
|
|
b->x=sa->s;
|
|
b->p=0;
|
|
b->n=0;
|
|
b->a=1024;
|
|
b->fd=0;
|
|
b->op=strallocwrite;
|
|
b->cookie=sa;
|
|
b->deinit=0;
|
|
return 0;
|
|
}
|