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

Function parse_xml_file

lib_acl/samples/xml/xml3/xml.c:188–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188static int parse_xml_file(const char *filepath)
189{
190 int n;
191 acl_int64 len;
192 char buf[10240];
193 ACL_VSTREAM *fp = acl_vstream_fopen(filepath, O_RDONLY, 0600, 8192);
194 ACL_XML2 *xml;
195 const char *mmap_file = "./local.map";
196
197 if (fp == NULL) {
198 printf("open %s error %s\r\n", filepath, acl_last_serror());
199 return -1;
200 }
201 len = acl_vstream_fsize(fp);
202 if (len <= 0) {
203 printf("fsize %s error %s\r\n", filepath, acl_last_serror());
204 acl_vstream_close(fp);
205 return -1;
206 }
207 len *= 4;
208
209 xml = acl_xml2_mmap_file(mmap_file, len, 1, NULL);
210
211 ACL_METER_TIME("-------------begin--------------");
212 while (1) {
213 n = acl_vstream_read(fp, buf, sizeof(buf) - 1);
214 if (n == ACL_VSTREAM_EOF)
215 break;
216 buf[n] = 0;
217 acl_xml2_update(xml, buf);
218 }
219 ACL_METER_TIME("-------------end--------------");
220
221 acl_vstream_close(fp);
222
223 if (acl_xml2_is_complete(xml, "root"))
224 printf("Xml is complete OK, filepath: %s\r\n", filepath);
225 else
226 printf("Xml is not complete, filepath: %s\r\n", filepath);
227 acl_xml2_free(xml);
228
229 printf("Enter any key to continue ...\r\n");
230 getchar();
231
232 return 0;
233}
234
235static void walk_xml(ACL_XML2* xml)
236{

Callers 1

mainFunction · 0.70

Calls 9

acl_vstream_fopenFunction · 0.85
acl_last_serrorFunction · 0.85
acl_vstream_fsizeFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_xml2_mmap_fileFunction · 0.85
acl_vstream_readFunction · 0.85
acl_xml2_updateFunction · 0.85
acl_xml2_is_completeFunction · 0.85
acl_xml2_freeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…