summaryrefslogtreecommitdiffstats
path: root/mbox.c
AgeCommit message (Collapse)Author
2021-07-17Use SEEK_SET and SEEK_END for fseek/fseeko whence parameter.Kevin McCarthy
Thanks to Vincent Lefèvre for pointing out the incorrect usage. POSIX does not specify the actual values (although they are evidently commonly in use).
2020-12-22Correct length to use LOFF_T.Kevin McCarthy
This is a part two, made in master, to the stable branch commit 11b18027. These are mostly length adjustments to use LOFF_T, matching the BODY->length type. An argument could be made for size_t instead, and a few places in Mutt do assign between those types. I've used LOFF_T because off_t is a signed integer. Some changes in this commit affect loops that decrement a length pointer while > 0. Switching to a size_t could create a wraparound infinite loop bug. This also changes the Content-Length header parser to use atoll() intead of atol(). I noticed from the man page that atol() doesn't seem to return -1 on error. But I've kept the check anyway.
2020-12-12Add "headers" parameter to mx_open_message().Kevin McCarthy
This will allow some operations to retrieve only headers, such as ~h pattern matching or the new list menu. Modify the IMAP and POP3 implementation to retrieve only headers when the parameter is set. Headers-only will use the message cache if one exists, but will not populate the message cache (since the body of the message is not downloaded.)
2020-09-06Block signals during mbox-append operation.Kevin McCarthy
I first noticed this back in 2017, but no one replied to my query to mutt-dev and I forgot about it too. Thanks to Oswald Buddenhagen for the followup when he was going through the mailing list archives, confirming the mistake. I've also reviewed MUTT_APPEND and MUTT_NEWFOLDER uses to make sure the context is properly closed (and the signals restored).
2020-07-08Fix utimensat() to use cwd for relative paths.Kevin McCarthy
The utimensat() invocations were missing the AT_FDCWD parameter, meaning they would not work on relative paths. I can't remember whether I completely missed that difference from utime, or somehow thought all the paths would be full paths. :-( In any case, Mutt currently does not expand relative paths in mutt_expand_path(), so the paths can most certainly be relative in those calls too. This caused a bug where atimes were not being properly reset for mailbox entries.
2019-10-15Convert mbox_sync_mailbox() to use buffer pool.Kevin McCarthy
Rewrite return(-1) to a new fatal target to ensure cleanup. Remove some repetitive unlink(tempfile) operations by adding a new flag pointing when to start and stop that during a bail.
2019-01-04Clean up formatting.Kevin McCarthy
Add spaces after if, else, while, for, switch. Unify the brace placement style. The vast majority of the code uses Allman style so convert the relatively few K&R braces over.
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.
2018-07-24Skip sort in mbox_sync_mailbox() when new/reopen occurs.Kevin McCarthy
Callers of mx_sync_mailbox() and mx_close_mailbox() already check for those cases and call update_index(). So remove the need_sort flag setting when mbox_check_mailbox() returns new/reopen inside mbox_sync_mailbox().
2018-07-24Add ctx->vsize = 0 in a couple of places.Vincent Lefevre
It is not clear whether this is needed, but in both cases, the old value (if not 0) is obsolete. If there is a bug somewhere else about vsize, it will be easier to notice it.
2018-06-18Convert context and buffy to use nanosecond timestamps.Kevin McCarthy
The inotify interface has an unfortunate side effect of making Mutt react too quickly to new mail. Sometimes, the mail is only half-delivered when the mailbox is checked. Because Mutt is using the stat mtime - seconds resolution - this means it won't realize there are more messages delivered during the same second. Nanosecond resolution fields were standardized in POSIX.1-2008, so check for and use those if they are available.
2018-02-14Avoid a potential integer overflow if a Content-Length value is huge.Vincent Lefevre
2017-12-17manually touch atime when reading a mbox fileAdam Borowski
The only common use of atime left is local mail agents leaving a mark on mbox file after the mail has been read. And, since POSIX-2008, it is possible to use futimens() to alter atime even on filesystems mounted with noatime. There's no extra cost for doing this on when atime updates are enabled: the inode will be dirty already.
2017-03-02Prevent segv if open-appending to an mbox fails. (closes #3918)Kevin McCarthy
If mbox_open_mailbox_append() fails, ctx->fp will be null. Add a check in mbox_close_mailbox(), to prevent a segv from passing null to fileno().
2017-01-28Improve the label completion hash table usage.Kevin McCarthy
Move the hash table inside the Context. Hook message arrival/deletion to update the label hash. Change the label hash to strdup keys. Use hash_find_elem when updating the counter, to reduce unnecessary add/delete operations.
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-08Move mbox close-append logic inside mbox_close_mailbox().Kevin McCarthy
The mx_fastclose_mailbox() calls mx_ops->close(), which invokes mbox_close_mailbox(). Also, close the ctx->fp inside mbox_close_mailbox(). This way, the (to be added) compress logic can call the mx_ops->close() instead of "knowing" to close the fp before recompressing. mx_fastclose_mailbox() will safe_fclose() the fp again, but I'm leaving it there just in case I missed a usage of the fp in some other part of the code. Thanks to Damien Riegel for the original patch.
2016-08-01Convert mx_open_mailbox_append() to use ctx->mx_ops.Kevin McCarthy
Set the flag MUTT_NEWFOLDER to signal Maildir and MH to create the directory structure. Distribute the "open append" code to mbox, mh, and imap/imap.c. Set pop's mx_ops handler to NULL to signal it is not supported.
2016-07-31Move fflush and fsync to the mbox and mmdf commit_msg functions.Kevin McCarthy
The case statement in mx_commit_message() was previously distributed to the various ops->commit_msg() handlers, but the fflush and fsync were not.
2016-07-17Add the trash folder patch.Kevin McCarthy
This is based on the trash folder patch by Cedric Duval. Modifications to the original patch are: * Use a flag called M_PURGE instead of M_APPENDED. The same flag is then used in the following "purge" patch instead of adding a different flag. * Removed the counter in context. The existing context->deleted is all that's needed. * Removed the "auto unset M_PURGE" when M_DELETED is unset inside _mutt_set_flag(), although this is convenient, it easily leads to header->purge not being reset in a few situations. * Reset purge flag along with the deleted flag if $delete is answered no. * Set M_PURGE on an edited message. (edit_one_message()) * Preserve purge flag in mutt_reopen_mailbox() * Turn off OPTCONFIRMAPPEND when saving to the trash, rather than hardcoding it off in mutt_save_confirm(). That way, normal save to the folder will respect the option.
2016-06-18add commit_msg to struct mx_opsDamien Riegel
2016-06-18add mmdf_commit_message functionDamien Riegel
Move MMDF operations that were done in mx_commit_message to a dedicated mmdf_commit_message function.
2016-06-18add mbox_commit_message functionDamien Riegel
Move mbox operations that were done in mx_commit_message to a dedicated mbox_commit_message function.
2016-06-18add close_msg to struct mx_opsDamien Riegel
2016-06-17Add open_msg to struct mx_opsDamien Riegel
Add the callback to open an existing message to struct mx_ops. For mbox, mmdf, maildir, and mh, the code was implemented directly into mx_open_message, so it is moved in their respective source files. For imap and pop, there were already <mailbox>_fetch_message functions, but their argument order has been changed to pass the context as a first argument.
2016-06-07Make extended buffy independent of the sidebar.Kevin McCarthy
Add new boolean option $mail_check_stats (default off) and $mail_check_stats_interval. The first turns extended buffy on. The second sets the amount of time in between extended buffy checks (defaulting to 60 seconds). Remove the option $sidebar_refresh_time. Change mutt_buffy_check() to only notify the sidebar to redraw if a mailbox buffy value changes. Remove the #ifdefs around the extended buffy functions. The next patch will merge these functions with the basic functions and pass a parameter instead. Imap is a special case, because it sends out the status in one batch. Change this to perform the comparisons inside cmd_parse_status() and flag the sidebar there. It was previously directly assigning the status counters (unsigned int) to the buffy->new (short). Change this to assign 1/0.
2016-06-04Add neomutt version of sidebar patch. (closes #3829)Richard Russon
This is the patch from neomutt; branch 'devel/win-sidebar'; commit c796fa85f9cacefb69b8f7d8545fc9ba71674180 with the following changes: - move the sample muttrc and vimrc to contrib. - remove the README.sidebar. - empty out the PATCHES file.
2016-05-26add check operation to struct mx_opsDamien Riegel
In mx_check_mailbox switch case, we simply call <mailbox>_check_mailbox, so this operation can be move into the mx_ops structure pretty easily. This commit adds a mandatory "check" operation to struct mx_ops and change all mailboxes to use it. Check functions are made static as they are only used in their respective source files now.
2016-05-25add open_new_msg operation to struct mx_opsDamien Riegel
The code was already using a function pointer to do this operation. This commit moves this function pointer to the mx_ops structure and the open_new_message functions to their respective source files if it needs to.
2016-05-12Start decoupling mailbox operations.Damien Riegel
Introduce a dedicated structure for mailbox operations: struct mx_ops. Move the open and close operations into that structure. Assign this structure to the context in mx_open_mailbox. This is currently based on the "magic" for the mailbox type, but may be refactored in the future. Add a stub mbox_close_mailbox function. This function does nothing, the main purpose is to introduce a mx_ops structure for mbox, so its usage is similar to mh/imap/pop. We reuse the name that was made available by the previous commmit. Note that the actual closing of the descriptor is done in mx.c. To be more consistent with other mailboxes, introduce functions mh_open_mailbox and maildir_open_mailbox, and create a dedicated structure for mmdf.
2016-05-12rename mbox_close_mailbox to mx_close_mailbox_append and move itDamien Riegel
mbox_close_mailbox was used as the counterpart of mx_open_mailbox_append. To make things clearer, rename it mx_close_mailbox_append. As it is only used in mx.c, move it there and make it static.
2016-05-09Change M_* symbols to MUTT_*Derek Martin
Changeset 23334e967dd7 created a workaround for a namespace conflict with Solaris and derivatives. After some discussion, the team decided it would be best to move away from using the "M_" prefix for macros. This patch was automatically generated by running: perl -wpi -e 's/\bM_(\w+)\b/MUTT_$1/g' `find . -name '*.[ch]' -print` with the exception that sys_socket.h was exempted. (That file will be backed out subsequent to this commit.) Thanks to Andras Salamon for supplying the perl script used to make this change.
2016-03-15Prevent ctx->fp from being closed twice in the event of an error.Kevin McCarthy
The previous patch from Vincent exposed a crash if ftruncate() fails in mbox_sync_mailbox(). Change fclose() to safe_fclose(), to avoid it being called twice.
2016-03-15Check return value of ftruncate() in mbox_sync_mailbox().Vincent Lefevre
Generate an error in the event that ftruncate() fails.
2016-01-01Update copyright notices.Kevin McCarthy
This patch only updates existing copyright notices in the source files, using commit dates since the last copyright update in commits e3af935cdb1a and f8fd60d8d3f2. Add a notice to the COPYRIGHT file to refer to our mercurial repository for the full commit history. Add myself to the COPYRIGHT file and smime_keys.pl file.
2013-07-23fix typos in commentsOndřej Bílka
2013-04-11backout c1371176ea45Michael Elkins
2013-04-10fix various compiler warnings; most were due to unchecked return values from ↵Michael Elkins
system calls.
2011-05-22Fix some minor warningsBrendan Cully
2010-09-20Fix typoEmanuele Giaquinta
2010-09-12add $mail_check_recent boolean to control whether Mutt will notify about all ↵Michael Elkins
new mail, or just new mail received since the last visit to a mailbox closes #3271 partly addresses #3310
2010-08-05when parsing From_ lines in mmdf/mbox, the TZ should be computed based on ↵Michael Elkins
the time in the string rather than the current time, otherwise DST issues cause the computed time to be wrong. closes #2177
2009-06-21Pass buffer size to mutt_mktemp()Rocco Rutte
2009-06-19Fixup atime for mbox/mmdf also when mailbox is unchanged but has new mail. ↵Rocco Rutte
See #1362.
2009-06-19Don't mangle atime/mtime for mbox folders without new mail upon sync. Closes ↵Rocco Rutte
#1362, #3271.
2009-06-18Backout experimental patchRocco Rutte
2009-06-18UPDATING: add note about -a and --Rocco Rutte