diff options
| author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:47:14 +0000 |
|---|---|---|
| committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:47:14 +0000 |
| commit | 3eaf4237194e25804f221af93c269d3d97e2809d (patch) | |
| tree | cdedf3fc954b0727b0b34aa9b0b211cc18f854eb /include/inn/buffer.h | |
| download | smartcardauth-3eaf4237194e25804f221af93c269d3d97e2809d.tar.gz smartcardauth-3eaf4237194e25804f221af93c269d3d97e2809d.zip | |
Added my SmartCard login/session lock/unlock utility
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smartcardauth@1097604 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'include/inn/buffer.h')
| -rw-r--r-- | include/inn/buffer.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/inn/buffer.h b/include/inn/buffer.h new file mode 100644 index 0000000..e9deb2b --- /dev/null +++ b/include/inn/buffer.h @@ -0,0 +1,48 @@ +/* $Id: buffer.h 6295 2003-04-16 05:46:38Z rra $ +** +** Counted, reusable memory buffer. +** +** A buffer is an allocated bit of memory with a known size and a separate +** data length. It's intended to store strings and can be reused repeatedly +** to minimize the number of memory allocations. Buffers increase in +** increments of 1K. +** +** A buffer contains a notion of the data that's been used and the data +** that's been left, used when the buffer is an I/O buffer where lots of data +** is buffered and then slowly processed out of the buffer. The total length +** of the data is used + left. If a buffer is just used to store some data, +** used can be set to 0 and left stores the length of the data. +*/ + +#ifndef INN_BUFFER_H +#define INN_BUFFER_H 1 + +#include <inn/defines.h> + +struct buffer { + size_t size; /* Total allocated length. */ + size_t used; /* Data already used. */ + size_t left; /* Remaining unused data. */ + char *data; /* Pointer to allocated memory. */ +}; + +BEGIN_DECLS + +/* Allocate a new buffer and initialize its contents. */ +struct buffer *buffer_new(void); + +/* Resize a buffer to be at least as large as the provided size. */ +void buffer_resize(struct buffer *, size_t); + +/* Set the buffer contents, ignoring anything currently there. */ +void buffer_set(struct buffer *, const char *data, size_t length); + +/* Append data to the buffer. */ +void buffer_append(struct buffer *, const char *data, size_t length); + +/* Swap the contents of two buffers. */ +void buffer_swap(struct buffer *, struct buffer *); + +END_DECLS + +#endif /* INN_BUFFER_H */ |
