X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/340e776784a8902d43e6c4658c45254202e2779e..62078c1601192c2594b954a122ac44a0c319c9bd:/charfuncs.h diff --git a/charfuncs.h b/charfuncs.h new file mode 100644 index 0000000..f394e15 --- /dev/null +++ b/charfuncs.h @@ -0,0 +1,57 @@ +/* + * charfuncs.h - Routines for dealing with character streams. + * + * Jonathan McDowell + * + * Copyright 2002 Project Purple + */ + +#ifndef __CHARFUNCS_H__ +#define __CHARFUNCS_H__ + +#include + +/** + * buffer_ctx - Shared with CGI buffer stuff... + * @buffer: The data buffer. + * @offset: Our current position in the buffer. + * @size: The size of the data buffer. + */ +struct buffer_ctx { + char *buffer; + int offset; + int size; +}; + +/** + * buffer_fetchchar - Fetches a char from a buffer. + * @ctx: Our buffer context structure. + * @count: The number of characters to get from the buffer. + * @c: Where to put the characters retrieved. + */ +int buffer_fetchchar(void *ctx, size_t count, unsigned char *c); + +/** + * buffer_putchar - Puts a char to a buffer. + * @ctx: Our buffer context structure. + * @count: The number of characters to put into the buffer. + * @c: The characters to add to the buffer. + * + * Adds characters to the buffer references by the buffer context. If we + * fill it then we double the size of the current buffer and then add the + * rest. + */ +int buffer_putchar(void *ctx, size_t count, unsigned char *c); + +/** + * file_fetchchar - Fetches a char from a file. + */ +int file_fetchchar(void *fd, size_t count, unsigned char *c); + +/** + * file_putchar - Puts a char to a file. + */ +int file_putchar(void *fd, size_t count, unsigned char *c); + + +#endif /* __CHARFUNCS_H__ */