/* IRCfs - IRC FileServ for *nix. * Copyright (C) 2002 Nick 'Zaf' Clifford * For licensing details, refer to the LICENSE file in the source * code directory. */ #ifndef __include_circbuf_h__ #define __include_circbuf_h__ #include "runtime.h" struct circbuf; struct circbuf *circbuf_create(POOL p, size_t bytes); /* Returns total size of buffer */ size_t circbuf_size(struct circbuf *cb); /* Returns num of bytes in buffer */ size_t circbuf_bytes(struct circbuf *cb); /* Returns num of free bytes in buffer */ size_t circbuf_remaining(struct circbuf *db); /* Resize the buffer if can */ int circbuf_resize(struct circbuf *cb, size_t newsize); /* Add these bytes to the buffer */ int circbuf_add(struct circbuf *cb, const char *data, size_t size); /* Get size bytes from buffer */ int circbuf_get(struct circbuf *cb, char *data, size_t size); /* Get bytes until ch from buffer */ int circbuf_get_till(struct circbuf *cb, char *data, size_t size, char ch); int circbuf_find_ch(struct circbuf *cb, char ch); /* Get size bytes from buffer, but don't pop the bytes off */ int circbuf_peek(struct circbuf *cb, char *data, size_t size); /* Manually pop size bytes from buffer */ int circbuf_pop(struct circbuf *cb, size_t size); void circbuf_destroy(struct circbuf *cb); #endif