]> the.earth.li Git - onak.git/blob - charfuncs.h
Fix compilation with later versions of Nettle
[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, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __CHARFUNCS_H__
21 #define __CHARFUNCS_H__
22
23 #include <stdlib.h>
24
25 /**
26  * @brief Shared with CGI buffer stuff...
27  */
28 struct buffer_ctx {
29         /** The data buffer. */
30         char *buffer;
31         /** Our current position in the buffer. */
32         size_t offset;
33         /** The size of the data buffer. */
34         size_t size;
35 };
36
37 /**
38  * @brief Fetches a char from a buffer.
39  * @param ctx Our buffer context structure.
40  * @param count The number of characters to get from the buffer.
41  * @param c Where to put the characters retrieved.
42  */
43 int buffer_fetchchar(void *ctx, size_t count, void *c);
44
45 /**
46  * @brief Puts a char to a buffer.
47  * @param ctx Our buffer context structure.
48  * @param count The number of characters to put into the buffer.
49  * @param c The characters to add to the buffer.
50  *
51  * Adds characters to the buffer references by the buffer context. If we
52  * fill it then we double the size of the current buffer and then add the
53  * rest.
54  */
55 int buffer_putchar(void *ctx, size_t count, void *c);
56
57 /**
58  * @brief Fetches a char from a file.
59  */
60 int file_fetchchar(void *fd, size_t count, void *c);
61
62 /**
63  * @brief Puts a char to a file.
64  */
65 int file_putchar(void *fd, size_t count, void *c);
66
67 /**
68  * @brief Gets a char from stdin.
69  */
70 int stdin_getchar(void *ctx, size_t count, void *c);
71
72 /**
73  * @brief Puts a char to stdout.
74  */
75 int stdout_putchar(void *ctx, size_t count, void *c);
76
77 #endif /* __CHARFUNCS_H__ */