[evolution-data-server] Simplify camel_imapx_stream_nstring_stream().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Simplify camel_imapx_stream_nstring_stream().
- Date: Sun, 14 Jul 2013 16:58:20 +0000 (UTC)
commit 6455c445a8cd57b81ffcf4aea37eb7859548e52d
Author: Matthew Barnes <mbarnes redhat com>
Date: Sun Jul 14 08:37:06 2013 -0400
Simplify camel_imapx_stream_nstring_stream().
camel/camel-imapx-stream.c | 52 +++++++++++++++++++++++++------------------
1 files changed, 30 insertions(+), 22 deletions(-)
---
diff --git a/camel/camel-imapx-stream.c b/camel/camel-imapx-stream.c
index 3d04f41..16c134d 100644
--- a/camel/camel-imapx-stream.c
+++ b/camel/camel-imapx-stream.c
@@ -538,52 +538,60 @@ camel_imapx_stream_nstring_stream (CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error)
{
+ camel_imapx_token_t tok;
guchar *token;
guint len;
- gint ret = 0;
- CamelStream * mem = NULL;
- GError *local_error = NULL;
+ CamelStream *mem = NULL;
- g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (is), -1);
- g_return_val_if_fail (stream != NULL, -1);
+ g_return_val_if_fail (CAMEL_IS_IMAPX_STREAM (is), IMAPX_TOK_ERROR);
+ g_return_val_if_fail (stream != NULL, IMAPX_TOK_ERROR);
*stream = NULL;
- switch (camel_imapx_stream_token (is, &token, &len, cancellable, &local_error)) {
+ tok = camel_imapx_stream_token (is, &token, &len, cancellable, error);
+
+ switch (tok) {
+ case IMAPX_TOK_ERROR:
+ return IMAPX_TOK_ERROR;
+
case IMAPX_TOK_STRING:
- mem = camel_stream_mem_new_with_buffer ((gchar *) token, len);
+ mem = camel_stream_mem_new_with_buffer (
+ (gchar *) token, len);
*stream = mem;
- break;
+ return 0;
+
case IMAPX_TOK_LITERAL:
- /* if len is big, we could automatically use a file backing */
+ /* If len is big, we could
+ * automatically use a file backing. */
camel_imapx_stream_set_literal (is, len);
mem = camel_stream_mem_new ();
if (camel_stream_write_to_stream ((CamelStream *) is, mem, cancellable, error) == -1)
{
g_object_unref (mem);
- ret = -1;
- break;
+ return IMAPX_TOK_ERROR;
}
g_seekable_seek (
G_SEEKABLE (mem), 0,
G_SEEK_SET, NULL, NULL);
-
*stream = mem;
- break;
+ return 0;
+
case IMAPX_TOK_TOKEN:
- if (toupper (token[0]) == 'N' && toupper (token[1]) == 'I' && toupper (token[2]) ==
'L' && token[3] == 0) {
+ if (toupper (token[0]) == 'N' &&
+ toupper (token[1]) == 'I' &&
+ toupper (token[2]) == 'L' &&
+ token[3] == 0) {
*stream = NULL;
- break;
+ return 0;
}
+ /* fall through */
+
default:
- ret = -1;
- if (local_error == NULL)
- g_set_error (error, CAMEL_IMAPX_ERROR, 1, "nstring: token not string");
- else
- g_propagate_error (error, local_error);
+ g_set_error (
+ error, CAMEL_IMAPX_ERROR, 1,
+ "nstring: token not string");
+ return IMAPX_TOK_ERROR;
}
-
- return ret;
}
guint64
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]