NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
private.h File Reference
#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
#include "sequence.h"
+ Include dependency graph for private.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int maildir_move_to_mailbox (struct Mailbox *m, struct MdEmailArray *mda)
 Copy the Maildir list to the Mailbox. More...
 
bool mh_mkstemp (struct Mailbox *m, FILE **fp, char **tgt)
 Create a temporary file. More...
 
mode_t mh_umask (struct Mailbox *m)
 Create a umask from the mailbox directory. More...
 

Variables

bool C_CheckNew
 Config: (maildir,mh) Check for new mail while the mailbox is open. More...
 
bool C_MaildirCheckCur
 Config: Check both 'new' and 'cur' directories for new mail. More...
 
bool C_MaildirHeaderCacheVerify
 Config: (hcache) Check for maildir changes when opening mailbox. More...
 
bool C_MhPurge
 Config: Really delete files in MH mailboxes. More...
 
char * C_MhSeqFlagged
 Config: MH sequence for flagged message. More...
 
char * C_MhSeqReplied
 Config: MH sequence to tag replied messages. More...
 
char * C_MhSeqUnseen
 Config: MH sequence for unseen messages. More...
 

Detailed Description

Maildir/MH private types

Authors
  • 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 private.h.

Function Documentation

◆ maildir_move_to_mailbox()

int maildir_move_to_mailbox ( struct Mailbox m,
struct MdEmailArray *  mda 
)

Copy the Maildir list to the Mailbox.

Parameters
[in]mMailbox
[out]mdaMaildir array to copy, then free
Return values
numNumber of new emails
0Error

Definition at line 77 of file shared.c.

78 {
79  if (!m)
80  return 0;
81 
82  int oldmsgcount = m->msg_count;
83 
84  struct MdEmail *md = NULL;
85  struct MdEmail **mdp = NULL;
86  ARRAY_FOREACH(mdp, mda)
87  {
88  md = *mdp;
89  mutt_debug(LL_DEBUG2, "Considering %s\n", NONULL(md->canon_fname));
90  if (!md->email)
91  continue;
92 
93  mutt_debug(LL_DEBUG2, "Adding header structure. Flags: %s%s%s%s%s\n",
94  md->email->flagged ? "f" : "", md->email->deleted ? "D" : "",
95  md->email->replied ? "r" : "", md->email->old ? "O" : "",
96  md->email->read ? "R" : "");
97  if (m->msg_count == m->email_max)
98  mx_alloc_memory(m);
99 
100  m->emails[m->msg_count] = md->email;
101  m->emails[m->msg_count]->index = m->msg_count;
102  mailbox_size_add(m, md->email);
103 
104  md->email = NULL;
105  m->msg_count++;
106  }
107 
108  int num = 0;
109  if (m->msg_count > oldmsgcount)
110  num = m->msg_count - oldmsgcount;
111 
112  maildirarray_clear(mda);
113  return num;
114 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mh_mkstemp()

bool mh_mkstemp ( struct Mailbox m,
FILE **  fp,
char **  tgt 
)

Create a temporary file.

Parameters
[in]mMailbox to create the file in
[out]fpFile handle
[out]tgtFile name
Return values
trueSuccess
falseFailure

Definition at line 73 of file mh.c.

74 {
75  int fd;
76  char path[PATH_MAX];
77 
78  mode_t omask = umask(mh_umask(m));
79  while (true)
80  {
81  snprintf(path, sizeof(path), "%s/.neomutt-%s-%d-%" PRIu64, mailbox_path(m),
82  NONULL(ShortHostname), (int) getpid(), mutt_rand64());
83  fd = open(path, O_WRONLY | O_EXCL | O_CREAT, 0666);
84  if (fd == -1)
85  {
86  if (errno != EEXIST)
87  {
88  mutt_perror(path);
89  umask(omask);
90  return false;
91  }
92  }
93  else
94  {
95  *tgt = mutt_str_dup(path);
96  break;
97  }
98  }
99  umask(omask);
100 
101  *fp = fdopen(fd, "w");
102  if (!*fp)
103  {
104  FREE(tgt);
105  close(fd);
106  unlink(path);
107  return false;
108  }
109 
110  return true;
111 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mh_umask()

mode_t mh_umask ( struct Mailbox m)

Create a umask from the mailbox directory.

Parameters
mMailbox
Return values
numUmask

Definition at line 54 of file shared.c.

55 {
57  if (mdata && mdata->mh_umask)
58  return mdata->mh_umask;
59 
60  struct stat st;
61  if (stat(mailbox_path(m), &st) != 0)
62  {
63  mutt_debug(LL_DEBUG1, "stat failed on %s\n", mailbox_path(m));
64  return 077;
65  }
66 
67  return 0777 & ~st.st_mode;
68 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ C_CheckNew

bool C_CheckNew

Config: (maildir,mh) Check for new mail while the mailbox is open.

Definition at line 37 of file config.c.

◆ C_MaildirCheckCur

bool C_MaildirCheckCur

Config: Check both 'new' and 'cur' directories for new mail.

Definition at line 38 of file config.c.

◆ C_MaildirHeaderCacheVerify

bool C_MaildirHeaderCacheVerify

Config: (hcache) Check for maildir changes when opening mailbox.

Definition at line 40 of file config.c.

◆ C_MhPurge

bool C_MhPurge

Config: Really delete files in MH mailboxes.

Definition at line 43 of file config.c.

◆ C_MhSeqFlagged

char* C_MhSeqFlagged

Config: MH sequence for flagged message.

Definition at line 44 of file config.c.

◆ C_MhSeqReplied

char* C_MhSeqReplied

Config: MH sequence to tag replied messages.

Definition at line 45 of file config.c.

◆ C_MhSeqUnseen

char* C_MhSeqUnseen

Config: MH sequence for unseen messages.

Definition at line 46 of file config.c.

NONULL
#define NONULL(x)
Definition: string2.h:37
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
mailbox_size_add
void mailbox_size_add(struct Mailbox *m, const struct Email *e)
Add an email's size to the total size of a Mailbox.
Definition: mailbox.c:200
MdEmail::canon_fname
char * canon_fname
Definition: mdemail.h:36
MdEmail::email
struct Email * email
Definition: mdemail.h:35
MaildirMboxData
Maildir-specific Mailbox data -.
Definition: mdata.h:34
maildir_mdata_get
struct MaildirMboxData * maildir_mdata_get(struct Mailbox *m)
Get the private data for this Mailbox.
Definition: mdata.c:61
maildirarray_clear
void maildirarray_clear(struct MdEmailArray *mda)
Free a Maildir array.
Definition: mdemail.c:66
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
FREE
#define FREE(x)
Definition: memory.h:40
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
Email::old
bool old
Email is seen, but unread.
Definition: email.h:50
mx_alloc_memory
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
Definition: mx.c:1230
Mailbox::mdata
void * mdata
Driver specific data.
Definition: mailbox.h:136
ARRAY_FOREACH
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:206
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
mutt_rand64
uint64_t mutt_rand64(void)
Create a 64-bit random number.
Definition: random.c:129
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Mailbox::email_max
int email_max
Number of pointers in emails.
Definition: mailbox.h:100
MdEmail
A Maildir Email helper.
Definition: mdemail.h:33
Email::flagged
bool flagged
Marked important?
Definition: email.h:43
Email::deleted
bool deleted
Email is deleted.
Definition: email.h:45
ShortHostname
WHERE char * ShortHostname
Short version of the hostname.
Definition: mutt_globals.h:50
Email::index
int index
The absolute (unsorted) message number.
Definition: email.h:86
mailbox_path
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:206
Email::replied
bool replied
Email has been replied to.
Definition: email.h:54
mh_umask
mode_t mh_umask(struct Mailbox *m)
Create a umask from the mailbox directory.
Definition: shared.c:54
Email::read
bool read
Email is read.
Definition: email.h:51
LL_DEBUG2
@ LL_DEBUG2
Log at debug level 2.
Definition: logging.h:41