Resuming my study of how Papyrix parses, styles, & lays out XHTML5 ebooks...
There's a helper that checks with its a callback, timeout, and/or memory-availability to determine when to stop for now.
There's a finalizer & helper, as well as an initializer-helper. Not too much to remark upon here, besides saying this is where callbacks are (de)registered with the XML parser.
There's a mainloop method that parses the XML prologue if it wasn't already, loops, feeds some final data, & cleans up.
1/
Each iteration of that loop periodically checks (via the aforementioned helper) whether it should abort, asks eXpat to allocate a buffer, carefully reads the file into it, rewrites data: URIs, considers invoking a progress callback, hands the buffer back to eXpat propagating errors, & checks if an emergency paragraph-split has been flagged. If so & memory's available it computes available screen realestate, & runs the text-wrap routine with callbacks.
2/?