TestBase64Client.cpp
Go to the documentation of this file.
00001 // TestBase64Client.cpp : A simple xmlrpc client that returns a png file
00002 // encoded as base64 data to the client.
00003 //
00004 // Usage: TestBase64Client serverHost serverPort outputfile
00005 // Requests a png file from the specified server and saves it in outputfile.
00006 // Link against xmlrpc lib and whatever socket libs your system needs (ws2_32.lib on windows)
00007 
00008 #include "XmlRpc.h"
00009 #include <iostream>
00010 #include <fstream>
00011 #include <stdlib.h>
00012 
00013 using namespace XmlRpc;
00014 
00015 int main(int argc, char* argv[])
00016 {
00017   if (argc != 4) {
00018     std::cerr << "Usage: TestBase64Client serverHost serverPort outputFile\n";
00019     return -1;
00020   }
00021   int port = atoi(argv[2]);
00022 
00023   //XmlRpc::setVerbosity(5);
00024   XmlRpcClient c(argv[1], port);
00025 
00026   XmlRpcValue noArgs, result;
00027   if (c.execute("TestBase64", noArgs, result))
00028   {
00029     const XmlRpcValue::BinaryData& data = result;
00030     std::ofstream outfile(argv[3], std::ios::binary | std::ios::trunc);
00031     if (outfile.fail())
00032       std::cerr << "Error opening " << argv[3] << " for output.\n";
00033     else
00034     {
00035       int n = int(data.size());
00036       for (int i=0; i<n; ++i)
00037         outfile << data[i];
00038     }
00039   }
00040   else
00041     std::cout << "Error calling 'TestBase64'\n\n";
00042 
00043   return 0;
00044 }
00045 


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley
autogenerated on Mon Oct 6 2014 11:46:40