1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-stream-buffer.h :stream which buffers another stream */
7 * Michael Zucchi <notzed@ximian.com>
9 * Copyright 2000 Ximian Inc. (www.ximian.com) .
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.
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.
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
27 #ifndef CAMEL_STREAM_BUFFER_H
28 #define CAMEL_STREAM_BUFFER_H 1
31 #include <camel/camel-seekable-stream.h>
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))
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;
48 struct _CamelStreamBuffer
50 CamelStream parent_object;
52 /* these are all of course, private */
55 unsigned char *buf, *ptr, *end;
58 unsigned char *linebuf; /* for reading lines at a time */
61 CamelStreamBufferMode mode;
62 unsigned int flags; /* internal flags */
67 CamelStreamClass parent_class;
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);
76 } CamelStreamBufferClass;
79 /* Standard Camel function */
80 CamelType camel_stream_buffer_get_type (void);
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);
91 CamelStream *camel_stream_buffer_set_vbuf (CamelStreamBuffer *b, CamelStreamBufferMode mode, char *buf, guint32 size); */
93 /* read a line of characters */
94 int camel_stream_buffer_gets (CamelStreamBuffer *sbf, char *buf, unsigned int max);
96 char *camel_stream_buffer_read_line (CamelStreamBuffer *sbf);
100 #endif /* CAMEL_STREAM_BUFFER_H */