aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-stream-buffer.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-06-07 06:55:06 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-06-07 06:55:06 +0800
commit4b82b86ee5df1cfcbcbc46cc421804a6a0cb8da2 (patch)
tree122b4b705f90414589e8b0d07586ceb7a2489067 /camel/camel-stream-buffer.c
parentaf805a2733c9e2ca44e27360c6162d60cfc1aa53 (diff)
downloadgsoc2013-evolution-4b82b86ee5df1cfcbcbc46cc421804a6a0cb8da2.tar.gz
gsoc2013-evolution-4b82b86ee5df1cfcbcbc46cc421804a6a0cb8da2.tar.zst
gsoc2013-evolution-4b82b86ee5df1cfcbcbc46cc421804a6a0cb8da2.zip
Changed the read and write method prototypes to return an ssize_t type
2000-06-06 Jeffrey Stedfast <fejj@helixcode.com> * camel-stream.[c,h]: Changed the read and write method prototypes to return an ssize_t type rather than an int and also changed the 'number of bytes' to read or write to a size_t type * camel-stream-fs.c: same as above * camel-stream-mem.c: again, same as above * camel-stream-buffer.c: same * camel-imap-stream.[c,h]: Added this new stream, cache's previously read data so each successive call will instead read from the cache svn path=/trunk/; revision=3450
Diffstat (limited to 'camel/camel-stream-buffer.c')
-rw-r--r--camel/camel-stream-buffer.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c
index 68dcc7ad21..633e42095b 100644
--- a/camel/camel-stream-buffer.c
+++ b/camel/camel-stream-buffer.c
@@ -38,8 +38,8 @@ enum {
#define BUF_SIZE 1024
-static int stream_read (CamelStream *stream, char *buffer, unsigned int n);
-static int stream_write (CamelStream *stream, const char *buffer, unsigned int n);
+static ssize_t stream_read (CamelStream *stream, char *buffer, size_t n);
+static ssize_t stream_write (CamelStream *stream, const char *buffer, size_t n);
static int stream_flush (CamelStream *stream);
static int stream_close (CamelStream *stream);
static gboolean stream_eos (CamelStream *stream);
@@ -75,7 +75,7 @@ camel_stream_buffer_class_init (CamelStreamBufferClass *camel_stream_buffer_clas
}
static void
-camel_stream_buffer_init (gpointer object, gpointer klass)
+camel_stream_buffer_init (gpointer object, gpointer klass)
{
CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (object);
@@ -246,12 +246,12 @@ CamelStream *camel_stream_buffer_new_with_vbuf (CamelStream *stream, CamelStream
return CAMEL_STREAM (sbf);
}
-static int
-stream_read (CamelStream *stream, char *buffer, unsigned int n)
+static ssize_t
+stream_read (CamelStream *stream, char *buffer, size_t n)
{
CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
- int bytes_read = 1;
- int bytes_left;
+ ssize_t bytes_read = 1;
+ ssize_t bytes_left;
char *bptr = buffer;
g_return_val_if_fail( (sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_READ, 0);
@@ -291,17 +291,17 @@ stream_read (CamelStream *stream, char *buffer, unsigned int n)
}
}
- return bptr-buffer;
+ return (ssize_t)(bptr - buffer);
}
-static int
-stream_write (CamelStream *stream, const char *buffer, unsigned int n)
+static ssize_t
+stream_write (CamelStream *stream, const char *buffer, size_t n)
{
CamelStreamBuffer *sbf = CAMEL_STREAM_BUFFER (stream);
const char *bptr = buffer;
- int bytes_written = 1;
- int bytes_left;
- int total = n;
+ ssize_t bytes_written = 1;
+ ssize_t bytes_left;
+ ssize_t total = n;
g_return_val_if_fail( (sbf->mode & CAMEL_STREAM_BUFFER_MODE) == CAMEL_STREAM_BUFFER_WRITE, 0);
@@ -336,6 +336,7 @@ stream_write (CamelStream *stream, const char *buffer, unsigned int n)
}
if (bytes_written == -1)
return -1;
+
return total;
}
@@ -405,7 +406,7 @@ int camel_stream_buffer_gets(CamelStreamBuffer *sbf, char *buf, unsigned int max
while (inptr<inend && outptr<outend) {
c = *inptr++;
*outptr++ = c;
- if (c=='\n') {
+ if (c == '\n') {
*outptr = 0;
sbf->ptr = inptr;
return outptr-buf;
@@ -422,10 +423,10 @@ int camel_stream_buffer_gets(CamelStreamBuffer *sbf, char *buf, unsigned int max
} while (bytes_read>0);
sbf->ptr = inptr;
- if (outptr<=outend)
+ if (outptr <= outend)
*outptr = 0;
- return outptr-buf;
+ return (int)(outptr - buf);
}
/**
@@ -473,3 +474,8 @@ camel_stream_buffer_read_line (CamelStreamBuffer *sbf)
return g_strdup(sbf->linebuf);
}
+
+
+
+
+