![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Simple [io] buffer declarations and operations. More...
Go to the source code of this file.
Classes | |
| struct | SimpleBuf_T |
Macros | |
| #define | SIMPLEBUF_ABS 0 |
| absolute | |
| #define | SIMPLEBUF_REL 1 |
| relative | |
Functions | |
| SimpleBuf_T * | SimpleBufNew () |
| Allocate a new simple buffer with no internal buffer allocation. More... | |
| SimpleBuf_T * | SimpleBufNewWithBuf (size_t nBufSize) |
| Allocate a new simple buffer with internal buffer of nBufSize. More... | |
| void | SimpleBufDelete (SimpleBuf_T *pBuf) |
| Delete a simple buffer along with the internal buffer. More... | |
| void | SimpleBufSetBuf (SimpleBuf_T *pBuf, byte_t *pRWBuf, size_t nBufSize, size_t nLen) |
| Set simple buffer's internal read/write buffer. More... | |
| size_t | SimpleBufCopy (SimpleBuf_T *pTgt, SimpleBuf_T *pSrc) |
| Copy contents of source simple buffer to the end of the target simple buffer. More... | |
| static void | SimpleBufClear (SimpleBuf_T *pBuf) |
| Clear contents of buffer. More... | |
| static size_t | SimpleBufReadSeek (SimpleBuf_T *pBuf, size_t rpos, int how) |
| Seek buffer read head to the new read position. More... | |
| static size_t | SimpleBufWriteSeek (SimpleBuf_T *pBuf, size_t wpos, int how) |
| Seek buffer write head to the new write position. More... | |
| static size_t | SimpleBufHasSize (SimpleBuf_T *pBuf) |
| Returns size of buffer. More... | |
| static bool_t | SimpleBufIsEmpty (SimpleBuf_T *pBuf) |
| Test if simple buffer is empty. More... | |
| static bool_t | SimpleBufIsFull (SimpleBuf_T *pBuf) |
| Test if simple buffer is full. More... | |
| static size_t | SimpleBufHasLen (SimpleBuf_T *pBuf) |
| Returns number of bytes currently in buffer. More... | |
| static size_t | SimpleBufHasAvail (SimpleBuf_T *pBuf) |
| Returns number of bytes available in buffer for writing. More... | |
| static byte_t * | SimpleBufGetReadPtr (SimpleBuf_T *pBuf) |
| Returns pointer to internal I/O buffer at the current read position. More... | |
| static byte_t * | SimpleBufGetWritePtr (SimpleBuf_T *pBuf) |
| Returns pointer to internal I/O buffer at the current write position. More... | |
| static int | SimpleBufGetC (SimpleBuf_T *pBuf) |
| Gets byte from buffer at current read position, advancing read position. More... | |
| static int | SimpleBufPutC (SimpleBuf_T *pBuf, byte_t c) |
| Puts byte into buffer at current write position, advancing write position. More... | |
Simple [io] buffer declarations and operations.
The buffer is orgainized as a simple linear buffer with independent read and write positions. Ideal for multi-tasking.
* [----------buffer-----------------] * ^ ^ ^ * RPos WPos BufSize *
—
Definition in file simplebuf.h.
|
inlinestatic |
Clear contents of buffer.
| pBuf | Pointer to simple buffer. |
Definition at line 89 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, and SimpleBuf_T::m_nWPos.
Referenced by SocketBufClear().
| size_t SimpleBufCopy | ( | SimpleBuf_T * | pTgt, |
| SimpleBuf_T * | pSrc | ||
| ) |
Copy contents of source simple buffer to the end of the target simple buffer.
| pTgt | Pointer to target simple buffer. |
| pSrc | Pointer to source simple buffer. |
Return Value:
Definition at line 165 of file simplebuf.c.
References SimpleBuf_T::m_nBufSize, SimpleBuf_T::m_nRPos, SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, and NULL.
| void SimpleBufDelete | ( | SimpleBuf_T * | pBuf | ) |
Delete a simple buffer along with the internal buffer.
Actual deletion on occurs if buffer is owned by this simple buffer.
| pBuf | Pointer to simple buffer to be deleted. |
Definition at line 111 of file simplebuf.c.
References SimpleBuf_T::m_bBufDel, SimpleBuf_T::m_pRWBuf, and NULL.
Referenced by SocketBufNewBuf(), and SocketDelete().
|
inlinestatic |
Gets byte from buffer at current read position, advancing read position.
| pBuf | Pointer to simple buffer. |
Definition at line 227 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, SimpleBuf_T::m_pRWBuf, and SimpleBufIsEmpty().
|
inlinestatic |
Returns pointer to internal I/O buffer at the current read position.
| pBuf | Pointer to simple buffer. |
Definition at line 202 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, SimpleBuf_T::m_pRWBuf, NULL, and SimpleBufIsEmpty().
Referenced by SocketWrite().
|
inlinestatic |
Returns pointer to internal I/O buffer at the current write position.
| pBuf | Pointer to simple buffer. |
Definition at line 214 of file simplebuf.h.
References SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, NULL, and SimpleBufIsFull().
Referenced by SocketRead().
|
inlinestatic |
Returns number of bytes available in buffer for writing.
| pBuf | Pointer to simple buffer. |
Definition at line 190 of file simplebuf.h.
References SimpleBuf_T::m_nBufSize, and SimpleBuf_T::m_nWPos.
Referenced by SocketRead().
|
inlinestatic |
Returns number of bytes currently in buffer.
| pBuf | Pointer to simple buffer. |
Definition at line 178 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, and SimpleBuf_T::m_nWPos.
Referenced by SocketBufGetLen(), and SocketWrite().
|
inlinestatic |
Returns size of buffer.
| pBuf | Pointer to simple buffer. |
Definition at line 142 of file simplebuf.h.
References SimpleBuf_T::m_nBufSize.
Referenced by SocketBufGetSize().
|
inlinestatic |
Test if simple buffer is empty.
| pBuf | Pointer to simple buffer. |
Definition at line 154 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, and SimpleBuf_T::m_nWPos.
Referenced by SimpleBufGetC(), and SimpleBufGetReadPtr().
|
inlinestatic |
Test if simple buffer is full.
| pBuf | Pointer to simple buffer. |
Definition at line 166 of file simplebuf.h.
References SimpleBuf_T::m_nBufSize, and SimpleBuf_T::m_nWPos.
Referenced by SimpleBufGetWritePtr(), and SimpleBufPutC().
| SimpleBuf_T* SimpleBufNew | ( | ) |
Allocate a new simple buffer with no internal buffer allocation.
Definition at line 70 of file simplebuf.c.
References SimpleBuf_T::m_bBufDel, SimpleBuf_T::m_nBufSize, SimpleBuf_T::m_nRPos, SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, NEW, and NULL.
Referenced by SocketNew().
| SimpleBuf_T* SimpleBufNewWithBuf | ( | size_t | nBufSize | ) |
Allocate a new simple buffer with internal buffer of nBufSize.
| nBufSize | Size in bytes of internal buffer to allocate with simple buffer. |
Definition at line 91 of file simplebuf.c.
References SimpleBuf_T::m_bBufDel, SimpleBuf_T::m_nBufSize, SimpleBuf_T::m_nRPos, SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, and NEW.
Referenced by SocketBufNewBuf().
|
inlinestatic |
Puts byte into buffer at current write position, advancing write position.
| pBuf | Pointer to simple buffer. |
| c | Byte to put. |
Definition at line 245 of file simplebuf.h.
References C_DECLS_END, SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, and SimpleBufIsFull().
|
inlinestatic |
Seek buffer read head to the new read position.
| pBuf | Pointer to simple buffer. |
| rpos | New read position. |
| how | Seek to absolute position (default) or relative to current position. |
Definition at line 105 of file simplebuf.h.
References SimpleBuf_T::m_nRPos, SimpleBuf_T::m_nWPos, and SIMPLEBUF_REL.
Referenced by SocketWrite().
| void SimpleBufSetBuf | ( | SimpleBuf_T * | pBuf, |
| byte_t * | pRWBuf, | ||
| size_t | nBufSize, | ||
| size_t | nLen | ||
| ) |
Set simple buffer's internal read/write buffer.
| pBuf | Pointer to simple buffer. |
| pRWBuf | Pointer to buffer to be set as the internal read/write buffer. |
| nBufSize | Size in bytes of pRWBuf. |
| nLen | Current length (bytes) of data in pRWBuf. |
Definition at line 134 of file simplebuf.c.
References SimpleBuf_T::m_bBufDel, SimpleBuf_T::m_nBufSize, SimpleBuf_T::m_nRPos, SimpleBuf_T::m_nWPos, SimpleBuf_T::m_pRWBuf, and NULL.
Referenced by SocketBufSetBuf().
|
inlinestatic |
Seek buffer write head to the new write position.
| pBuf | Pointer to simple buffer. |
| wpos | New write position. |
| how | Seek to absolute position (default) or relative to current position. |
Definition at line 125 of file simplebuf.h.
References SimpleBuf_T::m_nBufSize, SimpleBuf_T::m_nWPos, and SIMPLEBUF_REL.
Referenced by SocketRead().