int ns__bitwiseAnd( struct soap *soap, char *src1, char *src2, char **OutputMatFilename) { double start, end; start = omp_get_wtime(); Mat matSrc1; if(!readMat(src1, matSrc1)) { cerr << "And :: src1 can not read bin file" << endl; return soap_receiver_fault(soap, "And :: src1 can not read bin file", NULL); } Mat matSrc2; if(!readMat(src2, matSrc2)) { cerr << "And :: src2 can not read bin file" << endl; return soap_receiver_fault(soap, "And :: src2 can not read bin file", NULL); } int cols = matSrc1.cols ; int srcType1 = matSrc1.type(); int srcType2 = matSrc2.type(); if(srcType1 != srcType2 ) { matSrc2.convertTo(matSrc2, srcType1); } Mat dst; bitwise_and(matSrc1, matSrc2, dst); /* generate output file name */ *OutputMatFilename = (char*)soap_malloc(soap, 60); getOutputFilename(OutputMatFilename,"_bitwiseAnd"); /* save to bin */ if(!saveMat(*OutputMatFilename, dst)) { cerr << "And:: save mat to binary file" << endl; return soap_receiver_fault(soap, "And :: save mat to binary file", NULL); } matSrc1.release(); matSrc2.release(); dst.release(); end = omp_get_wtime(); cerr<<"ns__And time elapsed "<<end-start<<endl; return SOAP_OK; }
int __ns1__dtx(struct soap *soap, _XML x, struct _ns2__commingtotown *response) { struct soap *csoap = soap_copy(soap); struct tm tm; time_t now, xmas; double sec, days; soap_set_namespaces(csoap, gmt_namespaces); if (soap_call_t__gmt(csoap, "http://www.cs.fsu.edu/~engelen/gmtlitserver.cgi", NULL, &now)) { soap_end(csoap); soap_free(csoap); return soap_receiver_fault(soap, "Cannot connect to GMT server", NULL); } tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0; tm.tm_mday = 25; tm.tm_mon = 11; tm.tm_year = gmtime(&now)->tm_year; /* this year */ tm.tm_isdst = 0; tm.tm_zone = NULL; xmas = soap_timegm(&tm); if (xmas < now) { tm.tm_year++; /* xmas just passed, go to next year */ xmas = soap_timegm(&tm); } sec = difftime(xmas, now); soap_set_namespaces(csoap, calc_namespaces); if (soap_call_ns__add(csoap, NULL, NULL, sec, 86400, &days)) { soap_end(csoap); soap_free(csoap); return soap_receiver_fault(soap, "Cannot connect to calc server", NULL); } soap_end(csoap); soap_free(csoap); response->days = (int)days; return SOAP_OK; }
int ns__get_radar_data(soap* soap, int sessionID, char* site, char* product, struct DateTime time, struct RadarData* result) { DarxendClient* client = client_manager_get_client(sessionID); if (!client) return die_bad_client(soap); unsigned int length = 0; gchar* psite = g_ascii_strdown(site, -1); gchar* pproduct = g_ascii_strup(product, -1); char* data = radar_data_manager_read_data(psite, pproduct, time, &length); g_free(psite); g_free(pproduct); if (!data) return soap_receiver_fault(soap, "Data not found", NULL); gchar* b64data = g_base64_encode((guchar*)data, length); free(data); result->data = (char*)soap_malloc(soap, strlen(b64data)); strcpy(result->data, b64data); g_free(b64data); return SOAP_OK; }
static void glite_jp_server_err2fault(const glite_jp_context_t ctx,struct soap *soap) { struct SOAP_ENV__Detail *detail; struct jptype__genericFault *item; #if GSOAP_VERSION >= 20709 struct jptype__genericFault *f; item = f = jp2s_error(soap,ctx->error); #else struct _genericFault *f = soap_malloc(soap, sizeof *f); item = f->jpelem__genericFault = jp2s_error(soap,ctx->error); #endif soap_receiver_fault(soap,"Oh, shit!",NULL); // no error in JP context? if (!item) return; detail = (struct SOAP_ENV__Detail *)soap_faultdetail(soap); #if GSOAP_VERSION >= 20700 detail->fault = (void *)f; #else detail->value = (void *)f; #endif detail->__type = GFNUM; detail->__any = NULL; if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; else soap->fault->detail = detail; }
int ns__MatToJPG (struct soap *soap, char *InputMatFilename, char **OutputMatFilename) { double start, end; start = omp_get_wtime(); Mat src; /* check if it is not 8U then convert to 8UC(n) */ int chan = src.channels(); if( src.type() != 0 || src.type() != 8 || src.type() != 16 ) { src.convertTo(src, CV_8UC(chan)); } /* generate output file name */ *OutputMatFilename = (char*)soap_malloc(soap, FILENAME_SIZE); getOutputFilename(OutputMatFilename,".jpg"); if(!imwrite(*OutputMatFilename, src)) { cerr<< "MatToJPG:: can not save mat to jpg file" << endl; return soap_receiver_fault(soap, "MatToJPG:: can not save mat to jpg file", NULL); } src.release(); end = omp_get_wtime(); cerr<<"ns__MatToJPG "<<"time elapsed "<<end-start<<endl; return SOAP_OK; }
//********************************************************************************** // GetSerieShotFiles //********************************************************************************** int GetSerieShotFiles(struct soap* soap, HtiMsgHelper &msg, struct ArrayOfFiles *files ) { // list of screenshot files is returned char** tmp_array_ptr = NULL; int i = 0; files->__size = 0; while( i < msg.GetMsgLen() ) { int fileNameLen = msg.GetMsgBody()[i++]; tmp_array_ptr = (char**) realloc(tmp_array_ptr, (files->__size+1)*sizeof(char**)); tmp_array_ptr[files->__size++] = msg.GetSoapString( i, fileNameLen ); i += fileNameLen; } if ( files->__size == 0 ) { soap->error = soap_receiver_fault( soap, "HtiError", "No screenshot files returned"); return SOAP_FAULT; } // alloc (soap) space for pointers & copy data from tmp_array_ptr files->__ptr = (char**) soap_malloc(soap, sizeof(char**)*files->__size); memcpy(files->__ptr, tmp_array_ptr, sizeof(char**)*files->__size); free(tmp_array_ptr); return SOAP_OK; }
void cms_clientFree( cms_client client) { struct soap* soap; cms_soapThread soapThread; cms_thread(client)->terminate = TRUE; os_mutexLock(&client->conditionMutex); os_condSignal(&client->condition); os_mutexUnlock(&client->conditionMutex); cms_threadDeinit(cms_thread(client)); if(client->soapEnvs){ os_mutexLock(&client->soapMutex); soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs)); while(soap){ soap->error = soap_receiver_fault(soap, "Service is terminating.", NULL); soap_send_fault(soap); soap_destroy(soap); soap_end(soap); soap_done(soap); os_free(soap); soap = (struct soap*)(c_iterTakeFirst(client->soapEnvs)); } c_iterFree(client->soapEnvs); client->soapEnvs = NULL; os_mutexUnlock(&client->soapMutex); } if(client->threads){ soapThread = cms_soapThread(c_iterTakeFirst(client->threads)); while(soapThread){ cms_soapThreadFree(soapThread); (void)u_observableAction(u_observable(client->service->uservice), cms_clientStatisticsThreadRemove, client->service); soapThread = cms_soapThread(c_iterTakeFirst(client->threads)); } c_iterFree(client->threads); client->threads = NULL; } os_mutexDestroy(&client->soapMutex); os_mutexDestroy(&client->threadMutex); os_mutexDestroy(&client->conditionMutex); os_condDestroy(&client->condition); client->initCount = 0; if(client->service->configuration->verbosity >= 5){ OS_REPORT(OS_INFO, CMS_CONTEXT, 0, "Client thread stopped for IP: %d.%d.%d.%d", (int)(client->ip>>24)&0xFF, (int)(client->ip>>16)&0xFF, (int)(client->ip>>8)&0xFF, (int)(client->ip&0xFF)); }
int ns__dilate( struct soap *soap, char *InputMatFilename, char *elementFilename, int iteration=1, char **OutputMatFilename=NULL) { double start, end; start = omp_get_wtime(); Mat src; if(!readMat(InputMatFilename, src)) { cerr << "dilate :: can not read bin file" << endl; return soap_receiver_fault(soap, "dilate :: can not read bin file", NULL); } Mat dst; Mat element; if(!readMat(elementFilename, element)) { cerr<<"dilate :: use default element"<<endl; element.release(); dilate(src, dst, Mat(), Point(-1, -1), iteration); } else { cerr<<"dilate :: use defined element"<<endl; dilate(src, dst, element, Point(-1, -1), iteration); } /* generate output file name */ *OutputMatFilename = (char*)soap_malloc(soap, 60); getOutputFilename(OutputMatFilename,"_dilate"); /* save to bin */ if(!saveMat(*OutputMatFilename, dst)) { cerr << "dilate :: save mat to binary file" << endl; return soap_receiver_fault(soap, "dilate :: save mat to binary file", NULL); } src.release(); dst.release(); element.release(); return SOAP_OK; }
int ns__search_radar_data( soap* soap, int sessionID, char* site, char* product, struct DateTime* start, struct DateTime* end, int* result) { DarxendClient* client = client_manager_get_client(sessionID); if (!client) return die_bad_client(soap); if (!start) return soap_receiver_fault(soap, "Start date must not be null", NULL); if (!verifyDate(start)) return soap_receiver_fault(soap, "Invalid start date", "Value out of range"); if (end) { if (!verifyDate(end)) return soap_receiver_fault(soap, "Invalid end date", "Value out of range"); if ((start->date.year > end->date.year) || (start->date.year == end->date.year && start->date.month > end->date.month) || (start->date.year == end->date.year && start->date.month == end->date.month && start->date.day > end->date.day) || (start->date.year == end->date.year && start->date.month == end->date.month && start->date.day == end->date.day && start->time.hour > end->time.hour) || (start->date.year == end->date.year && start->date.month == end->date.month && start->date.day == end->date.day && start->time.hour == end->time.hour && start->time.minute > end->time.minute)) return soap_receiver_fault(soap, "Start date must be before end date.", NULL); } gchar* psite = g_ascii_strdown(site, -1); gchar* pproduct = g_ascii_strup(product, -1); *result = darxend_client_search(client, psite, pproduct, start, end); g_free(psite); g_free(pproduct); 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); return soap_receiver_fault(soap, "Power function domain error", s); } 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_receiver_fault(soap, "Division by zero", s); } return SOAP_OK; }
/* Server definitions */ int adb__status(struct soap* soap, xsd__string dbName, adb__statusResponse &adbStatusResponse){ const char *argv[]={"./audioDB",COM_STATUS,"-d",dbName}; const unsigned argc = 4; try { audioDB(argc, argv, &adbStatusResponse); return SOAP_OK; } catch(char *err) { soap_receiver_fault(soap, err, ""); return SOAP_FAULT; } }
int ns3__getQuote(struct soap *soap, char *symbol, char *country, float &result) { float q, r; // soap->user contains an environment that we can use to make calls that do not interfere with the current service environment if (soap_call_ns1__getQuote((struct soap*)soap->user, "http://services.xmethods.net/soap", NULL, symbol, q) == 0 && soap_call_ns2__getRate((struct soap*)soap->user, "http://services.xmethods.net/soap", NULL, "us", country, r) == 0) { result = q*r; return SOAP_OK; } soap_receiver_fault(soap, *soap_faultstring((struct soap*)soap->user), NULL); return SOAP_FAULT; // pass soap fault messages on to the client of this app }
void *mime_client_write_open(struct soap *soap, void *unused_handle, const char *id, const char *type, const char *description, enum soap_mime_encoding encoding) { /* Note: the 'unused_handle' is always NULL */ FILE *fd; const char *file; fprintf(stderr, "Opening streaming inbound MIME channel for id=%s type=%s\n", id, type); /* soap->user points to array of keys (strings) that are file names */ file = *(char**)soap->user; soap->user = (void*)(((char**)soap->user)+1); fd = fopen(file, "wb"); if (!fd) soap->error = soap_receiver_fault(soap, "Cannot save data to file", file); return (void*)fd; }
//********************************************************************************** // ns1__deregister() //********************************************************************************** int ns1__deregister(struct soap* soap, char *host, struct ns1__deregisterResponse *out) { if(check_mandatory_string_parameter(soap, host, "host")) return SOAP_FAULT; if(g_HtiStifClients->Remove(host) != 0) { soap->error = soap_receiver_fault(soap, "HtiGateway", "deregister: did not find host"); return SOAP_FAULT; } return SOAP_OK; }
int agentService::setCameraURI(struct camera__uri *_info, struct camera__info &_infoResponse) { std::clog << "### INIZIO ###" << std::endl; ManagerAgent* server = static_cast<ManagerAgent*>(this->user); std::clog << "uuid: " << _info->uuid << std::endl; if (server->servers.find(_info->uuid) == server->servers.end()) { if (_info->uuid != "SwitchServer") server->servers[_info->uuid] = new RTSPserverManager(); else server->servers[_info->uuid] = new RTSPserverGate(); if (server->servers[_info->uuid]->getLocation().empty()) { server->urls[_info->uuid]["live"] = _info->streamURI; server->servers[_info->uuid]->setLocation(_info->streamURI); server->servers[_info->uuid]->setPath("/" + _info->uuid); server->servers[_info->uuid]->run(); std::clog << "CoreServer: " << server->CoreProxy->getEndpoint() << std::endl; std::clog << "StreamURI: " << _info->streamURI << std::endl; std::clog << "TEST : " << server->servers[_info->uuid]->getPath() << std::endl; //boost::thread* serve; _infoResponse.uuid = _info->uuid; _infoResponse.Info_type = "HubServer"; _infoResponse.Info = "rtsp://" + std::string(server->getIP()) + ":" + RTSPserver::port1 + server->servers[_info->uuid]->getPath(); std::clog << "server : " << _infoResponse.Info << std::endl; //serve = new boost::thread(boost::bind(&SMC::CoreServerProxy::run,server->CoreProxy)); } std::clog << "### FINE BENE ###" << std::endl; return SOAP_OK; // server->CoreProxy->setCameraInfo(_info->uuid,"HubServer",server->servers[_info->uuid]->getPath()); } else { //_infoResponse.uuid.clear(); std::clog << "### FINE ERRORE ###" << std::endl; std::clog << "Camera esistente" << std::endl; return soap_receiver_fault(this, "Camera gia inserita nel sistema", NULL); } }
int adb__liszt(struct soap* soap, xsd__string dbName, xsd__int lisztOffset, xsd__int lisztLength, adb__lisztResponse& adbLisztResponse){ INTSTRINGIFY(lisztOffset, lisztOffsetStr); INTSTRINGIFY(lisztLength, lisztLengthStr); const char *argv[] = {"./audioDB", COM_LISZT, "-d",dbName, "--lisztOffset", lisztOffsetStr, "--lisztLength", lisztLengthStr}; const unsigned argc = 8; try{ audioDB(argc, argv, soap, &adbLisztResponse); return SOAP_OK; } catch(char *err) { soap_receiver_fault(soap, err, ""); return SOAP_FAULT; } }
int HtiStifMsg::SendReceiveMsg(struct soap* soap, int timeout) { //dump(msgBody, msgBodyLen); BYTE commandCode = msgBody[0]; // Send the message to symbian side HtiSoapHandlerInterface* handler = static_cast<HtiSoapHandlerInterface*>(soap->user); handler->SendHtiMessage(HTI_STIF_UID, msgBody, msgBodyLen); // Clean these up for received HTI message delete msgBody; msgBody = NULL; msgBodyLen = 0; while(1) { if (handler->WaitForHtiMessage(timeout)) { int err = handle_received_message(handler, TRUE); // NOTE: this will be destroyed by gateway msgBody = (BYTE*) handler->ReceivedHtiMessageBody(); msgBodyLen = handler->ReceivedHtiMessageBodySize(); // Received a HTI initiated msg // Start waiting again if( (err == HTI_RECV_ASYNC_CALL_SERVICED) || (err == HTI_RECV_ASYNC_CALL_SERVICE_ERROR) ) { continue; } if( err == HTI_RECV_ERROR_MESSAGE ) SetSoapFaultFromReceivedHtiError(soap, msgBody, msgBodyLen); return err; } else { // timeout soap->error = soap_receiver_fault(soap, "HtiGateway", "No response from symbian side"); return HTI_RECV_TIMEOUT; } } }
int HtiStifMsg::CheckResponseCommandCode(struct soap *soap, BYTE commandCode) { int result = SOAP_OK; if( msgBody[0] != commandCode ) { char msg[] = "incorrect response CommandCode (expected 0x%x, got 0x%x)"; int msgLen = _scprintf(msg, commandCode, msgBody[0])+1; // +1 for nul char char *buf = new char[msgLen]; sprintf(buf, msg, commandCode, msgBody[0]); soap->error = soap_receiver_fault(soap, "HtiError", buf); delete buf; result = SOAP_FAULT; } return result; }
void SoapHandler::SendSoapFaultFromReceivedHtiError() { if ( m_SoapEnv && IsReceivedHtiError() ) { stringstream s; s<<"<htiError xmlns=\'urn:hti/fault\'><frameworkErrorCode>"; s<<m_ReceiveHtiMsg->HtiErrorCode(); s<<"</frameworkErrorCode><serviceErrorCode>"; s<<m_ReceiveHtiMsg->ServiceErrorCode(); s<<"</serviceErrorCode><serviceErrorDescription>"; s<<m_ReceiveHtiMsg->ErrorDescription(); s<<"</serviceErrorDescription>"; s<<"</htiError>"; soap_receiver_fault(m_SoapEnv, "HtiError", s.str().c_str() ); } }
int ns__search_get_records(soap* soap, int sessionID, int searchID, int start, int count, struct DateTimeArray* result) { DarxendClient* client = client_manager_get_client(sessionID); if (!client) return die_bad_client(soap); DateTime* results = radar_data_manager_get_search_records(searchID, start, count); result->__size = count; result->array = soap_malloc(soap, count * sizeof(DateTime)); memcpy(result->array, results, count*sizeof(DateTime)); free(results); if (!result->array) return soap_receiver_fault(soap, "Invalid search request", "No results"); return SOAP_OK; }
static void *dime_write_open(struct soap *soap, const char *id, const char *type, const char *options) { // we can return NULL without setting soap->error if we don't want to use the streaming callback for this DIME attachment FILE *handle = NULL; char *name; // get file name from options (not '\0' terminated) if (options) { size_t len = ((unsigned char)options[2] << 8) | ((unsigned char)options[3]); // option string length name = (char*)soap_malloc(soap, len + 1); strncpy(name, options + 4, len); name[len] = '\0'; handle = fopen(name, "wb"); if (!handle) { soap->error = SOAP_EOF; // could not open file for writing soap->errnum = errno; // get reason return NULL; } } else soap->error = soap_receiver_fault(soap, "Cannot save to file, because no file name was present in attachment", NULL); return (void*)handle; }
void SetSoapFaultFromReceivedHtiError(struct soap *soap, BYTE *receivedMsgBody, int receivedMsgBodyLen) { if( receivedMsgBodyLen == 10 ) { // This is a standard error message // (eg. not authenticated) HtiSoapHandlerInterface* handler = static_cast<HtiSoapHandlerInterface*>(soap->user); handler->SendSoapFaultFromReceivedHtiError(); return; } // Get error codes int frameworkErrorCode = *((BYTE*)(receivedMsgBody + 1)); int serviceErrorCode = *((DWORD*)(receivedMsgBody + 2)); // Get error description // NOTE: first byte is skipped because it contains the command code int serviceErrorDescLen = receivedMsgBodyLen - 11; char* serviceErrorDesc = new char[receivedMsgBodyLen - 11 + 1]; memcpy(serviceErrorDesc, receivedMsgBody+11, serviceErrorDescLen); serviceErrorDesc[serviceErrorDescLen] = 0x0; // Fill the xml struct std::stringstream s; s<<"<htiError xmlns=\'urn:hti/fault\'><frameworkErrorCode>"; s<<frameworkErrorCode; s<<"</frameworkErrorCode><serviceErrorCode>"; s<<serviceErrorCode; s<<"</serviceErrorCode><serviceErrorDescription>"; s<<serviceErrorDesc; s<<"</serviceErrorDescription>"; s<<"</htiError>"; soap->error = soap_receiver_fault(soap, "HtiError", s.str().c_str() ); delete serviceErrorDesc; }
void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap) { char *et,*ed; struct SOAP_ENV__Detail *detail; #if GSOAP_VERSION >= 20709 struct lbt__genericFault *f = soap_malloc(soap,sizeof *f); struct lbt__genericFault *item = f; #else struct _genericFault *f = soap_malloc(soap,sizeof *f); struct lbt__genericFault *item = f->lbe__genericFault = soap_malloc(soap, sizeof *item); #endif memset(item, 0, sizeof(*item)); item->code = edg_wll_Error(ctx,&et,&ed); item->text = soap_malloc(soap,strlen(et)+1); strcpy(item->text, et); free(et); if (ed) { item->description = soap_malloc(soap,strlen(ed)+1); strcpy(item->description,ed); free(ed); } detail = (struct SOAP_ENV__Detail *)soap_faultdetail(soap); detail->__type = GFNUM; #if GSOAP_VERSION >= 20700 detail->fault = f; #else detail->value = f; #endif detail->__any = NULL; soap_receiver_fault(soap,"An error occurred, see detail",NULL); if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; else soap->fault->detail = detail; }
OPENSPLICE_SERVICE_ENTRYPOINT (ospl_cmsoap, cmsoap) { cms_service cms; cms_client client; c_bool success; char* name = NULL; char* config; c_long slave; struct soap* soap; slave = -1; soap = NULL; if(argc == 3) { name = argv[1]; config = argv[2]; cms = cms_serviceNew(name,config); if(cms != NULL){ os_signalHandlerExitRequestHandle erh = os_signalHandlerExitRequestHandleNil; if(!os_serviceGetSingleProcess()){ erh = os_signalHandlerRegisterExitRequestCallback(exitRequestHandler, NULL, NULL, NULL, cms); } while(cms->terminate == FALSE){ while( (slave < 0) && (cms->terminate == FALSE)){ slave = soap_accept(cms->soap); } if (slave < 0) { if(cms->configuration->verbosity > 0){ /* soap_accept is likely to return -1 when the soap service is shutdown * so should be an INFO message here rather than a WARNING */ OS_REPORT(OS_INFO, CMS_CONTEXT, 0, "not accepting requests."); } cms->terminate = TRUE; } else { if(cms->configuration->verbosity > 6){ OS_REPORT(OS_INFO, CMS_CONTEXT, 0, "Thread %d accepts connection from IP %d.%d.%d.%d\n", slave, (int)(cms->soap->ip>>24)&0xFF, (int)(cms->soap->ip>>16)&0xFF, (int)(cms->soap->ip>>8)&0xFF, (int)(cms->soap->ip&0xFF)); } client = cms_serviceLookupClient(cms); if(client != NULL){ soap = soap_copy(cms->soap); if (soap == NULL) { if(cms->configuration->verbosity > 0){ OS_REPORT(OS_ERROR, CMS_CONTEXT, 0, "Could not allocate SOAP environment."); } cms->terminate = TRUE; } else { soap->socket = slave; slave = -1; success = cms_clientHandleRequest(client, soap); if(success == FALSE){ soap->error = soap_receiver_fault(soap, "Could not handle request.", NULL); soap_send_fault(soap); soap_destroy(soap); soap_end(soap); soap_done(soap); os_free(soap); soap = NULL; } } } else { if(cms->configuration->verbosity > 3){ OS_REPORT(OS_INFO, CMS_CONTEXT, 0, "Maximum number of clients reached."); } if (soap == NULL) { if(cms->configuration->verbosity > 0){ OS_REPORT(OS_ERROR, CMS_CONTEXT, 0, "Could not allocate SOAP environment."); } cms->terminate = TRUE; } else { soap->socket = slave; slave = -1; soap->error = soap_receiver_fault(soap, "Maximum number of clients reached.", NULL); soap_send_fault(soap); soap_destroy(soap); soap_end(soap); soap_done(soap); soap = NULL; } } } }
int ns__trainANN(struct soap *soap, char *inputMatFilename, char *neuralFile, char **OutputMatFilename) { double start, end; start = omp_get_wtime(); Mat src; //must be 3ch image if(!readMat(inputMatFilename, src)) { cerr << "trainANN :: can not read bin file" << endl; soap->fault->faultstring = "trainANN :: can not read bin file"; return SOAP_FAULT; } // convert src to CvMat to use an old-school function CvMat tmp = src; CV_Assert(tmp.cols == src.cols && tmp.rows == src.rows && tmp.data.ptr == (uchar*)src.data && tmp.step == src.step); CvMat *input3Ch = cvCreateMat(src.rows, src.cols, CV_32FC3); cvConvert(&tmp, input3Ch); CvMat *output1Ch = cvCreateMat(src.rows, src.cols, CV_32FC1); CvANN_MLP* neuron = NULL ; if (neuron == NULL ) neuron = new CvANN_MLP(); else neuron->clear(); if(!ByteArrayToANN(neuralFile, neuron)){ cerr << "trainANN :: can not load byte array to neural" << endl; return soap_receiver_fault(soap, "trainANN :: can not load byte array to neural", NULL); } CvMat input_nn = cvMat(input3Ch->height*input3Ch->width, 3, CV_32FC1, input3Ch->data.fl); CvMat output_nn = cvMat(output1Ch->height*output1Ch->width, 1, CV_32FC1, output1Ch->data.fl); neuron->predict(&input_nn, &output_nn); Mat resultNN = cvarrToMat(output1Ch, false); /* generate output file name */ *OutputMatFilename = (char*)soap_malloc(soap, FILENAME_SIZE); time_t now = time(0); strftime(*OutputMatFilename, sizeof(OutputMatFilename)*FILENAME_SIZE, "/home/lluu/dir/%Y%m%d_%H%M%S_trainANN", localtime(&now)); /* save to bin */ if(!saveMat(*OutputMatFilename, resultNN)) { cerr << "trainANN :: save mat to binary file" << endl; return soap_receiver_fault(soap, "trainANN :: save mat to binary file", NULL); } src.release(); resultNN.release(); cvReleaseMat(&output1Ch); end = omp_get_wtime(); cerr<<"ns__trainANN "<<"time elapsed "<<end-start<<endl; return SOAP_OK; }
int die_bad_client(soap* soap) { g_debug("Throwing invalid session fault"); return soap_receiver_fault(soap, "Invalid session ID", NULL); }
int ns__awizoGetSenderInfo(struct soap* soap, long id, struct ns__senderComplex** sender ) { /* ------------------------------------------ */ void* dbase_handler = NULL; char* stringSQL = NULL; long longRet = 0; void* query_result = NULL; long rows = 0; long cols = 0; void* result = NULL; db_row_strings_t* rowstruct = NULL; long fetched = 0; /* ------------------------------------------ */ PRINT_INFO("AWIZOSOAPSERVERINF Get Information of Awizo Sender.\n"); if (_GLOBAL_shptr->awizoAction != queueNothing) { PRINT_INFO("AWIZOSOAPSERVERINF Can't get information about awizo sender, server already in use!\n" ); return soap_receiver_fault(soap, "Can't get information of awizo sender from database" , "Awizo serwer already in use"); } (*sender)=(struct ns__senderComplex*)soap_malloc(soap, sizeof(struct ns__senderComplex)); if((*sender) == NULL) { PRINT_ERROR("Błąd alokacji pamięci. Error = %d\n", BMD_ERR_MEMORY); return soap_receiver_fault(soap, "Memory allocation failed", NULL); } memset(*sender,0,sizeof(struct ns__senderComplex)); if ( asprintf( &stringSQL, "SELECT name, email, created, deleted, smtpaddr, smtpport, smtpuser, smtppassword, pfxfile, pfxpin, maximagesize, csvdir, csvseparator, awizoaction, allowimageabsent, smsapiurl, smsapierror FROM mailing_message_senders WHERE id = %ld;", id) < 0) { PRINT_ERROR("Błąd alokacji pamięci. Error = %d\n", BMD_ERR_MEMORY); return soap_receiver_fault(soap, "Memory allocation failed", NULL); } longRet = bmd_db_connect2(_GLOBAL_awizoConfig.dbIP, \ _GLOBAL_awizoConfig.dbPort, \ _GLOBAL_awizoConfig.dbName, \ _GLOBAL_awizoConfig.dbUser, \ _GLOBAL_awizoConfig.dbPassword, \ &dbase_handler); if ( longRet < 0 ){ PRINT_ERROR("Błąd połączenia z bazą danych. Error = %d\n", BMD_ERR_OP_FAILED); return soap_receiver_fault(soap, "Database connection failed", "Maybe database server does not work"); } if ( bmd_db_execute_sql( dbase_handler, stringSQL, &rows, &cols, &result) < 0 ) { PRINT_ERROR("Błąd zapytania do bazy danych. Error = %d\n", BMD_ERR_OP_FAILED); bmd_db_disconnect(&dbase_handler); free0(stringSQL); return soap_receiver_fault(soap, "SQL request failed", NULL); } free0(stringSQL); longRet = bmd_db_result_get_row(dbase_handler, result, 0, 0, &rowstruct, FETCH_NEXT, &fetched ); if (longRet == 0) { asprintf(&((*sender)->name), "%s", rowstruct->colvals[0]); asprintf(&((*sender)->email), "%s", rowstruct->colvals[1]); asprintf(&((*sender)->created), "%s", rowstruct->colvals[2]); asprintf(&((*sender)->deleted), "%s", rowstruct->colvals[3]); asprintf(&((*sender)->smtpaddr), "%s", rowstruct->colvals[4]); asprintf(&((*sender)->smtpport), "%s", rowstruct->colvals[5]); asprintf(&((*sender)->smtpuser), "%s", rowstruct->colvals[6]); asprintf(&((*sender)->smtppassword), "%s", rowstruct->colvals[7]); asprintf(&((*sender)->pfxfile), "%s", rowstruct->colvals[8]); asprintf(&((*sender)->pfxpin), "%s", rowstruct->colvals[9]); asprintf(&((*sender)->maximagesize), "%s", rowstruct->colvals[10]); asprintf(&((*sender)->csvdir), "%s", rowstruct->colvals[11]); asprintf(&((*sender)->csvseparator), "%s", rowstruct->colvals[12]); (*sender)->awizoaction = atol(rowstruct->colvals[13]); (*sender)->allowimageabsent = atol(rowstruct->colvals[14]); asprintf(&((*sender)->smsapiurl), "%s", rowstruct->colvals[15]); asprintf(&((*sender)->smsapierror), "%s", rowstruct->colvals[16]); } bmd_db_row_struct_free( &rowstruct ); bmd_db_result_free( &result ); fetched = 0; bmd_db_disconnect(&dbase_handler); return SOAP_OK; }
//********************************************************************************** // ns1__runStifTestCase() //********************************************************************************** int ns1__runStifTestCase(struct soap* soap, char *moduleName, int testCaseIndex, struct runStifTestCaseResponse &r) { soap->error = soap_receiver_fault(soap, "HtiGateway", "runStifTestCase: not supported"); return SOAP_FAULT; }
//********************************************************************************** // ns1__queryStifTestCaseResult() //********************************************************************************** int ns1__queryStifTestCaseResult(struct soap* soap, int testCaseId, queryStifTestCaseResultResponse &r) { soap->error = soap_receiver_fault(soap, "HtiGateway", "queryStifTestCaseResult: not supported"); return SOAP_FAULT; }