NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
adata.c File Reference

Imap-specific Account data. More...

#include "config.h"
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "adata.h"
+ Include dependency graph for adata.c:

Go to the source code of this file.

Functions

void imap_adata_free (void **ptr)
 Free the private Account data - Implements Account::adata_free() More...
 
struct ImapAccountDataimap_adata_new (struct Account *a)
 Allocate and initialise a new ImapAccountData structure. More...
 
struct ImapAccountDataimap_adata_get (struct Mailbox *m)
 Get the Account data for this mailbox. More...
 

Detailed Description

Imap-specific Account data.

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 adata.c.

Function Documentation

◆ imap_adata_free()

void imap_adata_free ( void **  ptr)

Free the private Account data - Implements Account::adata_free()

Definition at line 40 of file adata.c.

41 {
42  if (!ptr || !*ptr)
43  return;
44 
45  struct ImapAccountData *adata = *ptr;
46 
47  FREE(&adata->capstr);
48  mutt_buffer_dealloc(&adata->cmdbuf);
49  FREE(&adata->buf);
50  FREE(&adata->cmds);
51 
52  if (adata->conn)
53  {
54  if (adata->conn->close)
55  adata->conn->close(adata->conn);
56  FREE(&adata->conn);
57  }
58 
59  FREE(ptr);
60 }
struct ImapCommand * cmds
Definition: adata.h:69
char * capstr
Definition: adata.h:54
struct Buffer cmdbuf
Definition: adata.h:73
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
int(* close)(struct Connection *conn)
Definition: connection.h:119
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
IMAP-specific Account data -.
Definition: adata.h:39
char * buf
Definition: adata.h:59
#define FREE(x)
Definition: memory.h:40
struct Connection * conn
Definition: adata.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ imap_adata_new()

struct ImapAccountData* imap_adata_new ( struct Account a)

Allocate and initialise a new ImapAccountData structure.

Return values
ptrNew ImapAccountData

Definition at line 66 of file adata.c.

67 {
68  struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
69  adata->account = a;
70 
71  static unsigned char new_seqid = 'a';
72 
73  adata->seqid = new_seqid;
74  const short c_imap_pipeline_depth =
75  cs_subset_number(NeoMutt->sub, "imap_pipeline_depth");
76  adata->cmdslots = c_imap_pipeline_depth + 2;
77  adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
78 
79  if (++new_seqid > 'z')
80  new_seqid = 'a';
81 
82  return adata;
83 }
struct ImapCommand * cmds
Definition: adata.h:69
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
Container for Accounts, Notifications.
Definition: neomutt.h:36
unsigned char seqid
tag sequence prefix
Definition: adata.h:56
struct Account * account
Parent Account.
Definition: adata.h:78
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
int cmdslots
Definition: adata.h:70
IMAP-specific Account data -.
Definition: adata.h:39
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:

◆ imap_adata_get()

struct ImapAccountData* imap_adata_get ( struct Mailbox m)

Get the Account data for this mailbox.

Parameters
mMailbox
Return values
ptrPrivate data

Definition at line 90 of file adata.c.

91 {
92  if (!m || (m->type != MUTT_IMAP) || !m->account)
93  return NULL;
94  return m->account->adata;
95 }
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
'IMAP' Mailbox type
Definition: mailbox.h:53
+ Here is the caller graph for this function: