static int fast_message_init(xmlNodePtr node, struct fast_message *msg) { struct fast_field *field; int nr_fields; xmlChar *prop; int pmap_bit; int ret = 1; if (xmlStrcmp(node->name, (const xmlChar *)"template")) goto exit; prop = xmlGetProp(node, (const xmlChar *)"id"); if (prop != NULL) msg->tid = strtol((char *)prop, NULL, 10); else msg->tid = 0; xmlFree(prop); prop = xmlGetProp(node, (const xmlChar *)"reset"); if (prop != NULL && !xmlStrcmp(prop, (const xmlChar *)"T")) fast_msg_add_flags(msg, FAST_MSG_FLAGS_RESET); xmlFree(prop); nr_fields = xmlChildElementCount(node); msg->fields = calloc(nr_fields, sizeof(struct fast_field)); if (!msg->fields) goto exit; msg->nr_fields = 0; pmap_bit = 1; node = node->xmlChildrenNode; while (node != NULL) { if (node->type != XML_ELEMENT_NODE) { node = node->next; continue; } field = msg->fields + msg->nr_fields; if (fast_field_init(node, field)) goto exit; if (pmap_required(field)) field->pmap_bit = pmap_bit++; msg->nr_fields++; node = node->next; } ret = 0; exit: return ret; }
static int fast_message_init(xmlNodePtr node, struct fast_message *msg) { struct fast_field *field; int nr_fields; xmlChar *prop; int ret = 1; if (xmlStrcmp(node->name, (const xmlChar *)"template")) goto exit; prop = xmlGetProp(node, (const xmlChar *)"id"); if (prop != NULL) msg->tid = strtol((char *)prop, NULL, 10); else msg->tid = 0; xmlFree(prop); prop = xmlGetProp(node, (const xmlChar *)"name"); if (prop != NULL) strncpy(msg->name, (const char *)prop, sizeof(msg->name)); else strncpy(msg->name, (const char *)"", sizeof(msg->name)); xmlFree(prop); prop = xmlGetProp(node, (const xmlChar *)"reset"); if (prop != NULL && !xmlStrcmp(prop, (const xmlChar *)"T")) fast_msg_add_flags(msg, FAST_MSG_FLAGS_RESET); xmlFree(prop); nr_fields = xmlChildElementCount(node); msg->fields = calloc(nr_fields, sizeof(struct fast_field)); if (!msg->fields) goto exit; msg->nr_fields = 0; msg->ghtab = g_hash_table_new(g_str_hash, g_str_equal); if (!msg->ghtab) goto exit; node = node->xmlChildrenNode; while (node != NULL) { if (node->type != XML_ELEMENT_NODE) { node = node->next; continue; } field = msg->fields + msg->nr_fields; if (fast_field_init(node, field)) goto exit; if (strlen(field->name)) g_hash_table_insert(msg->ghtab, field->name, field); msg->nr_fields++; node = node->next; } ret = 0; exit: return ret; }