NeoMutt  2025-12-11-1039-g550ac6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
reverse.h File Reference

Manage alias reverse lookups. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct HashTablealias_reverse_init (void)
 Set up the Reverse Alias Hash Table.
void alias_reverse_cleanup (struct HashTable **reverse)
 Clear up the Reverse Alias Hash Table.
void alias_reverse_add (struct Alias *alias)
 Add an email address lookup for an Alias.
void alias_reverse_delete (struct HashTable *reverse_aliases, struct Alias *alias)
 Remove an email address lookup for an Alias.

Detailed Description

Manage alias reverse lookups.

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

Function Documentation

◆ alias_reverse_init()

struct HashTable * alias_reverse_init ( void )

Set up the Reverse Alias Hash Table.

Return values
ptrEmpty HashTable

Definition at line 43 of file reverse.c.

44{
45 /* reverse alias keys need to be strdup'ed because of idna conversions */
47}
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys).
Definition hash.c:262
@ MUTT_HASH_ALLOW_DUPS
allow duplicate keys to be inserted
Definition hash.h:118
@ MUTT_HASH_STRCASECMP
use strcasecmp() to compare keys
Definition hash.h:116
@ MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition hash.h:117
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alias_reverse_cleanup()

void alias_reverse_cleanup ( struct HashTable ** reverse)

Clear up the Reverse Alias Hash Table.

Parameters
reverseHashTable to free

Definition at line 53 of file reverse.c.

54{
55 mutt_hash_free(reverse);
56}
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:460
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alias_reverse_add()

void alias_reverse_add ( struct Alias * alias)

Add an email address lookup for an Alias.

Parameters
aliasAlias to use

Definition at line 62 of file reverse.c.

63{
64 if (!alias)
65 return;
66
67 /* Note that the address mailbox should be converted to intl form
68 * before using as a key in the hash. This is currently done
69 * by all callers, but added here mostly as documentation. */
70 mutt_addrlist_to_intl(&alias->addr, NULL);
71
73 ASSERT(mod_data);
74
75 struct Address *addr = NULL;
76 TAILQ_FOREACH(addr, &alias->addr, entries)
77 {
78 if (!addr->group && addr->mailbox)
79 mutt_hash_insert(mod_data->reverse_aliases, buf_string(addr->mailbox), addr);
80 }
81}
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition address.c:1304
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys).
Definition hash.c:338
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
#define ASSERT(COND)
Definition signal2.h:59
An email address.
Definition address.h:35
bool group
Group mailbox?
Definition address.h:38
struct Buffer * mailbox
Mailbox and host address.
Definition address.h:37
Alias private Module data.
Definition module_data.h:33
struct HashTable * reverse_aliases
Hash Table of aliases (email address -> alias).
Definition module_data.h:36
struct AddressList addr
List of Addresses the Alias expands to.
Definition alias.h:37
Container for Accounts, Notifications.
Definition neomutt.h:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alias_reverse_delete()

void alias_reverse_delete ( struct HashTable * reverse_aliases,
struct Alias * alias )

Remove an email address lookup for an Alias.

Parameters
reverse_aliasesReverse alias Hash Table
aliasAlias to use

Definition at line 88 of file reverse.c.

89{
90 if (!alias)
91 return;
92
93 /* If the alias addresses were converted to local form, they won't
94 * match the hash entries. */
95 mutt_addrlist_to_intl(&alias->addr, NULL);
96
97 struct Address *addr = NULL;
98 TAILQ_FOREACH(addr, &alias->addr, entries)
99 {
100 if (!addr->group && addr->mailbox)
101 mutt_hash_delete(reverse_aliases, buf_string(addr->mailbox), addr);
102 }
103}
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
Definition hash.c:430
Here is the call graph for this function:
Here is the caller graph for this function: