summaryrefslogtreecommitdiffstats
path: root/compress.c
AgeCommit message (Collapse)Author
2019-01-04Clean up code indentation.Kevin McCarthy
These are mostly automated changes corresponding to the emacs settings: (c-set-style "linux") (setq c-basic-offset 2) (c-set-offset 'case-label '+) Most of the code follows the convention: (add-to-list 'c-cleanup-list 'space-before-funcall) but this is not enforced by this indentation cleanup. Also, I personally dislike tabs, so I have: (setq-default indent-tabs-mode nil) in my own configuration. However I have no desire to change every line just for that effect. So this cleanup does nothing about the mix issue. Some of the secondary files (e.g. regex.c) have been skipped. I've also skipped crypt-gpgme.c, because I need to think about that file. Werner Koch and the GnuPG team contributed most it, and it follows the Gnu indentation settings. It should probably be made uniform with Mutt, but I don't want to discourage future GnuPG contribution to the file. I manually reverted a few unsightly cleanups, and added a few tweeks when I saw things that could be improved.
2018-12-31Remove trailing whitespace.Kevin McCarthy
The result of find . -name "*.[ch]" -exec emacs -batch {} \ --eval="(progn (delete-trailing-whitespace) (and (buffer-modified-p) (save-buffer)))" \;
2018-12-17Add mx operation save_to_header_cache.Kevin McCarthy
This will be used when reading protected headers, to store the encrypted subject in the header cache so it can be searched with.
2018-07-25Add mx_ops.msg_padding_size to return the padding for a mx type.Kevin McCarthy
Mbox pads with a 1 byte, while mmdf pads with 10. Because compress depends on the child type, we create a mx_ops, which allows compress.c to delegate to the child ops.
2016-11-18Improve two compress translation messages.Kevin McCarthy
Change the "Error executing" to "Error running", which is used in multiple places elsewhere in mutt. This also removes the unnecessary newline. Remove the leading space in the "Error compressing" message, and change it to match the error message in editmsg.c.
2016-11-13Compress: check mailbox type if possible when appending.Kevin McCarthy
If an append hook isn't defined, then mutt has to decompress the mailbox. In that case, we can check the type of the decompressed mailbox instead of defaulting to DefaultMagic.
2016-11-13Compress: escape single quotes when invoking the compress/decompress commands.Kevin McCarthy
The format strings are placed in single quotes. mutt_system() invokes sh, so escape the single quotes using bourne-shell syntax: '\''
2016-11-13Compress: fix check_mailbox and sync_mailbox.Kevin McCarthy
Change check_mailbox to delegate to the child_ops->check_mailbox if the compressed mailbox has changed. This allows the mailbox to properly recover if both the decompressed mailbox and compressed file have changed. Change sync_mailbox to call check_mailbox before attempting to sync. This will prevent overwriting external changes to the compressed mailbox.
2016-11-13Create mx_ops.sync operation. Refactor compress to use the mx_ops.sync.Kevin McCarthy
Change compress.sync_mailbox() to lock the compressed mailbox around both the tempfile sync and compress operations. This will prevent changes made inbetween the two syncs from being overwritten. Thanks to Damien Riegel for his original patch refactoring mx_ops.sync, which this patch is partially based upon.
2016-11-13Compress: pull the lock/unlock operations into the open,close,sync operations.Kevin McCarthy
Some operations, such as open_append and sync, need an exclusive lock across a longer period than a single compress/decompress. Remove it from the execute_command and pull into the outer callers. Store lock information inside compress_info. Sync and check_mailbox need more fixes, which will be addressed in subsequent patches.
2016-11-13Compress: safe_fopen() the tempfile, to prevent tempfile attacks.Kevin McCarthy
2016-11-13Compress: add delegate calls to open_append and close mx_ops functions.Kevin McCarthy
The open_append and close were partially duplicating mbox open_append and close operations internally. Change it to call the actual delegate functions instead. Inline the open_read() function inside open_mailbox(). Having it split improved nothing and just complicated the code (i.e. added error-handling checks in open_mailbox() that in reality could not fail).
2016-11-13Compress: fix several logic and memory bugs.Kevin McCarthy
setup_paths leaks memory: realpath is already set in mx_open_mailbox() restore_paths is unneeded. mx_fastclose_mailbox() will free stuff, and nothing is looking at the path once we are closing or aborting. Make a copy of the hooks. Otherwise 'unhook *' will leave dangling pointers. Add compress_info freeing inside mx_fastclose_mailbox(). Only free inside compress.c when we want to prevent close() from doing anything. close_mailbox() didn't preserve ctx->path on error. execute_command() didn't return an error if the mutt_system() command failed. mx_open_mailbox_append() should check mutt_comp_can_append() only for the case that the mailbox doesn't exist. When it exists, mx_get_magic() has already looked at the file contents before checking for matching open_hooks. In open_append_mailbox() if no append hook is defined, it should't call ci->open() if the mailbox doesn't exist. It should act just like append and create a temporary file. check_mailbox() needs more work. For now, at least have it properly close the mailbox on error.
2016-11-13Compress: prefix external functions with "mutt_"Kevin McCarthy
Also, include compress.h in compress.c so the mx_comp_ops doesn't need to be redeclared.
2016-11-13Compress patch from the neomutt repository.Kevin McCarthy
With the following changes: - po/de.po changes trimmed to just the compress additions. - Move the sample muttrc to contrib, and add it to the Makefile.am so it is distributed. Remove the sample vimrc. - Remove extra fluff from manual. Thanks to Roland Rosenfeld for the original patch, and to the NeoMutt team for their work cleaning up the patch.