Register iOS app as handler for PDF, XPS and CBZ files.
Avoid diving by zero in mudraw.
Move guts of pdfclean into new pdf_write function.

Expose pdf_write function through the document interface.
Fix typo in pdf writing code.
Free document/app when document cannot be shown in X11 viewer.
Fix locking issues discovered by Sebras.

When reading the xref, if certain objects are indirect references
(Size, Prev, XrefStm) we can 'relock' a lock we already hold.

Work around that here.
Simple mupdfposter app

Divides large format pdfs into a new pdf with multiple pages, that tile
the original PDF.
Remove 2 unused variables.

Leftovers from recent mupdfclean refactoring.
Proper fix for previous locking issues.

Sebras pointed out that my previous (untested) fix was wrong,
as we don't resolve indirect objects until we attempt to interpret
them. The fix is just to move the interpretation (pdf_to_int())
into the unlocked section.
Fix problem with SEGV in page tree loading.

Found in a file synthesized by Sebras. Many thanks!
Always print the file name upon errors in mudraw.
Add omitted mupdfposter.vcproj file.
Bug 693022: Image/Pixmaps stuck in cache

Zeniko points out that images that don't decode on demand (i.e. ones
that are held as pixmaps all the time) can never be evicted from the
cache due to them holding a pointer to the pixmap, which holds a pointer
back to the image.

His fix is to only cache images that decode on demand.

The actual patch applied here is slightly tweaked from his version;
firstly the 'dontcache' logic is reversed to 'cache' to avoid overloading
my poor brain with another negation.

Secondly, one change to a condition is not taken on, as it is (I believe)
unnecessary.
Do not rely on printf NULL-pointer handling for missing font names.
Warn instead of giving error on missing password in pdfshow.

This means pdfshow can show objects in encrypted PDFs again.
Add scripts to generate hyperlinked source in HTML.
Fix bug in ARM code in draw_simple_scale

The scale_row_from_temp code was broken. Firstly the rounding was wrong
in the 'bulk' case (not a big deal), but more importantly on
configurations where unaligned loads were not allowed (such as the nook),
we could still crash due to an incorrect test to avoid that code.

Thanks to Kammerer for the report, and testing of fixed version.
Update seeking behaviour of null streams.

In order to (hopefully) allow page content streams to be interpreted
without having to preload them all into memory before we run them, we
need to make the stream reading code cope with other users moving
the stream pointer.

For example: Consider the case where we are midway through
interpreting a contents stream, and us hitting an operator that
requires something to be read from Resources. This will move the
underlying stream file pointer, and cause the contents stream to
read incorrectly when control returns to the interpreter.

The solution to this seems to be fairly simple; whenever we create
a filter out of the file stream, the existing code puts in a 'null'
filter first, to enforce a length limit on the stream. This null
filter already does most of the work we need it to, in that by it
being there, the buffering of data is done in the null filter rather
than in the underlying stream layer.

All we need to do is to keep track of where in the underlying stream
the null filter thinks it is, and ensure that it seeks there before
each read (in case anyone else has moved it).

We move the setting of the offset to be explicit in the pdf_open_filter
(and associated) call(s), rather than requiring fz_seeks elsewhere.
Switch to reading content streams on the fly during interpretation.

Previously, before interpreting a pages content stream we would
load it entirely into a buffer. Then we would interpret that
buffer. This has a cost in memory use.

Here, we update the code to read from a stream on the fly.

This has required changes in various different parts of the code.

Firstly, we have removed all use of the FILE lock - as stream
reads can now safely be interrupted by resource (or object) reads
from elsewhere in the file, the file lock becomes a very hard
thing to maintain, and doesn't actually benefit us at all. The
choices were to either use a recursive lock, or to remove it
entirely; I opted for the latter.

The file lock enum value remains as a placeholder for future use in
extendable data streams.

Secondly, we add a new 'concat' filter that concatenates a series of
streams together into one, optionally putting whitespace between each
stream (as the pdf parser requires this).

Finally, we change page/xobject/pattern content streams to work
on the fly, but we leave type3 glyphs using buffers (as presumably
these will be run repeatedly).
Bug 693028 - improve mupdf viewer handling of broken page streams

Currently, if a page stream cannot be read, mupdf gives an alert box
and then exits. This is annoying when reading a large pdf.

Here we change the code to only exit if a page is completely broken;
in the case of missing page contents, or missing links, we give a warning
and just render the best we can.

Also, update a couple of error messages to be less misleading.