File: rpcbecho.cpp

package info (click to toggle)
cxxtools 3.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,960 kB
  • sloc: cpp: 68,550; ansic: 15,641; sh: 4,239; makefile: 841
file content (46 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <cxxtools/arg.h>
#include <cxxtools/log.h>
#include <cxxtools/sslcertificate.h>
#include <cxxtools/remoteprocedure.h>
#include <cxxtools/bin/rpcclient.h>

bool noAccept(const cxxtools::SslCertificate& cert)
{
    std::cout << "cert \"" << cert.getSubject() << "\" not accepted" << std::endl;
    return false;
}

////////////////////////////////////////////////////////////////////////
// main
//
int main(int argc, char* argv[])
{
  try
  {
    log_init();

    cxxtools::Arg<std::string> ip(argc, argv, 'i');
    cxxtools::Arg<unsigned short> port(argc, argv, 'p', 7003);
    cxxtools::Arg<std::string> cert(argc, argv, 'c');
    cxxtools::Arg<std::string> ca(argc, argv, 'C');

    cxxtools::bin::RpcClient client(ip, port, cert);

    if (ca.isSet())
        client.setSslVerify(2, ca);

    cxxtools::RemoteProcedure<std::string, std::string> echo(client, "echo");

    for (int a = 1; a < argc; ++a)
    {
      std::string v = echo(argv[a]);
      std::cout << v << '\n';
    }
  }
  catch (const std::exception& e)
  {
    std::cerr << e.what() << std::endl;
  }
}