Jpp  19.1.0-rc.1
the software that should make you happy
Functions
JPutMessage.cc File Reference

Auxiliary program to send message to ControlHost server. More...

#include <string>
#include <iostream>
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
#include "JNet/JControlHost.hh"

Go to the source code of this file.

Functions

int main (int argc, const char *argv[])
 

Detailed Description

Auxiliary program to send message to ControlHost server.

The option -H <hostname>[:port] correponds to the hostname and the port of the server, respectively. The option -t corresponds to the ControlHost tag. The option -m <message> corresponds to the message (should be quoted "" if it consists of multiple tokens).

Author
mdejong

Definition in file JPutMessage.cc.

Function Documentation

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Definition at line 19 of file JPutMessage.cc.

20 {
21  using namespace std;
22 
23  string hostname;
24  JNET::JTag tag;
25  string message;
26  bool use_cin;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to send message to ControlHost server.");
32 
33  zap['H'] = make_field(hostname) = "localhost";
34  zap['t'] = make_field(tag);
35  zap['m'] = make_field(message) = "";
36  zap['c'] = make_field(use_cin);
37  zap['d'] = make_field(debug) = 3;
38 
39  zap(argc, argv);
40  }
41  catch(const exception &error) {
42  FATAL(error.what() << endl);
43  }
44 
45 
46  using namespace JPP;
47 
48  JControlHost::Throw(true);
49 
50  try {
51 
52  JControlHost out(hostname);
53 
54  if (!use_cin)
55 
56  out.PutFullString(tag, message);
57 
58  else {
59 
60  for ( ; ; ) {
61 
62  cout << "> " << flush;
63 
64  getline(cin, message);
65 
66  if (message != "")
67  out.PutFullString(tag, message);
68  else
69  break;
70  }
71  }
72  }
73  catch(const JControlHostException& error) {
74  ERROR(error << endl);
75  }
76 }
#define ERROR(A)
Definition: JMessage.hh:66
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
Exception for ControlHost.
Definition: JException.hh:486
ControlHost class.
ControlHost tag.
Definition: JTag.hh:38
Utility class to parse command line options.
Definition: JParser.hh:1714
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14