program-client.c revision 2454dfa32c93c20a8522c6ed42fe057baaac9f9a
/* Copyright (c) 2002-2017 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>
#define MAX_OUTPUT_BUFFER_SIZE 16384
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
{
int ret;
}
return -1;
}
return ret;
}
static
{
int ret;
return -1;
return ret;
}
static
{
struct program_client_extra_fd *efds;
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;
if (ret < 0) {
i_error("write(%s) failed: %s",
}
return ret;
}
if (!pclient->output_dot_created &&
}
if (pclient->output_dot_created &&
switch (res) {
break;
return 1;
return 0;
i_error("read(%s) failed: %s",
return -1;
i_error("write(%s) failed: %s",
return -1;
}
}
if (ret < 0) {
i_error("write(%s) failed: %s",
}
return ret;
}
}
if (!program_client_input_pending(pclient)) {
} else if (program_client_close_output(pclient) < 0) {
}
}
return 1;
}
{
const unsigned char *data;
int ret = 0;
pclient);
}
if (!pclient->input_dot_created &&
}
if (pclient->input_dot_created &&
/* just read it empty */
&size) > 0)
}
switch (res) {
}
break;
return;
i_error("read(%s) failed: %s",
return;
i_error("write(%s) failed: %s",
return;
}
} else {
while ((ret =
ret == -2) {
}
if (ret == 0)
return;
if (ret < 0) {
if (input->stream_errno != 0) {
i_error("read(%s) failed: %s",
return;
}
}
}
return;
return;
}
}
}
static
{
}
}
{
int ret = 1;
}
/* 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)
{
struct program_client_extra_fd *efds;
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
{
}
{
int ret = -2;
if (ret == -2) {
}
return -1;
}
void *context)
{
if (program_client_connect(pclient) < 0)
}