/* Copyright (c) 2013-2018 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 {
char *temp_path_prefix;
char *name;
int fd;
bool fd_tried;
};
enum ostream_send_istream_result *res_r);
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;
}
{
}
if (ret < 0) {
/* not really expecting this to happen */
i_error("iostream-temp %s: read(%s*) failed: %m",
return -1;
}
return 0;
}
static ssize_t
{
unsigned int i;
for (i = 0; i < iov_count; i++) {
i_error("iostream-temp %s: write(%s*) failed: %m - moving to memory",
return -1;
for (; i < iov_count; i++) {
}
return bytes;
}
}
return bytes;
}
static ssize_t
{
unsigned int i;
return -1;
}
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;
}
enum ostream_send_istream_result *res_r)
{
switch (*res_r) {
/* everything copied */
break;
i_unreached();
"iostream-temp: read(%s) failed: %s",
break;
break;
}
return ret;
}
static bool
enum ostream_send_istream_result *res_r)
{
return FALSE;
return FALSE;
}
} else {
}
/* we should be at EOF now. o_stream_send_istream() asserts if
eof isn't set. */
return TRUE;
}
static enum ostream_send_istream_result
{
return res;
}
}
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,
{
if (name[0] == '\0') {
"(temp iostream in %s)", temp_path_prefix));
} else {
}
return output;
}
{
buffer_free(&buf);
}
{
const char *for_path;
int fd;
for_path = "";
else
if (fd == -1)
else {
}
/* return the original failed stream. */
} else {
}
return input;
}