OpenVMS Source Code Demos
CALCCLIENT
#define VERSION "calcclient-cpp-100.1" // <<<--- change as required
//===============================================================================================================================
// title: calcclient.cpp
// author: Neil Rieck (adapted from "gsoap/samples/calc++/calcclient.c")
// created: 2013-05-27
// os: OpenVMS-8.4 (Alpha)
// target: gSOAP for OpenVMS
// compiler: HP C++ V7.3-009 for OpenVMS Alpha V8.4
// build: $ cxx/names=(as_is,shortened)/prefix=all/float=ieee/ieee=denorm -
// /using_std/define=(__USE_STD_IOSTREAM) -
// /include=gsoap$root:[include] calcclient.cpp /list
// caveat: if you don't do it this way on an OpenVMS machine then the compiler will throw error messages like this:
// %CXX-E-NOTMEMBER, namespace "std" has no member "istream"
// %CXX-E-NOTMEMBER, namespace "std" has no member "ostream"
//===============================================================================================================================
const char server[] = "http://142.180.221.226:5001/calcserver.exe"; // change as required
//
#include <iostream> // required when using c++ apps with gSOAP
#include "SoapCalcProxy.h" // calc class defined here
#include "calc.nsmap" //
int main(int argc, char **argv)
{ // struct soap soap; // superfluous since soap is defined in an object
double a, b, result;
//
fprintf(stderr, "-i-program: %s\n",VERSION);
fprintf(stderr, "-i-connect string: %s\n",server);
if (argc < 4) { // do we have enough args?
fprintf(stderr, "-e-Usage: [add|sub|mul|div|pow] number number\n");
exit(0); //
} //
//
calcProxy calc; // create an instance of calcProxy call calc
calc.soap_endpoint = server; // set our destination URI
a = strtod(argv[2], NULL); // cmd line param #2 is value 1
b = strtod(argv[3], NULL); // cmd line param #3 is value 2
//
switch (*argv[1]) { // cmd line param #1 is the command
case 'a':
calc.add(a, b, &result);
break;
case 's':
calc.sub(a, b, &result);
break;
case 'm':
calc.mul(a, b, &result);
break;
case 'd':
calc.div(a, b, &result);
break;
case 'p':
calc.pow(a, b, &result);
break;
default:
fprintf(stderr, "-i-Unknown command\n");
exit(0);
}
if (calc.error){
calc.soap_stream_fault(std::cerr);
return 2; // vms-e- (error)
}else{
fprintf(stderr, "result = %g\n", result);
return 1; // vms-s- (sucess)
}
}