cscvs to tla changeset 97
[onak.git] / charfuncs.h
1 /*
2  * charfuncs.h - Routines for dealing with character streams.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2002 Project Purple
7  *
8  * $Id: charfuncs.h,v 1.3 2003/09/30 17:15:39 noodles Exp $
9  */
10
11 #ifndef __CHARFUNCS_H__
12 #define __CHARFUNCS_H__
13
14 #include <stdlib.h>
15
16 /**
17  *      buffer_ctx - Shared with CGI buffer stuff...
18  *      @buffer: The data buffer.
19  *      @offset: Our current position in the buffer.
20  *      @size: The size of the data buffer.
21  */
22 struct buffer_ctx {
23         char *buffer;
24         int offset;
25         int size;
26 };
27
28 /**
29  *      buffer_fetchchar - Fetches a char from a buffer.
30  *      @ctx: Our buffer context structure.
31  *      @count: The number of characters to get from the buffer.
32  *      @c: Where to put the characters retrieved.
33  */
34 int buffer_fetchchar(void *ctx, size_t count, unsigned char *c);
35
36 /**
37  *      buffer_putchar - Puts a char to a buffer.
38  *      @ctx: Our buffer context structure.
39  *      @count: The number of characters to put into the buffer.
40  *      @c: The characters to add to the buffer.
41  *
42  *      Adds characters to the buffer references by the buffer context. If we
43  *      fill it then we double the size of the current buffer and then add the
44  *      rest.
45  */
46 int buffer_putchar(void *ctx, size_t count, unsigned char *c);
47
48 /**
49  *      file_fetchchar - Fetches a char from a file.
50  */
51 int file_fetchchar(void *fd, size_t count, unsigned char *c);
52
53 /**
54  *      file_putchar - Puts a char to a file.
55  */
56 int file_putchar(void *fd, size_t count, unsigned char *c);
57
58 /**
59  *      stdin_getchar - Gets a char from stdin.
60  */
61 int stdin_getchar(void *ctx, size_t count, unsigned char *c);
62
63 /**
64  *      stdout_putchar - Puts a char to stdout.
65  */
66 int stdout_putchar(void *ctx, size_t count, unsigned char *c);
67
68 #endif /* __CHARFUNCS_H__ */