bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic void ipc_client_disconnect(struct ipc_client *client);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic void ipc_client_input_line(struct ipc_client *client, const char *line)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_error("IPC proxy sent unexpected input: %s", line);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen switch (*line++) {
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_error("IPC proxy sent invalid input: %s", line);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen cmds[0].callback(state, line, cmds[0].context);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic void ipc_client_input(struct ipc_client *client)
8a1e199862549ee3092db0de2f78c3a48c3ab1dbTimo Sirainen while ((line = i_stream_next_line(client->input)) != NULL) T_BEGIN {
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic int ipc_client_connect(struct ipc_client *client)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_error("connect(%s) failed: %m", client->path);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen client->io = io_add(client->fd, IO_READ, ipc_client_input, client);
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi client->input = i_stream_create_fd(client->fd, (size_t)-1);
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi client->output = o_stream_create_fd(client->fd, (size_t)-1);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_set_no_error_handling(client->output, TRUE);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenstatic void ipc_client_disconnect(struct ipc_client *client)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen i_error("close(%s) failed: %m", client->path);
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenvoid ipc_client_deinit(struct ipc_client **_client)
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainenvoid ipc_client_cmd(struct ipc_client *client, const char *cmd,
83942ac160cdfb922c3a2f29ddfae2a13ebf8b5dTimo Sirainen ipc_client_callback_t *callback, void *context)