NAME

catbuf_extract - block read function for data buffers

SYNOPSIS

#include <cat.h>

int catbuf_extract(cat_buffer *b, int offset, int length, void *outbuf);

DESCRIPTION

catbuf_extract() extracts a range of bytes from buffer b, starting at offset, and stores them in the buffer pointed to by outbuf.

offset is relative to the beginning of the buffer and must therefore point to a valid position within the buffer.

If length is negative, all bytes up to the end of the buffer are extracted.

The extracted data is removed from buffer b. Removing data before the current index changes the index. If outbuf is NULL, the removed data is discarded.

catbuf_delete(), catbuf_insert(), and catbuf_extract() are block read/write functions for data buffers.

RETURN VALUES

This function returns the length of the extracted data, or a negative value on error.

SEE ALSO

cat, catbuf, catbuf_delete, catbuf_insert