#include "soapH.h" #include "calc.nsmap" #include #include #ifdef MOD_GSOAP #include #else #include #endif #ifdef MOD_GSOAP IMPLEMENT_GSOAP_SERVER() #else int main(int argc, char **argv) { struct soap soap; CGIplus_InitVMS (argc, argv); soap_init1 (&soap, SOAP_IO_BUFFER); while (CGIplus_Accept() >= 0) { soap_serve(&soap); soap_end(&soap); } return 0; } #endif /* MOD_GSOAP */ int ns__add(struct soap *soap, double a, double b, double *result) { *result = a + b; return SOAP_OK; } int ns__sub(struct soap *soap, double a, double b, double *result) { *result = a - b; return SOAP_OK; } int ns__mul(struct soap *soap, double a, double b, double *result) { *result = a * b; return SOAP_OK; } int ns__div(struct soap *soap, double a, double b, double *result) { if (b) *result = a / b; else { char *s = (char*)soap_malloc(soap, 1024); sprintf(s, "Can't divide %f by %f", a, b); return soap_sender_fault(soap, "Division by zero", s); } return SOAP_OK; } int ns__pow(struct soap *soap, double a, double b, double *result) { *result = pow(a, b); if (soap_errno == EDOM) /* soap_errno is like errno, but compatible with Win32 */ { char *s = (char*)soap_malloc(soap, 1024); sprintf(s, "Can't take the power of %f to %f", a, b); sprintf(s, "Can't take power of %f to %f", a, b); return soap_sender_fault(soap, "Power function domain error", s); } return SOAP_OK; } int ns__repeat(struct soap *soap, char *repeat, unsigned int times, char **result) { if (!times || !repeat) { *result = NULL; } else { *result = soap_malloc(soap, strlen(repeat) * times + 1); for (unsigned int i = 0; i < times; i++) { strncpy(*result + i * strlen(repeat), repeat, strlen(repeat)); } (*result)[times * strlen(repeat)] = '\0'; } return SOAP_OK; }