NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
neomutt.c File Reference

Container for Accounts, Notifications. More...

#include "config.h"
#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "neomutt.h"
#include "account.h"
#include "command.h"
#include "mailbox.h"
#include "module_api.h"
#include "muttlib.h"
+ Include dependency graph for neomutt.c:

Go to the source code of this file.

Macros

#define CONFIG_INIT_TYPE(CS, NAME)
 Register a config type in the config set.
 
#define CONFIG_INIT_VARS(CS, NAME)
 Initialize config variables for a subsystem.
 

Functions

static bool init_env (struct NeoMutt *n, char **envp)
 Initialise the Environment.
 
static bool init_locale (struct NeoMutt *n)
 Initialise the Locale/NLS settings.
 
static void localise_config (struct ConfigSet *cs)
 Localise some config.
 
static void reset_tilde (struct ConfigSet *cs)
 Temporary measure.
 
static bool init_config (struct NeoMutt *n)
 Initialise the config system.
 
static bool init_commands (struct NeoMutt *n)
 Initialise the NeoMutt commands.
 
static bool init_modules (struct NeoMutt *n)
 Initialise the Modules.
 
struct NeoMuttneomutt_new (void)
 Create the main NeoMutt object.
 
bool neomutt_init (struct NeoMutt *n, char **envp, const struct Module **modules)
 Initialise NeoMutt.
 
static bool cleanup_modules (struct NeoMutt *n)
 Clean up each of the Modules.
 
void neomutt_cleanup (struct NeoMutt *n)
 Clean up NeoMutt and Modules.
 
void neomutt_free (struct NeoMutt **ptr)
 Free a NeoMutt.
 
bool neomutt_account_add (struct NeoMutt *n, struct Account *a)
 Add an Account to the global list.
 
void neomutt_account_remove (struct NeoMutt *n, struct Account *a)
 Remove an Account from the global list.
 
void neomutt_accounts_free (struct NeoMutt *n)
 
struct MailboxArray neomutt_mailboxes_get (struct NeoMutt *n, enum MailboxType type)
 Get an Array of matching Mailboxes.
 
FILE * mutt_file_fopen_masked_full (const char *path, const char *mode, const char *file, int line, const char *func)
 Wrapper around mutt_file_fopen_full()
 
void * neomutt_get_module_data (struct NeoMutt *n, enum ModuleId id)
 Get the private data for a Module.
 
void neomutt_set_module_data (struct NeoMutt *n, enum ModuleId id, void *data)
 Set the private data for a Module.
 

Variables

struct NeoMutt * NeoMutt = NULL
 Global NeoMutt object.
 

Detailed Description

Container for Accounts, Notifications.

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

Macro Definition Documentation

◆ CONFIG_INIT_TYPE

#define CONFIG_INIT_TYPE ( CS,
NAME )
Value:
extern const struct ConfigSetType Cst##NAME; \
cs_register_type(CS, &Cst##NAME)

Register a config type in the config set.

Definition at line 50 of file neomutt.c.

50#define CONFIG_INIT_TYPE(CS, NAME) \
51 extern const struct ConfigSetType Cst##NAME; \
52 cs_register_type(CS, &Cst##NAME)

◆ CONFIG_INIT_VARS

#define CONFIG_INIT_VARS ( CS,
NAME )
Value:
bool config_init_##NAME(struct ConfigSet *cs); \
config_init_##NAME(CS)
Container for lots of config items.
Definition set.h:251

Initialize config variables for a subsystem.

Definition at line 55 of file neomutt.c.

55#define CONFIG_INIT_VARS(CS, NAME) \
56 bool config_init_##NAME(struct ConfigSet *cs); \
57 config_init_##NAME(CS)

Function Documentation

◆ init_env()

static bool init_env ( struct NeoMutt * n,
char ** envp )
static

Initialise the Environment.

Parameters
nNeoMutt
envpExternal environment
Return values
trueSuccess

Definition at line 65 of file neomutt.c.

66{
67 if (!n)
68 return false;
69
72
73 envlist_free(&n->env);
74 n->env = envlist_init(envp);
75
76 return true;
77}
void envlist_free(char ***envp)
Free the private copy of the environment.
Definition envlist.c:42
char ** envlist_init(char **envp)
Create a copy of the environment.
Definition envlist.c:58
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:731
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
char ** env
Private copy of the environment variables.
Definition neomutt.h:58
char * username
User's login name.
Definition neomutt.h:57
char * home_dir
User's home directory.
Definition neomutt.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_locale()

static bool init_locale ( struct NeoMutt * n)
static

Initialise the Locale/NLS settings.

Parameters
nNeoMutt
Return values
trueSuccess

Definition at line 84 of file neomutt.c.

85{
86 if (!n)
87 return false;
88
89 setlocale(LC_ALL, "");
90
91#ifdef ENABLE_NLS
92 const char *domdir = mutt_str_getenv("TEXTDOMAINDIR");
93 if (domdir)
94 bindtextdomain(PACKAGE, domdir);
95 else
96 bindtextdomain(PACKAGE, MUTTLOCALEDIR);
97 textdomain(PACKAGE);
98#endif
99
100 n->time_c_locale = duplocale(LC_GLOBAL_LOCALE);
101 if (n->time_c_locale)
102 n->time_c_locale = newlocale(LC_TIME_MASK, "C", n->time_c_locale);
103
104 if (!n->time_c_locale)
105 {
106 mutt_error("%s", strerror(errno)); // LCOV_EXCL_LINE
107 return false; // LCOV_EXCL_LINE
108 }
109
110#ifndef LOCALES_HACK
111 /* Do we have a locale definition? */
112 if (mutt_str_getenv("LC_ALL") || mutt_str_getenv("LANG") || mutt_str_getenv("LC_CTYPE"))
113 {
114 OptLocales = true;
115 }
116#endif
117
118 return true;
119}
#define mutt_error(...)
Definition logging2.h:94
bool OptLocales
(pseudo) set if user has valid locale definition
Definition mbyte.c:45
locale_t time_c_locale
Current locale but LC_TIME=C.
Definition neomutt.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ localise_config()

static void localise_config ( struct ConfigSet * cs)
static

Localise some config.

Parameters
csConfig Set

Definition at line 126 of file neomutt.c.

127{
128 struct Buffer *value = buf_pool_get();
129 struct HashElemArray hea = get_elem_list(cs, GEL_ALL_CONFIG);
130 struct HashElem **hep = NULL;
131
132 ARRAY_FOREACH(hep, &hea)
133 {
134 struct HashElem *he = *hep;
135 if (!(he->type & D_L10N_STRING))
136 continue;
137
138 buf_reset(value);
139 cs_he_initial_get(cs, he, value);
140
141 // Lookup the translation
142 const char *l10n = gettext(buf_string(value));
143 config_he_set_initial(cs, he, l10n);
144 }
145
146 ARRAY_FREE(&hea);
147 buf_pool_release(&value);
148}
#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
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
bool config_he_set_initial(struct ConfigSet *cs, struct HashElem *he, const char *value)
Set the initial value of a Config Option.
Definition helpers.c:312
int cs_he_initial_get(const struct ConfigSet *cs, struct HashElem *he, struct Buffer *result)
Get the initial, or parent, value of a config item.
Definition set.c:558
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
The item stored in a Hash Table.
Definition hash.h:44
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition hash.h:45
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
Definition subset.c:81
@ GEL_ALL_CONFIG
All the normal config (no synonyms or deprecated)
Definition subset.h:81
#define D_L10N_STRING
String can be localised.
Definition types.h:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_tilde()

static void reset_tilde ( struct ConfigSet * cs)
static

Temporary measure.

Parameters
csConfig Set

Definition at line 155 of file neomutt.c.

156{
157 static const char *names[] = { "folder", "mbox", "postponed", "record" };
158
159 struct Buffer *value = buf_pool_get();
160 for (size_t i = 0; i < countof(names); i++)
161 {
162 struct HashElem *he = cs_get_elem(cs, names[i]);
163 if (!he)
164 continue;
165 buf_reset(value);
166 cs_he_initial_get(cs, he, value);
167 expand_path(value, false);
168 config_he_set_initial(cs, he, value->data);
169 }
170 buf_pool_release(&value);
171}
struct HashElem * cs_get_elem(const struct ConfigSet *cs, const char *name)
Get the HashElem representing a config item.
Definition set.c:176
#define countof(x)
Definition memory.h:49
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
char * data
Pointer to data.
Definition buffer.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_config()

static bool init_config ( struct NeoMutt * n)
static

Initialise the config system.

Parameters
nNeomutt
Return values
trueSuccess

Set up the config variables in three stages:

  • Create the config types
  • Create the config variables
  • Set some run-time defaults

Definition at line 183 of file neomutt.c.

184{
185 if (!n)
186 return false;
187
188 n->cs = cs_new(500);
189
190 n->sub = cs_subset_new(NULL, NULL, n->notify);
192 n->sub->cs = n->cs;
193
194 bool rc = true;
195
196 // Set up the Config Types
197 for (enum ModuleId id = MODULE_ID_MAIN; id < MODULE_ID_MAX; id++)
198 {
199 const struct Module *mod = n->modules[id];
200 if (!mod)
201 continue;
202
203 if (mod->config_define_types)
204 {
205 mutt_debug(LL_DEBUG3, "%s:config_define_types()\n", mod->name);
206 rc &= mod->config_define_types(n, n->sub->cs);
207 }
208 }
209
210 if (!rc)
211 return false;
212
213 // Define the Config Variables
214 for (enum ModuleId id = MODULE_ID_MAIN; id < MODULE_ID_MAX; id++)
215 {
216 const struct Module *mod = n->modules[id];
217 if (!mod)
218 continue;
219
221 {
222 mutt_debug(LL_DEBUG3, "%s:config_define_variables()\n", mod->name);
223 rc &= mod->config_define_variables(n, n->sub->cs);
224 }
225 }
226
227 if (!rc)
228 return false;
229
230 // Post-processing
231#ifdef ENABLE_NLS
233#endif
234 reset_tilde(n->sub->cs);
235
236 /* Unset suspend by default if we're the session leader */
237 if (getsid(0) == getpid())
238 config_str_set_initial(n->sub->cs, "suspend", "no");
239
240 return rc;
241}
bool config_str_set_initial(struct ConfigSet *cs, const char *name, const char *value)
Set the initial value of a Config Option.
Definition helpers.c:332
struct ConfigSet * cs_new(size_t size)
Create a new Config Set.
Definition set.c:128
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG3
Log at debug level 3.
Definition logging2.h:47
ModuleId
Unique Module Ids.
Definition module_api.h:42
@ MODULE_ID_MAX
Definition module_api.h:93
@ MODULE_ID_MAIN
ModuleMain, NeoMutt Email Client
Definition module_api.h:44
static void localise_config(struct ConfigSet *cs)
Localise some config.
Definition neomutt.c:126
static void reset_tilde(struct ConfigSet *cs)
Temporary measure.
Definition neomutt.c:155
struct ConfigSet * cs
Parent ConfigSet.
Definition subset.h:50
enum ConfigScope scope
Scope of Subset, e.g. SET_SCOPE_ACCOUNT.
Definition subset.h:48
const char * name
Name of the library module.
Definition module_api.h:104
bool(* config_define_types)(struct NeoMutt *n, struct ConfigSet *cs)
Definition module_api.h:125
bool(* config_define_variables)(struct NeoMutt *n, struct ConfigSet *cs)
Definition module_api.h:137
const struct Module * modules[MODULE_ID_MAX]
Library modules.
Definition neomutt.h:42
struct ConfigSet * cs
Config set.
Definition neomutt.h:48
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
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_NEOMUTT
This Config is NeoMutt-specific (global)
Definition subset.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init_commands()

static bool init_commands ( struct NeoMutt * n)
static

Initialise the NeoMutt commands.

Parameters
nNeomutt
Return values
trueSuccess

Definition at line 248 of file neomutt.c.

249{
250 if (!n)
251 return false;
252
253 struct CommandArray *ca = &n->commands;
254
255 bool rc = true;
256
257 // Set up the Config Types
258 for (enum ModuleId id = MODULE_ID_MAIN; id < MODULE_ID_MAX; id++)
259 {
260 const struct Module *mod = n->modules[id];
261 if (!mod)
262 continue;
263
264 if (mod->commands_register)
265 {
266 mutt_debug(LL_DEBUG3, "%s:commands_register()\n", mod->name);
267 rc &= mod->commands_register(n, ca);
268 }
269 }
270
271 return rc;
272}
bool(* commands_register)(struct NeoMutt *n, struct CommandArray *ca)
Definition module_api.h:149
struct CommandArray commands
NeoMutt commands.
Definition neomutt.h:53
+ Here is the caller graph for this function:

◆ init_modules()

static bool init_modules ( struct NeoMutt * n)
static

Initialise the Modules.

Parameters
nNeomutt
Return values
trueSuccess

Definition at line 279 of file neomutt.c.

280{
281 if (!n)
282 return false;
283
284 bool rc = true;
285
286 // Initialise the Modules
287 for (enum ModuleId id = MODULE_ID_MAIN; id < MODULE_ID_MAX; id++)
288 {
289 const struct Module *mod = n->modules[id];
290 if (!mod)
291 continue;
292
293 if (mod->init)
294 {
295 mutt_debug(LL_DEBUG3, "%s:init()\n", mod->name);
296 rc &= mod->init(n);
297 }
298 }
299
300 return rc;
301}
bool(* init)(struct NeoMutt *n)
Definition module_api.h:113
+ Here is the caller graph for this function:

◆ neomutt_new()

struct NeoMutt * neomutt_new ( void )

Create the main NeoMutt object.

Return values
ptrNew NeoMutt

Definition at line 307 of file neomutt.c.

308{
309 return MUTT_MEM_CALLOC(1, struct NeoMutt);
310}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the caller graph for this function:

◆ neomutt_init()

bool neomutt_init ( struct NeoMutt * n,
char ** envp,
const struct Module ** modules )

Initialise NeoMutt.

Parameters
nNeoMutt
envpExternal environment
modulesLibrary modules to initialise
Return values
trueSuccess

Definition at line 319 of file neomutt.c.

320{
321 if (!n || !modules)
322 return false;
323
324 for (int i = 0; modules[i]; i++)
325 {
326 const struct Module *mod = modules[i];
327
328 n->modules[mod->mid] = mod;
329 }
330
331 if (!init_env(n, envp))
332 return false;
333
334 if (!init_locale(n))
335 return false;
336
337 if (!init_config(n))
338 return false;
339
340 if (!init_commands(n))
341 return false;
342
343 if (!init_modules(n))
344 return false;
345
346 ARRAY_INIT(&n->accounts);
347 n->notify = notify_new();
349
352
355
356 n->groups = groups_new();
357
358 // Change the current umask, and save the original one
359 n->user_default_umask = umask(077);
360 mutt_debug(LL_DEBUG1, "user's umask %03o\n", n->user_default_umask);
361 mutt_debug(LL_DEBUG3, "umask set to 077\n");
362
363 return true;
364}
struct HashTable * groups_new(void)
Create a HashTable for the Address Groups.
Definition group.c:267
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
static bool init_modules(struct NeoMutt *n)
Initialise the Modules.
Definition neomutt.c:279
static bool init_locale(struct NeoMutt *n)
Initialise the Locale/NLS settings.
Definition neomutt.c:84
static bool init_config(struct NeoMutt *n)
Initialise the config system.
Definition neomutt.c:183
static bool init_env(struct NeoMutt *n, char **envp)
Initialise the Environment.
Definition neomutt.c:65
static bool init_commands(struct NeoMutt *n)
Initialise the NeoMutt commands.
Definition neomutt.c:248
struct Notify * notify
Notifications: NotifyConfig, EventConfig.
Definition subset.h:51
enum ModuleId mid
Module Id.
Definition module_api.h:103
struct Notify * notify_timeout
Timeout notifications handler.
Definition neomutt.h:47
struct AccountArray accounts
All Accounts.
Definition neomutt.h:50
struct Notify * notify_resize
Window resize notifications handler.
Definition neomutt.h:46
mode_t user_default_umask
User's default file writing permissions (inferred from umask)
Definition neomutt.h:52
struct HashTable * groups
Hash Table: "group-name" -> Group.
Definition neomutt.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanup_modules()

static bool cleanup_modules ( struct NeoMutt * n)
static

Clean up each of the Modules.

Parameters
nNeoMutt
Return values
trueSuccess

Definition at line 371 of file neomutt.c.

372{
373 if (!n)
374 return false;
375
376 bool rc = true;
377
378 // Cleanup the Modules
379 for (enum ModuleId id = MODULE_ID_MAIN; id < MODULE_ID_MAX; id++)
380 {
381 const struct Module *mod = n->modules[id];
382 if (!mod)
383 continue;
384
385 if (mod->cleanup)
386 {
387 mutt_debug(LL_DEBUG3, "%s:cleanup()\n", mod->name);
388 rc &= mod->cleanup(n);
389 }
390
391 if (n->module_data[mod->mid])
392 {
393 mutt_debug(LL_DEBUG1, "Module %s didn't clean up its data\n", mod->name);
394 rc = false;
395 }
396 }
397
398 return rc;
399}
bool(* cleanup)(struct NeoMutt *n)
Definition module_api.h:177
void * module_data[MODULE_ID_MAX]
Private library module data.
Definition neomutt.h:43
+ Here is the caller graph for this function:

◆ neomutt_cleanup()

void neomutt_cleanup ( struct NeoMutt * n)

Clean up NeoMutt and Modules.

Parameters
nNeoMutt

Definition at line 405 of file neomutt.c.

406{
407 if (!n)
408 return;
409
412}
void commands_clear(struct CommandArray *ca)
Clear an Array of Commands.
Definition command.c:70
static bool cleanup_modules(struct NeoMutt *n)
Clean up each of the Modules.
Definition neomutt.c:371
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_free()

void neomutt_free ( struct NeoMutt ** ptr)

Free a NeoMutt.

Parameters
[out]ptrNeoMutt to free

Definition at line 418 of file neomutt.c.

419{
420 if (!ptr || !*ptr)
421 return;
422
423 struct NeoMutt *n = *ptr;
424
426
427 if (n->sub)
428 {
429 struct ConfigSet *cs = n->sub->cs;
430 cs_subset_free(&n->sub);
431 cs_free(&cs);
432 }
433
436 notify_free(&n->notify);
437 if (n->time_c_locale)
438 freelocale(n->time_c_locale);
439
440 groups_free(&n->groups);
441
442 FREE(&n->home_dir);
443 FREE(&n->username);
444
445 envlist_free(&n->env);
446
447 FREE(ptr);
448}
void groups_free(struct HashTable **pptr)
Free Address Groups HashTable.
Definition group.c:280
void cs_free(struct ConfigSet **ptr)
Free a Config Set.
Definition set.c:142
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
void neomutt_accounts_free(struct NeoMutt *n)
Definition neomutt.c:497
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:

◆ neomutt_account_add()

bool neomutt_account_add ( struct NeoMutt * n,
struct Account * a )

Add an Account to the global list.

Parameters
nNeoMutt
aAccount to add
Return values
trueAccount was added

Definition at line 456 of file neomutt.c.

457{
458 if (!n || !a)
459 return false;
460
461 ARRAY_ADD(&n->accounts, a);
463
464 mutt_debug(LL_NOTIFY, "NT_ACCOUNT_ADD: %s %p\n",
465 mailbox_get_type_name(a->type), (void *) a);
466 struct EventAccount ev_a = { a };
468 return true;
469}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
@ NT_ACCOUNT_ADD
Account has been added.
Definition account.h:67
const char * mailbox_get_type_name(enum MailboxType type)
Get the type of a Mailbox.
Definition mailbox.c:325
@ 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_ACCOUNT
Account has changed, NotifyAccount, EventAccount.
Definition notify_type.h:36
enum MailboxType type
Type of Mailboxes this Account contains.
Definition account.h:37
struct Notify * notify
Notifications: NotifyAccount, EventAccount.
Definition account.h:41
An Event that happened to an Account.
Definition account.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_account_remove()

void neomutt_account_remove ( struct NeoMutt * n,
struct Account * a )

Remove an Account from the global list.

Parameters
nNeoMutt
aAccount to remove

Definition at line 476 of file neomutt.c.

477{
478 if (!n || !a || ARRAY_EMPTY(&n->accounts))
479 return;
480
481 struct Account **ap = NULL;
482 ARRAY_FOREACH(ap, &n->accounts)
483 {
484 if ((*ap) != a)
485 continue;
486
487 ARRAY_REMOVE(&n->accounts, ap);
488 account_free(&a);
489 break;
490 }
491}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
void account_free(struct Account **ptr)
Free an Account.
Definition account.c:148
A group of associated Mailboxes.
Definition account.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_accounts_free()

void neomutt_accounts_free ( struct NeoMutt * n)
  • Free all the Accounts
    Parameters
    nNeoMutt

Definition at line 497 of file neomutt.c.

498{
499 if (!n)
500 return;
501
502 if (!ARRAY_EMPTY(&n->accounts))
503 {
504 mutt_debug(LL_NOTIFY, "NT_ACCOUNT_DELETE_ALL\n");
505 struct EventAccount ev_a = { NULL };
507
508 struct Account **ap = NULL;
509 ARRAY_FOREACH(ap, &n->accounts)
510 {
511 account_free(ap);
512 }
513 }
514
515 ARRAY_FREE(&n->accounts);
516}
@ NT_ACCOUNT_DELETE_ALL
All Accounts are about to be deleted.
Definition account.h:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ neomutt_mailboxes_get()

struct MailboxArray neomutt_mailboxes_get ( struct NeoMutt * n,
enum MailboxType type )

Get an Array of matching Mailboxes.

Parameters
nNeoMutt
typeType of Account to match, see MailboxType
Return values
objArray of Mailboxes
Note
If type is MUTT_MAILBOX_ANY then all Mailbox types will be matched

Definition at line 526 of file neomutt.c.

527{
528 struct MailboxArray ma = ARRAY_HEAD_INITIALIZER;
529
530 if (!n)
531 return ma;
532
533 struct Account **ap = NULL;
534 struct Mailbox **mp = NULL;
535
536 ARRAY_FOREACH(ap, &n->accounts)
537 {
538 struct Account *a = *ap;
539 if ((type > MUTT_UNKNOWN) && (a->type != type))
540 continue;
541
542 ARRAY_FOREACH(mp, &a->mailboxes)
543 {
544 ARRAY_ADD(&ma, *mp);
545 }
546 }
547
548 return ma;
549}
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
struct MailboxArray mailboxes
All Mailboxes.
Definition account.h:40
A mailbox.
Definition mailbox.h:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_file_fopen_masked_full()

FILE * mutt_file_fopen_masked_full ( const char * path,
const char * mode,
const char * file,
int line,
const char * func )

Wrapper around mutt_file_fopen_full()

Parameters
pathFilename
modeMode e.g. "r" readonly; "w" read-write
fileSource file
lineSource line number
funcSource function
Return values
ptrFILE handle
NULLError, see errno

Apply the user's umask, then call mutt_file_fopen_full().

Definition at line 563 of file neomutt.c.

565{
566 // Set the user's umask (saved on startup)
567 mode_t old_umask = umask(NeoMutt->user_default_umask);
568 mutt_debug(LL_DEBUG3, "umask set to %03o\n", NeoMutt->user_default_umask);
569
570 // The permissions will be limited by the umask
571 FILE *fp = mutt_file_fopen_full(path, mode, 0666, file, line, func);
572
573 umask(old_umask); // Immediately restore the umask
574 mutt_debug(LL_DEBUG3, "umask set to %03o\n", old_umask);
575
576 return fp;
577}
FILE * mutt_file_fopen_full(const char *path, const char *mode, const mode_t perms, const char *file, int line, const char *func)
Call fopen() safely.
Definition file.c:556
+ Here is the call graph for this function:

◆ neomutt_get_module_data()

void * neomutt_get_module_data ( struct NeoMutt * n,
enum ModuleId id )

Get the private data for a Module.

Parameters
nNeoMutt
idModule Id
Return values
ptrPrivate Module data

Definition at line 585 of file neomutt.c.

586{
587 if (!n)
588 return NULL;
589
590 return n->module_data[id];
591}

◆ neomutt_set_module_data()

void neomutt_set_module_data ( struct NeoMutt * n,
enum ModuleId id,
void * data )

Set the private data for a Module.

Parameters
nNeoMutt
idModule Id
dataPrivate Module data

Definition at line 599 of file neomutt.c.

600{
601 if (!n)
602 return;
603
604 n->module_data[id] = data;
605}
+ Here is the caller graph for this function:

Variable Documentation

◆ NeoMutt

struct NeoMutt* NeoMutt = NULL

Global NeoMutt object.

Definition at line 47 of file neomutt.c.