/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
*/
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "str.h"
#include "safe-mkstemp.h"
#include "istream-private.h"
#include "istream-seekable.h"
#include "ostream-dot.h"
#include "istream-dot.h"
#include "ostream.h"
#include "lib-signals.h"
#include "program-client-private.h"
#include <unistd.h>
static
*context)
{
/* do not call callback when destroying */
if (pclient->destroying) return;
}
static
{
int fd;
if (fd == -1) {
return -1;
}
/* we just want the fd, unlink it */
/* shouldn't happen.. */
i_close_fd(&fd);
return -1;
}
return fd;
}
static
{
i_error("program `%s' execution timed out (> %u msecs)",
}
static
{
i_error("program `%s' socket connection timed out (> %u msecs)",
}
static
{
}
}
static
{
int ret;
return -1;
return ret;
}
static
{
unsigned int i, count;
return;
for(i = 0; i < count; i++) {
}
}
{
if (pclient->output_seekable ||
else
}
}
-1 :
}
static
{
int ret;
if (pclient->disconnected)
return;
}
enum program_client_error error)
{
return;
}
static
{
unsigned int count, i;
return TRUE;
}
for(i = 0; i < count; i++) {
return TRUE;
}
}
}
return FALSE;
}
static
{
int ret = 0;
/* flush the output first, before writing more */
if (ret < 0) {
i_error("write(%s) failed: %s",
}
return ret;
}
/* initialize dot stream if required */
if (!pclient->output_dot_created &&
}
/* transfer provided input stream to output towards program */
switch (res) {
break;
return 1;
return 0;
i_error("read(%s) failed: %s",
return -1;
i_error("write(%s) failed: %s",
return -1;
}
}
/* finish and flush program output */
i_error("write(%s) failed: %s",
return -1;
}
if (ret == 0)
return 0;
}
/* check whether program i/o is finished */
if (!program_client_input_pending(pclient)) {
/* finished */
/* close output towards program, so that it reads EOF */
} else if (program_client_close_output(pclient) < 0) {
}
}
return 1;
}
{
const unsigned char *data;
int ret = 0;
/* initialize seekable output if required */
pclient);
}
/* initialize dot stream if required */
if (!pclient->input_dot_created &&
}
/* transfer input from program to provided output stream */
switch (res) {
break;
return;
i_error("read(%s) failed: %s",
return;
i_error("write(%s) failed: %s",
return;
}
}
/* read (the remainder of) the outer stream */
if (ret == 0)
return;
if (ret < 0) {
if (input->stream_errno != 0) {
i_error("read(%s) failed: %s",
return;
}
}
/* flush output stream to make sure all is sent */
i_error("write(%s) failed: %s",
return;
}
if (ret == 0)
return;
}
/* check whether program i/o is finished */
return;
}
/* finished */
}
static
{
}
}
{
}
/* run output */
}
}
return ret;
}
const char *path,
const char *const *args,
const struct program_client_settings *set)
{
}
{
}
{
}
const char *temp_prefix)
{
}
{
i_stream_seek(input, 0);
return input;
}
void *context)
{
unsigned int i, count;
for(i = 0; i < count; i++) {
break;
}
}
}
}
const char *value)
{
const char *env;
}
{
/* Create streams for normal program I/O */
}
}
/* Create streams for additional output through side-channel fds */
unsigned int count, i;
for(i = 0; i < count; i++) {
t_strdup_printf("program output fd=%d",
&efds[i]);
}
}
}
{
}
{
}
const struct program_client_settings *set,
const char **error_r)
{
uri+5,
args,
set);
return 0;
uri+5,
args,
return 0;
const char *host;
return -1;
}
args,
return 0;
} else {
"Unsupported program client scheme '%s'",
return -1;
}
}
static
{
}
{
if (ret == -2) {
}
return -1;
}
void *context)
{
if (program_client_connect(pclient) < 0)
}