Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-seekable-stream.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-stream-fs.h :stream based on unix filesystem */
3
4 /*
5  * Author:
6  *  Bertrand Guiheneuf <bertrand@helixcode.com>
7  *
8  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of version 2 of the GNU Lesser General Public
12  * License as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24
25
26 #ifndef CAMEL_SEEKABLE_STREAM_H
27 #define CAMEL_SEEKABLE_STREAM_H 1
28
29 #include <sys/types.h>
30 #include <unistd.h>
31 #include <camel/camel-stream.h>
32
33 #define CAMEL_SEEKABLE_STREAM_TYPE     (camel_seekable_stream_get_type ())
34 #define CAMEL_SEEKABLE_STREAM(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStream))
35 #define CAMEL_SEEKABLE_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SEEKABLE_STREAM_TYPE, CamelSeekableStreamClass))
36 #define CAMEL_IS_SEEKABLE_STREAM(o)    (CAMEL_CHECK_TYPE((o), CAMEL_SEEKABLE_STREAM_TYPE))
37
38 G_BEGIN_DECLS
39
40 typedef enum {
41         CAMEL_STREAM_SET = SEEK_SET,
42         CAMEL_STREAM_CUR = SEEK_CUR,
43         CAMEL_STREAM_END = SEEK_END
44 } CamelStreamSeekPolicy;
45
46 #define CAMEL_STREAM_UNBOUND (~0)
47
48 struct _CamelSeekableStream {
49         CamelStream parent_object;
50
51         off_t position;         /* current postion in the stream */
52         off_t bound_start;      /* first valid position */
53         off_t bound_end;        /* first invalid position */
54 };
55
56 typedef struct {
57         CamelStreamClass parent_class;
58
59         /* Virtual methods */
60         off_t (*seek)       (CamelSeekableStream *stream, off_t offset,
61                              CamelStreamSeekPolicy policy);
62         off_t (*tell)       (CamelSeekableStream *stream);
63         int  (*set_bounds)  (CamelSeekableStream *stream,
64                              off_t start, off_t end);
65 } CamelSeekableStreamClass;
66
67 /* Standard Camel function */
68 CamelType camel_seekable_stream_get_type (void);
69
70 /* public methods */
71 off_t    camel_seekable_stream_seek            (CamelSeekableStream *stream, off_t offset,
72                                                 CamelStreamSeekPolicy policy);
73 off_t    camel_seekable_stream_tell            (CamelSeekableStream *stream);
74 int      camel_seekable_stream_set_bounds      (CamelSeekableStream *stream, off_t start, off_t end);
75
76 G_END_DECLS
77
78 #endif /* CAMEL_SEEKABLE_STREAM_H */