File: TestBase64Client.cpp

package info (click to toggle)
flxmlrpc 0.1.4-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,056 kB
  • sloc: sh: 11,511; cpp: 3,648; makefile: 63
file content (90 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download | duplicates (3)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// TestBase64Client.cpp : A simple xmlrpc client that returns a png file

// encoded as base64 data to the client.

//

// Usage: TestBase64Client serverHost serverPort outputfile

// Requests a png file from the specified server and saves it in outputfile.

// Link against xmlrpc lib and whatever socket libs your system needs (ws2_32.lib on windows)



#include "XmlRpc.h"

#include <iostream>

#include <fstream>

#include <stdlib.h>



using namespace XmlRpc;



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

{

  if (argc != 4) {

    std::cerr << "Usage: TestBase64Client serverHost serverPort outputFile\n";

    return -1;

  }

  int port = atoi(argv[2]);



  //XmlRpc::setVerbosity(5);

  XmlRpcClient c(argv[1], port);



  XmlRpcValue noArgs, result;

  if (c.execute("TestBase64", noArgs, result))

  {

    const XmlRpcValue::BinaryData& data = result;

    std::ofstream outfile(argv[3], std::ios::binary | std::ios::trunc);

    if (outfile.fail())

      std::cerr << "Error opening " << argv[3] << " for output.\n";

    else

    {

      int n = int(data.size());

      for (int i=0; i<n; ++i)

        outfile << data[i];

    }

  }

  else

    std::cout << "Error calling 'TestBase64'\n\n";



  return 0;

}