Exemplo n.º 1
0
static int fast_misc_init(xmlNodePtr node, struct fast_field *field)
{
	xmlChar *prop;

	if (node == NULL)
		return 1;

	prop = xmlGetProp(node, (const xmlChar *)"charset");

	if (prop != NULL && !xmlStrcmp(prop, (const xmlChar *)"unicode"))
		field_add_flags(field, FAST_FIELD_FLAGS_UNICODE);

	xmlFree(prop);

	prop = xmlGetProp(node, (const xmlChar *)"name");
	if (prop != NULL)
		strncpy(field->name, (const char *)prop, sizeof(field->name));

	xmlFree(prop);

	prop = xmlGetProp(node, (const xmlChar *)"id");
	if (prop != NULL)
		field->id = atoi((const char *)prop);

	xmlFree(prop);

	return 0;
}
Exemplo n.º 2
0
static int fast_decimal_init_individ(xmlNodePtr node, struct fast_field *field)
{
	struct fast_decimal *decimal;
	int ret = -1;

	decimal = &field->decimal_value;

	decimal->fields = calloc(2, sizeof(struct fast_field));
	if (!decimal->fields)
		goto exit;

	node = node->xmlChildrenNode;

	while (node) {
		if (node->type != XML_ELEMENT_NODE) {
			node = node->next;
			continue;
		}

		if (!xmlStrcmp(node->name, (const xmlChar *)"exponent"))
			ret = fast_field_init(node, &decimal->fields[0]);
		else if (!xmlStrcmp(node->name, (const xmlChar *)"mantissa"))
			ret = fast_field_init(node, &decimal->fields[1]);
		else
			ret = -1;

		if (ret)
			goto exit;

		node = node->next;
	}

	field_add_flags(field, FAST_FIELD_FLAGS_DECIMAL_INDIVID);
	decimal->fields[0].presence = field->presence;

exit:
	return ret;
}
Exemplo n.º 3
0
static int fast_sequence_init(xmlNodePtr node, struct fast_field *field)
{
	struct fast_sequence *seq;
	struct fast_message *msg;
	struct fast_field *orig;
	xmlNodePtr tmp;
	int i, ret = 1;
	int nr_fields;
	int pmap_bit;

	field->ptr_value = calloc(1, sizeof(struct fast_sequence));
	if (!field->ptr_value)
		goto exit;

	seq = field->ptr_value;

	nr_fields = xmlChildElementCount(node);

	node = node->xmlChildrenNode;
	while (node && node->type != XML_ELEMENT_NODE)
		node = node->next;

	if (xmlStrcmp(node->name, (const xmlChar *)"length"))
		goto exit;

	if (fast_field_init(node, &seq->length))
		goto exit;

	if (!field_is_mandatory(field))
		seq->length.presence = FAST_PRESENCE_OPTIONAL;

	node = node->next;
	orig = field;

	for (i = 0; i < FAST_SEQUENCE_ELEMENTS; i++) {
		msg = seq->elements + i;
		tmp = node;

		msg->fields = calloc(nr_fields, sizeof(struct fast_field));
		if (!msg->fields)
			goto exit;

		msg->nr_fields = 0;
		pmap_bit = 0;

		while (tmp != NULL) {
			if (tmp->type != XML_ELEMENT_NODE) {
				tmp = tmp->next;
				continue;
			}

			field = msg->fields + msg->nr_fields;

			if (fast_field_init(tmp, field))
				goto exit;

			if (pmap_required(field)) {
				field_add_flags(orig, FAST_FIELD_FLAGS_PMAPREQ);
				field->pmap_bit = pmap_bit++;
			}

			msg->nr_fields++;
			tmp = tmp->next;
		}
	}

	ret = 0;

exit:
	return ret;
}