Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-stream-buffer.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-stream-buffer.h :stream which buffers another stream */
3
4 /*
5  *
6  * Author :
7  *  Michael Zucchi <notzed@ximian.com>
8  *
9  * Copyright 2000 Ximian Inc. (www.ximian.com) .
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of version 2 of the GNU Lesser General Public
13  * License as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
23  * USA
24  */
25
26
27 #ifndef CAMEL_STREAM_BUFFER_H
28 #define CAMEL_STREAM_BUFFER_H 1
29
30 #include <stdio.h>
31 #include <camel/camel-seekable-stream.h>
32
33 #define CAMEL_STREAM_BUFFER_TYPE     (camel_stream_buffer_get_type ())
34 #define CAMEL_STREAM_BUFFER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBuffer))
35 #define CAMEL_STREAM_BUFFER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_STREAM_BUFFER_TYPE, CamelStreamBufferClass))
36 #define CAMEL_IS_STREAM_BUFFER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_STREAM_BUFFER_TYPE))
37
38 G_BEGIN_DECLS
39
40 typedef enum {
41         CAMEL_STREAM_BUFFER_BUFFER = 0,
42         CAMEL_STREAM_BUFFER_NONE,
43         CAMEL_STREAM_BUFFER_READ = 0x00,
44         CAMEL_STREAM_BUFFER_WRITE = 0x80,
45         CAMEL_STREAM_BUFFER_MODE = 0x80
46 } CamelStreamBufferMode;
47
48 struct _CamelStreamBuffer
49 {
50         CamelStream parent_object;
51
52         /* these are all of course, private */
53         CamelStream *stream;
54
55         unsigned char *buf, *ptr, *end;
56         int size;
57
58         unsigned char *linebuf; /* for reading lines at a time */
59         int linesize;
60
61         CamelStreamBufferMode mode;
62         unsigned int flags;     /* internal flags */
63 };
64
65
66 typedef struct {
67         CamelStreamClass parent_class;
68
69         /* Virtual methods */
70         void (*init) (CamelStreamBuffer *stream_buffer, CamelStream *stream,
71                       CamelStreamBufferMode mode);
72         void (*init_vbuf) (CamelStreamBuffer *stream_buffer,
73                            CamelStream *stream, CamelStreamBufferMode mode,
74                            char *buf, guint32 size);
75
76 } CamelStreamBufferClass;
77
78
79 /* Standard Camel function */
80 CamelType camel_stream_buffer_get_type (void);
81
82
83 /* public methods */
84 CamelStream *camel_stream_buffer_new (CamelStream *stream,
85                                       CamelStreamBufferMode mode);
86 CamelStream *camel_stream_buffer_new_with_vbuf (CamelStream *stream,
87                                                 CamelStreamBufferMode mode,
88                                                 char *buf, guint32 size);
89
90 /* unimplemented
91    CamelStream *camel_stream_buffer_set_vbuf (CamelStreamBuffer *b, CamelStreamBufferMode mode, char *buf, guint32 size); */
92
93 /* read a line of characters */
94 int camel_stream_buffer_gets (CamelStreamBuffer *sbf, char *buf, unsigned int max);
95
96 char *camel_stream_buffer_read_line (CamelStreamBuffer *sbf);
97
98 G_END_DECLS
99
100 #endif /* CAMEL_STREAM_BUFFER_H */