Add initial Doxygen support
[onak.git] / charfuncs.h
1 /**
2  * @file charfuncs.h
3  * @brief Routines for dealing with character streams.
4  *
5  * Copyright 2002 Jonathan McDowell <noodles@earth.li>
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 51
18  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef __CHARFUNCS_H__
22 #define __CHARFUNCS_H__
23
24 #include <stdlib.h>
25
26 /**
27  * @brief Shared with CGI buffer stuff...
28  */
29 struct buffer_ctx {
30         /** The data buffer. */
31         char *buffer;
32         /** Our current position in the buffer. */
33         size_t offset;
34         /** The size of the data buffer. */
35         size_t size;
36 };
37
38 /**
39  * @brief Fetches a char from a buffer.
40  * @param ctx Our buffer context structure.
41  * @param count The number of characters to get from the buffer.
42  * @param c Where to put the characters retrieved.
43  */
44 int buffer_fetchchar(void *ctx, size_t count, void *c);
45
46 /**
47  * @brief Puts a char to a buffer.
48  * @param ctx Our buffer context structure.
49  * @param count The number of characters to put into the buffer.
50  * @param c The characters to add to the buffer.
51  *
52  * Adds characters to the buffer references by the buffer context. If we
53  * fill it then we double the size of the current buffer and then add the
54  * rest.
55  */
56 int buffer_putchar(void *ctx, size_t count, void *c);
57
58 /**
59  * @brief Fetches a char from a file.
60  */
61 int file_fetchchar(void *fd, size_t count, void *c);
62
63 /**
64  * @brief Puts a char to a file.
65  */
66 int file_putchar(void *fd, size_t count, void *c);
67
68 /**
69  * @brief Gets a char from stdin.
70  */
71 int stdin_getchar(void *ctx, size_t count, void *c);
72
73 /**
74  * @brief Puts a char to stdout.
75  */
76 int stdout_putchar(void *ctx, size_t count, void *c);
77
78 #endif /* __CHARFUNCS_H__ */