iostream-temp.c revision c076ad69e28e7d41af83ada84e12019793ffcfa2
/* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "str.h"
#include "safe-mkstemp.h"
#include "write-full.h"
#include "istream-private.h"
#include "ostream-private.h"
#include "iostream-temp.h"
#include <unistd.h>
struct temp_ostream {
struct ostream_private ostream;
char *temp_path_prefix;
enum iostream_temp_flags flags;
char *name;
int fd;
bool fd_tried;
};
static void
bool close_parent ATTR_UNUSED)
{
}
{
return -1;
return -1;
}
return -1;
}
return -1;
}
/* make the fd available also to o_stream_get_fd(),
e.g. for unit tests */
return 0;
}
static ssize_t
{
unsigned int i;
for (i = 0; i < iov_count; i++) {
return -1;
}
}
return bytes;
}
static ssize_t
{
unsigned int i;
for (i = 0; i < iov_count; i++) {
if (o_stream_temp_move_to_fd(tstream) == 0) {
iov_count-i);
}
/* failed to move to temp fd, just keep it in memory */
}
}
return ret;
}
{
int ret = -1;
/* everything copied */
ret = 0;
}
return ret;
}
{
return 0;
return o_stream_temp_dup_cancel(outstream);
return 0;
}
} else {
return o_stream_temp_dup_cancel(outstream);
}
/* we should be at EOF now. o_stream_send_istream() asserts if
eof isn't set. */
return 1;
}
{
int ret;
return ret;
}
}
static int
{
} else {
return -1;
}
}
return 0;
}
{
return 0;
}
enum iostream_temp_flags flags)
{
}
enum iostream_temp_flags flags,
const char *name)
{
}
enum iostream_temp_flags flags,
const char *name,
{
struct temp_ostream *tstream;
if (name[0] == '\0') {
"(temp iostream in %s)", temp_path_prefix));
} else {
}
return output;
}
{
buffer_free(&buf);
}
{
struct temp_ostream *tstream =
const char *for_path;
int fd;
for_path = "";
else
if (fd == -1)
else {
}
/* return the original failed stream. */
} else {
}
return input;
}