Server 0.0.1
HTTP/REST server implementation

src/cbuf/read.c

Go to the documentation of this file.
00001 
00023 #include <sys/types.h>
00024 #include <unistd.h>
00025 #include <errno.h>
00026 
00027 #include "cbuf.h"
00028 #include "stream.h"
00029 
00030 
00031 ssize_t
00032 cbufRead(Cbuf this, Stream st)
00033 {
00034         ssize_t rrsize = 0;
00035         size_t  rsize  = cbufGetFree(this);
00036 
00037         if (0 == rsize) {
00038                 errno = ECBUFOVFL;
00039                 return -1;
00040         }
00041 
00042         rrsize = streamRead(st, cbufGetWrite(this), rsize);
00043 
00044         switch (rrsize) {
00045                 case  0:
00046                         rrsize = -2;
00047                         // DROP THROUGH
00048 
00049                 case -1:
00050                         break;
00051 
00052                 default:
00053                         cbufIncWrite(this, rrsize);
00054                         break;
00055         }
00056 
00057         return rrsize;
00058 }
00059 
00060 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines