| 628 | } |
| 629 | |
| 630 | static void build_xml(void) |
| 631 | { |
| 632 | size_t size = 2000; |
| 633 | ACL_VSTRING *vbuf = acl_vstring_alloc(size); |
| 634 | ACL_XML2 *xml = acl_xml2_alloc(vbuf); |
| 635 | ACL_XML2_NODE *node1, *node2, *node3; |
| 636 | const char *buf; |
| 637 | const char* pp = "<users name=\"users list\">text1<user name=\"user11\" value=\"zsx11\">text11<age name=\"user111\" value=\"zsx111\">text111</age></user><user name=\"value2\" value=\"zsx2\">text2</user><user name=\"value3\" value=\"zsx3\">text3</user></users>"; |
| 638 | |
| 639 | /* |
| 640 | vbuf->maxlen = size; |
| 641 | */ |
| 642 | |
| 643 | node1 = acl_xml2_create_node(xml, "users", "text1"); |
| 644 | acl_xml2_node_add_child(xml->root, node1); |
| 645 | (void) acl_xml2_node_add_attr(node1, "name", "users list"); |
| 646 | |
| 647 | node2 = acl_xml2_create_node(xml, "user", "text11"); |
| 648 | acl_xml2_node_add_child(node1, node2); |
| 649 | acl_xml2_node_add_attrs(node2, "name", "user11", "value", "zsx11", NULL); |
| 650 | |
| 651 | node3 = acl_xml2_create_node(xml, "age", "text111"); |
| 652 | acl_xml2_node_add_child(node2, node3); |
| 653 | acl_xml2_node_add_attrs(node3, "name", "user111", "value", "zsx111", NULL); |
| 654 | |
| 655 | node2 = acl_xml2_create_node(xml, "user", "text2"); |
| 656 | acl_xml2_node_add_child(node1, node2); |
| 657 | acl_xml2_node_add_attrs(node2, "name", "value2", "value", "zsx2", NULL); |
| 658 | |
| 659 | node2 = acl_xml2_create_node(xml, "user", "text3"); |
| 660 | acl_xml2_node_add_child(node1, node2); |
| 661 | acl_xml2_node_add_attrs(node2, "name", "value3", "value", "zsx3", NULL); |
| 662 | |
| 663 | printf("--------------------xml string-------------------\r\n"); |
| 664 | buf = acl_xml2_build(xml); |
| 665 | printf("[%s]\n", buf); |
| 666 | |
| 667 | if (strlen(buf) != (size_t) (acl_vstring_end(xml->vbuf) - buf)) { |
| 668 | printf("invalid length: %ld, %ld, %p\r\n", (long) strlen(buf), |
| 669 | (long) (acl_vstring_end(xml->vbuf) - buf), |
| 670 | acl_vstring_end(xml->vbuf)); |
| 671 | assert(0); |
| 672 | } |
| 673 | printf("length: %ld, %ld\r\n", (long) strlen(buf), |
| 674 | (long) (acl_vstring_end(xml->vbuf) - buf)); |
| 675 | |
| 676 | if (strcmp(pp, buf) == 0) |
| 677 | printf(">>>>>>>>OK<<<<<<<<<<<\r\n"); |
| 678 | else { |
| 679 | printf(">>>>>>>>Error<<<<<<<<\r\n"); |
| 680 | assert(0); |
| 681 | } |
| 682 | |
| 683 | printf("--------------------xml string end---------------\r\n"); |
| 684 | |
| 685 | |
| 686 | acl_vstring_free(vbuf); |
| 687 | acl_xml2_free(xml); |
no test coverage detected
searching dependent graphs…