# # # patch "automate_ostream.hh" # from [d7fa401c88c9b69035201b918c721c5a5d38c10d] # to [e191a9d2ccc72b568e82c63a478d070dac3a2aa6] # # patch "automate_ostream_demuxed.hh" # from [29fd0c1a2de69865bdd348145ae8bcef351b2ee0] # to [97eca47597abccc55de0260c370365af417a57bd] # # patch "cmd_automate.cc" # from [7f69cbb88920c6447952def2e84f13279d086977] # to [b622d3f6f85db7bb92b1ea63a0616583fc14a7d8] # # patch "cmd_netsync.cc" # from [7ebeec90d949fecfa3e89fe9ed5097069236807a] # to [8630d1b862c0074caf0e2e53af86936e4e80d241] # # patch "network/automate_session.cc" # from [8f4f14eec76351d1fcd5571ebbd25b228bb02800] # to [b115ca75afabc548cdb4a289f7296cc73ec68bf6] # ============================================================ --- automate_ostream.hh d7fa401c88c9b69035201b918c721c5a5d38c10d +++ automate_ostream.hh e191a9d2ccc72b568e82c63a478d070dac3a2aa6 @@ -72,7 +72,7 @@ public: out->flush(); } } - void write_out_of_band(char type, std::string const& data) + void write_out_of_band(char type, std::string const & data) { unsigned chunksize = _bufsize; size_t length = data.size(), offset = 0; @@ -123,6 +123,9 @@ public: virtual void end_cmd() { _M_autobuf.end_cmd(); } + + virtual void write_out_of_band(char type, std::string const & data) + { _M_autobuf.write_out_of_band(type, data); } }; typedef basic_automate_streambuf automate_streambuf; ============================================================ --- automate_ostream_demuxed.hh 29fd0c1a2de69865bdd348145ae8bcef351b2ee0 +++ automate_ostream_demuxed.hh 97eca47597abccc55de0260c370365af417a57bd @@ -14,6 +14,7 @@ #include #include "automate_ostream.hh" +#include "simplestring_xform.hh" template > class basic_automate_streambuf_demuxed : public std::basic_streambuf<_CharT, _Traits> @@ -60,6 +61,28 @@ public: return 0; } + void write_out_of_band(char type, std::string const & data) + { + // FIXME: ignore tickers, because we'd have to track their state + // here and they would pollute the output too much anyways + if (type == 't') + return; + + std::string out; + i18n_format prefix; + if (type == 'w') + prefix = F("%s: remote warning: ") % prog_name; + else if (type == 'e') + prefix = F("%s: remote error: ") % prog_name; + else if (type == 'p') + prefix = F("%s: remote message: ") % prog_name; + else + I(false); + + prefix_lines_with(prefix.str(), data, out); + (*errout) << out << std::endl; + } + int_type overflow(int_type c = traits_type::eof()) { sync(); @@ -92,6 +115,7 @@ struct basic_automate_ostream_demuxed : typedef basic_automate_streambuf_demuxed<_CharT, _Traits> streambuf_type; streambuf_type _M_autobuf; +public: basic_automate_ostream_demuxed(std::basic_ostream<_CharT, _Traits> &out, std::basic_ostream<_CharT, _Traits> &err, size_t blocksize) @@ -113,6 +137,9 @@ struct basic_automate_ostream_demuxed : virtual void end_cmd() { _M_autobuf.end_cmd(); } + + virtual void write_out_of_band(char type, std::string const & data) + { _M_autobuf.write_out_of_band(type, data); } }; typedef basic_automate_streambuf_demuxed automate_streambuf_demuxed; ============================================================ --- cmd_automate.cc 7f69cbb88920c6447952def2e84f13279d086977 +++ cmd_automate.cc b622d3f6f85db7bb92b1ea63a0616583fc14a7d8 @@ -106,7 +106,7 @@ static void out_of_band_to_automate_stre static void out_of_band_to_automate_streambuf(char channel, std::string const& text, void *opaque) { - reinterpret_cast(opaque)->write_out_of_band(channel, text); + reinterpret_cast(opaque)->write_out_of_band(channel, text); } // Name: stdio @@ -167,8 +167,8 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", automate_reader ar(std::cin); vector > params; vector cmdline; - global_sanity.set_out_of_band_handler(&out_of_band_to_automate_streambuf, - &os._M_autobuf); + global_sanity.set_out_of_band_handler(&out_of_band_to_automate_streambuf, &os); + while (true) { automate const * acmd = 0; @@ -243,7 +243,7 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", catch (option::option_error & e) { os.set_err(1); - os._M_autobuf.write_out_of_band('e', e.what()); + os.write_out_of_band('e', e.what()); os.end_cmd(); ar.reset(); continue; @@ -251,7 +251,7 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", catch (recoverable_failure & f) { os.set_err(1); - os._M_autobuf.write_out_of_band('e', f.what()); + os.write_out_of_band('e', f.what()); os.end_cmd(); ar.reset(); continue; @@ -266,7 +266,7 @@ CMD_AUTOMATE_NO_STDIO(stdio, "", catch (recoverable_failure & f) { os.set_err(2); - os._M_autobuf.write_out_of_band('e', f.what()); + os.write_out_of_band('e', f.what()); } os.end_cmd(); } ============================================================ --- cmd_netsync.cc 7ebeec90d949fecfa3e89fe9ed5097069236807a +++ cmd_netsync.cc 8630d1b862c0074caf0e2e53af86936e4e80d241 @@ -443,7 +443,7 @@ CMD_AUTOMATE_NO_STDIO(remote, client_voice, source_and_sink_role, info); E(os.get_error() == 0, origin::network, - F("Received remote error code %d") % os.get_error()); + F("received remote error code %d") % os.get_error()); } CMD(push, "push", "", CMD_REF(network), ============================================================ --- network/automate_session.cc 8f4f14eec76351d1fcd5571ebbd25b228bb02800 +++ network/automate_session.cc b115ca75afabc548cdb4a289f7296cc73ec68bf6 @@ -267,7 +267,7 @@ bool automate_session::do_work(transacti if (stream == 'm' || stream == 'l') (*output_stream) << packet_data; else - output_stream->_M_autobuf.write_out_of_band(stream, packet_data); + output_stream->write_out_of_band(stream, packet_data); if (stream == 'l') {