20 #ifndef _das_buffer_h_
21 #define _das_buffer_h_
49 typedef struct das_buffer{
154 DasBuf* pThis,
int nIndent1,
int nIndent,
int nWrap,
const char* fmt, ...
246 DasBuf* pThis,
const char* sDelim,
size_t uDelimLen,
size_t* pLen
size_t DasBuf_written(const DasBuf *pThis)
Get the size of the data in the buffer.
size_t DasBuf_strip(DasBuf *pThis)
Adjust read points so that the data starts and ends on non-space values.
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
DasErrCode DasBuf_initReadWrite(DasBuf *pThis, char *sBuf, size_t uLen)
Initialize a read-write buffer that points to an external byte array.
size_t DasBuf_writeSpace(const DasBuf *pThis)
Get the remaining write space in the buffer.
void DasBuf_reinit(DasBuf *pThis)
Re-initialize a buffer including read and write points This version can be a little quicker than init...
DasErrCode DasBuf_puts(DasBuf *pThis, const char *sStr)
Add a string to the buffer.
DasErrCode DasBuf_write(DasBuf *pThis, const void *pData, size_t uLen)
Add generic data to the buffer.
Little buffer class to handle accumulating string data.
Definition: buffer.h:49
int DasBuf_writeFromSock(DasBuf *pThis, int nFd, size_t uLen)
Add generic data to the buffer from a socket.
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.
size_t DasBuf_readOffset(const DasBuf *pThis)
Get the offset of the read position.
DasErrCode DasBuf_setReadOffset(DasBuf *pThis, size_t uPos)
Set the offset of the read position.
int DasBuf_writeFrom(DasBuf *pThis, FILE *pIn, size_t uLen)
Add generic data to the buffer from a file.
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...
DasErrCode DasBuf_paragraph(DasBuf *pThis, int nIndent1, int nIndent, int nWrap, const char *fmt,...)
Write wrapped utf-8 text to the buffer.
DasBuf * new_DasBuf(size_t uLen)
Create a new Read-Write buffer on the heap Allocates a new char buffer of the indicated size...
DasErrCode DasBuf_initReadOnly(DasBuf *pThis, const char *sBuf, size_t uLen)
Initialize a read-only buffer than points to an external byte array.
size_t DasBuf_unread(const DasBuf *pThis)
Get the number of bytes remaining from the read begin point to the read end point.
int DasBuf_writeFromSSL(DasBuf *pThis, void *vpSsl, size_t uLen)
Add generic data to the buffer from an OpenSSL object.
DasErrCode DasBuf_printf(DasBuf *pThis, const char *sFmt,...)
Write formatted strings to the buffer.
void del_DasBuf(DasBuf *pThis)
Free a buffer object along with it's backing store.