-/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file
- */
+/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#define MAX_OUTPUT_BUFFER_SIZE 16384
#define MAX_OUTPUT_MEMORY_BUFFER (1024*128)
-static
-void program_client_callback(struct program_client *pclient, int result, void
- *context)
+static void
+program_client_callback(struct program_client *pclient, int result,
+ void *context)
{
/* do not call callback when destroying */
if (pclient->destroying) return;
callback(result, context);
}
-static
-int program_client_seekable_fd_callback(const char **path_r, void *context)
+static int
+program_client_seekable_fd_callback(const char **path_r, void *context)
{
struct program_client *pclient = (struct program_client *)context;
string_t *path;
return fd;
}
-static
-void program_client_timeout(struct program_client *pclient)
+static void
+program_client_timeout(struct program_client *pclient)
{
i_error("program `%s' execution timed out (> %u msecs)",
pclient->path, pclient->set.input_idle_timeout_msecs);
program_client_fail(pclient, PROGRAM_CLIENT_ERROR_RUN_TIMEOUT);
}
-static
-void program_client_connect_timeout(struct program_client *pclient)
+static void
+program_client_connect_timeout(struct program_client *pclient)
{
i_error("program `%s' socket connection timed out (> %u msecs)",
pclient->path, pclient->set.client_connect_timeout_msecs);
program_client_fail(pclient, PROGRAM_CLIENT_ERROR_CONNECT_TIMEOUT);
}
-static
-int program_client_connect(struct program_client *pclient)
+static int
+program_client_connect(struct program_client *pclient)
{
if (pclient->set.client_connect_timeout_msecs != 0) {
- pclient->to = timeout_add(pclient->set.client_connect_timeout_msecs,
- program_client_connect_timeout, pclient);
+ pclient->to = timeout_add(
+ pclient->set.client_connect_timeout_msecs,
+ program_client_connect_timeout, pclient);
}
return pclient->connect(pclient);
}
-static
-int program_client_close_output(struct program_client *pclient)
+static int
+program_client_close_output(struct program_client *pclient)
{
int ret;
return ret;
}
-static
-void program_client_disconnect_extra_fds(struct program_client *pclient)
+static void
+program_client_disconnect_extra_fds(struct program_client *pclient)
{
struct program_client_extra_fd *efds;
unsigned int i, count;
pclient->disconnected = TRUE;
- if (pclient->other_error && pclient->error == PROGRAM_CLIENT_ERROR_NONE) {
+ if (pclient->other_error &&
+ pclient->error == PROGRAM_CLIENT_ERROR_NONE) {
pclient->error = PROGRAM_CLIENT_ERROR_OTHER;
}
program_client_callback(pclient,
- pclient->error != PROGRAM_CLIENT_ERROR_NONE ?
- -1 :
- (int)pclient->exit_code,
+ (pclient->error != PROGRAM_CLIENT_ERROR_NONE ?
+ -1 : (int)pclient->exit_code),
pclient->context);
}
-static
-void program_client_disconnect(struct program_client *pclient, bool force)
+static void
+program_client_disconnect(struct program_client *pclient, bool force)
{
int ret;
program_client_disconnect(pclient, TRUE);
}
-static
-bool program_client_input_pending(struct program_client *pclient)
+static bool
+program_client_input_pending(struct program_client *pclient)
{
struct program_client_extra_fd *efds = NULL;
unsigned int count, i;
return FALSE;
}
-static
-int program_client_program_output(struct program_client *pclient)
+static int
+program_client_program_output(struct program_client *pclient)
{
struct istream *input = pclient->input;
struct ostream *output = pclient->program_output;
if (pclient->output_seekable && pclient->seekable_output == NULL) {
struct istream *input_list[2] = { input, NULL };
- input = i_stream_create_seekable(input_list, MAX_OUTPUT_MEMORY_BUFFER,
- program_client_seekable_fd_callback,
- pclient);
+ input = i_stream_create_seekable(input_list,
+ MAX_OUTPUT_MEMORY_BUFFER,
+ program_client_seekable_fd_callback, pclient);
i_stream_unref(&pclient->program_input);
pclient->program_input = input;
program_client_disconnect(pclient, FALSE);
}
-static
-void program_client_extra_fd_input(struct program_client_extra_fd *efd)
+static void
+program_client_extra_fd_input(struct program_client_extra_fd *efd)
{
struct program_client *pclient = efd->pclient;
pclient->output_seekable = TRUE;
}
-struct istream *program_client_get_output_seekable(struct program_client *pclient)
+struct istream *
+program_client_get_output_seekable(struct program_client *pclient)
{
struct istream *input = pclient->seekable_output;
efds[i].input = i_stream_create_fd
(efds[i].parent_fd, (size_t)-1);
i_stream_set_name(efds[i].input,
- t_strdup_printf("program output fd=%d",
- efds[i].child_fd));
+ t_strdup_printf("program output fd=%d",
+ efds[i].child_fd));
efds[i].io = io_add(efds[i].parent_fd, IO_READ,
program_client_extra_fd_input,
&efds[i]);
void program_client_destroy(struct program_client **_pclient)
{
struct program_client *pclient = *_pclient;
+
*_pclient = NULL;
pclient->destroying = TRUE;
const char **error_r)
{
if (strncmp(uri, "exec:", 5) == 0) {
- *pc_r = program_client_local_create(
- uri+5,
- args,
- set);
+ *pc_r = program_client_local_create(uri+5, args, set);
return 0;
} else if (strncmp(uri, "unix:", 5) == 0) {
- *pc_r = program_client_unix_create(
- uri+5,
- args,
- set, noreply);
+ *pc_r = program_client_unix_create(uri+5, args, set, noreply);
return 0;
} else if (strncmp(uri, "tcp:", 4) == 0) {
const char *host;
in_port_t port;
- if (net_str2hostport(uri+4, 0, &host, &port) < 0 || port == 0) {
+
+ if (net_str2hostport(uri+4, 0, &host, &port) < 0 ||
+ port == 0) {
*error_r = t_strdup_printf(
- "Invalid tcp syntax, must be host:port in '%s'", uri+4);
+ "Invalid tcp syntax, "
+ "must be host:port in '%s'", uri+4);
return -1;
}
- *pc_r = program_client_net_create(
- host, port,
- args,
- set, noreply);
+ *pc_r = program_client_net_create(host, port, args, set,
+ noreply);
return 0;
} else {
*error_r = t_strdup_printf(
}
}
-static
-void program_client_run_callback(int result, int *context)
+static void
+program_client_run_callback(int result, int *context)
{
*context = result;
io_loop_stop(current_ioloop);