/* * sbuf.h * * A string buffer library. * * Header file. * * Author: Dario Rodriguez dario@softhome.net * This library is licensed on the terms of the GNU LGPL v2+ */ #ifndef SBUF_H #define SBUF_H typedef struct { long used; long got; long size; char *buf; } sbuf; /* sbuf, high level api */ sbuf *sbuf_init(long bufsize); sbuf *sbuf_staticinit(sbuf *uninitsbuf, long bufsize, char *buf); void sbuf_free(sbuf *buf); void sbuf_staticfree(sbuf *buf); int sbuf_fill(sbuf *buf, int fd, long numbytes); char *sbuf_getline(sbuf *buf); void sbuf_discard(sbuf *buf); void sbuf_wipe(sbuf *buf); /* sbuf, additional functionality */ char *sbuf_getbytes(sbuf *buf, long numbytes); long sbuf_count(sbuf *buf); char *sbuf_ptr(sbuf *buf); long sbuf_add(sbuf *buf, const char *data, long datasize); long sbuf_addstr(sbuf *buf, const char *str); long sbuf_unused(sbuf *buf); char *sbuf_ptrunused(sbuf *buf); long sbuf_addfromunused(sbuf *buf, long numbytes); long sbuf_send(sbuf *buf, int fd, long numbytes); #endif