| 186 | } |
| 187 | |
| 188 | static 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 | |
| 235 | static void walk_xml(ACL_XML2* xml) |
| 236 | { |
no test coverage detected
searching dependent graphs…