summaryrefslogtreecommitdiff
path: root/apps/pdfclean.c
AgeCommit message (Collapse)Author
2013-06-20Rearrange source files.Tor Andersson
2013-06-19Exception handling changesRobin Watts
In preparation for work on progressive loading, update the exception handling scheme slightly. Until now, exceptions (as thrown with fz_throw, and caught with fz_try/fz_catch) have merely had an informative string. They have never had anything that can be compared to see if an error is of a particular type. We now introduce error codes; when we fz_throw, we now always give an error code, and can optionally (using fz_throw_message) give both an error code and an informative string. When we fz_rethrow from within a fz_catch, both the error code and the error message is maintained. Using fz_rethrow_message we can 'improve' the error message, but the code is maintained. The error message can be read out using fz_caught_message() and the error code can be read as fz_caught(). Currently we only define a 'generic' error. This will expand in future versions to include other error types that may be tested for.
2013-06-18Merge common and internal headers into one.Tor Andersson
2013-06-18Move header files into separate include directory.Tor Andersson
2013-05-29Access the trailer via an interfacePaul Gardiner
2012-12-24Bug 693503: Fix leak while writing a broken file.Robin Watts
While investigating samples_mupdf_001/2599.pdf.asan.58.1778, a leak showed up while cleaning the file, due to not dropping an object in an error case. mutool clean -dif samples_mupdf_001/2599.pdf.asan.58.1778 leak.pdf Simple Fix. Also extend PDF writing so that it can cope with skipping errors so we at least get something out at the end. Problem found in a test file supplied by Mateusz "j00ru" Jurczyk and Gynvael Coldwind of the Google Security Team using Address Sanitizer. Many thanks!
2012-10-05Rename mubusy to mutool.Tor Andersson
2012-01-27Rename pdfdraw to mupdfdraw etc.Robin Watts
This a) improves our branding, and b) avoids conflicts with other pdf tools out there (pdfinfo etc).
2012-01-27Rename pdf_xref type to pdf_document.Tor Andersson
2012-01-19Remove confusing optional 'password' argument to pdf_open_xref.Tor Andersson
Require that clients call pdf_needs_password/pdf_authenticate_password instead. For dumb clients, we still allow for decrypting a file with a blank password without calling those functions.
2012-01-11Use enum for FZ_STORE_DEFAULT default size.Tor Andersson
2012-01-11Hide glyph cache in context.Tor Andersson
2012-01-11Set default values for alloc context and max store size if none are given.Sebastian Rasmussen
2012-01-10Automatically load page tree when accessing a page/page count.Sebastian Rasmussen
2012-01-10Fix many spelling errors.Sebastian Rasmussen
2012-01-06pdfclean; trailer dictionary expansion fixRobin Watts
The logic controlling whether to expand a trailer dictionary or not was reversed. Fixed here. Thanks to Zeniko for pointing this out.
2012-01-03Add mubusy buildRobin Watts
Add simple combined exe build for mupdf/muxps tools.
2011-12-15Remove 'soft limit' on pixmaps in favour of fz_store.Robin Watts
Change the fz_store to be limited to 256 Megs. Remove the soft limit for pixmaps; the store will automatically throw old resources away to stay below the limit.
2011-12-15Rework pdf_store to fz_store, a part of fz_context.Robin Watts
Firstly, we rename pdf_store to fz_store, reflecting the fact that there are no pdf specific dependencies on it. Next, we rework it so that all the objects that can be stored in the store start with an fz_storable structure. This consists of a reference count, and a function used to free the object when the reference count reaches zero. All the keep/drop functions are then reimplemented by calling fz_keep_sharable/fz_drop_sharable. The 'drop' functions as supplied by the callers are thus now 'free' functions, only called if the reference count drops to 0. The store changes to keep all the items in the store in the linked list (which becomes a doubly linked one). We still make use of the hashtable to index into this list quickly, but we now have the objects in an LRU ordering within the list. Every object is put into the store, with a size record; this is an estimate of how much memory would be freed by freeing that object. The store is moved into the context and given a maximum size; when new things are inserted into the store, care is taken to ensure that we do not expand beyond this size. We evict any stored items (that are not in use) starting from the least recently used. Finding an object in the store now takes a reference to it already. LOCK and UNLOCK comments are used to indicate where locks need to be taken and released to ensure thread safety.
2011-12-12Add -i and -f flags to pdfclean.Robin Watts
Update pdfclean with some new decompression options; -d changes it's definition (though not it's behaviour) to mean "decompress all streams". New flags, -i and -f toggle the decompression of image and font streams respectively.
2011-12-08Stylistic changes when testing pointer values for NULL.Tor Andersson
Also: use 'cannot' instead of 'failed to' in error messages.
2011-12-08Remove deprecated error handling code.Tor Andersson
2011-11-25Merge branch 'master' into contextRobin Watts
2011-11-17Bug 692487: Make pdfclean keep internal links where possible.Robin Watts
Take on a (cosmetically tweaked) version of Zenikos patch to allow pdfclean to keep link destinations that are in preserved pages.
2011-11-17Fix bug 692627; pdfclean -ggg of encrypted files fails.Robin Watts
Encryption bakes the object numbers into the strings/streams. This means that our renumbering technique falls down; when we move an object to its new position, then come to read it, we find that it decrypts badly. The fix here is (as suggested by Zeniko) to avoid renumbering when encryption is in use.
2011-10-04Reintroduce alloc context section.Robin Watts
This was removed during a previous commit to make the editing easier. Now added back in.
2011-10-04Move to exception handling rather than error passing throughout.Robin Watts
This frees us from passing errors back everywhere, and hence enables us to pass results back as return values. Rather than having to explicitly check for errors everywhere and bubble them, we now allow exception handling to do the work for us; the downside to this is that we no longer emit as much debugging information as we did before (though this could be put back in). For now, the debugging information we have lost has been retained in comments with 'RJW:' at the start. This code needs fuller testing, but is being committed as a work in progress.
2011-09-21Add warning context.Tor Andersson
2011-09-21Rename malloc functions for arrays (fz_calloc and fz_realloc).Tor Andersson
2011-09-21Don't thread ctx through safe fz_obj functions.Tor Andersson
2011-09-20Reshuffle exception context code to fit Tor's aesthetic sense.Tor Andersson
2011-09-15Add context to mupdf.Robin Watts
Huge pervasive change to lots of files, adding a context for exception handling and allocation. In time we'll move more statics into there. Also fix some for(i = 0; i < function(...); i++) calls.
2011-09-14Initial import of exception handling codeRobin Watts
Import exception handling code from WSS, modified to fit into the fitz world. With this code we have 'real' fz_try/fz_catch/fz_rethrow functions, handling a fz_except type. We therefore rename the existing fz_throw/ fz_catch/fz_rethrow to be fz_error_make/fz_error_handle/fz_error_note. We don't actually use fz_try/fz_catch/fz_rethrow yet...
2011-04-05Clean up xps and pdf page access functions.Tor Andersson
2011-04-04Le Roi est mort, vive le Roi!Tor Andersson
The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code.
2011-03-06Inhibit warning message spam by introducing a repeat counter.Tor Andersson
2011-01-27Add fz_calloc function to check for integer overflow when allocating arrays, ↵Tor Andersson
and change the signature of fz_realloc to match.
2010-12-30Adhere to nil idiom.Sebastian Rasmussen
2010-12-13Allow reverse page ranges for pdf tools.Sebastian Rasmussen
2010-12-04Support repairing PDF documents with compressed object streams.Tor Andersson
2010-12-04Add option to ascii hex encode binary streams in pdfclean.Tor Andersson
2010-09-27Fix typo.Tor Andersson
2010-08-07Fix typo in pdfclean that caused a segfault.Sebastian Rasmussen
2010-07-28Combine duplicate object removal and xref compacting into a single pass in ↵Sebastian Rasmussen
pdfclean.
2010-07-29Use chained reader like interface for filters instead of process interface.Tor Andersson
2010-07-26Only drop objects that have been renumbered in pdfclean.Sebastian Rasmussen
2010-07-20Replace explicit comparisons with MIN/MAX/ABS macros.Sebastian Rasmussen
2010-07-19Update usage text in pdfclean.Tor Andersson
2010-07-19Update debian package and the man pages for the command line tools.Tor Andersson
2010-07-17Minor edits.Tor Andersson