NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
module.c File Reference

Definition of the Alias Module. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "alias.h"
#include "module_data.h"
#include "reverse.h"
+ Include dependency graph for module.c:

Go to the source code of this file.

Functions

static bool alias_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool alias_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool alias_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool alias_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef AliasVars []
 Config definitions for the alias library.
 
const struct Command AliasCommands []
 Alias Commands.
 
const struct Module ModuleAlias
 Module for the Alias library.
 

Detailed Description

Definition of the Alias Module.

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

Function Documentation

◆ alias_init()

static bool alias_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 47 of file module.c.

48{
49 struct AliasModuleData *mod_data = MUTT_MEM_CALLOC(1, struct AliasModuleData);
51
52 mod_data->notify = notify_new();
53 notify_set_parent(mod_data->notify, n->notify);
54
55 STAILQ_INIT(&mod_data->alternates);
56 STAILQ_INIT(&mod_data->unalternates);
57
58 mod_data->alternates_notify = notify_new();
60
61 ARRAY_INIT(&mod_data->aliases);
63
64 mod_data->groups = groups_new();
65
66 mod_data->auto_subscribe_cache = NULL;
67 STAILQ_INIT(&mod_data->mail);
68 STAILQ_INIT(&mod_data->subscribed);
69 STAILQ_INIT(&mod_data->unmail);
70 STAILQ_INIT(&mod_data->unsubscribed);
71
72 return true;
73}
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
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
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
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
#define STAILQ_INIT(head)
Definition queue.h:410
struct HashTable * alias_reverse_init(void)
Set up the Reverse Alias Hash Table.
Definition reverse.c:43
Alias private Module data.
Definition module_data.h:33
struct AliasArray aliases
User's email aliases.
Definition module_data.h:35
struct HashTable * reverse_aliases
Hash Table of aliases (email address -> alias)
Definition module_data.h:36
struct RegexList unalternates
Regexes to exclude false matches in alternates.
Definition module_data.h:39
struct RegexList subscribed
Regexes to match subscribed mailing lists.
Definition module_data.h:49
struct RegexList mail
Regexes to match mailing lists.
Definition module_data.h:48
struct Notify * alternates_notify
Notifications: NotifyAlternates.
Definition module_data.h:40
struct HashTable * auto_subscribe_cache
Hash Table: "mailto:" (no value)
Definition module_data.h:47
struct HashTable * groups
Hash Table: "group-name" -> Group.
Definition module_data.h:45
struct RegexList unmail
Regexes to exclude false matches in mail.
Definition module_data.h:50
struct RegexList unsubscribed
Regexes to exclude false matches in subscribed.
Definition module_data.h:51
struct Notify * notify
Notifications.
Definition module_data.h:34
struct RegexList alternates
Regexes to match the user's alternate email addresses.
Definition module_data.h:38
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:

◆ alias_config_define_variables()

static bool alias_config_define_variables ( struct NeoMutt * n,
struct ConfigSet * cs )
static

Define the Config Variables - Implements Module::config_define_variables()

Definition at line 78 of file module.c.

79{
81}
struct ConfigDef AliasVars[]
Config definitions for the alias library.
Definition config.c:112
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
+ Here is the call graph for this function:

◆ alias_commands_register()

static bool alias_commands_register ( struct NeoMutt * n,
struct CommandArray * ca )
static

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 86 of file module.c.

87{
89}
const struct Command AliasCommands[]
Alias Commands.
Definition commands.c:361
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
+ Here is the call graph for this function:

◆ alias_cleanup()

static bool alias_cleanup ( struct NeoMutt * n,
void * data )
static

Clean up a Module - Implements Module::cleanup()

Definition at line 94 of file module.c.

95{
96 struct AliasModuleData *mod_data = data;
97
98 notify_free(&mod_data->notify);
100
103
104 struct Alias **ap = NULL;
105 ARRAY_FOREACH(ap, &mod_data->aliases)
106 {
108 }
109 aliaslist_clear(&mod_data->aliases);
110
112
113 groups_free(&mod_data->groups);
114
116 mutt_regexlist_free(&mod_data->mail);
118 mutt_regexlist_free(&mod_data->unmail);
120
121 FREE(&mod_data);
122 return true;
123}
void groups_free(struct HashTable **pptr)
Free Address Groups HashTable.
Definition group.c:280
void aliaslist_clear(struct AliasArray *aa)
Empty a List of Aliases.
Definition alias.c:698
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:459
#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 mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition regex.c:179
void alias_reverse_cleanup(struct HashTable **reverse)
Clear up the Reverse Alias Hash Table.
Definition reverse.c:53
void alias_reverse_delete(struct HashTable *reverse_aliases, struct Alias *alias)
Remove an email address lookup for an Alias.
Definition reverse.c:88
A shortcut for an email address or addresses.
Definition alias.h:35
+ Here is the call graph for this function:

Variable Documentation

◆ AliasVars

struct ConfigDef AliasVars[]
extern

Config definitions for the alias library.

Definition at line 112 of file config.c.

112 {
113 // clang-format off
114 { "alias_file", DT_PATH|D_PATH_FILE, IP "~/.neomuttrc", 0, NULL,
115 "Save new aliases to this file"
116 },
117 { "alias_format", DT_EXPANDO|D_NOT_EMPTY, IP "%3i %f%t %-15a %-56A | %C%> %Y", IP &AliasFormatDef, NULL,
118 "printf-like format string for the alias menu"
119 },
121 "Sort method for the alias menu"
122 },
123 { "query_command", DT_STRING|D_STRING_COMMAND, 0, 0, NULL,
124 "External command to query and external address book"
125 },
126 { "query_format", DT_EXPANDO|D_NOT_EMPTY, IP "%3i %t %-25N %-25E | %C%> %Y", IP &QueryFormatDef, NULL,
127 "printf-like format string for the query menu (address book)"
128 },
129
130 { "sort_alias", DT_SYNONYM, IP "alias_sort", IP "2024-11-19" },
131
132 { NULL },
133 // clang-format on
134};
static const struct Mapping AliasSortMethods[]
Sort methods for email aliases.
Definition config.c:42
static const struct ExpandoDefinition QueryFormatDef[]
Expando definitions.
Definition config.c:88
static const struct ExpandoDefinition AliasFormatDef[]
Expando definitions.
Definition config.c:60
@ ALIAS_SORT_ALIAS
Sort by Alias short name.
Definition sort.h:31
#define IP
Definition set.h:55
#define D_STRING_COMMAND
A command.
Definition types.h:99
#define D_PATH_FILE
Path is a file.
Definition types.h:104
@ DT_SYNONYM
synonym for another variable
Definition types.h:45
@ DT_STRING
a string
Definition types.h:44
@ DT_SORT
sorting methods
Definition types.h:43
@ DT_EXPANDO
an expando
Definition types.h:34
@ DT_PATH
a path to a file/directory
Definition types.h:39
#define D_SORT_REVERSE
Sort flag for -reverse prefix.
Definition types.h:120
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition types.h:80

◆ AliasCommands

const struct Command AliasCommands[]
extern

Alias Commands.

Definition at line 361 of file commands.c.

361 {
362 // clang-format off
363 { "alias", CMD_ALIAS, parse_alias,
364 N_("Define an alias (name to email address)"),
365 N_("alias [ -group <name> ... ] <key> <address> [,...] [ # <comments> ]"),
366 "configuration.html#alias" },
367 { "alternates", CMD_ALTERNATES, parse_alternates,
368 N_("Define a list of alternate email addresses for the user"),
369 N_("alternates [ -group <name> ... ] <regex> [ <regex> ... ]"),
370 "configuration.html#alternates" },
371 { "group", CMD_GROUP, parse_group,
372 N_("Add addresses to an address group"),
373 N_("group [ -group <name> ... ] { -rx <regex> ... | -addr <address> ... }"),
374 "configuration.html#addrgroup" },
375 { "lists", CMD_LISTS, parse_lists,
376 N_("Add address to the list of mailing lists"),
377 N_("lists [ -group <name> ... ] <regex> [ ... ]"),
378 "configuration.html#lists" },
379 { "subscribe", CMD_SUBSCRIBE, parse_subscribe,
380 N_("Add address to the list of subscribed mailing lists"),
381 N_("subscribe [ -group <name> ... ] <regex> [ ... ]"),
382 "configuration.html#lists" },
383 { "unalias", CMD_UNALIAS, parse_unalias,
384 N_("Remove an alias definition"),
385 N_("unalias { * | <key> ... }"),
386 "configuration.html#alias" },
387 { "unalternates", CMD_UNALTERNATES, parse_unalternates,
388 N_("Remove addresses from `alternates` list"),
389 N_("unalternates { * | <regex> ... }"),
390 "configuration.html#alternates" },
391 { "ungroup", CMD_UNGROUP, parse_group,
392 N_("Remove addresses from an address `group`"),
393 N_("ungroup [ -group <name> ... ] { * | -rx <regex> ... | -addr <address> ... }"),
394 "configuration.html#addrgroup" },
395 { "unlists", CMD_UNLISTS, parse_unlists,
396 N_("Remove address from the list of mailing lists"),
397 N_("unlists { * | <regex> ... }"),
398 "configuration.html#lists" },
399 { "unsubscribe", CMD_UNSUBSCRIBE, parse_unsubscribe,
400 N_("Remove address from the list of subscribed mailing lists"),
401 N_("unsubscribe { * | <regex> ... }"),
402 "configuration.html#lists" },
403
404 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
405 // clang-format on
406};
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_SUBSCRIBE
:subscribe
Definition command.h:120
@ CMD_UNSUBSCRIBE
:unsubscribe
Definition command.h:148
@ CMD_UNALIAS
:unalias
Definition command.h:126
@ CMD_GROUP
:group
Definition command.h:82
@ CMD_ALIAS
:alias
Definition command.h:64
@ CMD_LISTS
:lists
Definition command.h:90
@ CMD_UNGROUP
:ungroup
Definition command.h:133
@ CMD_NONE
No Command.
Definition command.h:62
@ CMD_ALTERNATES
:alternates
Definition command.h:65
@ CMD_UNLISTS
:unlists
Definition command.h:137
@ CMD_UNALTERNATES
:unalternates
Definition command.h:127
enum CommandResult parse_unalias(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unalias' command - Implements Command::parse() -.
Definition commands.c:308
enum CommandResult parse_subscribe(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'subscribe' command - Implements Command::parse() -.
Definition group.c:239
enum CommandResult parse_unlists(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unlists' command - Implements Command::parse() -.
Definition group.c:291
enum CommandResult parse_alternates(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'alternates' command - Implements Command::parse() -.
Definition alternates.c:68
enum CommandResult parse_lists(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'lists' command - Implements Command::parse() -.
Definition group.c:191
enum CommandResult parse_group(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'group' and 'ungroup' commands - Implements Command::parse() -.
Definition group.c:90
enum CommandResult parse_unalternates(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unalternates' command - Implements Command::parse() -.
Definition alternates.c:119
enum CommandResult parse_unsubscribe(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unsubscribe' command - Implements Command::parse() -.
Definition group.c:335
enum CommandResult parse_alias(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'alias' command - Implements Command::parse() -.
Definition commands.c:178
#define N_(a)
Definition message.h:32

◆ ModuleAlias

const struct Module ModuleAlias
Initial value:
= {
"alias",
NULL,
NULL,
NULL,
}
void alias_cleanup(void)
void alias_init(void)
static bool alias_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:86
static bool alias_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:78

Module for the Alias library.

Definition at line 128 of file module.c.

128 {
130 "alias",
132 NULL, // config_define_types
135 NULL, // gui_init
136 NULL, // gui_cleanup
138};