make a blocking version of the header parser. When the fs stream uses
[platform/upstream/evolution-data-server.git] / camel / camel-seekable-stream.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* 
4  *
5  * Author : 
6  *  Bertrand Guiheneuf <bertrand@helixcode.com>
7  *
8  * Copyright 1999, 2000 HelixCode (http://www.helixcode.com) .
9  *
10  * This program is free software; you can redistribute it and/or 
11  * modify it under the terms of the GNU General Public License as 
12  * published by the Free Software Foundation; either version 2 of the
13  * License, or (at your option) any later version.
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 General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23  * USA
24  */
25
26
27
28 #include <config.h>
29 #include "camel-seekable-stream.h"
30 #include "camel-log.h"
31
32 static CamelStreamClass *parent_class=NULL;
33
34
35 /* Returns the class for a CamelSeekableStream */
36 #define CSS_CLASS(so) CAMEL_SEEKABLE_STREAM_CLASS (GTK_OBJECT(so)->klass)
37
38 static gint _seek (CamelSeekableStream *stream, gint offset, CamelStreamSeekPolicy policy);
39
40
41 static void
42 camel_seekable_stream_class_init (CamelSeekableStreamClass *camel_seekable_stream_class)
43 {
44         CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_seekable_stream_class);
45         GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_seekable_stream_class);
46
47         parent_class = gtk_type_class (camel_stream_get_type ());
48         
49         camel_seekable_stream_class->seek = _seek;
50
51 }
52
53 GtkType
54 camel_seekable_stream_get_type (void)
55 {
56         static GtkType camel_seekable_stream_type = 0;
57         
58         if (!camel_seekable_stream_type)        {
59                 GtkTypeInfo camel_seekable_stream_info =        
60                 {
61                         "CamelSeekableStream",
62                         sizeof (CamelSeekableStream),
63                         sizeof (CamelSeekableStreamClass),
64                         (GtkClassInitFunc) camel_seekable_stream_class_init,
65                         (GtkObjectInitFunc) NULL,
66                                 /* reserved_1 */ NULL,
67                                 /* reserved_2 */ NULL,
68                         (GtkClassInitFunc) NULL,
69                 };
70                 
71                 camel_seekable_stream_type = gtk_type_unique (camel_stream_get_type (), &camel_seekable_stream_info);
72         }
73         
74         return camel_seekable_stream_type;
75 }
76
77
78
79
80 static gint
81 _seek (CamelSeekableStream *stream, 
82        gint offset, 
83        CamelStreamSeekPolicy policy)
84 {
85         return -1;
86 }
87
88
89
90 /**
91  * camel_stream_seek:
92  * @stream: a CamelStream object.
93  * @offset: offset value
94  * @policy: what to do with the offset
95  * 
96  * 
97  * 
98  * Return value: new position, -1 if operation failed.
99  **/
100 gint
101 camel_seekable_stream_seek (CamelSeekableStream *stream, 
102                             gint offset, 
103                             CamelStreamSeekPolicy policy)
104 {
105         return CSS_CLASS (stream)->seek (stream, offset, policy);
106 }
107
108
109
110
111 /**
112  * camel_seekable_stream_get_current_position: get the position of a stream
113  * @stream: seekable stream object 
114  * 
115  * Get the current position of a seekable stream.
116  * 
117  * Return value: the position.
118  **/
119 guint32  
120 camel_seekable_stream_get_current_position  (CamelSeekableStream *stream)
121 {
122         return stream->cur_pos;         
123 }
124
125
126
127
128
129
130
131
132