- ctx.flags &= ~XML_DOM_FREE;
- xml_set_source(&ctx, bfdopen_shared(0, 4096));
- int state;
- bprintf(out, "PULL: start\n");
- while ((state = xml_next(&ctx)) >= 0 && state != XML_STATE_EOF)
- switch (state)
- {
- case XML_STATE_CHARS:
- bprintf(out, "PULL: chars");
- show_node(ctx.node);
- break;
- case XML_STATE_STAG:
- bprintf(out, "PULL: element_start");
- show_node(ctx.node);
- break;
- case XML_STATE_ETAG:
- bprintf(out, "PULL: element_end </%s>\n", ctx.node->name);
- break;
- case XML_STATE_COMMENT:
- bprintf(out, "PULL: comment");
- show_node(ctx.node);
- break;
- case XML_STATE_PI:
- bprintf(out, "PULL: pi");
- show_node(ctx.node);
- break;
-#if 0
- case XML_STATE_CDATA:
- bprintf(out, "PULL: cdata [%s]\n", ctx.node->text);
- break;
-#endif
- }
- if (state != XML_STATE_EOF)
- bprintf(out, "PULL: fatal error\n");
+ ctx.flags |= XML_ALLOC_ALL;
+ if (want_parse_dtd)
+ ctx.flags |= XML_PARSE_DTD;
+ if (want_ignore_comments)
+ ctx.flags &= ~(XML_REPORT_COMMENTS | XML_ALLOC_COMMENTS);
+ if (want_ignore_pis)
+ ctx.flags &= ~(XML_REPORT_PIS | XML_ALLOC_PIS);
+ if (want_file_entities)
+ ctx.h_resolve_entity = h_resolve_entity;
+ xml_push_fastbuf(&ctx, bfdopen_shared(0, 4096));
+ bputs(out, "PULL: start\n");
+ if (want_pull)
+ {
+ ctx.pull = XML_PULL_CHARS | XML_PULL_STAG | XML_PULL_ETAG | XML_PULL_COMMENT | XML_PULL_PI;
+ uns state;
+ while (state = xml_next(&ctx))
+ switch (state)
+ {
+ case XML_STATE_CHARS:
+ bputs(out, "PULL: chars");
+ show_node(ctx.node);
+ break;
+ case XML_STATE_STAG:
+ bputs(out, "PULL: stag");
+ show_node(ctx.node);
+ break;
+ case XML_STATE_ETAG:
+ bprintf(out, "PULL: etag </%s>\n", ctx.node->name);
+ break;
+ case XML_STATE_COMMENT:
+ bputs(out, "PULL: comment");
+ show_node(ctx.node);
+ break;
+ case XML_STATE_PI:
+ bputs(out, "PULL: pi");
+ show_node(ctx.node);
+ break;
+ default:
+ bputs(out, "PULL: unknown\n");
+ break;
+ }
+ }