NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
reverse.c File Reference

Manage alias reverse lookups. More...

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

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 Alias *alias)
 Remove an email address lookup for an Alias.
 
struct Addressalias_reverse_lookup (const struct Address *addr)
 Does the user have an alias for the given address.
 

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

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:261
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition hash.h:113
#define MUTT_HASH_ALLOW_DUPS
allow duplicate keys to be inserted
Definition hash.h:114
#define MUTT_HASH_STRCASECMP
use strcasecmp() to compare keys
Definition hash.h:112
+ 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:459
+ 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(md);
74
75 struct Address *addr = NULL;
76 TAILQ_FOREACH(addr, &alias->addr, entries)
77 {
78 if (!addr->group && addr->mailbox)
80 }
81}
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition address.c:1297
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:337
@ 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:585
#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:35
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 Alias * alias)

Remove an email address lookup for an Alias.

Parameters
aliasAlias to use

Definition at line 87 of file reverse.c.

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

◆ alias_reverse_lookup()

struct Address * alias_reverse_lookup ( const struct Address * addr)

Does the user have an alias for the given address.

Parameters
addrAddress to lookup
Return values
ptrMatching Address

Definition at line 112 of file reverse.c.

113{
114 if (!addr || !addr->mailbox)
115 return NULL;
116
118 ASSERT(md);
119
121}
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition hash.c:364
+ Here is the call graph for this function:
+ Here is the caller graph for this function: