NeoMutt  2022-04-29-323-g5fcc6c
Teaching an old dog new tricks
mdata.h File Reference

Imap-specific Mailbox data. More...

#include <stdint.h>
#include "private.h"
#include "mutt/lib.h"
+ Include dependency graph for mdata.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ImapMboxData
 IMAP-specific Mailbox data -. More...


void imap_mdata_free (void **ptr)
 Free the private Mailbox data - Implements Mailbox::mdata_free() More...
struct ImapMboxDataimap_mdata_get (struct Mailbox *m)
 Get the Mailbox data for this mailbox. More...
struct ImapMboxDataimap_mdata_new (struct ImapAccountData *adata, const char *name)
 Allocate and initialise a new ImapMboxData structure. More...

Detailed Description

Imap-specific Mailbox data.

  • 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 mdata.h.

Function Documentation

◆ imap_mdata_free()

void imap_mdata_free ( void **  ptr)

Free the private Mailbox data - Implements Mailbox::mdata_free()

Definition at line 40 of file mdata.c.

42 if (!ptr || !*ptr)
43 return;
45 struct ImapMboxData *mdata = *ptr;
48 mutt_list_free(&mdata->flags);
49 FREE(&mdata->name);
50 FREE(&mdata->real_name);
51 FREE(&mdata->munge_name);
52 FREE(ptr);
void imap_mdata_cache_reset(struct ImapMboxData *mdata)
Release and clear cache data of ImapMboxData structure.
Definition: util.c:106
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
#define FREE(x)
Definition: memory.h:43
IMAP-specific Mailbox data -.
Definition: mdata.h:39
void * mdata
Driver specific data.
Definition: mailbox.h:132
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_mdata_get()

struct ImapMboxData * imap_mdata_get ( struct Mailbox m)

Get the Mailbox data for this mailbox.

Return values

Definition at line 60 of file mdata.c.

62 if (!m || (m->type != MUTT_IMAP) || !m->mdata)
63 return NULL;
64 return m->mdata;
'IMAP' Mailbox type
Definition: mailbox.h:50
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
+ Here is the caller graph for this function:

◆ imap_mdata_new()

struct ImapMboxData * imap_mdata_new ( struct ImapAccountData adata,
const char *  name 

Allocate and initialise a new ImapMboxData structure.

adataImap Account data
nameName for Mailbox
Return values
ptrNew ImapMboxData

Definition at line 73 of file mdata.c.

75 char buf[1024] = { 0 };
76 struct ImapMboxData *mdata = mutt_mem_calloc(1, sizeof(struct ImapMboxData));
78 mdata->real_name = mutt_str_dup(name);
80 imap_fix_path(adata->delim, name, buf, sizeof(buf));
81 if (buf[0] == '\0')
82 mutt_str_copy(buf, "INBOX", sizeof(buf));
83 mdata->name = mutt_str_dup(buf);
85 imap_munge_mbox_name(adata->unicode, buf, sizeof(buf), mdata->name);
86 mdata->munge_name = mutt_str_dup(buf);
88 mdata->reopen &= IMAP_REOPEN_ALLOW;
90 STAILQ_INIT(&mdata->flags);
92#ifdef USE_HCACHE
93 imap_hcache_open(adata, mdata);
94 if (mdata->hcache)
95 {
96 size_t dlen = 0;
97 void *uidvalidity = mutt_hcache_fetch_raw(mdata->hcache, "/UIDVALIDITY", 12, &dlen);
98 if (uidvalidity && (dlen < sizeof(uint32_t)))
99 {
101 uidvalidity = NULL;
102 }
103 void *uidnext = mutt_hcache_fetch_raw(mdata->hcache, "/UIDNEXT", 8, &dlen);
104 if (uidnext && (dlen < sizeof(unsigned int)))
105 {
106 mutt_hcache_free_raw(mdata->hcache, &uidnext);
107 uidnext = NULL;
108 }
109 unsigned long long *modseq = mutt_hcache_fetch_raw(mdata->hcache, "/MODSEQ", 7, &dlen);
110 if (modseq && (dlen < sizeof(unsigned long long)))
111 {
112 mutt_hcache_free_raw(mdata->hcache, (void **) &modseq);
113 modseq = NULL;
114 }
115 if (uidvalidity)
116 {
117 mdata->uidvalidity = *(uint32_t *) uidvalidity;
118 mdata->uid_next = uidnext ? *(unsigned int *) uidnext : 0;
119 mdata->modseq = modseq ? *modseq : 0;
120 mutt_debug(LL_DEBUG3, "hcache uidvalidity %u, uidnext %u, modseq %llu\n",
121 mdata->uidvalidity, mdata->uid_next, mdata->modseq);
122 }
124 mutt_hcache_free_raw(mdata->hcache, &uidnext);
125 mutt_hcache_free_raw(mdata->hcache, (void **) &modseq);
127 }
130 return mdata;
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
void * mutt_hcache_fetch_raw(struct HeaderCache *hc, const char *key, size_t keylen, size_t *dlen)
Fetch a message's header from the cache.
Definition: hcache.c:529
void mutt_hcache_free_raw(struct HeaderCache *hc, void **data)
Multiplexor for StoreOps::free.
Definition: hcache.c:548
Allow re-opening a folder upon expunge.
Definition: private.h:66
char * imap_fix_path(char delim, const char *mailbox, char *path, size_t plen)
Fix up the imap path.
Definition: util.c:685
void imap_hcache_close(struct ImapMboxData *mdata)
Close the header cache.
Definition: util.c:339
void imap_munge_mbox_name(bool unicode, char *dest, size_t dlen, const char *src)
Quote awkward characters in a mailbox name.
Definition: util.c:911
void imap_hcache_open(struct ImapAccountData *adata, struct ImapMboxData *mdata)
Open a header cache.
Definition: util.c:297
Log at debug level 3.
Definition: logging.h:42
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:250
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:652
#define STAILQ_INIT(head)
Definition: queue.h:372
char delim
Path delimiter.
Definition: adata.h:75
bool unicode
If true, we can send UTF-8, and the server will use UTF8 rather than mUTF7.
Definition: adata.h:62
unsigned long long modseq
Definition: mdata.h:52
uint32_t uidvalidity
Definition: mdata.h:50
char * name
Mailbox name.
Definition: mdata.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function: