istream.c revision 0a0cd45a633112a2ae6aad801c1e6afe53ab95de
/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "str.h"
#include "istream-internal.h"
{
}
{
}
{
}
}
{
}
{
}
{
if (stream->stream_errno == 0)
}
{
}
{
return -1;
stream->stream_errno = 0;
switch (ret) {
case -2:
break;
case -1:
if (stream->stream_errno != 0) {
/* error handling should be easier if we now just
assume the stream is now at EOF */
} else {
}
break;
case 0:
break;
}
return ret;
}
{
/* within buffer */
return;
}
/* have to seek forward */
return;
stream->stream_errno = 0;
}
{
return TRUE;
/* use the fast route only if the parent stream is at the
expected offset */
return FALSE;
}
{
return;
}
return;
}
{
return;
}
{
return;
}
{
return NULL;
}
{
}
{
char *ret;
end = i - 1;
else
end = i;
/* modify the buffer directly */
} else {
/* use a temporary string to return it */
}
i++;
return ret;
}
{
char *ret_buf;
size_t i;
stream->stream_errno = 0;
return NULL;
}
i_error("i_stream_next_line() called for unmodifiable stream");
return NULL;
}
/* @UNSAFE */
/* got it */
break;
}
}
return ret_buf;
}
{
char *line;
for (;;) {
break;
if (i_stream_read(stream) <= 0)
return NULL;
}
return line;
}
const unsigned char *
{
*size_r = 0;
return NULL;
}
}
{
*size_r = 0;
return NULL;
}
}
{
do {
return 1;
/* we need more data */
if (ret > 0)
} while (ret > 0);
if (ret == -2)
return -2;
if (ret == 0) {
/* need to read more */
return 0;
}
if (read_more) {
/* we read at least some new data */
return 0;
}
} else {
}
return -1;
}
{
}
{
else
if (stream->max_buffer_size > 0 &&
}
{
i_assert(wanted_size > 0);
/* remove the unused bytes from beginning of buffer */
} else if (stream->max_buffer_size == 0 ||
/* buffer is full - grow it */
}
}
}
{
return FALSE;
return TRUE;
}
static void
{
}
static const struct stat *
{
}
struct istream *
{
}
}
}
#ifdef STREAM_TEST
/* gcc istream.c -o teststream liblib.a -Wall -DHAVE_CONFIG_H -DSTREAM_TEST -g */
#include <fcntl.h>
#include <unistd.h>
#include "ostream.h"
{
size_t i;
for (i = 0; i < size; i++)
}
int main(void)
{
unsigned char buf[1024];
const unsigned char *data;
lib_init();
if (fd1 < 0)
i_fatal("open() failed: %m");
if (fd2 < 0)
i_fatal("open() failed: %m");
/* write initial data */
for (i = 0; i < sizeof(buf); i++)
/* test reading */
i_stream_seek(input, 0);
/* test moving data */
i_stream_seek(input, 0);
/* test moving with limits */
i_stream_seek(l_input, 0);
i_stream_seek(input, 0);
/* reading within limits */
i_stream_seek(l_input, 0);
unlink("teststream.1");
unlink("teststream.2");
return 0;
}
#endif