20 #ifndef _das_buffer_h_
21 #define _das_buffer_h_
47 typedef struct das_buffer{
152 DasBuf* pThis,
int nIndent1,
int nIndent,
int nWrap,
const char* fmt, ...
276 DasBuf* pThis,
const char* sDelim,
size_t uDelimLen,
size_t* pLen
DAS_API size_t DasBuf_writeSpace(const DasBuf *pThis)
Get the remaining write space in the buffer.
DAS_API DasErrCode DasBuf_setReadOffset(DasBuf *pThis, size_t uPos)
Set the offset of the read position.
DAS_API DasErrCode DasBuf_initReadOnly(DasBuf *pThis, const char *sBuf, size_t uLen)
Initialize a read-only buffer than points to an external byte array.
DAS_API size_t DasBuf_readOffset(const DasBuf *pThis)
Get the offset of the read position.
DAS_API DasErrCode DasBuf_paragraph(DasBuf *pThis, int nIndent1, int nIndent, int nWrap, const char *fmt,...)
Write wrapped utf-8 text to the buffer.
DAS_API int DasBuf_writeFromSSL(DasBuf *pThis, void *vpSsl, size_t uLen)
Add generic data to the buffer from an OpenSSL object.
DAS_API int DasBuf_writeFrom(DasBuf *pThis, FILE *pIn, size_t uLen)
Add generic data to the buffer from a file.
DAS_API int DasBuf_writeFromSock(DasBuf *pThis, int nFd, size_t uLen)
Add generic data to the buffer from a socket.
DAS_API const char * DasBuf_readRec(DasBuf *pThis, const char *sDelim, size_t uDelimLen, size_t *pLen)
Return a pointer to the start of the current line and advance the read point to the start of the next...
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: defs.h:164
Buffer class to handle accumulating byte streams.
Definition: buffer.h:47
DAS_API size_t DasBuf_unread(const DasBuf *pThis)
Get the number of bytes remaining from the read begin point to the read end point.
DAS_API size_t DasBuf_written(const DasBuf *pThis)
Get the size of the data in the buffer.
DAS_API DasErrCode DasBuf_printf(DasBuf *pThis, const char *sFmt,...)
Write formatted strings to the buffer.
DAS_API void del_DasBuf(DasBuf *pThis)
Free a buffer object along with it's backing store.
DAS_API DasErrCode DasBuf_initReadWrite(DasBuf *pThis, char *sBuf, size_t uLen)
Initialize a read-write buffer that points to an external byte array.
DAS_API const ubyte * DasBuf_direct(const DasBuf *pThis, size_t *pLength)
Get a constant point to un-read bytes in the buffer and the number un-read.
DAS_API size_t DasBuf_strip(DasBuf *pThis)
Adjust read points so that the data starts and ends on non-space values.
DAS_API DasErrCode DasBuf_puts(DasBuf *pThis, const char *sStr)
Add a string to the buffer.
DAS_API void DasBuf_reinit(DasBuf *pThis)
Re-initialize a buffer including read and write points This version can be a little quicker than init...
DAS_API DasBuf * new_DasBuf(size_t uLen)
Create a new Read-Write buffer on the heap Allocates a new char buffer of the indicated size,...
DAS_API size_t DasBuf_peek(const DasBuf *pThis, char *pOut, size_t uOut)
Peak at bytes from a buffer Copies bytes out of a buffer but does not increment the read point.
DAS_API DasErrCode DasBuf_write(DasBuf *pThis, const void *pData, size_t uLen)
Add generic data to the buffer.
DAS_API int DasBuf_last(const DasBuf *pThis)
Peak the last byte in the buffer.
DAS_API size_t DasBuf_read(DasBuf *pThis, char *pOut, size_t uOut)
Read bytes from a buffer Copies bytes out of a buffer and increments the read point.