aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-09-07 07:57:53 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-09-07 07:57:53 +0800
commitcc50420bf04f13fb7c3697bf524ed7772bfe6601 (patch)
treee53e5a819beef9faefe33c32969a46f8f2125cb2 /camel
parent681e043977a95aa3a7e37d85478d89c14556d3aa (diff)
downloadgsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar.gz
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar.bz2
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar.lz
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar.xz
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.tar.zst
gsoc2013-evolution-cc50420bf04f13fb7c3697bf524ed7772bfe6601.zip
Use camel_stream_buffer_read_line() instead of duplicationing the
2001-09-06 Jeffrey Stedfast <fejj@ximian.com> * camel-remote-store.c (remote_recv_line): Use camel_stream_buffer_read_line() instead of duplicationing the functionality. Also, the previous way was broken anyway. What if a line was the same length as our buffer? Then we'd go and read a second line and a third and so on until they weren't the same length, leaving \r's in the middle of the buffer. svn path=/trunk/; revision=12662
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-remote-store.c37
2 files changed, 18 insertions, 28 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index c4b8905b86..80213af0a5 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2001-09-06 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-remote-store.c (remote_recv_line): Use
+ camel_stream_buffer_read_line() instead of duplicationing the
+ functionality. Also, the previous way was broken anyway. What if a
+ line was the same length as our buffer? Then we'd go and read a
+ second line and a third and so on until they weren't the same
+ length, leaving \r's in the middle of the buffer.
+
2001-09-06 Dan Winship <danw@ximian.com>
* providers/pop3/camel-pop3-store.c (pop3_get_response): Fix this
diff --git a/camel/camel-remote-store.c b/camel/camel-remote-store.c
index 0bd78cf45c..4715019179 100644
--- a/camel/camel-remote-store.c
+++ b/camel/camel-remote-store.c
@@ -449,10 +449,8 @@ static int
remote_recv_line (CamelRemoteStore *store, char **dest, CamelException *ex)
{
CamelStreamBuffer *stream;
- GByteArray *bytes;
- gchar buf[1024], *ret;
CamelException internal_ex;
- gint nread;
+ char *buf;
*dest = NULL;
@@ -468,49 +466,32 @@ remote_recv_line (CamelRemoteStore *store, char **dest, CamelException *ex)
}
stream = CAMEL_STREAM_BUFFER (store->istream);
- bytes = g_byte_array_new ();
-
- do {
- nread = camel_stream_buffer_gets (stream, buf, sizeof (buf));
- if (nread > 0)
- g_byte_array_append (bytes, buf, nread);
- } while (nread == sizeof (buf) - 1);
+ buf = camel_stream_buffer_read_line (stream);
camel_exception_init (&internal_ex);
- if (nread == -1) {
+ if (buf == NULL) {
if (errno == EINTR)
camel_exception_set (&internal_ex, CAMEL_EXCEPTION_USER_CANCEL, _("Operation cancelled"));
else
- camel_exception_set (&internal_ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, g_strerror (errno));
- } else if (bytes->len == 0)
- camel_exception_set (&internal_ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED,
- _("Server unexpectedly disconnected"));
+ camel_exception_setv (&internal_ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
+ _("Server unexpectedly disconnected: %s"),
+ g_strerror (errno));
+ }
if (camel_exception_is_set (&internal_ex)) {
camel_exception_xfer (ex, &internal_ex);
- g_byte_array_free (bytes, TRUE);
camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
return -1;
}
- g_byte_array_append (bytes, "", 1);
- ret = bytes->data;
- nread = bytes->len - 1;
- g_byte_array_free (bytes, FALSE);
-
- /* strip off the CRLF sequence */
- while (nread > 0 && ret[nread] != '\r')
- ret[nread--] = '\0';
- ret[nread] = '\0';
-
- *dest = ret;
+ *dest = buf;
#if d(!)0
if (camel_verbose_debug)
fprintf (stderr, "received: %s\n", *dest);
#endif
- return nread;
+ return strlen (*dest);
}
/**