NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
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...
 

Macros

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

Functions

enum MxStatus mbox_check (struct Mailbox *m, struct stat *sb, 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...
 

Variables

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

Detailed Description

Mbox local mailbox type.

Authors
  • 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 http://www.gnu.org/licenses/.

Definition in file lib.h.

Macro Definition Documentation

◆ MMDF_SEP

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

Definition at line 60 of file lib.h.

Function Documentation

◆ mbox_check()

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

◆ mbox_reset_atime()

void mbox_reset_atime ( struct Mailbox m,
struct stat *  st 
)

Reset the access time on the mailbox file.

Parameters
mMailbox
stTimestamp

if mailbox has at least 1 new message, sets mtime > atime of mailbox so mailbox check reports new mail

Definition at line 842 of file mbox.c.

843 {
844  struct utimbuf utimebuf;
845  struct stat st2;
846 
847  if (!st)
848  {
849  if (stat(mailbox_path(m), &st2) < 0)
850  return;
851  st = &st2;
852  }
853 
854  utimebuf.actime = st->st_atime;
855  utimebuf.modtime = st->st_mtime;
856 
857  /* When $mbox_check_recent is set, existing new mail is ignored, so do not
858  * reset the atime to mtime-1 to signal new mail. */
859  const bool c_mail_check_recent =
860  cs_subset_bool(NeoMutt->sub, "mail_check_recent");
861  if (!c_mail_check_recent && (utimebuf.actime >= utimebuf.modtime) && mbox_has_new(m))
862  {
863  utimebuf.actime = utimebuf.modtime - 1;
864  }
865 
866  utime(mailbox_path(m), &utimebuf);
867 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:215
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
Container for Accounts, Notifications.
Definition: neomutt.h:36
static bool mbox_has_new(struct Mailbox *m)
Does the mailbox have new mail.
Definition: mbox.c:720
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.

Parameters
pathPath to the mailbox
Return values
trueThe folder contains new mail

Definition at line 815 of file mbox.c.

816 {
817  bool rc = false;
818 
819  enum MailboxType type = mx_path_probe(path);
820 
821  if ((type != MUTT_MBOX) && (type != MUTT_MMDF))
822  return false;
823 
824  FILE *fp = fopen(path, "rb");
825  if (fp)
826  {
827  rc = test_last_status_new(fp);
828  mutt_file_fclose(&fp);
829  }
830 
831  return rc;
832 }
static bool test_last_status_new(FILE *fp)
Is the last message new.
Definition: mbox.c:790
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
&#39;mmdf&#39; Mailbox type
Definition: mailbox.h:49
&#39;mbox&#39; Mailbox type
Definition: mailbox.h:48
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1317
MailboxType
Supported mailbox formats.
Definition: mailbox.h:43
+ Here is the call graph for this function: