#include #include #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "JNet/JControlHost.hh" /** * \file * * Auxiliary program to send message to ControlHost server. * * The option -H \[:port] correponds to the hostname and the port of the server, respectively. * The option -t corresponds to the ControlHost tag. * The option -m \ corresponds to the message (should be quoted "" if it consists of multiple tokens). * \author mdejong */ int main(int argc, const char *argv[]) { using namespace std; string hostname; JNET::JTag tag; string message; bool use_cin; int debug; try { JParser<> zap("Auxiliary program to send message to ControlHost server."); zap['H'] = make_field(hostname) = "localhost"; zap['t'] = make_field(tag); zap['m'] = make_field(message) = ""; zap['c'] = make_field(use_cin); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; JControlHost::Throw(true); try { JControlHost out(hostname); if (!use_cin) out.PutFullString(tag, message); else { for ( ; ; ) { cout << "> " << flush; getline(cin, message); if (message != "") out.PutFullString(tag, message); else break; } } } catch(const JControlHostException& error) { ERROR(error << endl); } }