Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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 }
Utility class to parse command line options.
Definition: JParser.hh:1517
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define ERROR(A)
Definition: JMessage.hh:66
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
#define FATAL(A)
Definition: JMessage.hh:67
ControlHost tag.
Definition: JTag.hh:38
int debug
debug level