NeoMutt  2023-05-17-33-gce4425
Teaching an old dog new tricks
lib.h File Reference

Mbox local mailbox type. More...

#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include "core/lib.h"
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MboxAccountData
 Mbox-specific Account data -. More...


#define MMDF_SEP   "\001\001\001\001\n"


enum MxStatus mbox_check (struct Mailbox *m, struct stat *st, bool check_stats)
enum MailboxType mbox_path_probe (const char *path, const struct stat *st)
 Is this an mbox Mailbox? - Implements MxOps::path_probe() -. More...
void mbox_reset_atime (struct Mailbox *m, struct stat *st)
 Reset the access time on the mailbox file. More...
bool mbox_test_new_folder (const char *path)
 Test if an mbox or mmdf mailbox has new mail. More...


const struct MxOps MxMboxOps
 Mbox Mailbox - Implements MxOps -. More...
const struct MxOps MxMmdfOps
 MMDF Mailbox - Implements MxOps -. More...

Detailed Description

Mbox local mailbox type.

  • Michael R. Elkins
  • Richard Russon

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

Definition in file lib.h.

Macro Definition Documentation


#define MMDF_SEP   "\001\001\001\001\n"

Definition at line 61 of file lib.h.

Function Documentation

◆ mbox_check()

enum MxStatus mbox_check ( struct Mailbox m,
struct stat *  st,
bool  check_stats 

◆ mbox_reset_atime()

void mbox_reset_atime ( struct Mailbox m,
struct stat *  st 

Reset the access time on the mailbox file.


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.

853 struct utimbuf utimebuf;
854 struct stat st2 = { 0 };
856 if (!st)
857 {
858 if (stat(mailbox_path(m), &st2) < 0)
859 return;
860 st = &st2;
861 }
863 utimebuf.actime = st->st_atime;
864 utimebuf.modtime = st->st_mtime;
866 /* When $mbox_check_recent is set, existing new mail is ignored, so do not
867 * reset the atime to mtime-1 to signal new mail. */
868 const bool c_mail_check_recent = cs_subset_bool(NeoMutt->sub, "mail_check_recent");
869 if (!c_mail_check_recent && (utimebuf.actime >= utimebuf.modtime) && mbox_has_new(m))
870 {
871 utimebuf.actime = utimebuf.modtime - 1;
872 }
874 utime(mailbox_path(m), &utimebuf);
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:209
static bool mbox_has_new(struct Mailbox *m)
Does the mailbox have new mail.
Definition: mbox.c:717
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mbox_test_new_folder()

bool mbox_test_new_folder ( const char *  path)

Test if an mbox or mmdf mailbox has new mail.

pathPath to the mailbox
Return values
trueThe folder contains new mail

Definition at line 824 of file mbox.c.

826 bool rc = false;
828 enum MailboxType type = mx_path_probe(path);
830 if ((type != MUTT_MBOX) && (type != MUTT_MMDF))
831 return false;
833 FILE *fp = fopen(path, "rb");
834 if (fp)
835 {
836 rc = test_last_status_new(fp);
837 mutt_file_fclose(&fp);
838 }
840 return rc;
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:150
Supported mailbox formats.
Definition: mailbox.h:41
'mmdf' Mailbox type
Definition: mailbox.h:46
'mbox' Mailbox type
Definition: mailbox.h:45
static bool test_last_status_new(FILE *fp)
Is the last message new.
Definition: mbox.c:799
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1344
+ Here is the call graph for this function: