1 /* 2 * camel-imapx-input-stream.h 3 * 4 * This library is free software: you can redistribute it and/or modify it 5 * under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation. 7 * 8 * This library is distributed in the hope that it will be useful, but 9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 * for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this library. If not, see <http://www.gnu.org/licenses/>. 15 * 16 */ 17 18 #ifndef CAMEL_IMAPX_INPUT_STREAM_H 19 #define CAMEL_IMAPX_INPUT_STREAM_H 20 21 #include <gio/gio.h> 22 23 /* Standard GObject macros */ 24 #define CAMEL_TYPE_IMAPX_INPUT_STREAM \ 25 (camel_imapx_input_stream_get_type ()) 26 #define CAMEL_IMAPX_INPUT_STREAM(obj) \ 27 (G_TYPE_CHECK_INSTANCE_CAST \ 28 ((obj), CAMEL_TYPE_IMAPX_INPUT_STREAM, CamelIMAPXInputStream)) 29 #define CAMEL_IMAPX_INPUT_STREAM_CLASS(cls) \ 30 (G_TYPE_CHECK_CLASS_CAST \ 31 ((cls), CAMEL_TYPE_IMAPX_INPUT_STREAM, CamelIMAPXInputStreamClass)) 32 #define CAMEL_IS_IMAPX_INPUT_STREAM(obj) \ 33 (G_TYPE_CHECK_INSTANCE_TYPE \ 34 ((obj), CAMEL_TYPE_IMAPX_INPUT_STREAM)) 35 #define CAMEL_IS_IMAPX_INPUT_STREAM_CLASS(cls) \ 36 (G_TYPE_CHECK_CLASS_TYPE \ 37 ((cls), CAMEL_TYPE_IMAPX_INPUT_STREAM)) 38 #define CAMEL_IMAPX_INPUT_STREAM_GET_CLASS(obj) \ 39 (G_TYPE_INSTANCE_GET_CLASS \ 40 ((obj), CAMEL_TYPE_IMAPX_INPUT_STREAM, CamelIMAPXInputStreamClass)) 41 42 #define CAMEL_IMAPX_ERROR \ 43 (camel_imapx_error_quark ()) 44 45 G_BEGIN_DECLS 46 47 typedef struct _CamelIMAPXInputStream CamelIMAPXInputStream; 48 typedef struct _CamelIMAPXInputStreamClass CamelIMAPXInputStreamClass; 49 typedef struct _CamelIMAPXInputStreamPrivate CamelIMAPXInputStreamPrivate; 50 51 typedef enum { 52 CAMEL_IMAPX_ERROR_SERVER_RESPONSE_MALFORMED = 1, 53 CAMEL_IMAPX_ERROR_IGNORE /* may ignore such errors */ 54 } CamelIMAPXError; 55 56 typedef enum { 57 IMAPX_TOK_ERROR = -1, 58 IMAPX_TOK_TOKEN = 256, 59 IMAPX_TOK_STRING, 60 IMAPX_TOK_INT, 61 IMAPX_TOK_LITERAL, 62 } camel_imapx_token_t; 63 64 struct _CamelIMAPXInputStream { 65 GFilterInputStream parent; 66 CamelIMAPXInputStreamPrivate *priv; 67 }; 68 69 struct _CamelIMAPXInputStreamClass { 70 GFilterInputStreamClass parent_class; 71 72 /* Padding for future expansion */ 73 gpointer reserved[20]; 74 }; 75 76 GQuark camel_imapx_error_quark (void) G_GNUC_CONST; 77 GType camel_imapx_input_stream_get_type 78 (void) G_GNUC_CONST; 79 GInputStream * camel_imapx_input_stream_new (GInputStream *base_stream); 80 gint camel_imapx_input_stream_buffered 81 (CamelIMAPXInputStream *is); 82 gboolean camel_imapx_input_stream_get_utf8_accept 83 (CamelIMAPXInputStream *is); 84 void camel_imapx_input_stream_set_utf8_accept 85 (CamelIMAPXInputStream *is, 86 gboolean utf8_accept); 87 88 camel_imapx_token_t 89 camel_imapx_input_stream_token (CamelIMAPXInputStream *is, 90 guchar **start, 91 guint *len, 92 GCancellable *cancellable, 93 GError **error); 94 95 void camel_imapx_input_stream_ungettoken 96 (CamelIMAPXInputStream *is, 97 camel_imapx_token_t tok, 98 guchar *token, 99 guint len); 100 void camel_imapx_input_stream_set_literal 101 (CamelIMAPXInputStream *is, 102 guint literal); 103 gint camel_imapx_input_stream_gets (CamelIMAPXInputStream *is, 104 guchar **start, 105 guint *len, 106 GCancellable *cancellable, 107 GError **error); 108 gint camel_imapx_input_stream_getl (CamelIMAPXInputStream *is, 109 guchar **start, 110 guint *len, 111 GCancellable *cancellable, 112 GError **error); 113 114 /* gets an atom, upper-cases */ 115 gboolean camel_imapx_input_stream_atom (CamelIMAPXInputStream *is, 116 guchar **start, 117 guint *len, 118 GCancellable *cancellable, 119 GError **error); 120 /* gets an atom or string */ 121 gboolean camel_imapx_input_stream_astring 122 (CamelIMAPXInputStream *is, 123 guchar **start, 124 GCancellable *cancellable, 125 GError **error); 126 /* gets a NIL or a string, start==NULL if NIL */ 127 gboolean camel_imapx_input_stream_nstring 128 (CamelIMAPXInputStream *is, 129 guchar **start, 130 GCancellable *cancellable, 131 GError **error); 132 /* gets a NIL or string into a GBytes, bytes==NULL if NIL */ 133 gboolean camel_imapx_input_stream_nstring_bytes 134 (CamelIMAPXInputStream *is, 135 GBytes **out_bytes, 136 gboolean with_progress, 137 GCancellable *cancellable, 138 GError **error); 139 /* gets 'text' */ 140 gboolean camel_imapx_input_stream_text (CamelIMAPXInputStream *is, 141 guchar **text, 142 GCancellable *cancellable, 143 GError **error); 144 145 /* gets a 'number' */ 146 gboolean camel_imapx_input_stream_number 147 (CamelIMAPXInputStream *is, 148 guint64 *number, 149 GCancellable *cancellable, 150 GError **error); 151 152 /* skips the rest of a line, including literals, etc */ 153 gboolean camel_imapx_input_stream_skip (CamelIMAPXInputStream *is, 154 GCancellable *cancellable, 155 GError **error); 156 157 gboolean camel_imapx_input_stream_skip_until 158 (CamelIMAPXInputStream *is, 159 const gchar *delimiters, 160 GCancellable *cancellable, 161 GError **error); 162 163 G_END_DECLS 164 165 #endif /* CAMEL_IMAPX_INPUT_STREAM_H */ 166