bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic void notify_connection_unref(struct notify_connection *conn);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic void notify_connection_destroy(struct notify_connection *conn);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic bool notify_input_error(struct notify_connection *conn)
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid notify_connection_sync_callback(bool success, void *context)
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_nsend_str(conn->output, success ? "+\n" : "-\n");
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainennotify_input_line(struct notify_connection *conn, const char *line)
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* <username> \t <priority> */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen if (replication_priority_parse(args[1], &priority) < 0) {
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen i_error("Client sent invalid priority: %s", args[1]);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen replicator_connection_notify(replicator, args[0], priority);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen replicator_connection_notify_sync(replicator, args[0], conn);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic void notify_input(struct notify_connection *conn)
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* buffer full */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen /* disconnected */
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen while ((line = i_stream_next_line(conn->input)) != NULL) {
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenvoid notify_connection_create(int fd, bool fifo)
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainen conn->io = io_add(fd, IO_READ, notify_input, conn);
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi conn->input = i_stream_create_fd(fd, MAX_INBUF_SIZE);
e93184a9055c2530366dfe617e07199603c399ddMartti Rannanjärvi conn->output = o_stream_create_fd(fd, (size_t)-1);
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen o_stream_set_no_error_handling(conn->output, TRUE);
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic void notify_connection_unref(struct notify_connection *conn)
447e086422f1ab7cc16833583ed70a4af7a84bc5Timo Sirainenstatic void notify_connection_destroy(struct notify_connection *conn)