istream-file.c revision 143cb2e0744e647f8fc637bbdea1106c1587a4bf
/* Copyright (c) 2002-2003 Timo Sirainen */
/* @UNSAFE: whole file */
#include "lib.h"
#include "alarm-hup.h"
#include "istream-internal.h"
#include "network.h"
#include <time.h>
#include <unistd.h>
#define I_STREAM_MIN_SIZE 4096
#define STREAM_IS_BLOCKING(fstream) \
((fstream)->timeout_msecs != 0)
struct file_istream {
int timeout_msecs;
void (*timeout_cb)(void *);
void *timeout_context;
unsigned int file:1;
unsigned int autoclose_fd:1;
};
{
i_error("file_istream.close() failed: %m");
}
}
{
}
{
}
void (*timeout_cb)(void *), void *context)
{
if (timeout_msecs != 0)
}
{
else
if (fstream->max_buffer_size > 0 &&
}
{
}
{
return -1;
/* remove the unused bytes from beginning of buffer */
} else if (fstream->max_buffer_size == 0 ||
/* buffer is full - grow it */
}
return -2; /* buffer full */
}
/* virtual limit reached == EOF */
return -1;
}
if (size > read_limit)
size = read_limit;
}
ret = -1;
do {
/* timeouted */
return -1;
}
} else {
}
if (ret == 0) {
/* EOF */
return -1;
}
if (ret < 0) {
/* treat as disconnection */
return -1;
}
ret = 0;
else {
return -1;
}
}
ret = 0;
} else {
}
}
return ret;
}
{
}
{
return;
}
}
{
struct file_istream *fstream;
/* get size of fd if it's a file */
else
}