first commit

This commit is contained in:
2025-11-25 10:55:38 +07:00
commit 88ebdb465c
57 changed files with 9213 additions and 0 deletions

108
test/FileClient.cpp Normal file
View File

@@ -0,0 +1,108 @@
// FileClient.cpp : A simple xmlrpc client. Usage: FileClient serverHost serverPort xmlfile
// Reads an xmlrpc request from the specified xmlfile and calls the method on the server.
//
// 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;
std::string parseRequest(std::string const& xml, XmlRpcValue& params);
int main(int argc, char* argv[])
{
if (argc != 4) {
std::cerr << "Usage: FileClient serverHost serverPort requestXmlFile\n";
return -1;
}
int port = atoi(argv[2]);
XmlRpc::setVerbosity(5);
XmlRpcClient c(argv[1], port);
//
std::ifstream infile(argv[3]);
if (infile.fail()) {
std::cerr << "Could not open file '" << argv[3] << "'.\n";
return -1;
}
// Suck in the file. This is a one-liner in good compilers (which vc++ 6 is not)...
infile.seekg(0L, std::ios::end);
long nb = infile.tellg();
infile.clear();
infile.seekg(0L);
char* b = new char[nb+1];
infile.read(b, nb);
b[nb] = 0;
std::cout << "Read file.\n";
// Find the methodName and parse the params
std::string s(b);
XmlRpcValue params;
std::string name = parseRequest(s, params);
if (name.empty()) {
std::cerr << "Could not parse file\n";
return -1;
}