MCPcopy Create free account
hub / github.com/acl-dev/acl / parse_xml_file

Function parse_xml_file

lib_acl/samples/xml/xml2/main.c:465–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463}
464
465static int parse_xml_file(const char *filepath)
466{
467 int n;
468 char buf[10240];
469 ACL_VSTREAM *fp = acl_vstream_fopen(filepath, O_RDONLY, 0600, 8192);
470 ACL_XML *xml = acl_xml_alloc();
471
472 if (fp == NULL) {
473 printf("open %s error %s\r\n", filepath, acl_last_serror());
474 acl_xml_free(xml);
475 return -1;
476 }
477
478 ACL_METER_TIME("-------------begin--------------");
479 while (1) {
480 n = acl_vstream_read(fp, buf, sizeof(buf) - 1);
481 if (n == ACL_VSTREAM_EOF)
482 break;
483 buf[n] = 0;
484 acl_xml_update(xml, buf);
485 }
486 ACL_METER_TIME("-------------end--------------");
487
488 acl_vstream_close(fp);
489
490 if (acl_xml_is_complete(xml, "root"))
491 printf("Xml is complete OK, filepath: %s\r\n", filepath);
492 else
493 printf("Xml is not complete, filepath: %s\r\n", filepath);
494 acl_xml_free(xml);
495
496 printf("Enter any key to continue ...\r\n");
497 getchar();
498
499 return 0;
500}
501
502static void test1(void)
503{

Callers 1

mainFunction · 0.70

Calls 8

acl_vstream_fopenFunction · 0.85
acl_xml_allocFunction · 0.85
acl_last_serrorFunction · 0.85
acl_xml_freeFunction · 0.85
acl_vstream_readFunction · 0.85
acl_xml_updateFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_xml_is_completeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…