Mbox local mailbox type. More...
#include "config.h"
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <utime.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "lib.h"
#include "progress/lib.h"
#include "copy.h"
#include "globals.h"
#include "mutt_header.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
Go to the source code of this file.
Data Structures | |
struct | MUpdate |
Store of new offsets, used by mutt_sync_mailbox() More... | |
Functions | |
static void | mbox_adata_free (void **ptr) |
Free the private Account data - Implements Account::adata_free() More... | |
static struct MboxAccountData * | mbox_adata_new (void) |
Create a new MboxAccountData struct. More... | |
static int | init_mailbox (struct Mailbox *m) |
Add Mbox data to the Mailbox. More... | |
static struct MboxAccountData * | mbox_adata_get (struct Mailbox *m) |
Get the private data associated with a Mailbox. More... | |
static int | mbox_lock_mailbox (struct Mailbox *m, bool excl, bool retry) |
Lock a mailbox. More... | |
static void | mbox_unlock_mailbox (struct Mailbox *m) |
Unlock a mailbox. More... | |
static enum MxOpenReturns | mmdf_parse_mailbox (struct Mailbox *m) |
Read a mailbox in MMDF format. More... | |
static enum MxOpenReturns | mbox_parse_mailbox (struct Mailbox *m) |
Read a mailbox from disk. More... | |
static int | reopen_mailbox (struct Mailbox *m) |
Close and reopen a mailbox. More... | |
static bool | mbox_has_new (struct Mailbox *m) |
Does the mailbox have new mail. More... | |
static int | fseek_last_message (FILE *fp) |
Find the last message in the file. More... | |
static bool | test_last_status_new (FILE *fp) |
Is the last message new. More... | |
bool | mbox_test_new_folder (const char *path) |
Test if an mbox or mmdf mailbox has new mail. More... | |
void | mbox_reset_atime (struct Mailbox *m, struct stat *st) |
Reset the access time on the mailbox file. More... | |
static bool | mbox_ac_owns_path (struct Account *a, const char *path) |
Check whether an Account owns a Mailbox path - Implements MxOps::ac_owns_path() -. More... | |
static bool | mbox_ac_add (struct Account *a, struct Mailbox *m) |
Add a Mailbox to an Account - Implements MxOps::ac_add() -. More... | |
static FILE * | mbox_open_readwrite (struct Mailbox *m) |
Open an mbox read-write. More... | |
static FILE * | mbox_open_readonly (struct Mailbox *m) |
Open an mbox read-only. More... | |
static enum MxOpenReturns | mbox_mbox_open (struct Mailbox *m) |
Open a Mailbox - Implements MxOps::mbox_open() -. More... | |
static bool | mbox_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags) |
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -. More... | |
static enum MxStatus | mbox_mbox_check (struct Mailbox *m) |
Check for new mail - Implements MxOps::mbox_check() -. More... | |
static enum MxStatus | mbox_mbox_sync (struct Mailbox *m) |
Save changes to the Mailbox - Implements MxOps::mbox_sync() -. More... | |
static enum MxStatus | mbox_mbox_close (struct Mailbox *m) |
Close a Mailbox - Implements MxOps::mbox_close() -. More... | |
static bool | mbox_msg_open (struct Mailbox *m, struct Message *msg, struct Email *e) |
Open an email message in a Mailbox - Implements MxOps::msg_open() -. More... | |
static bool | mbox_msg_open_new (struct Mailbox *m, struct Message *msg, const struct Email *e) |
Open a new message in a Mailbox - Implements MxOps::msg_open_new() -. More... | |
static int | mbox_msg_commit (struct Mailbox *m, struct Message *msg) |
Save changes to an email - Implements MxOps::msg_commit() -. More... | |
static int | mbox_msg_close (struct Mailbox *m, struct Message *msg) |
Close an email - Implements MxOps::msg_close() -. More... | |
static int | mbox_msg_padding_size (struct Mailbox *m) |
Bytes of padding between messages - Implements MxOps::msg_padding_size() -. More... | |
enum MailboxType | mbox_path_probe (const char *path, const struct stat *st) |
Is this an mbox Mailbox? - Implements MxOps::path_probe() -. More... | |
static int | mbox_path_canon (char *buf, size_t buflen) |
Canonicalise a Mailbox path - Implements MxOps::path_canon() -. More... | |
static int | mbox_path_pretty (char *buf, size_t buflen, const char *folder) |
Abbreviate a Mailbox path - Implements MxOps::path_pretty() -. More... | |
static int | mbox_path_parent (char *buf, size_t buflen) |
Find the parent of a Mailbox path - Implements MxOps::path_parent() -. More... | |
static int | mbox_path_is_empty (const char *path) |
Is the mailbox empty - Implements MxOps::path_is_empty() -. More... | |
static int | mmdf_msg_commit (struct Mailbox *m, struct Message *msg) |
Save changes to an email - Implements MxOps::msg_commit() -. More... | |
static int | mmdf_msg_padding_size (struct Mailbox *m) |
Bytes of padding between messages - Implements MxOps::msg_padding_size() -. More... | |
static enum MxStatus | mbox_mbox_check_stats (struct Mailbox *m, uint8_t flags) |
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -. More... | |
Variables | |
const struct MxOps | MxMboxOps |
Mbox Mailbox - Implements MxOps -. More... | |
const struct MxOps | MxMmdfOps |
MMDF Mailbox - Implements MxOps -. More... | |
Mbox local mailbox type.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file mbox.c.
|
static |
Free the private Account data - Implements Account::adata_free()
Definition at line 77 of file mbox.c.
|
static |
Create a new MboxAccountData struct.
ptr | New MboxAccountData |
Definition at line 89 of file mbox.c.
|
static |
Add Mbox data to the Mailbox.
m | Mailbox |
0 | Success |
-1 | Error Bad format |
Definition at line 100 of file mbox.c.
|
static |
Get the private data associated with a Mailbox.
m | Mailbox |
ptr | Private data |
Definition at line 119 of file mbox.c.
|
static |
Lock a mailbox.
m | Mailbox to lock |
excl | Exclusive lock? |
retry | Should retry if unable to lock? |
0 | Success |
-1 | Failure |
Definition at line 134 of file mbox.c.
|
static |
Unlock a mailbox.
m | Mailbox to unlock |
Definition at line 158 of file mbox.c.
|
static |
Read a mailbox in MMDF format.
m | Mailbox |
enum | MxOpenReturns |
Definition at line 178 of file mbox.c.
|
static |
Read a mailbox from disk.
m | Mailbox |
enum | MxOpenReturns |
Note that this function is also called when new mail is appended to the currently open folder, and NOT just when the mailbox is initially read.
Definition at line 349 of file mbox.c.
|
static |
Close and reopen a mailbox.
m | Mailbox |
>0 | Success, e.g. MX_STATUS_REOPENED, MX_STATUS_NEW_MAIL |
-1 | Error |
Definition at line 539 of file mbox.c.
|
static |
|
static |
Find the last message in the file.
fp | File to search |
0 | Success |
-1 | No message found |
Definition at line 736 of file mbox.c.
|
static |
Is the last message new.
fp | File to check |
true | The last message is new |
Definition at line 799 of file mbox.c.
bool mbox_test_new_folder | ( | const char * | path | ) |
Test if an mbox or mmdf mailbox has new mail.
path | Path to the mailbox |
true | The folder contains new mail |
Definition at line 824 of file mbox.c.
void mbox_reset_atime | ( | struct Mailbox * | m, |
struct stat * | st | ||
) |
Reset the access time on the mailbox file.
m | Mailbox |
st | Timestamp |
if mailbox has at least 1 new message, sets mtime > atime of mailbox so mailbox check reports new mail
Definition at line 851 of file mbox.c.
|
static |
Open an mbox read-write.
m | Mailbox |
ptr | FILE handle |
This function ensures that the FILE and readonly flag are changed atomically.
Definition at line 907 of file mbox.c.
|
static |
Open an mbox read-only.
m | Mailbox |
ptr | FILE handle |
This function ensures that the FILE and readonly flag are changed atomically.
Definition at line 922 of file mbox.c.