#include <util.h>
Classes | |
| class | packet |
Public Member Functions | |
| stream_buffer (char *buf, size_t buf_length) | |
| Construct a buffer, but take over ownership of the buffer passed. | |
| size_t | size () const |
| Get the total number of bytes stored in the stream_buffer. | |
| size_t | write (const text &str) |
| Write a text string to the buffer. | |
| size_t | write (const char *data, size_t sz) |
| Write bytes to the buffer. | |
| size_t | read (char *data, size_t sz) |
| Read from the buffer. | |
| void | putBack (char *data, size_t sz) |
| Put back previously read bytes to the buffer. | |
| ssize_t | dump (int fh) |
| Read from the buffer and write directly to a file handle. | |
| size_t | write_URL_encoded (const char *data, size_t sz) |
| Write data as URL-encoded form. | |
| size_t | read_URL_encoded (char *data, size_t sz) |
| Read from the buffer, assuming the buffer is storing URL-encoded data. | |
| ssize_t | find (char c, size_t from) const |
| Find the offset into the buffer where the first instance of the given character is. | |
| void | read_URL_params (vector< pair< text, text > > ¶ms) |
| ssize_t | find (const text &boundary, size_t from) const |
| Find the offset into the buffer where the first instance of the text string is is. | |
| ssize_t | skip_to_multipart_form_data (const text &boundary) |
| This method skips to the beginning of the next multipart-form-data buffer and reports its size. | |
| void | write_to_ostream (ostream &out) const |
| Write the entire buffer to an output stream. | |
| void | write_to_ostream (text &out) const |
| Write the entire buffer to a text string object. | |
Rather than continually realloc a buffer and memcpy, this simply keeps a vector of the various buffers as they were read in.
| karoo::stream_buffer::stream_buffer | ( | char * | buf, | |
| size_t | buf_length | |||
| ) |
Construct a buffer, but take over ownership of the buffer passed.
This means that the stream_buffer destructor will free up the memory (which it assumes was allocated using new).
| buf | the data which this stream_buffer will take ownership of | |
| buf_length | the length of the data. Note that the memory pointed to by buf will be delete[]ed by the stream_buffer object when it is destroyed, so the caller MUST NOT free up the memory, and the memory MUST NOT be on the stack. |
| ssize_t karoo::stream_buffer::dump | ( | int | fh | ) |
Read from the buffer and write directly to a file handle.
| fh | the file handle to write to |
| ssize_t karoo::stream_buffer::find | ( | const text & | boundary, | |
| size_t | from | |||
| ) | const |
Find the offset into the buffer where the first instance of the text string is is.
This is used for getting the offset of a multipart-form-data boundary.
| boundary | the string to look for | |
| from | the offset to start searching from. |
| ssize_t karoo::stream_buffer::find | ( | char | c, | |
| size_t | from | |||
| ) | const |
Find the offset into the buffer where the first instance of the given character is.
| c | the character to look for | |
| from | the offset to start searching from. |
| void karoo::stream_buffer::putBack | ( | char * | data, | |
| size_t | sz | |||
| ) |
Put back previously read bytes to the buffer.
| data | the data buffer | |
| sz | the total number of bytes |
| size_t karoo::stream_buffer::read | ( | char * | data, | |
| size_t | sz | |||
| ) |
Read from the buffer.
| data | a data buffer where the characters can be received. | |
| sz | the total number of bytes that the data buffer can receive |
| size_t karoo::stream_buffer::read_URL_encoded | ( | char * | data, | |
| size_t | sz | |||
| ) |
Read from the buffer, assuming the buffer is storing URL-encoded data.
| data | a data buffer where the characters can be received. | |
| sz | the total number of bytes that the data buffer can receive |
| size_t karoo::stream_buffer::size | ( | ) | const |
| ssize_t karoo::stream_buffer::skip_to_multipart_form_data | ( | const text & | boundary | ) |
This method skips to the beginning of the next multipart-form-data buffer and reports its size.
| boundary | the string used by the multipart-form-data as a boundary between buffers. |
| size_t karoo::stream_buffer::write | ( | const char * | data, | |
| size_t | sz | |||
| ) |
Write bytes to the buffer.
| data | the bytes to be written | |
| sz | the number of bytes to be written |
| size_t karoo::stream_buffer::write | ( | const text & | str | ) |
| void karoo::stream_buffer::write_to_ostream | ( | text & | out | ) | const |
| void karoo::stream_buffer::write_to_ostream | ( | ostream & | out | ) | const |
Write the entire buffer to an output stream.
| out | the output stream. |
| size_t karoo::stream_buffer::write_URL_encoded | ( | const char * | data, | |
| size_t | sz | |||
| ) |
Write data as URL-encoded form.
| data | the bytes to be written | |
| sz | the number of bytes to be written |
1.5.8