Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / providers / imapp / camel-imapp-stream.h
1 /*
2  *  Copyright (C) 2000 Ximian Inc.
3  *
4  *  Authors: Michael Zucchi <notzed@ximian.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef _CAMEL_IMAPP_STREAM_H
22 #define _CAMEL_IMAPP_STREAM_H
23
24 #include <camel/camel-stream.h>
25
26 #define CAMEL_IMAPP_STREAM(obj)         CAMEL_CHECK_CAST (obj, camel_imapp_stream_get_type (), CamelIMAPPStream)
27 #define CAMEL_IMAPP_STREAM_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_imapp_stream_get_type (), CamelIMAPPStreamClass)
28 #define CAMEL_IS_IMAP_STREAM(obj)      CAMEL_CHECK_TYPE (obj, camel_imapp_stream_get_type ())
29
30 G_BEGIN_DECLS
31
32 typedef struct _CamelIMAPPStreamClass CamelIMAPPStreamClass;
33 typedef struct _CamelIMAPPStream CamelIMAPPStream;
34
35 typedef enum {
36         IMAP_TOK_PROTOCOL = -2,
37         IMAP_TOK_ERROR = -1,
38         IMAP_TOK_TOKEN = 256,
39         IMAP_TOK_STRING,
40         IMAP_TOK_INT,
41         IMAP_TOK_LITERAL,
42 } camel_imapp_token_t;
43
44 struct _CamelIMAPPStream {
45         CamelStream parent;
46
47         CamelStream *source;
48
49         /*int state;*/
50         unsigned char *buf, *ptr, *end;
51         unsigned int literal;
52
53         unsigned int unget;
54         camel_imapp_token_t unget_tok;
55         unsigned char *unget_token;
56         unsigned int unget_len;
57
58         unsigned char *tokenbuf, *tokenptr, *tokenend;
59 };
60
61 struct _CamelIMAPPStreamClass {
62         CamelStreamClass parent_class;
63 };
64
65 CamelType        camel_imapp_stream_get_type    (void);
66
67 CamelStream     *camel_imapp_stream_new         (CamelStream *source);
68
69 camel_imapp_token_t camel_imapp_stream_token    (CamelIMAPPStream *is, unsigned char **start, unsigned int *len); /* throws IO,PARSE exception */
70 void             camel_imapp_stream_ungettoken  (CamelIMAPPStream *is, camel_imapp_token_t tok, unsigned char *token, unsigned int len);
71
72 void             camel_imapp_stream_set_literal (CamelIMAPPStream *is, unsigned int literal);
73 int              camel_imapp_stream_gets                (CamelIMAPPStream *is, unsigned char **start, unsigned int *len);
74 int              camel_imapp_stream_getl                (CamelIMAPPStream *is, unsigned char **start, unsigned int *len);
75
76 /* all throw IO,PARSE exceptions */
77
78 /* gets an atom, upper-cases */
79 int              camel_imapp_stream_atom                (CamelIMAPPStream *is, unsigned char **start, unsigned int *len);
80 /* gets an atom or string */
81 int              camel_imapp_stream_astring     (CamelIMAPPStream *is, unsigned char **start);
82 /* gets a NIL or a string, start==NULL if NIL */
83 int              camel_imapp_stream_nstring     (CamelIMAPPStream *is, unsigned char **start);
84 /* gets a NIL or string into a stream, stream==NULL if NIL */
85 int              camel_imapp_stream_nstring_stream(CamelIMAPPStream *is, CamelStream **stream);
86 /* gets 'text' */
87 int              camel_imapp_stream_text                (CamelIMAPPStream *is, unsigned char **text);
88
89 /* gets a 'number' */
90 guint32          camel_imapp_stream_number(CamelIMAPPStream *is);
91
92 G_END_DECLS
93
94 #endif /* ! _CAMEL_IMAPP_STREAM_H */