istream-seekable.c revision 8255a22cccf3b0ccf38206c594941820ac1c9e00
/* Copyright (C) 2005 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "hex-binary.h"
#include "randgen.h"
#include "write-full.h"
#include "istream-internal.h"
#include "istream-seekable.h"
#include <fcntl.h>
#include <unistd.h>
#include <time.h>
struct seekable_istream {
char *temp_prefix;
unsigned int cur_idx;
int fd;
};
{
unsigned int i;
}
{
unsigned int i;
}
{
unsigned int i;
}
{
unsigned char randbuf[8];
const char *path;
int fd;
/* create a temporary file */
for (;;) {
NULL);
continue;
return -1;
}
if (fd != -1)
break;
return -1;
}
}
/* we just want the fd, unlink it */
/* shouldn't happen.. */
return -1;
}
/* copy our currently read buffer to it */
return -1;
}
return 0;
}
{
return -1;
}
/* error */
return -1;
}
/* go to next stream */
/* last one, EOF */
return -1;
}
/* see if stream has pending data */
if (size != 0)
return size;
}
return ret;
}
{
const unsigned char *data;
/* need to read more */
return FALSE;
/* read more to buffer */
if (*ret <= 0)
return TRUE;
/* we should have more now. */
}
return TRUE;
}
{
const unsigned char *data;
return ret;
/* copy everything to temp file and use it as the stream */
if (copy_to_temp_file(sstream) < 0) {
return -1;
}
}
/* need to read more */
if (ret <= 0)
return ret;
/* save to our file */
i_error("write_full(%s...) failed: %m",
return -1;
}
}
if (ret <= 0) {
}
return ret;
}
bool mark __attr_unused__)
{
}
{
/* we want to know the full size of the file, so read until
we're finished */
do {
if (ret == 0) {
i_panic("i_stream_stat() used for non-blocking "
"seekable stream");
}
}
/* using a file backed buffer, we can use real fstat() */
} else {
/* buffer is completely in memory */
}
}
struct istream *
{
struct seekable_istream *sstream;
const unsigned char *data;
unsigned int count;
/* initialize our buffer from first stream's pending data */
}