static int parse_cdata(xmlNodePtr node, simple_binary_t **sibxml) { int ret = 0; Octstr *temp; temp = create_octstr_from_node((char *)node); parse_octet_string(temp, sibxml); octstr_destroy(temp); return ret; }
static int parse_text(xmlNodePtr node, simple_binary_t **sibxml) { Octstr *temp; temp = create_octstr_from_node((char *)node); octstr_shrink_blanks(temp); octstr_strip_blanks(temp); if (octstr_len(temp) == 0) { octstr_destroy(temp); return 0; } parse_inline_string(temp, sibxml); octstr_destroy(temp); return 0; }
/* * Tokenises an attribute, and in most cases, the start of its value (some- * times whole of it). Tokenisation is based on tables in si, chapters 9.3.2 * and 9.3.3. * Returns 0 when success, -1 when error. */ static int parse_attribute(xmlAttrPtr attr, simple_binary_t **sibxml) { Octstr *name, *value, *valueos, *tokenized_date; unsigned char si_hex; size_t i, value_len; name = octstr_create((char *)attr->name); if (attr->children != NULL) value = create_octstr_from_node((char *)attr->children); else value = NULL; if (value == NULL) goto error; i = 0; valueos = NULL; while (i < NUMBER_OF_ATTRIBUTES) { if (octstr_compare(name, octstr_imm(si_attributes[i].name)) == 0) { if (si_attributes[i].value_part == NULL) { break; } else { value_len = octstr_len(valueos = octstr_imm(si_attributes[i].value_part)); if (octstr_ncompare(value, valueos, value_len) == 0) { break; } } } ++i; } if (i == NUMBER_OF_ATTRIBUTES) goto error; tokenized_date = NULL; si_hex = si_attributes[i].token; if (action(si_hex)) { output_char(si_hex, sibxml); } else if (url(si_hex)) { output_char(si_hex, sibxml); octstr_delete(value, 0, octstr_len(valueos)); parse_url_value(value, sibxml); } else if (date(si_hex)) { if ((tokenized_date = tokenize_date(value)) == NULL) goto error; output_char(si_hex, sibxml); output_octet_string(tokenized_date, sibxml); } else { output_char(si_hex, sibxml); parse_inline_string(value, sibxml); } octstr_destroy(tokenized_date); octstr_destroy(name); octstr_destroy(value); return 0; error: octstr_destroy(name); octstr_destroy(value); return -1; }
/* * Tokenises an attribute, and in most cases, its value. (Some values are re- * presented as an inline string). Tokenisation is based on tables in ota, * chapters 8.1 and 8.2. * Returns 0 when success, -1 when error. */ static int parse_attribute(xmlAttrPtr attr, simple_binary_t **otabxml) { Octstr *name, *value, *valueos, *nameos; unsigned char ota_hex; size_t i; name = octstr_create(attr->name); if (attr->children != NULL) value = create_octstr_from_node(attr->children); else value = NULL; if (value == NULL) goto error; i = 0; valueos = NULL; nameos = NULL; while (i < NUMBER_OF_ATTRIBUTES) { nameos = octstr_imm(ota_attributes[i].name); if (octstr_compare(name, nameos) == 0) { if (ota_attributes[i].value != NULL) { valueos = octstr_imm(ota_attributes[i].value); } if (octstr_compare(value, valueos) == 0) { break; } if (octstr_compare(valueos, octstr_imm("INLINE")) == 0) { break; } } ++i; } if (i == NUMBER_OF_ATTRIBUTES) { warning(0, "unknown attribute %s in OTA source", octstr_get_cstr(name)); warning(0, "its value being %s", octstr_get_cstr(value)); goto error; } ota_hex = ota_attributes[i].token; if (!use_inline_string(valueos)) { output_char(ota_hex, otabxml); } else { output_char(ota_hex, otabxml); parse_inline_string(value, otabxml); } octstr_destroy(name); octstr_destroy(value); return 0; error: octstr_destroy(name); octstr_destroy(value); return -1; }