buffer.h revision c0435c854a0e7246373b9752d163095cc4fbe985
#ifndef __BUFFER_H
#define __BUFFER_H
/* Create a static sized buffer. Writes past this size will simply not
succeed. */
/* Create a static sized buffer. Writes past this size will kill the program. */
/* Create a modifyable buffer from given data. */
/* Create a non-modifyable buffer from given data. */
/* Creates a dynamically growing buffer. Whenever write would exceed the
current size it's grown. */
/* Free the memory used by buffer. Not needed if the memory is free'd
directly from the memory pool. */
/* Free the memory used by buffer structure, but return the buffer data
unfree'd. NOTE: Current start_pos doesn't affect the returned value. */
/* Write data to buffer at specified position, returns number of bytes
written. */
/* Append data to buffer, returns number of bytes written. */
/* Append character to buffer, returns 1 if written, 0 if not. */
/* Insert data to buffer, returns number of bytes inserted. */
/* Delete data from buffer, returns number of bytes deleted. */
/* Copy data from buffer to another. The buffers may be same in which case
it's internal copying, possibly with overlapping positions (ie. memmove()
like functionality). copy_size may be set to (size_t)-1 to copy the rest of
the used data in buffer. Returns the number of bytes actually copied. */
/* Append data to buffer from another. copy_size may be set to (size_t)-1 to
copy the rest of the used data in buffer. */
/* Returns pointer to specified position in buffer, or NULL if there's not
enough space. */
/* Increase the buffer usage by given size, and return a pointer to beginning
of it, or NULL if there's not enough space in buffer. */
/* Returns pointer to beginning of buffer data. Current used size of buffer is
stored in used_size if it's non-NULL. */
/* Like buffer_get_data(), but don't return it as const. Returns NULL if the
buffer is non-modifyable. */
/* Set the "used size" of buffer, ie. 0 would set the buffer empty.
Must not be used to grow buffer. */
/* Returns the current used buffer size. */
/* Change the buffer start position. The buffer acts as if data was removed or
inserted to beginning. Returns the old start position. */
/* Returns the current start position. */
/* Limit buffer size temporarily. All handling is treated as if this is the
current allocated memory size, except dynamic buffer won't be grown.
Setting the limit to (size_t)-1 removes it. Returns the old limit. */
/* Returns the current buffer limit, or (size_t)-1 if there's none. */
/* Returns the current buffer size. */
#endif