Exemple #1
0
static void setAuthorization(soap *soap, const string &access_token)
{
    soap->header = (SOAP_ENV__Header *)soap_malloc(soap, sizeof(SOAP_ENV__Header));
    //soap->header->oxns__Authorization = (char*)soap_malloc(soap, (access_token.length() + 1)
    //        * sizeof(char));
    //strcpy(soap->header->oxns__Authorization, access_token.c_str());
    soap->header->oxns__Authorization = (char *)access_token.c_str();
}
SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap *soap)
{
	if (!soap->fault)
	{	soap->fault = (struct SOAP_ENV__Fault*)soap_malloc(soap, sizeof(struct SOAP_ENV__Fault));
		if (!soap->fault)
			return;
		soap_default_SOAP_ENV__Fault(soap, soap->fault);
	}
	if (soap->version == 2 && !soap->fault->SOAP_ENV__Code)
	{	soap->fault->SOAP_ENV__Code = (struct SOAP_ENV__Code*)soap_malloc(soap, sizeof(struct SOAP_ENV__Code));
		soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code);
	}
	if (soap->version == 2 && !soap->fault->SOAP_ENV__Reason)
	{	soap->fault->SOAP_ENV__Reason = (struct SOAP_ENV__Reason*)soap_malloc(soap, sizeof(struct SOAP_ENV__Reason));
		soap_default_SOAP_ENV__Reason(soap, soap->fault->SOAP_ENV__Reason);
	}
}
Exemple #3
0
/* Convert glite_catalog_Permission to gSOAP's glite__Permission */
struct glite__Permission *_glite_catalog__glite_catalog_to_soap_Permission(struct soap *soap,
	const glite_catalog_Permission *permission)
{
	struct glite__Permission *spermission;
	int i;

	spermission = soap_malloc(soap, sizeof(*spermission));
	if (!spermission)
		return NULL;
	memset(spermission, 0, sizeof(*spermission));

	spermission->userName = soap_strdup(soap, permission->userName);
	spermission->groupName = soap_strdup(soap, permission->groupName);
	spermission->userPerm = _glite_catalog_to_soap_Perm(soap, permission->userPerm);
	spermission->groupPerm = _glite_catalog_to_soap_Perm(soap, permission->groupPerm);
	spermission->otherPerm = _glite_catalog_to_soap_Perm(soap, permission->otherPerm);

	if ((permission->userName && !spermission->userName) ||
			(permission->groupName && !spermission->groupName) ||
			!spermission->userPerm ||
			!spermission->groupPerm ||
			!spermission->otherPerm)
		return NULL;

	spermission->__sizeacl = permission->acl_cnt;
	if (!spermission->__sizeacl)
	{
		spermission->acl = NULL;
		return spermission;
	}

	spermission->acl = soap_malloc(soap,
		spermission->__sizeacl * sizeof(*spermission->acl));
	if (!spermission->acl)
		return NULL;

	for (i = 0; i < spermission->__sizeacl; i++)
	{
		spermission->acl[i] = to_soap_ACLEntry(soap, permission->acl[i]);
		if (!spermission->acl[i])
			return NULL;
	}

	return spermission;
}
static void *dime_write_open(struct soap *soap, const char *id, const char *type, const char *options)
{
	DBG("\n");
	// we can return NULL without setting soap->error if we don't want to use the streaming callback for this DIME attachment
	struct dime_write_handle *handle = (struct dime_write_handle*)soap_malloc(soap, sizeof(struct dime_write_handle));
	if (!handle)
	{
		soap->error = SOAP_EOM;
		return NULL;
	}


#if 0
	char *name = tempnam(TMPDIR, "data");
	fprintf(stderr, "Saving file %s\n", name);
	handle->name = soap_strdup(soap, name);
	free(name);
#else
	time_t t = time(NULL);
	struct tm tm = *localtime(&t);

	char name[64];
	memset(name, '\0', sizeof(name));

	switch(bkev){
	case EVENT_SET_FILENAME_CONFIG:
		sprintf(name, "configuration-%d-%d-%d-%d-%d-%d.conf",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	case EVENT_SET_FILENAME_FIRMWARE:
		sprintf(name, "firmware-%d-%d-%d-%d-%d-%d.ctfw",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	default:
		sprintf(name, "%d-%d-%d-%d-%d-%d",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour,	tm.tm_min, tm.tm_sec);
		break;
	}

	DBG("tmpname: %s\n", name);

	handle->name = soap_strdup(soap, name);
#endif


	handle->fd = fopen(handle->name, "wb");
	if (!handle->fd)
	{
		soap->error = SOAP_EOF; // could not open file for writing
		soap->errnum = errno; // get reason
		return NULL;
	}
	return (void*)handle;
}
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;
} 
/**
 * Gets the status of the job. 
 *
 * It maps the different states of PBS jobs to
 * pending and running. It does not make a difference between finished, 
 * cancelled, terminated and unknown jobs since PBS does not store this info.
 * @param jobid is the PID assigned by the queue
 * @return 0 if correct, non-zero if error
 */
int rm_getJobStatus(struct soap* s, char* jobid, char* user, struct bes__ActivityStatusType** jobStatus)
{
   struct bes__ActivityStatusType *activityStatus;
   int connectionIdentifier;
   //! stores the status of a job
   struct batch_status* status;

   if (!jobid || !jobStatus) {
      return BESE_BAD_ARG;
   }
   connectionIdentifier = pbs_connect(server);
   if (!connectionIdentifier)
	   return BESE_BACKEND;
   status = pbs_statjob(connectionIdentifier,jobid,NULL,NULL);
   pbs_disconnect(connectionIdentifier);
   if(status == NULL)
   {
      return BESE_NO_ACTIVITY;
   }
   activityStatus = (struct bes__ActivityStatusType*)soap_malloc(s, sizeof(struct bes__ActivityStatusType));
   if (activityStatus == NULL) {
      return BESE_MEM_ALLOC;
   }
   memset(activityStatus, 0, sizeof(struct bes__ActivityStatusType));
   struct attrl* attrList = status->attribs;
   while (attrList != NULL)
   {
      if(!strcmp(attrList->name, ATTR_state))
      {
        if(!strcmp(attrList->value, "T")) {
           activityStatus->state = Pending;
        }
        else if(!strcmp(attrList->value, "Q")) {
           activityStatus->state = Pending;
        }         
        else if(!strcmp(attrList->value,"H")) {
           activityStatus->state = Pending;
	}         
        else if(!strcmp(attrList->value,"W")){
           activityStatus->state = Pending;
        }         
        else if(!strcmp(attrList->value,"R")){
           activityStatus->state = Running;
        }
        else if(!strcmp(attrList->value,"E")) {
           activityStatus->state = Finished;
        }
        pbs_statfree(status);
	*jobStatus = activityStatus;
        return BESE_OK;
     }
     attrList = attrList->next;
  }
  pbs_statfree(status);
  return BESE_NO_ACTIVITY;
}
 soap_type_t * soap_calloc(struct soap *soap)
 {
     if(NULL == soap)
         throw std::invalid_argument("soap_calloc: soap is a null pointer");
     soap_type_t *ptr;
     if(NULL == (ptr = static_cast<soap_type_t*>(soap_malloc(soap, sizeof(soap_type_t)))))
         throw soap_bad_alloc("soap_calloc(soap)");
     memset(ptr, 0, sizeof(soap_type_t));
     return ptr;
 }
Exemple #8
0
int ns2__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, "<error xmlns=\"http://tempuri.org/\">Can't divide %f by %f</error>", a, b);
    return soap_sender_fault(soap, "Division by zero", s);
  }
  return SOAP_OK;
} 
Exemple #9
0
int ns2__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, "<error xmlns=\"http://tempuri.org/\">Can't take power of %f to %f</error>", a, b);
    return soap_sender_fault(soap, "Power function domain error", s);
  }
  return SOAP_OK;
} 
Exemple #10
0
static int getdata(struct soap *soap, const char *name, ns__Data& data)
{

	struct stat sb;
	FILE *fd = NULL;
	if (name && !strchr(name, '/') && !strchr(name, '\\') && !strchr(name, ':'))
	{ char *s = (char*)soap_malloc(soap, strlen(TMPDIR) + strlen(name) + 2);
		strcpy(s, TMPDIR);
		strcat(s, "/");
		strcat(s, name);
		fd = fopen(s, "rb");
		if (!fd)
		{ strcpy(s, name);
			fd = fopen(s, "rb");
		}
	}
	if (!fd)
		return SOAP_EOF;
	if ((soap->omode & SOAP_IO) == SOAP_IO_CHUNK) // chunked response is possible
	{ data.__ptr = (unsigned char*)fd; // must set to non-NULL (this is our fd handle which we need in the callbacks)
		data.__size = 0; // zero size streams data with HTTP chunking
	}
	else if (!fstat(fileno(fd), &sb) && sb.st_size > 0)
	{ // since we can get the length of the file, we can stream it
		data.__ptr = (unsigned char*)fd; // must set to non-NULL (this is our fd handle which we need in the callbacks)
		data.__size = sb.st_size;
	}
	else // we can't use HTTP chunking and we don't know the size, so buffer it
	{ int i;
		data.__ptr = (unsigned char*)soap_malloc(soap, MAX_FILE_SIZE);
		for (i = 0; i < MAX_FILE_SIZE; i++)
		{ int c;
			if ((c = fgetc(fd)) == EOF)
				break;
			data.__ptr[i] = c;
		}
		fclose(fd);
		data.__size = i;
	}
	data.type = (char*)""; // specify non-NULL id or type to enable DIME
	data.options = soap_dime_option(soap, 0, name);
	return SOAP_OK;
}
Exemple #11
0
char* GWConverter::qStringToChar( const QString &string )
{
  QCString str = string.utf8();

  char* charStr = (char*)soap_malloc( mSoap, str.length() + 1 );
  memcpy( charStr, str, str.length() );
  charStr[ str.length() ] = 0;

  return charStr;
}
Exemple #12
0
static struct ns2__requestParameterList* new_reqList(struct soap* soap, char* reqOp, char* paramName, char* comparOp, char* paramValue) {
  struct ns2__requestParameterList* reqList = (struct ns2__requestParameterList*) soap_malloc(soap, sizeof(struct ns2__requestParameterList));
  struct ns2__parameterListItem* listItem = (struct ns2__parameterListItem*) soap_malloc(soap, sizeof(struct ns2__parameterListItem));

  soap_default_ns2__requestParameterList(soap, reqList);
  soap_default_ns2__parameterListItem(soap, listItem);

  reqList->requestAPI = "REQUEST1";
  reqList->requestOperation = reqOp;
  reqList->parameters = listItem;
  reqList->__sizeparameters = 1;
  listItem->comparisonOp = comparOp;
  listItem->parameterValue = soap_malloc(soap, sizeof(char*));
  listItem->parameterValue[0] = paramValue;
  listItem->__sizeparameterValue = 1;
  listItem->parameterName = paramName;

  return reqList;
}
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;
} 
Exemple #14
0
int m__EchoTestMultiple(struct soap *soap, struct x__WrapperType *x__EchoTest, struct m__EchoTestMultipleResponse *response)
{ int i;
  if (!x__EchoTest)
    return soap_sender_fault(soap, "No data", NULL);
  /* allocate response */
  response->x__EchoTest = (struct x__WrapperType*)soap_malloc(soap, sizeof(struct x__WrapperType));
  if (!response->x__EchoTest)
    return SOAP_EOM;
  response->x__EchoTest->__size = x__EchoTest->__size;
  response->x__EchoTest->Data = (struct x__DataType*)soap_malloc(soap, sizeof(struct x__DataType) * x__EchoTest->__size);
  if (!response->x__EchoTest->Data)
    return SOAP_EOM;
  /* copy data into response, switching from base64 to MTOM and vice versa */
  for (i = 0; i < x__EchoTest->__size; ++i)
  { switch (x__EchoTest->Data[i].__union)
    { case SOAP_UNION_x__data_xop__Include:
        /* convert MTOM attachment to base64Binary */
        response->x__EchoTest->Data[i].__union = SOAP_UNION_x__data_base64;
        response->x__EchoTest->Data[i].choice.base64.__ptr = x__EchoTest->Data[i].choice.xop__Include.__ptr;
        response->x__EchoTest->Data[i].choice.base64.__size = x__EchoTest->Data[i].choice.xop__Include.__size;
        response->x__EchoTest->Data[i].xmime5__contentType = x__EchoTest->Data[i].choice.xop__Include.type;
        break;
      case SOAP_UNION_x__data_base64:
        /* convert base64Binary to MTOM attachment */
        response->x__EchoTest->Data[i].__union = SOAP_UNION_x__data_xop__Include;
        response->x__EchoTest->Data[i].choice.xop__Include.__ptr = x__EchoTest->Data[i].choice.base64.__ptr;
        response->x__EchoTest->Data[i].choice.xop__Include.__size = x__EchoTest->Data[i].choice.base64.__size;
        response->x__EchoTest->Data[i].choice.xop__Include.id = NULL;
        response->x__EchoTest->Data[i].choice.xop__Include.type = x__EchoTest->Data[i].xmime5__contentType;
        response->x__EchoTest->Data[i].choice.xop__Include.options = NULL;
        response->x__EchoTest->Data[i].xmime5__contentType = x__EchoTest->Data[i].xmime5__contentType;
#ifdef WITH_NOIDREF
        /* compiling with WITH_NOIDREF removes auto-detection of attachments */
        soap_set_mime(soap, NULL, NULL); /* so we explicitly set MIME attachments */
#endif
        break;
      default:
        return soap_sender_fault(soap, "Wrong data format", NULL);
    }
  }
  return SOAP_OK;
}
int CSetSoapSecurityDigest2Impl::soap_wsse_add_UsernameTokenText(struct soap *soap, 
												  const char *username, const char *password)  
{   
    _wsse__Security *security = soap->header->wsse__Security;  
    /* allocate a UsernameToken if we don't have one already */  
    if (!security->UsernameToken)  
        security->UsernameToken = (_wsse__UsernameToken*)soap_malloc(soap, sizeof(_wsse__UsernameToken));  
    soap_default__wsse__UsernameToken(soap, security->UsernameToken);  
    /* populate the UsernameToken */  
/*    security->UsernameToken->wsu__Id = soap_strdup(soap, id);  */
    security->UsernameToken->Username = soap_strdup(soap, username);  
    /* allocate and populate the Password */  
    if (password)  
    {   
        security->UsernameToken->Password = (_wsse__Password*)soap_malloc(soap, sizeof(_wsse__Password));  
        soap_default__wsse__Password(soap, security->UsernameToken->Password);  
        security->UsernameToken->Password->__item = soap_strdup(soap, password);  
    }  
    return SOAP_OK;  
}  
/// Web service operation 'Probe' (returns error code or SOAP_OK)
int OnvifRemoteDiscoveryBindingService::Probe(struct wsdd__ProbeType tdn__Probe, struct wsdd__ProbeMatchesType &tdn__ProbeResponse) {
	char *pEndpointAddress = NULL, *pTypes = NULL, *pItem = NULL, *pXAddrs = NULL, *pMatchBy = NULL, *pAction = NULL;

	onvif_db(("Entered: %s:%u.\n", __FUNCTION__, __LINE__));

#if WSDISCOVERY_SPEC_VER == WSDISCOVERY_SPEC_200901
   set_field_string(&pAction, "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/ProbeMatches");
   set_field_string(&pMatchBy, "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/rfc3986");
#else
   set_field_string(&pAction, "http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches");
   set_field_string(&pMatchBy, "http://schemas.xmlsoap.org/ws/2005/04/discovery/rfc3986");
#endif

	pTypes           = nativeGetTypes();
	pItem            = nativeGetScopesItem();
	pXAddrs          = nativeGetXAddrs(ONVIF_ETH_INF);
	pEndpointAddress = nativeGetEndpointAddress(ONVIF_ETH_INF);

	tdn__ProbeResponse.__sizeProbeMatch = 1;
	tdn__ProbeResponse.ProbeMatch = (struct wsdd__ProbeMatchType *) soap_malloc(this, sizeof(struct wsdd__ProbeMatchType));
	soap_default_wsdd__ProbeMatchType(this, tdn__ProbeResponse.ProbeMatch);

	soap_set_field_string(this, &tdn__ProbeResponse.ProbeMatch->wsa__EndpointReference.Address, pEndpointAddress);
	soap_set_field_string(this, &tdn__ProbeResponse.ProbeMatch->Types, pTypes);

	tdn__ProbeResponse.ProbeMatch->Scopes = (struct wsdd__ScopesType *)soap_malloc(this, sizeof(struct wsdd__ScopesType));
	soap_default_wsdd__ScopesType(this, tdn__ProbeResponse.ProbeMatch->Scopes);

	soap_set_field_string(this, &tdn__ProbeResponse.ProbeMatch->Scopes->__item, pItem);
	soap_set_field_string(this, &tdn__ProbeResponse.ProbeMatch->Scopes->MatchBy, pMatchBy);
	soap_set_field_string(this, &tdn__ProbeResponse.ProbeMatch->XAddrs, pXAddrs);
	tdn__ProbeResponse.ProbeMatch->MetadataVersion = 1;

	free(pAction);
	free(pMatchBy);
	free(pEndpointAddress);
	free(pTypes);
	free(pItem);
	free(pXAddrs);
	return SOAP_OK;
}
//**********************************************************************************
// SetDeltaScreenCaptureAttachment
//**********************************************************************************
int SetDeltaScreenCaptureAttachment(struct soap* soap,
							        BYTE* data,
							        int dataSize,
                                    BYTE command,
							        char* mimeType,
                                    struct ns1__captureDeltaScreenResponse &r)
{
	// Set rectangle
	r._returnDeltaAttachment.rect.topLeftX     = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.topLeftY     = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.bottomRightX = *(WORD*)data; data+=2;
	r._returnDeltaAttachment.rect.bottomRightY = *(WORD*)data; data+=2;
	dataSize -= 2*4;

	// No attachment?
	if ( dataSize == 0 )
		return SOAP_OK;

	// alloc soap memory for attachment
	char* soapAttachment = (char*)soap_malloc(soap, dataSize );
	memcpy( soapAttachment, data, dataSize );

	// get & set href for attachment
	char href[MAX_HREF_LEN];
	GetHref(href, command);
	r._returnDeltaAttachment.href = (char*)soap_malloc(soap, strlen(href)+1 );
	strcpy( r._returnDeltaAttachment.href, href );

	// default mimetype is bmp
	if ( !( mimeType ? strlen( mimeType ) : 0 ) )
        mimeType = "image/bmp";

	// set mimetype
	r._returnDeltaAttachment.mimeType = (char*)soap_malloc(soap, strlen(mimeType)+1 );
	strcpy( r._returnDeltaAttachment.mimeType, mimeType );

	// set the attahcment
	soap_set_dime(soap);
	return soap_set_dime_attachment(soap, soapAttachment, dataSize,
	                                mimeType, href, 0, NULL);
}
Exemple #18
0
SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap *soap)
{
	soap_fault(soap);
	if (soap->version == 2)
	{	if (!soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode)
		{	soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode = (struct SOAP_ENV__Code*)soap_malloc(soap, sizeof(struct SOAP_ENV__Code));
			soap_default_SOAP_ENV__Code(soap, soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode);
		}
		return (const char**)&soap->fault->SOAP_ENV__Code->SOAP_ENV__Subcode->SOAP_ENV__Value;
	}
	return (const char**)&soap->fault->faultcode;
}
Exemple #19
0
int calcService::pow(double a, double b, double *result)
{
	printf("pow ... \n");

	*result = ::pow(a, b);
	if (soap_errno == EDOM)	/* soap_errno is like errno, but compatible with Win32 */
	{ char *s = (char*)soap_malloc(this, 1024);
		(SOAP_SNPRINTF(s, 1024, 100), "<error xmlns=\"http://tempuri.org/\">Can't take power of %f to %f</error>", a, b);
		return soap_senderfault("Power function domain error", s);
	}
	return SOAP_OK;
}
Exemple #20
0
int check_header(struct soap *soap)
{ /* MUST have received a SOAP Header */
  if (!soap->header)
    return soap_sender_fault(soap, "No SOAP header", NULL);
  /* ... with a Message ID */
  if (!soap->header->wsa__MessageID)
    return soap_sender_fault(soap, "No WS-Addressing MessageID", NULL);
  soap->header->wsa__RelatesTo = (struct wsa__Relationship*)soap_malloc(soap, sizeof(struct wsa__Relationship));
  soap_default_wsa__Relationship(soap, soap->header->wsa__RelatesTo);
  soap->header->wsa__RelatesTo->__item = soap->header->wsa__MessageID;
  return SOAP_OK;
}
Exemple #21
0
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;
}
Exemple #22
0
int calcService::div(double a, double b, double *result)
{
	printf("div ... \n");

	if (b)
		*result = a / b;
	else
	{ char *s = (char*)soap_malloc(this, 1024);
		(SOAP_SNPRINTF(s, 1024, 100), "<error xmlns=\"http://tempuri.org/\">Can't divide %f by %f</error>", a, b);
		return soap_senderfault("Division by zero", s);
	}
	return SOAP_OK;
} 
Exemple #23
0
struct _ns1__messageResponseTypeDef* getMessage(struct soap* soap, struct ns2__requestParameterList* reqList) {
  struct _ns1__messageResponseTypeDef* respList = NULL;

  addSecurity(soap);
  respList = (struct _ns1__messageResponseTypeDef*) soap_malloc(soap, sizeof(struct _ns1__messageResponseTypeDef));

  if (soap_call___ns1__getMessage(soap, "https://tdl.integration.fema.gov/IPAWS_CAPService/IPAWS", NULL, reqList, respList)) {
    //    soap_print_fault(soap, stderr);
    return NULL;
  }

  return respList;
}
int m__GetData(struct soap *soap, struct x__Keys *keys, struct m__GetDataResponse *response)
{ int i;
  if ((soap->omode & SOAP_IO) == SOAP_IO_STORE)
    soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_BUFFER;
  if (!keys)
    return soap_sender_fault(soap, "No keys", NULL);
  /* Set up array of attachments to return */
  response->x__data.__size = keys->__size;
  response->x__data.item = soap_malloc(soap, keys->__size*sizeof(struct x__Data));
  for (i = 0; i < keys->__size; ++i)
    open_data(soap, keys->key[i], &response->x__data.item[i]);
  return SOAP_OK;
}
struct value& _array::operator[](int n)
{ if (!data.value)
  { data.__size = n + 1;
    data.value = (struct value*)soap_malloc(soap, data.__size * sizeof(struct value));
    for (int i = 0; i < data.__size; i++)
      soap_default_value(soap, &data.value[i]);
  }
  else if (data.__size <= n)
  { int oldsize = data.__size;
    data.__size = n + 1;
    struct value *newvalue = (struct value*)soap_malloc(soap, data.__size * sizeof(struct value));
    int i;
    for (i = 0; i < oldsize; i++)
      newvalue[i] = data.value[i];
    for (; i < data.__size; i++)
      soap_default_value(soap, &newvalue[i]);
    soap_unlink(soap, data.value);
    free(data.value);
    data.value = newvalue;
  }
  return data.value[n];
}
struct value& params::operator[](int n)
{ if (!param)
  { __size = n + 1;
    param = (struct param*)soap_malloc(soap, __size * sizeof(struct param));
    for (int i = 0; i < __size; i++)
      soap_default_param(soap, &param[i]);
  }
  else if (__size <= n)
  { int oldsize = __size;
    __size = n + 1;
    struct param *newparam = (struct param*)soap_malloc(soap, __size * sizeof(struct param));
    int i;
    for (i = 0; i < oldsize; i++)
      newparam[i] = param[i];
    for (; i < __size; i++)
      soap_default_param(soap, &newparam[i]);
    soap_unlink(soap, param);
    free(param);
    param = newparam;
  }
  return param[n].value;
}
Exemple #27
0
void* soap_malloc_zero(struct soap *p_soap, size_t n)
{
    register void *p = NULL;
    p = soap_malloc(p_soap, n);
    if (NULL == p)
    {
        return NULL;
    }

    memset(p, 0, n);

    return p;
}
static struct soap_dom_element*
createBESFaultElement(struct soap *s, 
        const char *bescode, const char *faultstring,
        struct soap_dom_element **besdetailpp)
{
    struct soap_dom_element *fault, *faultcode, *faultstr;
    struct soap_dom_element *detail, *besdetail;
    
    if (!s || !bescode || !faultstring || !besdetailpp) {
        return NULL;
    }
    
    fault = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    faultcode = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    faultstr = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    detail = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    besdetail = (struct soap_dom_element*)soap_malloc(s, sizeof(struct soap_dom_element));
    if (!fault || !faultcode || !faultstr || !detail || !besdetail) {
        return NULL;
    }
    memset(fault, 0, sizeof(struct soap_dom_element));
    memset(faultcode, 0, sizeof(struct soap_dom_element));
    memset(faultstr, 0, sizeof(struct soap_dom_element));
    memset(detail, 0, sizeof(struct soap_dom_element));
    memset(besdetail, 0, sizeof(struct soap_dom_element));
    
    faultcode->name = soap_strdup(s, "faultcode");
    faultcode->data = (char*)soap_malloc(s, strlen("bes:") + strlen(bescode) + 1);
    sprintf(faultcode->data, "bes:%s", bescode);
    faultcode->prnt = fault;
    faultcode->next = faultstr;
    faultcode->soap = s;
    
    faultstr->name = soap_strdup(s, "faultstring");
    faultstr->data = soap_strdup(s, faultstring);
    faultstr->prnt = fault;
    faultstr->next = detail;
    faultstr->soap = s;
    
    detail->name = soap_strdup(s, "detail");
    detail->elts = besdetail;
    detail->prnt = fault;
    detail->soap = s;

    besdetail->name = soap_strdup(s, bescode);
    besdetail->nstr = soap_strdup(s, BES_NS);
    besdetail->prnt = detail;
    besdetail->soap = s;
    
    fault->nstr = soap_strdup(s, BES_NS);
    fault->name = soap_strdup(s, "Fault");
    fault->elts = faultcode;
    fault->soap = s;
    
    *besdetailpp = besdetail;
    
    return fault;
}
Exemple #29
0
    void UserGetUri(struct soap *soap, struct _trt__GetProfilesResponse *trt__GetProfilesResponse,struct _tds__GetCapabilitiesResponse *capa_resp)  
    {  
	struct _trt__GetStreamUri *trt__GetStreamUri = (struct _trt__GetStreamUri *)malloc(sizeof(struct _trt__GetStreamUri));
	struct _trt__GetStreamUriResponse *trt__GetStreamUriResponse = (struct _trt__GetStreamUriResponse *)malloc(sizeof(struct _trt__GetStreamUriResponse));
        int result=0 ;  
        trt__GetStreamUri->StreamSetup = (struct tt__StreamSetup*)soap_malloc(soap,sizeof(struct tt__StreamSetup));//初始化,分配空间  
        trt__GetStreamUri->StreamSetup->Stream = 0;//stream type  
      
        trt__GetStreamUri->StreamSetup->Transport = (struct tt__Transport *)soap_malloc(soap, sizeof(struct tt__Transport));//初始化,分配空间  
        trt__GetStreamUri->StreamSetup->Transport->Protocol = 0;  
        trt__GetStreamUri->StreamSetup->Transport->Tunnel = 0;  
        trt__GetStreamUri->StreamSetup->__size = 1;  
        trt__GetStreamUri->StreamSetup->__any = NULL;  
        trt__GetStreamUri->StreamSetup->__anyAttribute =NULL;  
      
      
        trt__GetStreamUri->ProfileToken = trt__GetProfilesResponse->Profiles->token ;  
      
        printf("\n\n---------------Getting Uri----------------\n\n");  
      
        soap_wsse_add_UsernameTokenDigest(soap,"user", ONVIF_USER, ONVIF_PASSWORD);  
        soap_call___trt__GetStreamUri(soap, capa_resp->Capabilities->Media->XAddr, NULL, trt__GetStreamUri, trt__GetStreamUriResponse);  
      
      
        if (soap->error) {  
        printf("soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));  
        result = soap->error;  
      
        }  
        else{  
            printf("!!!!NOTE: RTSP Addr Get Done is :%s \n",trt__GetStreamUriResponse->MediaUri->Uri);  
	    //最后我们使用vlc -vvv命令来打开一个rstp网络流
	    char cmd_str[256];
	    memset(cmd_str, 0, sizeof(cmd_str));
	    sprintf(cmd_str, "vlc %s --sout=file/ps:device%d.mp4", trt__GetStreamUriResponse->MediaUri->Uri, HasDev);
	    popen((const char *)cmd_str, "r");		
        }  
    }  
Exemple #30
0
static struct jptype__genericFault* jp2s_error(struct soap *soap, const glite_jp_error_t *err)
{
	struct jptype__genericFault *ret = NULL;
	if (err) {
		ret = soap_malloc(soap,sizeof *ret);
		memset(ret,0,sizeof *ret);
		ret->code = err->code;
		ret->source = soap_strdup(soap,err->source);
		ret->text = soap_strdup(soap,strerror(err->code));
		ret->description = err->desc ? soap_strdup(soap,err->desc) : NULL;
		ret->reason = jp2s_error(soap,err->reason);
	}
	return ret;
}