Пример #1
0
SOAP_FMAC1 struct ns__getQuoteResponse * SOAP_FMAC2 soap_in_ns__getQuoteResponse(struct soap *soap, const char *tag, struct ns__getQuoteResponse *a, const char *type)
{
	short soap_flag_result = 1;
	if (soap_element_begin_in(soap, tag))
		return NULL;
	if (*soap->type && soap_match_tag(soap, soap->type, type))
	{	soap->error = SOAP_TYPE_MISMATCH;
		soap_revert(soap);
		return NULL;
	}
	if (soap->null)
	{	if (soap->enable_null)
		{	soap->error = SOAP_NULL;
			return NULL;
		}
		else
			return a;
	}
	if (soap->body && !*soap->href)
	{	a = (struct ns__getQuoteResponse *)soap_id_enter(soap, soap->id, a, SOAP_ns__getQuoteResponse, sizeof(struct ns__getQuoteResponse), 0);
		if (!a)
			return NULL;
		if (soap->alloced)
			soap_default_ns__getQuoteResponse(soap, a);
		for (;;)
		{	soap->error = SOAP_TAG_MISMATCH;
			if (soap_flag_result && soap->error == SOAP_TAG_MISMATCH)
				if (soap_in_float(soap, "result", &a->result, ""))
				{	soap_flag_result = 0;
					continue;
				}
			if (soap->error == SOAP_TAG_MISMATCH)
				soap->error = soap_ignore_element(soap);
			if (soap->error == SOAP_NO_TAG)
				break;
			if (soap->error)
			{	return NULL;
			}
		}
		if (soap_element_end_in(soap, tag))
			return NULL;
	}
	else
	{	a = (struct ns__getQuoteResponse *)soap_id_forward(soap, soap->href, (void**)soap_id_enter(soap, soap->id, a, SOAP_ns__getQuoteResponse, sizeof(struct ns__getQuoteResponse), 0), SOAP_ns__getQuoteResponse, sizeof(struct ns__getQuoteResponse));
		if (soap->alloced)
			soap_default_ns__getQuoteResponse(soap, a);
		if (soap->body && soap_element_end_in(soap, tag))
			return NULL;
	}
	return a;
}
Пример #2
0
SOAP_FMAC3 int SOAP_FMAC4 soap_ignore_element(struct soap *soap)
{
	if (!soap_peek_element(soap))
	{	int t;
		DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Unexpected element '%s' in input (level=%u, %d)\n", soap->tag, soap->level, soap->body));
		if (soap->mustUnderstand && !soap->other)
			return soap->error = SOAP_MUSTUNDERSTAND;
		if (((soap->mode & SOAP_XML_STRICT) && soap->part != SOAP_IN_HEADER) || !soap_match_tag(soap, soap->tag, "SOAP-ENV:"))
		{	DBGLOG(TEST, SOAP_MESSAGE(fdebug, "REJECTING element '%s'\n", soap->tag));
			return soap->error = SOAP_TAG_MISMATCH;
		}
		if (!*soap->id || !soap_getelement(soap, &t))
		{	soap->peeked = 0;
			if (soap->fignore)
				soap->error = soap->fignore(soap, soap->tag);
			else
				soap->error = SOAP_OK;
			DBGLOG(TEST, if (!soap->error) SOAP_MESSAGE(fdebug, "IGNORING element '%s'\n", soap->tag));
			if (!soap->error && soap->body)
			{	soap->level++;
				while (!soap_ignore_element(soap))
					;
				if (soap->error == SOAP_NO_TAG)
					soap->error = soap_element_end_in(soap, NULL);
			}
		}
Пример #3
0
SOAP_FMAC1 struct SOAP_ENV__Header * SOAP_FMAC2 soap_in_SOAP_ENV__Header(struct soap *soap, const char *tag, struct SOAP_ENV__Header *a, const char *type)
{;
	if (soap_element_begin_in(soap, tag))
		return NULL;
	if (*soap->type && soap_match_tag(soap, soap->type, type))
	{	soap->error = SOAP_TYPE_MISMATCH;
		soap_revert(soap);
		return NULL;
	}
	if (soap->null)
	{	if (soap->enable_null)
		{	soap->error = SOAP_NULL;
			return NULL;
		}
		else
			return a;
	}
	if (soap->body && !*soap->href)
	{	a = (struct SOAP_ENV__Header *)soap_id_enter(soap, soap->id, a, SOAP_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0);
		if (!a)
			return NULL;
		if (soap->alloced)
			soap_default_SOAP_ENV__Header(soap, a);
		for (;;)
		{	soap->error = SOAP_TAG_MISMATCH;
		/* transient dummy skipped */
			if (soap->error == SOAP_TAG_MISMATCH)
				soap->error = soap_ignore_element(soap);
			if (soap->error == SOAP_NO_TAG)
				break;
			if (soap->error)
			{	return NULL;
			}
		}
		if (soap_element_end_in(soap, tag))
			return NULL;
	}
	else
	{	a = (struct SOAP_ENV__Header *)soap_id_forward(soap, soap->href, (void**)soap_id_enter(soap, soap->id, a, SOAP_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header), 0), SOAP_SOAP_ENV__Header, sizeof(struct SOAP_ENV__Header));
		if (soap->alloced)
			soap_default_SOAP_ENV__Header(soap, a);
		if (soap->body && soap_element_end_in(soap, tag))
			return NULL;
	}
	return a;
}
Пример #4
0
long double *
soap_indecimal(struct soap *soap, const char *tag, long double *p, const char *type, int t)
{ if (soap_element_begin_in(soap, tag, 0, type))
    return NULL;
  p = (long double*)soap_id_enter(soap, soap->id, p, t, sizeof(long double), 0, NULL, NULL, NULL);
  if (*soap->href)
    p = (long double*)soap_id_forward(soap, soap->href, p, 0, t, 0, sizeof(long double), 0, NULL);
  else if (p)
  { if (soap_s2decimal(soap, soap_value(soap), p))
      return NULL;
  }
  if (soap->body && soap_element_end_in(soap, tag))
    return NULL;
  return p;
}
Пример #5
0
__int128_t * soap_in_xsd__integer(struct soap *soap, const char *tag, __int128_t *a, const char *type)
{
  if (soap_element_begin_in(soap, tag, 0, type))
    return NULL;
  a = (__int128_t*)soap_id_enter(soap, soap->id, a, SOAP_TYPE_xsd__integer, sizeof(__int128_t), NULL, NULL, NULL, NULL);
  if (*soap->href)
    a = (__int128_t*)soap_id_forward(soap, soap->href, a, 0, SOAP_TYPE_xsd__integer, 0, sizeof(__int128_t), 0, NULL, NULL);
  else if (a)
  {
    if (soap_s2xsd__integer(soap, soap_value(soap), a))
      return NULL;
  }
  if (soap->body && soap_element_end_in(soap, tag))
    return NULL;
  return a;
}
Пример #6
0
struct timeval *soap_in_xsd__dateTime(struct soap *soap, const char *tag, struct timeval *a, const char *type)
{ if (soap_element_begin_in(soap, tag, 0, NULL))
    return NULL;
  if (*soap->type
   && soap_match_tag(soap, soap->type, type)
   && soap_match_tag(soap, soap->type, ":dateTime"))
  { soap->error = SOAP_TYPE;
    soap_revert(soap);
    return NULL;
  }
  a = (struct timeval*)soap_id_enter(soap, soap->id, a, SOAP_TYPE_xsd__dateTime, sizeof(struct timeval), 0, NULL, NULL, NULL);
  if (*soap->href)
    a = (struct timeval*)soap_id_forward(soap, soap->href, a, 0, SOAP_TYPE_xsd__dateTime, 0, sizeof(struct timeval), 0, NULL);
  else if (a)
  { if (soap_s2xsd__dateTime(soap, soap_value(soap), a))
      return NULL;
  }
  if (soap->body && soap_element_end_in(soap, tag))
    return NULL;
  return a;
}
Пример #7
0
int load_options(const char *file, const char *name, struct option *options)
{ struct soap soap;
  soap_init(&soap);
  if (file)
  { soap.recvfd = open(file, O_RDONLY);
    if (soap.recvfd < 0)
    { soap_done(&soap);
      return EOF;
    }
  }
  if (!soap_begin_recv(&soap) && !soap_element_begin_in(&soap, name, 1))
  { struct t__Option t;
    while (soap_in_t__Option(&soap, "option", &t, NULL))
      if (set_option(t.key, t.val, options) < 0)
        ; /* error, just ignore for now */
    if (!soap_element_end_in(&soap, name))
      soap_end_recv(&soap);
  }
  if (file)
    close(soap.recvfd);
  soap_end(&soap);
  soap_done(&soap);
  return soap.error;
}
Пример #8
0
SOAP_FMAC1 struct SOAP_ENV__Fault * SOAP_FMAC2 soap_in_SOAP_ENV__Fault(struct soap *soap, const char *tag, struct SOAP_ENV__Fault *a, const char *type)
{
	short soap_flag_faultcode = 1, soap_flag_faultstring = 1, soap_flag_faultactor = 1, soap_flag_detail = 1;
	if (soap_element_begin_in(soap, tag))
		return NULL;
	if (*soap->type && soap_match_tag(soap, soap->type, type))
	{	soap->error = SOAP_TYPE_MISMATCH;
		soap_revert(soap);
		return NULL;
	}
	if (soap->null)
	{	if (soap->enable_null)
		{	soap->error = SOAP_NULL;
			return NULL;
		}
		else
			return a;
	}
	if (soap->body && !*soap->href)
	{	a = (struct SOAP_ENV__Fault *)soap_id_enter(soap, soap->id, a, SOAP_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0);
		if (!a)
			return NULL;
		if (soap->alloced)
			soap_default_SOAP_ENV__Fault(soap, a);
		for (;;)
		{	soap->error = SOAP_TAG_MISMATCH;
			if (soap_flag_faultcode && soap->error == SOAP_TAG_MISMATCH)
				if (soap_in_string(soap, "faultcode", &a->faultcode, ""))
				{	soap_flag_faultcode = 0;
					continue;
				}
			if (soap_flag_faultstring && soap->error == SOAP_TAG_MISMATCH)
				if (soap_in_string(soap, "faultstring", &a->faultstring, ""))
				{	soap_flag_faultstring = 0;
					continue;
				}
			if (soap_flag_faultactor && soap->error == SOAP_TAG_MISMATCH)
				if (soap_in_string(soap, "faultactor", &a->faultactor, ""))
				{	soap_flag_faultactor = 0;
					continue;
				}
			if (soap_flag_detail && soap->error == SOAP_TAG_MISMATCH)
				if (soap_in_string(soap, "detail", &a->detail, ""))
				{	soap_flag_detail = 0;
					continue;
				}
			if (soap->error == SOAP_TAG_MISMATCH)
				soap->error = soap_ignore_element(soap);
			if (soap->error == SOAP_NO_TAG)
				break;
			if (soap->error)
			{	return NULL;
			}
		}
		if (soap_element_end_in(soap, tag))
			return NULL;
	}
	else
	{	a = (struct SOAP_ENV__Fault *)soap_id_forward(soap, soap->href, (void**)soap_id_enter(soap, soap->id, a, SOAP_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault), 0), SOAP_SOAP_ENV__Fault, sizeof(struct SOAP_ENV__Fault));
		if (soap->alloced)
			soap_default_SOAP_ENV__Fault(soap, a);
		if (soap->body && soap_element_end_in(soap, tag))
			return NULL;
	}
	return a;
}
Пример #9
0
SOAP_FMAC2
soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type)
{ register struct soap_attribute *tp;
  register struct soap_dom_attribute **att;
  if (soap_peek_element(soap))
  { if (soap->error != SOAP_NO_TAG)
      return NULL;
    if (!node)
    { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
      { soap->error = SOAP_EOM;
        return NULL;
      }
    }
    soap_default_xsd__anyType(soap, node);
    if (!(node->data = soap_string_in(soap, 1, -1, -1)) || !*node->data)
      return NULL;
    soap->error = SOAP_OK;
    return node;
  }
  if (!node)
  { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
    { soap->error = SOAP_EOM;
      return NULL;
    }
  }
  soap_default_xsd__anyType(soap, node);
  node->nstr = soap_current_namespace(soap, soap->tag);
  if ((soap->mode & SOAP_DOM_ASIS))
    node->name = soap_strdup(soap, soap->tag);
  else
  { char *s = strchr(soap->tag, ':');
    if (s)
      node->name = soap_strdup(soap, s+1);
    else
      node->name = soap_strdup(soap, soap->tag);
  }
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' parsed in namespace '%s'\n", node->name, node->nstr?node->nstr:""));
  if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id))
  { if ((node->node = soap_getelement(soap, &node->type)))
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type));
      return node;
    }
    if (soap->error == SOAP_TAG_MISMATCH)
      soap->error = SOAP_OK;
    else
      return NULL;
  }
  att = &node->atts;
  for (tp = soap->attributes; tp; tp = tp->next)
  { if (tp->visible)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s' parsed\n", tp->name));
      *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
      if (!*att)
      { soap->error = SOAP_EOM;
        return NULL;
      }
      (*att)->next = NULL;
      (*att)->nstr = soap_current_namespace(soap, tp->name);
      if ((soap->mode & SOAP_DOM_ASIS) || !strncmp(tp->name, "xml", 3))
        (*att)->name = soap_strdup(soap, tp->name);
      else
      { char *s = strchr(tp->name, ':');
        if (s)
          (*att)->name = soap_strdup(soap, s+1);
        else
          (*att)->name = soap_strdup(soap, tp->name);
      }
      if (tp->visible == 2)
        (*att)->data = soap_strdup(soap, tp->value);
      else
        (*att)->data = NULL;
      (*att)->wide = NULL;
      (*att)->soap = soap;
      att = &(*att)->next;
      tp->visible = 0;
    }
  }
  soap_element_begin_in(soap, NULL, 1, NULL);
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' pulled\n", node->name));
  if (soap->body)
  { if (!soap_peek_element(soap))
    { struct soap_dom_element **elt;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name));
      elt = &node->elts;
      for (;;)
      { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL)))
        { if (soap->error != SOAP_NO_TAG)
            return NULL;
          soap->error = SOAP_OK;
          break;
        }
	(*elt)->prnt = node;
        elt = &(*elt)->next;
      }
    }
    else if (soap->error == SOAP_NO_TAG)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name));
      if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING))
      { if (!(node->data = soap_string_in(soap, 1, -1, -1)))
          return NULL;
      }
      else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1)))
        return NULL;
    }
    else
      return NULL;
    if (soap_element_end_in(soap, node->name))
      return NULL;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name));
  }
  return node;
}
Пример #10
0
struct tm *soap_in_xsd__dateTime(struct soap *soap, const char *tag, struct tm *a, const char *type)
{ if (soap_element_begin_in(soap, tag, 0))
    return NULL;
  if (*soap->type
   && soap_match_tag(soap, soap->type, type)
   && soap_match_tag(soap, soap->type, ":dateTime"))
  { soap->error = SOAP_TYPE;
    soap_revert(soap);
    return NULL;
  }
  a = (struct tm*)soap_id_enter(soap, soap->id, a, SOAP_TYPE_xsd__dateTime, sizeof(struct tm), 0, NULL, NULL, NULL);
  if (*soap->href)
    a = (struct tm*)soap_id_forward(soap, soap->href, a, 0, SOAP_TYPE_xsd__dateTime, 0, sizeof(struct tm), 0, NULL);
  else if (a)
  { const char *s = soap_value(soap);
    memset((void*)a, 0, sizeof(struct tm));
    if (s)
    { char zone[16];
      const char *t;
      zone[sizeof(zone)-1] = '\0';
      if (strchr(s, '-'))
        t = "%d-%d-%dT%d:%d:%d%15s";
      else if (strchr(s, ':'))
        t = "%4d%2d%2dT%d:%d:%d%15s";
      else /* parse non-XSD-standard alternative ISO 8601 format */
        t = "%4d%2d%2dT%2d%2d%2d%15s";
      sscanf(s, t, &a->tm_year, &a->tm_mon, &a->tm_mday, &a->tm_hour, &a->tm_min, &a->tm_sec, zone);
      if (a->tm_year == 1)
        a->tm_year = 70;
      else
        a->tm_year -= 1900;
      a->tm_mon--;
      if (*zone)
      { if (*zone == '.')
        { for (s = zone + 1; *s; s++)
            if (*s < '0' || *s > '9')
              break;
        }
        else
          s = zone;
        if (*s == '+' || *s == '-')
        { int h = 0, m = 0;
          if (s[3] == ':')
          { sscanf(s, "%d:%d", &h, &m);
            if (h < 0)
              m = -m;
          }
          else
          { m = (int)atol(s);
            h = m / 100;
            m = m % 100;
          }
          a->tm_hour -= h;
          a->tm_min -= m;
        }
        a->tm_isdst = 0;
      }
      else
        a->tm_isdst = -1;
    }
  }
  if (soap->body && soap_element_end_in(soap, tag))
    return NULL;
  return a;
}
Пример #11
0
SOAP_FMAC2
soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type)
{ register struct soap_attribute *tp;
  register struct soap_dom_attribute **att;
  register struct soap_nlist *np;
  register char *s;
  if (soap_peek_element(soap))
    return NULL;
  if (!node)
    if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
    { soap->error = SOAP_EOM;
      return NULL;
    }
  node->next = NULL;
  node->prnt = NULL;
  node->elts = NULL;
  node->atts = NULL;
  node->nstr = NULL;
  node->name = NULL;
  node->data = NULL;
  node->wide = NULL;
  node->node = NULL;
  node->type = 0;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node %s\n", soap->tag));
  np = soap->nlist;
  if (!(s = strchr(soap->tag, ':')))
  { while (np && *np->id) /* find default namespace, if present */
      np = np->next;
    s = soap->tag;
  }
  else
  { while (np && (strncmp(np->id, soap->tag, s - soap->tag) || np->id[s - soap->tag]))
      np = np->next;
    s++;
    if (!np)
    { soap->error = SOAP_NAMESPACE;
      return NULL;
    }
  }
  if (np)
  { if (np->index >= 0)
      node->nstr = soap->namespaces[np->index].ns;
    else if (np->ns)
      node->nstr = soap_strdup(soap, np->ns);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node namespace='%s'\n", node->nstr?node->nstr:""));
  }
  node->name = soap_strdup(soap, soap->tag);
  if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id))
  { if ((node->node = soap_getelement(soap, &node->type)))
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type));
      return node;
    }
    if (soap->error == SOAP_TAG_MISMATCH)
      soap->error = SOAP_OK;
    else
      return NULL;
  }
  att = &node->atts;
  for (tp = soap->attributes; tp; tp = tp->next)
    if (tp->visible)
    { np = soap->nlist;
      if (!(s = strchr(tp->name, ':')))
      { while (np && *np->id) /* find default namespace, if present */
          np = np->next;
        s = tp->name;
      }
      else
      { while (np && (strncmp(np->id, tp->name, s - tp->name) || np->id[s - tp->name]))
          np = np->next;
        s++;
        if (!np)
        { soap->error = SOAP_NAMESPACE;
          return NULL;
        }
      }
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s'\n", tp->name));
      *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
      if (!*att)
      { soap->error = SOAP_EOM;
        return NULL;
      }
      (*att)->next = NULL;
      (*att)->nstr = NULL;
      if (np)
      { if (np->index >= 0)
          (*att)->nstr = soap->namespaces[np->index].ns;
        else if (np->ns)
	  (*att)->nstr = soap_strdup(soap, np->ns);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM attribute namespace='%s'\n", (*att)->nstr?(*att)->nstr:""));
      }
      (*att)->name = soap_strdup(soap, s);
      if (tp->visible == 2)
        (*att)->data = soap_strdup(soap, tp->value);
      else
        (*att)->data = NULL;
      (*att)->wide = NULL;
      att = &(*att)->next;
      tp->visible = 0;
    }
  soap_element_begin_in(soap, NULL, 1);
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' accepted\n", node->name));
  if (soap->body)
  { wchar c;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has content\n", node->name));
    do c = soap_getchar(soap);
    while (c > 0 && c <= 32);
    if (c == EOF)
    { soap->error = SOAP_EOF;
      return NULL;
    }
    soap_unget(soap, c);
    if (c == '<')
    { struct soap_dom_element **elt;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name));
      elt = &node->elts;
      for (;;)
      { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL)))
        { if (soap->error == SOAP_NO_TAG)
            soap->error = SOAP_OK;
          else
            return NULL;
          break;
        }
	(*elt)->prnt = node;
        elt = &(*elt)->next;
      }
    }
    else
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name));
      if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING))
      { if (!(node->data = soap_string_in(soap, 1, -1, -1)))
          return NULL;
      }
      else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1)))
        return NULL;
    }
    if (soap_element_end_in(soap, node->name))
      return NULL;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name));
  }
  return node;
}