NeoMutt  2025-12-11-1073-gf33cdb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mailbox.h File Reference

Representation of a mailbox. More...

#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include <time.h>
#include "mutt/lib.h"
Include dependency graph for mailbox.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Mailbox
 A mailbox. More...
struct  EventMailbox
 An Event that happened to a Mailbox. More...

Macros

#define MUTT_ACL_ALL   ((1 << 11) - 1)
 All permissions.

Typedefs

typedef uint16_t AclFlags

Enumerations

enum  MailboxType {
  MUTT_MAILBOX_ANY = -2 , MUTT_MAILBOX_ERROR , MUTT_UNKNOWN , MUTT_MBOX ,
  MUTT_MMDF , MUTT_MH , MUTT_MAILDIR , MUTT_NNTP ,
  MUTT_IMAP , MUTT_NOTMUCH , MUTT_POP , MUTT_COMPRESSED
}
 Supported mailbox formats. More...
enum  AclFlag {
  MUTT_ACL_NONE = 0 , MUTT_ACL_ADMIN = 1U << 0 , MUTT_ACL_CREATE = 1U << 1 , MUTT_ACL_DELETE = 1U << 2 ,
  MUTT_ACL_DELMX = 1U << 3 , MUTT_ACL_EXPUNGE = 1U << 4 , MUTT_ACL_INSERT = 1U << 5 , MUTT_ACL_LOOKUP = 1U << 6 ,
  MUTT_ACL_POST = 1U << 7 , MUTT_ACL_READ = 1U << 8 , MUTT_ACL_SEEN = 1U << 9 , MUTT_ACL_WRITE = 1U << 10
}
 Mailbox ACL rights. More...
enum  ExpandoDataMailbox { ED_MBX_MAILBOX_NAME = 1 , ED_MBX_MESSAGE_COUNT , ED_MBX_PERCENTAGE }
 Expando UIDs for Mailboxes. More...
enum  NotifyMailbox {
  NT_MAILBOX_ADD = 1 , NT_MAILBOX_DELETE , NT_MAILBOX_DELETE_ALL , NT_MAILBOX_CHANGE ,
  NT_MAILBOX_INVALID , NT_MAILBOX_RESORT , NT_MAILBOX_UPDATE , NT_MAILBOX_UNTAG
}
 Types of Mailbox Event. More...

Functions

 ARRAY_HEAD (MailboxArray, struct Mailbox *)
void mailbox_changed (struct Mailbox *m, enum NotifyMailbox action)
 Notify observers of a change to a Mailbox.
void mailbox_clear_emails (struct Mailbox *m)
 Free all the Emails in a Mailbox.
struct Mailbox * mailbox_find (const char *path)
 Find the mailbox with a given path.
struct Mailbox * mailbox_find_name (const char *name)
 Find the mailbox with a given name.
void mailbox_free (struct Mailbox **ptr)
 Free a Mailbox.
int mailbox_gen (void)
 Get the next generation number.
struct Mailbox * mailbox_new (void)
 Create a new Mailbox.
bool mailbox_set_subset (struct Mailbox *m, struct ConfigSubset *sub)
 Set a Mailbox's Config Subset.
void mailbox_size_add (struct Mailbox *m, const struct Email *e)
 Add an email's size to the total size of a Mailbox.
void mailbox_size_sub (struct Mailbox *m, const struct Email *e)
 Subtract an email's size from the total size of a Mailbox.
void mailbox_update (struct Mailbox *m)
 Get the mailbox's current size.
void mailbox_gc_add (struct Email *e)
 Add an Email to the garbage-collection set.
void mailbox_gc_run (void)
 Run the garbage-collection.
const char * mailbox_get_type_name (enum MailboxType type)
 Get the type of a Mailbox.
static const char * mailbox_path (const struct Mailbox *m)
 Get the Mailbox's path string.

Detailed Description

Representation of a mailbox.

Authors
  • Richard Russon
  • Pietro Cerutti

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 mailbox.h.

Macro Definition Documentation

◆ MUTT_ACL_ALL

#define MUTT_ACL_ALL   ((1 << 11) - 1)

All permissions.

Definition at line 75 of file mailbox.h.

Typedef Documentation

◆ AclFlags

typedef uint16_t AclFlags

Definition at line 73 of file mailbox.h.

Enumeration Type Documentation

◆ MailboxType

Supported mailbox formats.

Enumerator
MUTT_MAILBOX_ANY 

Match any Mailbox type.

MUTT_MAILBOX_ERROR 

Error occurred examining Mailbox.

MUTT_UNKNOWN 

Mailbox wasn't recognised.

MUTT_MBOX 

'mbox' Mailbox type

MUTT_MMDF 

'mmdf' Mailbox type

MUTT_MH 

'MH' Mailbox type

MUTT_MAILDIR 

'Maildir' Mailbox type

MUTT_NNTP 

'NNTP' (Usenet) Mailbox type

MUTT_IMAP 

'IMAP' Mailbox type

MUTT_NOTMUCH 

'Notmuch' (virtual) Mailbox type

MUTT_POP 

'POP3' Mailbox type

MUTT_COMPRESSED 

Compressed file Mailbox type.

Definition at line 39 of file mailbox.h.

40{
41 MUTT_MAILBOX_ANY = -2,
44 MUTT_MBOX,
45 MUTT_MMDF,
46 MUTT_MH,
48 MUTT_NNTP,
49 MUTT_IMAP,
51 MUTT_POP,
53};
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
@ MUTT_MMDF
'mmdf' Mailbox type
Definition mailbox.h:45
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition mailbox.h:42
@ MUTT_POP
'POP3' Mailbox type
Definition mailbox.h:51
@ MUTT_MH
'MH' Mailbox type
Definition mailbox.h:46
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:48
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
@ MUTT_MBOX
'mbox' Mailbox type
Definition mailbox.h:44
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition mailbox.h:41
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition mailbox.h:52
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition mailbox.h:47

◆ AclFlag

enum AclFlag

Mailbox ACL rights.

Enumerator
MUTT_ACL_NONE 

No flags are set.

MUTT_ACL_ADMIN 

Administer the account (get/set permissions).

MUTT_ACL_CREATE 

Create a mailbox.

MUTT_ACL_DELETE 

Delete a message.

MUTT_ACL_DELMX 

Delete a mailbox.

MUTT_ACL_EXPUNGE 

Expunge messages.

MUTT_ACL_INSERT 

Add/copy into the mailbox (used when editing a message).

MUTT_ACL_LOOKUP 

Lookup mailbox (visible to 'list').

MUTT_ACL_POST 

Post (submit messages to the server).

MUTT_ACL_READ 

Read the mailbox.

MUTT_ACL_SEEN 

Change the 'seen' status of a message.

MUTT_ACL_WRITE 

Write to a message (for flagging or linking threads).

Definition at line 58 of file mailbox.h.

59{
60 MUTT_ACL_NONE = 0,
61 MUTT_ACL_ADMIN = 1U << 0,
62 MUTT_ACL_CREATE = 1U << 1,
63 MUTT_ACL_DELETE = 1U << 2,
64 MUTT_ACL_DELMX = 1U << 3,
65 MUTT_ACL_EXPUNGE = 1U << 4,
66 MUTT_ACL_INSERT = 1U << 5,
67 MUTT_ACL_LOOKUP = 1U << 6,
68 MUTT_ACL_POST = 1U << 7,
69 MUTT_ACL_READ = 1U << 8,
70 MUTT_ACL_SEEN = 1U << 9,
71 MUTT_ACL_WRITE = 1U << 10,
72};
@ MUTT_ACL_WRITE
Write to a message (for flagging or linking threads).
Definition mailbox.h:71
@ MUTT_ACL_INSERT
Add/copy into the mailbox (used when editing a message).
Definition mailbox.h:66
@ MUTT_ACL_DELMX
Delete a mailbox.
Definition mailbox.h:64
@ MUTT_ACL_ADMIN
Administer the account (get/set permissions).
Definition mailbox.h:61
@ MUTT_ACL_READ
Read the mailbox.
Definition mailbox.h:69
@ MUTT_ACL_POST
Post (submit messages to the server).
Definition mailbox.h:68
@ MUTT_ACL_CREATE
Create a mailbox.
Definition mailbox.h:62
@ MUTT_ACL_NONE
No flags are set.
Definition mailbox.h:60
@ MUTT_ACL_DELETE
Delete a message.
Definition mailbox.h:63
@ MUTT_ACL_EXPUNGE
Expunge messages.
Definition mailbox.h:65
@ MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition mailbox.h:70
@ MUTT_ACL_LOOKUP
Lookup mailbox (visible to 'list').
Definition mailbox.h:67

◆ ExpandoDataMailbox

Expando UIDs for Mailboxes.

See also
ED_MAILBOX, ExpandoDomain
Enumerator
ED_MBX_MAILBOX_NAME 

Mailbox, mailbox_path().

ED_MBX_MESSAGE_COUNT 

Mailbox.msg_count.

ED_MBX_PERCENTAGE 

EmailFormatInfo.pager_progress.

Definition at line 158 of file mailbox.h.

159{
163};
@ ED_MBX_MESSAGE_COUNT
Mailbox.msg_count.
Definition mailbox.h:161
@ ED_MBX_PERCENTAGE
EmailFormatInfo.pager_progress.
Definition mailbox.h:162
@ ED_MBX_MAILBOX_NAME
Mailbox, mailbox_path().
Definition mailbox.h:160

◆ NotifyMailbox

Types of Mailbox Event.

Observers of NT_MAILBOX will be passed an EventMailbox.

Note
Delete notifications are sent before the object is deleted.
Other notifications are sent after the event.
Enumerator
NT_MAILBOX_ADD 

Mailbox has been added.

NT_MAILBOX_DELETE 

Mailbox is about to be deleted.

NT_MAILBOX_DELETE_ALL 

All Mailboxes are about to be deleted.

NT_MAILBOX_CHANGE 

Mailbox has been changed.

NT_MAILBOX_INVALID 

Email list was changed.

NT_MAILBOX_RESORT 

Email list needs resorting.

NT_MAILBOX_UPDATE 

Update internal tables.

NT_MAILBOX_UNTAG 

Clear the 'last-tagged' pointer.

Definition at line 173 of file mailbox.h.

174{
175 NT_MAILBOX_ADD = 1,
179
180 /* These don't really belong here as they are tied to GUI operations.
181 * Eventually, they'll be eliminated. */
186};
@ NT_MAILBOX_UNTAG
Clear the 'last-tagged' pointer.
Definition mailbox.h:185
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:178
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition mailbox.h:183
@ NT_MAILBOX_DELETE
Mailbox is about to be deleted.
Definition mailbox.h:176
@ NT_MAILBOX_INVALID
Email list was changed.
Definition mailbox.h:182
@ NT_MAILBOX_DELETE_ALL
All Mailboxes are about to be deleted.
Definition mailbox.h:177
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition mailbox.h:184
@ NT_MAILBOX_ADD
Mailbox has been added.
Definition mailbox.h:175

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( MailboxArray ,
struct Mailbox *  )

◆ mailbox_changed()

void mailbox_changed ( struct Mailbox * m,
enum NotifyMailbox action )

Notify observers of a change to a Mailbox.

Parameters
mMailbox
actionChange to Mailbox

Definition at line 256 of file mailbox.c.

257{
258 if (!m)
259 return;
260
261 mutt_debug(LL_NOTIFY, "NT_MAILBOX_CHANGE: %s %p\n",
262 mailbox_get_type_name(m->type), (void *) m);
263 struct EventMailbox ev_m = { m };
264 notify_send(m->notify, NT_MAILBOX, action, &ev_m);
265}
const char * mailbox_get_type_name(enum MailboxType type)
Get the type of a Mailbox.
Definition mailbox.c:349
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:50
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:50
An Event that happened to a Mailbox.
Definition mailbox.h:192
enum MailboxType type
Mailbox type.
Definition mailbox.h:104
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:147
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_clear_emails()

void mailbox_clear_emails ( struct Mailbox * m)

Free all the Emails in a Mailbox.

Parameters
mMailbox

Free every Email in the array, including any left beyond msg_count, and the Message-ID and Subject Hash Tables that point to them. The tables are rebuilt when they are next needed. The message counts and size are reset.

The emails array itself is kept for reuse.

Definition at line 149 of file mailbox.c.

150{
151 if (!m)
152 return;
153
156
157 for (int i = 0; i < m->email_max; i++)
158 email_free(&m->emails[i]);
159
160 m->msg_count = 0;
161 m->msg_deleted = 0;
162 m->msg_flagged = 0;
163 m->msg_new = 0;
164 m->msg_tagged = 0;
165 m->msg_unread = 0;
166 m->size = 0;
167 m->vcount = 0;
168}
void email_free(struct Email **ptr)
Free an Email.
Definition email.c:46
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:460
int vcount
The number of virtual messages.
Definition mailbox.h:101
int msg_new
Number of new messages.
Definition mailbox.h:94
int msg_count
Total number of messages.
Definition mailbox.h:90
int email_max
Size of emails array.
Definition mailbox.h:99
struct HashTable * subj_hash
Hash Table: "Subject" -> Email.
Definition mailbox.h:126
struct Email ** emails
Array of Emails.
Definition mailbox.h:98
struct HashTable * id_hash
Hash Table: "Message-ID" -> Email.
Definition mailbox.h:125
int msg_deleted
Number of deleted messages.
Definition mailbox.h:95
off_t size
Size of the Mailbox.
Definition mailbox.h:86
int msg_flagged
Number of flagged messages.
Definition mailbox.h:92
int msg_tagged
How many messages are tagged?
Definition mailbox.h:96
int msg_unread
Number of unread messages.
Definition mailbox.h:91
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_find()

struct Mailbox * mailbox_find ( const char * path)

Find the mailbox with a given path.

Parameters
pathPath to match
Return values
ptrMatching Mailbox

Definition at line 175 of file mailbox.c.

176{
177 if (!path)
178 return NULL;
179
180 struct stat st = { 0 };
181 struct stat st_tmp = { 0 };
182
183 if (stat(path, &st) != 0)
184 return NULL;
185
186 struct MailboxArray ma = neomutt_mailboxes_get(NeoMutt, MUTT_MAILBOX_ANY);
187 struct Mailbox **mp = NULL;
188 struct Mailbox *m = NULL;
189 ARRAY_FOREACH(mp, &ma)
190 {
191 if ((stat(mailbox_path(*mp), &st_tmp) == 0) &&
192 (st.st_dev == st_tmp.st_dev) && (st.st_ino == st_tmp.st_ino))
193 {
194 m = *mp;
195 break;
196 }
197 }
198
199 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
200 return m;
201}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:217
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:607
A mailbox.
Definition mailbox.h:81
Container for Accounts, Notifications.
Definition neomutt.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_find_name()

struct Mailbox * mailbox_find_name ( const char * name)

Find the mailbox with a given name.

Parameters
nameName to match
Return values
ptrMatching Mailbox
NULLNo matching mailbox found
Note
This searches across all Accounts

Definition at line 211 of file mailbox.c.

212{
213 if (!name)
214 return NULL;
215
216 struct MailboxArray ma = neomutt_mailboxes_get(NeoMutt, MUTT_MAILBOX_ANY);
217 struct Mailbox **mp = NULL;
218 struct Mailbox *m = NULL;
219 ARRAY_FOREACH(mp, &ma)
220 {
221 if (mutt_str_equal((*mp)->name, name))
222 {
223 m = *mp;
224 break;
225 }
226 }
227
228 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
229 return m;
230}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
char * name
A short name for the Mailbox.
Definition mailbox.h:84
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_free()

void mailbox_free ( struct Mailbox ** ptr)

Free a Mailbox.

Parameters
[out]ptrMailbox to free

Definition at line 90 of file mailbox.c.

91{
92 if (!ptr || !*ptr)
93 return;
94
95 struct Mailbox *m = *ptr;
96
97 const bool do_free = (m->opened == 0) && !m->visible;
98
99 mutt_debug(LL_DEBUG3, "%sfreeing %s mailbox %s with refcount %d\n",
100 do_free ? "" : "not ", m->visible ? "visible" : "invisible",
101 buf_string(&m->pathbuf), m->opened);
102
103 if (!do_free)
104 {
105 return;
106 }
107
108 mutt_debug(LL_NOTIFY, "NT_MAILBOX_DELETE: %s %p\n",
109 mailbox_get_type_name(m->type), (void *) m);
110 struct EventMailbox ev_m = { m };
111 notify_send(m->notify, NT_MAILBOX, NT_MAILBOX_DELETE, &ev_m);
112
113 mutt_debug(LL_NOTIFY, "NT_EMAIL_DELETE_ALL\n");
114 struct EventEmail ev_e = { 0, NULL };
115 notify_send(m->notify, NT_EMAIL, NT_EMAIL_DELETE_ALL, &ev_e);
116
118 mutt_hash_free(&m->label_hash);
119 m->email_max = 0;
120
121 if (m->mdata_free && m->mdata)
122 m->mdata_free(&m->mdata);
123
124 buf_dealloc(&m->pathbuf);
125 cs_subset_free(&m->sub);
126 FREE(&m->name);
127 FREE(&m->realpath);
128 FREE(&m->emails);
129 FREE(&m->v2r);
130 notify_free(&m->notify);
132
133 /* The NT_MAILBOX_DELETE notification might already have caused *ptr to be NULL,
134 * so call free() on the m pointer */
135 *ptr = NULL;
136 FREE(&m);
137}
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition buffer.c:383
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:99
void mailbox_gc_run(void)
Run the garbage-collection.
Definition mailbox.c:335
void mailbox_clear_emails(struct Mailbox *m)
Free all the Emails in a Mailbox.
Definition mailbox.c:149
@ NT_EMAIL_DELETE_ALL
All the Emails are about to be deleted.
Definition email.h:185
@ LL_DEBUG3
Log at debug level 3.
Definition logging2.h:47
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:92
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
@ NT_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition notify_type.h:44
An Event that happened to an Email.
Definition email.h:196
bool visible
True if a result of "mailboxes".
Definition mailbox.h:132
int opened
Number of times mailbox is opened.
Definition mailbox.h:130
void cs_subset_free(struct ConfigSubset **ptr)
Free a Config Subset.
Definition subset.c:112
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_gen()

int mailbox_gen ( void )

Get the next generation number.

Return values
numUnique number

Definition at line 59 of file mailbox.c.

60{
61 static int gen = 0;
62 return gen++;
63}
Here is the caller graph for this function:

◆ mailbox_new()

struct Mailbox * mailbox_new ( void )

Create a new Mailbox.

Return values
ptrNew Mailbox

Definition at line 69 of file mailbox.c.

70{
71 struct Mailbox *m = MUTT_MEM_CALLOC(1, struct Mailbox);
72
73 buf_init(&m->pathbuf);
74 m->notify = notify_new();
75
76 m->email_max = 25;
77 m->emails = MUTT_MEM_CALLOC(m->email_max, struct Email *);
78 m->v2r = MUTT_MEM_CALLOC(m->email_max, int);
79 m->gen = mailbox_gen();
80 m->notify_user = true;
81 m->poll_new_mail = true;
82
83 return m;
84}
struct Buffer * buf_init(struct Buffer *buf)
Initialise a new Buffer.
Definition buffer.c:74
int mailbox_gen(void)
Get the next generation number.
Definition mailbox.c:59
#define MUTT_MEM_CALLOC(n, T)
Definition memory.h:68
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
The envelope/body of an email.
Definition email.h:39
int * v2r
Mapping from virtual to real msgno.
Definition mailbox.h:100
bool poll_new_mail
Check for new mail.
Definition mailbox.h:117
bool notify_user
Notify the user of new mail.
Definition mailbox.h:115
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:82
int gen
Generation number, for sorting.
Definition mailbox.h:149
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_set_subset()

bool mailbox_set_subset ( struct Mailbox * m,
struct ConfigSubset * sub )

Set a Mailbox's Config Subset.

Parameters
mMailbox
subParent Config Subset
Return values
trueSuccess

Definition at line 293 of file mailbox.c.

294{
295 if (!m || m->sub || !sub)
296 return false;
297
298 m->sub = cs_subset_new(m->name, sub, m->notify);
300 return true;
301}
enum ConfigScope scope
Scope of Subset, e.g. SET_SCOPE_ACCOUNT.
Definition subset.h:48
struct ConfigSubset * sub
Inherited config items.
Definition mailbox.h:85
struct ConfigSubset * cs_subset_new(const char *name, struct ConfigSubset *sub_parent, struct Notify *not_parent)
Create a new Config Subset.
Definition subset.c:158
@ SET_SCOPE_MAILBOX
This Config is Mailbox-specific.
Definition subset.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
mMailbox
eEmail

Definition at line 272 of file mailbox.c.

273{
274 m->size += email_get_size(e);
275}
size_t email_get_size(const struct Email *e)
Compute the size of an email.
Definition email.c:121
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_size_sub()

void mailbox_size_sub ( struct Mailbox * m,
const struct Email * e )

Subtract an email's size from the total size of a Mailbox.

Parameters
mMailbox
eEmail

Definition at line 282 of file mailbox.c.

283{
284 m->size -= email_get_size(e);
285}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_update()

void mailbox_update ( struct Mailbox * m)

Get the mailbox's current size.

Parameters
mMailbox to check
Note
Only applies to local Mailboxes

Definition at line 238 of file mailbox.c.

239{
240 struct stat st = { 0 };
241
242 if (!m)
243 return;
244
245 if (stat(mailbox_path(m), &st) == 0)
246 m->size = (off_t) st.st_size;
247 else
248 m->size = 0;
249}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_gc_add()

void mailbox_gc_add ( struct Email * e)

Add an Email to the garbage-collection set.

Parameters
eEmail
Precondition
e is not NULL

Definition at line 321 of file mailbox.c.

322{
323 ASSERT(e);
324 if (GC.idx == countof(GC.arr))
325 {
327 }
328 GC.arr[GC.idx] = e;
329 GC.idx++;
330}
static struct EmailGarbageCollector GC
Set of Emails to be deleted.
Definition mailbox.c:313
#define countof(x)
Definition memory.h:49
#define ASSERT(COND)
Definition signal2.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_gc_run()

void mailbox_gc_run ( void )

Run the garbage-collection.

Definition at line 335 of file mailbox.c.

336{
337 for (size_t i = 0; i < GC.idx; i++)
338 {
339 email_free(&GC.arr[i]);
340 }
341 GC.idx = 0;
342}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_get_type_name()

const char * mailbox_get_type_name ( enum MailboxType type)

Get the type of a Mailbox.

Parameters
typeMailbox type, e.g. MUTT_IMAP
Return values
ptrString describing Mailbox type

Definition at line 349 of file mailbox.c.

350{
351 const char *name = mutt_map_get_name(type, MailboxTypes);
352 if (name)
353 return name;
354 return "UNKNOWN";
355}
static const struct Mapping MailboxTypes[]
Lookups for Mailbox types.
Definition mailbox.c:40
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition mapping.c:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mailbox_path()

const char * mailbox_path ( const struct Mailbox * m)
inlinestatic

Get the Mailbox's path string.

Parameters
mMailbox
Return values
ptrPath string

Definition at line 217 of file mailbox.h.

218{
219 return buf_string(&m->pathbuf); // LCOV_EXCL_LINE
220}
Here is the call graph for this function: