Example #1
0
int soap_out_xsd__integer(struct soap *soap, const char *tag, int id, const __int128_t *p, const char *type)
{
  if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, SOAP_TYPE_xsd__integer), type)
   || soap_string_out(soap, soap_xsd__integer2s(soap, *p), 0))
    return soap->error;
  return soap_element_end_out(soap, tag);
}
Example #2
0
int
soap_outdecimal(struct soap *soap, const char *tag, int id, const long double *p, const char *type, int n)
{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, p, n), type)
   || soap_string_out(soap, soap_decimal2s(soap, *p), 0))
    return soap->error;
  return soap_element_end_out(soap, tag);
}
int save_options(const char *file, const char *name, struct option *options)
{ struct soap soap;
  soap_init1(&soap, SOAP_XML_TREE);
  soap.namespaces = NULL;
  soap.encodingStyle = NULL;
  if (file)
  { soap.sendfd = open(file, O_CREAT | O_WRONLY);
    if (soap.sendfd < 0)
    { soap_done(&soap);
      return EOF;
    }
  }
  if (!soap_begin_send(&soap) && !soap_element_begin_out(&soap, name, 0, NULL))
  { struct option *p;
    struct t__Option t;
    for (p = options; p->name; p++)
    { t.val = NULL;
      if (!p->name[0])
      { if (!p->value)
          continue;
	t.key = NULL;
	t.val = p->value;
      }
      else if (p->name[1] == '.')
        t.key = (char*)p->name + 2;
      else
        t.key = (char*)p->name;
      if (p->selections && strchr(p->selections, ' '))
      { const char *s = p->selections - 1;
        char *r;
	int i;
        for (i = p->selected; i > 0; i--)
        { s = strchr(s + 1, ' ');
	  if (!s)
	    break;
	}
        if (s)
	{ t.val = soap_strdup(&soap, s + 1);
          r = strchr(t.val, ' ');
	  if (r)
	    *r = '\0';
        }
      }
      else if (p->value)
        t.val = p->value;
      else if (!p->selected)
        continue;
      if (soap_out_t__Option(&soap, "option", 0, &t, NULL))
        break;
    }
    if (!soap_element_end_out(&soap, name))
      soap_end_send(&soap);
  }
  if (file)
    close(soap.sendfd);
  soap_end(&soap);
  soap_done(&soap);
  return soap.error;
}
Example #4
0
SOAP_FMAC1 void SOAP_FMAC2 soap_out_SOAP_ENV__Fault(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Fault *a, const char *type)
{
	soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_SOAP_ENV__Fault), type);
	soap_out_string(soap, "faultcode", -1, &a->faultcode, "");
	soap_out_string(soap, "faultstring", -1, &a->faultstring, "");
	soap_out_string(soap, "faultactor", -1, &a->faultactor, "");
	soap_out_string(soap, "detail", -1, &a->detail, "");
	soap_element_end_out(soap, tag);
}
Example #5
0
int soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, const struct tm *a, const char *type)
{ if (!soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_xsd__dateTime), type))
  { strftime(soap->tmpbuf, sizeof(soap->tmpbuf), "%Y-%m-%dT%H:%M:%SZ", a);
    if (soap_string_out(soap, soap->tmpbuf, 0))
      return soap->error;
  }
  else
    return soap->error;
  return soap_element_end_out(soap, tag);
}
Example #6
0
SOAP_FMAC1 void SOAP_FMAC2 soap_out_ns__getQuoteResponse(struct soap *soap, const char *tag, int id, const struct ns__getQuoteResponse *a, const char *type)
{
	soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_ns__getQuoteResponse), type);
	soap_out_float(soap, "result", -1, &a->result, "");
	soap_element_end_out(soap, tag);
}
Example #7
0
SOAP_FMAC1 void SOAP_FMAC2 soap_out_ns__getQuote(struct soap *soap, const char *tag, int id, const struct ns__getQuote *a, const char *type)
{
	soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_ns__getQuote), type);
	soap_out_string(soap, "symbol", -1, &a->symbol, "");
	soap_element_end_out(soap, tag);
}
Example #8
0
SOAP_FMAC1 void SOAP_FMAC2 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
{
	soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_SOAP_ENV__Header), type);
	/* transient dummy skipped */
	soap_element_end_out(soap, tag);
}
Example #9
0
int soap_out_xsd__dateTime(struct soap *soap, const char *tag, int id, const struct timeval *a, const char *type)
{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_xsd__dateTime), type)
   || soap_string_out(soap, soap_xsd__dateTime2s(soap, *a), 0))
    return soap->error;
  return soap_element_end_out(soap, tag);
}
Example #10
0
int main(int argc, char *argv[])
{
// command line arguments
int nArg;
char *ptr;
char szFileType[64]="";
char szURL[256];
char szUsername[256]="";
char szPassword[256]="";
unsigned int FileSize=0;
char szTargetFileName[256]="";
unsigned int DelaySeconds;
char szCWMPAddress[256]="";

char szProxyHost[256]="";
unsigned int ProxyPort=0;
char szProxyUserId[256]="";
char szProxyPasswd[256]="";
char szTemp[256];
double DownloadSize;
FILE *tmpfile;  //add by wangjr 091201

struct soap soap;
struct Namespace empty_namespaces[] = { { NULL } };

  dprintf(LOG_LEVEL1, "\nDOWNLOAD MANAGER ..execution\n\n");

  // signal handling
  signal(SIGPIPE, sigpipe_handle);
  signal(SIGINT, sigint_handle);

  nErrorCode=0;

  // Command Line Arguments
  for (nArg = 1; nArg < argc; nArg++)
  {
    ptr = argv[nArg];
    if (strncmp(argv[nArg], "--CWMPAddress:", strlen("--CWMPAddress:")) == 0) {
      strcpy(szCWMPAddress, &ptr[strlen("--CWMPAddress:")]);
      dprintf(LOG_LEVEL1, "....CWMPAddress: %s\n", szCWMPAddress);
    }
    else if (strncmp(argv[nArg], "--FileType:", strlen("--FileType:")) == 0) {
      strcpy(szFileType, &ptr[strlen("--FileType:")]);
      dprintf(LOG_LEVEL1, "....FileType: %s\n", szFileType);
    }
    else if (strncmp(argv[nArg], "--URL:", strlen("--URL:")) == 0) {
      strcpy(szURL, &ptr[strlen("--URL:")]);
      dprintf(LOG_LEVEL1, "....URL: %s\n", szURL);
    }
    else if (strncmp(argv[nArg], "--Username:"******"--Username:"******"--Username:"******"....Username: %s\n", szUsername);
    }
    else if (strncmp(argv[nArg], "--Password:"******"--Password:"******"--Password:"******"....Password: %s\n", szPassword);
    }
    else if (strncmp(argv[nArg], "--FileSize:", strlen("--FileSize:")) == 0) {
      strcpy(szTemp, &ptr[strlen("--FileSize:")]);
      FileSize = atoi(szTemp);
      dprintf(LOG_LEVEL1, "....FileSize: %d\n", FileSize);
    }
    else if (strncmp(argv[nArg], "--TargetFileName:", strlen("--TargetFileName:")) == 0) {
      strcpy(szTargetFileName, &ptr[strlen("--TargetFileName:")]);
      dprintf(LOG_LEVEL1, "....TargetFileName: %s\n", szTargetFileName);
    }
    else if (strncmp(argv[nArg], "--DelaySeconds:", strlen("--DelaySeconds:")) == 0) {
      strcpy(szTemp, &ptr[strlen("--DelaySeconds:")]);
      DelaySeconds = atoi(szTemp);
      dprintf(LOG_LEVEL1, "....DelaySeconds: %d\n", DelaySeconds);
    }
    else if (strncmp(argv[nArg], "--ProxyHost:", strlen("--ProxyHost:")) == 0) {
      strcpy(szProxyHost, &ptr[strlen("--ProxyHost:")]);
      dprintf(LOG_LEVEL1, "....szProxyHost: %s\n", szProxyHost);
    }
    else if (strncmp(argv[nArg], "--ProxyPort:", strlen("--ProxyPort:")) == 0) {
      strcpy(szTemp, &ptr[strlen("--ProxyPort:")]);
      ProxyPort = atoi(szTemp);
      dprintf(LOG_LEVEL1, "....ProxyPort: %d\n", ProxyPort);
    }
    else if (strncmp(argv[nArg], "--ProxyUserId:", strlen("--ProxyUserId:")) == 0) {
      strcpy(szProxyUserId, &ptr[strlen("--ProxyUserId:")]);
      dprintf(LOG_LEVEL1, "....szProxyUserId: %s\n", szProxyUserId);
    }
    else if (strncmp(argv[nArg], "--ProxyPasswd:", strlen("--ProxyPasswd:")) == 0) {
      strcpy(szProxyPasswd, &ptr[strlen("--ProxyPasswd:")]);
      dprintf(LOG_LEVEL1, "....szProxyPasswd: %s\n", szProxyPasswd);
    }
  }

  DownloadSize = download_funct(szURL, szTargetFileName, szUsername, szPassword, szProxyHost, ProxyPort, szProxyUserId, szProxyPasswd);

  dprintf(LOG_LEVEL3, "....FileSize: %d\n", FileSize);
  
  if ((FileSize > 0) && ((unsigned long)DownloadSize != FileSize))  //update by wangjr
  	nErrorCode = 9010;
  //else 
  	//nErrorCode = 0;
/*        add by wangjr 091201   */
	tmpfile = fopen("/tmp/tr069", "w");
	if(tmpfile != NULL)
    {
		fprintf(tmpfile, "%d",nErrorCode);
	}
	fclose(tmpfile);
/*        add by wangjr 091201   */

  if (szCWMPAddress && (strcmp(szCWMPAddress, "") != 0))
  {
  // RESPONSE to CWMP server
  
  // ATTENTION : Don't use SOAP_IO_KEEPALIVE during SUBSCRIBE message
  // because each SUBSCRIBE must correspond to one TCP connection
    soap_init2(&soap,SOAP_ENC_XML|SOAP_IO_LENGTH|SOAP_XML_INDENT, SOAP_ENC_XML|SOAP_IO_LENGTH|SOAP_XML_INDENT);
    soap.accept_timeout = 60;
    soap.max_keep_alive = 100; // max keep-alive sequence
    soap.recv_timeout = 60; // Timeout after 5 minutes stall on recv 
    soap.send_timeout = 60; // Timeout after 1 minute stall on send 
    soap_set_namespaces(&soap, empty_namespaces);
  
    soap_connect_command(&soap, SOAP_POST, szCWMPAddress, "");
  
    soap_element_begin_out(&soap, CONST_MESSAGE, 0, NULL);
    soap_element_begin_out(&soap, "NAME", 0, NULL);
    sprintf(szTemp, "%s", CONST_DOWNLOADCOMPLETE);
    soap_send_raw(&soap, szTemp, strlen(szTemp));
    soap_element_end_out(&soap, "NAME");
  
    soap_element_begin_out(&soap, "Value", 0, NULL);
    sprintf(szTemp, "%d", nErrorCode);
    soap_send_raw(&soap, szTemp, strlen(szTemp));
    soap_element_end_out(&soap, "Value");
    soap_element_end_out(&soap, CONST_MESSAGE);
  
    soap_end_send(&soap);
    soap_closesock(&soap);
  
    soap_destroy((struct soap*)&soap); // dealloc C++ data
    soap_end((struct soap*)&soap); // dealloc data and clean up
    soap_done((struct soap*)&soap); // detach soap struct
  }

  dprintf(LOG_LEVEL3, "size of data downloaded: %f\n", DownloadSize);

  dprintf(LOG_LEVEL2, "DOWNLOAD MANAGER, END OF MAIN PROGRAM\n");
  return 0;
}
Example #11
0
int soap_out_xsd__duration(struct soap *soap, const char *tag, int id, const LONG64 *a, const char *type)
{ if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_xsd__duration), type)
   || soap_string_out(soap, soap_xsd__duration2s(soap, *a), 0))
    return soap->error;
  return soap_element_end_out(soap, tag);
}