A Buffer is a FIFO of bytes.
There are two ways to append data: append() and read(). Data in the buffer can be examined with operator or string(), removed with remove(), or written with write().
Generally, a buffer is used only to read or only to write. In the former case, its owner calls append() and EventLoop calls write(), and in the latter EventLoop calls read() and the object's owner calls remove() etc. However, its owner has the option of putting things into the buffer and later removing them. One class does use that: IMAPS.
Creates an empty Buffer.
Adds f to this Buffer, creating another Buffer behind f. All current contents are moved to the Buffer behind f.
This implies that for a read buffer, all unread contents will be filtered.
Appends the String s to a Buffer.
Appends l bytes starting at s to the Buffer. If l is 0 (the default), s is considered to be NUL-terminated.
This private function retrieves bytes that are not in the first Vector on behalf of operator(). It's kept here to make the inline function smaller. i is an internal variable, and this function should never be called except from the operator.
Have we encountered EOF when reading into this buffer?
Returns the errno value for the last error value encountered during IO on this Buffer, or 0 if there was no error.
Returns the byte at index i of the Buffer. Returns 0 if i is too large, or the buffer is empty.
Reads as much as possible from the file descriptor fd into the Buffer. It assumes that the file descriptor is nonblocking, and that enough memory is available.
Discards the first n bytes from the Buffer. If there are fewer than n bytes in the Buffer, the Buffer is left empty.
This function removes a line (terminated by LF or CRLF) of at most s bytes from the Buffer, and returns a pointer to a String with the line ending removed. If the Buffer does not contain a complete line less than s bytes long, this function a null pointer.
If s has its default value of 0, the entire Buffer is searched.
Returns the number of bytes in the Buffer.
Returns a string containing the first num bytes in the buffer. If the buffer contains fewer than num bytes, they are all returned. This function does not remove() the returned data.
Writes as much as possible from the Buffer to its file descriptor fd. That file descriptor must be nonblocking.
This web page based on source code belonging to Oryx Mail Systems GmbH. All rights reserved.