NeoMutt  2020-11-20
Teaching an old dog new tricks
DOXYGEN
reverse.c File Reference

Manage alias reverse lookups. More...

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

Go to the source code of this file.

Functions

void alias_reverse_init (void)
 Set up the Reverse Alias Hash Table. More...
 
void alias_reverse_shutdown (void)
 Clear up the Reverse Alias Hash Table. More...
 
void alias_reverse_add (struct Alias *alias)
 Add an email address lookup for an Alias. More...
 
void alias_reverse_delete (struct Alias *alias)
 Remove an email address lookup for an Alias. More...
 
struct Addressalias_reverse_lookup (const struct Address *addr)
 Does the user have an alias for the given address. More...
 

Variables

static struct HashTableReverseAliases
 Hash Table of aliases (email address -> alias) More...
 

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()

void alias_reverse_init ( void  )

Set up the Reverse Alias Hash Table.

Definition at line 42 of file reverse.c.

43 {
44  /* reverse alias keys need to be strdup'ed because of idna conversions */
47 }
#define MUTT_HASH_STRCASECMP
use strcasecmp() to compare keys
Definition: hash.h:98
#define MUTT_HASH_ALLOW_DUPS
allow duplicate keys to be inserted
Definition: hash.h:100
static struct HashTable * ReverseAliases
Hash Table of aliases (email address -> alias)
Definition: reverse.c:37
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition: hash.h:99
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
Definition: hash.c:251
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alias_reverse_shutdown()

void alias_reverse_shutdown ( void  )

Clear up the Reverse Alias Hash Table.

Definition at line 52 of file reverse.c.

53 {
55 }
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
static struct HashTable * ReverseAliases
Hash Table of aliases (email address -> alias)
Definition: reverse.c:37
+ 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 61 of file reverse.c.

62 {
63  if (!alias)
64  return;
65 
66  /* Note that the address mailbox should be converted to intl form
67  * before using as a key in the hash. This is currently done
68  * by all callers, but added here mostly as documentation. */
69  mutt_addrlist_to_intl(&alias->addr, NULL);
70 
71  struct Address *addr = NULL;
72  TAILQ_FOREACH(addr, &alias->addr, entries)
73  {
74  if (!addr->group && addr->mailbox)
76  }
77 }
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:327
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1304
bool group
Group mailbox?
Definition: address.h:38
static struct HashTable * ReverseAliases
Hash Table of aliases (email address -> alias)
Definition: reverse.c:37
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
+ 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 83 of file reverse.c.

84 {
85  if (!alias)
86  return;
87 
88  /* If the alias addresses were converted to local form, they won't
89  * match the hash entries. */
90  mutt_addrlist_to_intl(&alias->addr, NULL);
91 
92  struct Address *addr = NULL;
93  TAILQ_FOREACH(addr, &alias->addr, entries)
94  {
95  if (!addr->group && addr->mailbox)
97  }
98 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition: address.c:1304
bool group
Group mailbox?
Definition: address.h:38
static struct HashTable * ReverseAliases
Hash Table of aliases (email address -> alias)
Definition: reverse.c:37
void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *data)
Remove an element from a Hash Table.
Definition: hash.c:419
struct AddressList addr
List of Addresses the Alias expands to.
Definition: alias.h:36
+ 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 105 of file reverse.c.

106 {
107  if (!addr || !addr->mailbox)
108  return NULL;
109 
110  return mutt_hash_find(ReverseAliases, addr->mailbox);
111 }
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:354
char * mailbox
Mailbox and host address.
Definition: address.h:37
static struct HashTable * ReverseAliases
Hash Table of aliases (email address -> alias)
Definition: reverse.c:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ ReverseAliases

struct HashTable* ReverseAliases
static

Hash Table of aliases (email address -> alias)

Definition at line 37 of file reverse.c.