NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
alternates.c File Reference

Alternate address handling. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "mutt.h"
#include "alternates.h"
#include "command_parse.h"
#include "init.h"
#include "mutt_commands.h"
+ Include dependency graph for alternates.c:

Go to the source code of this file.

Functions

void alternates_free (void)
 Free the alternates lists. More...
 
void alternates_init (void)
 Set up the alternates lists. More...
 
void mutt_alternates_reset (struct Mailbox *m)
 Clear the recipient valid flag of all emails. More...
 
enum CommandResult parse_alternates (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'alternates' command - Implements Command::parse() -. More...
 
enum CommandResult parse_unalternates (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unalternates' command - Implements Command::parse() -. More...
 
bool mutt_alternates_match (const char *addr)
 Compare an Address to the Un/Alternates lists. More...
 

Variables

struct RegexList Alternates = STAILQ_HEAD_INITIALIZER(Alternates)
 List of regexes to match the user's alternate email addresses. More...
 
struct RegexList UnAlternates = STAILQ_HEAD_INITIALIZER(UnAlternates)
 List of regexes to blacklist false matches in Alternates. More...
 
static struct NotifyAlternatesNotify = NULL
 

Detailed Description

Alternate address handling.

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

Function Documentation

◆ alternates_free()

void alternates_free ( void  )

Free the alternates lists.

Definition at line 50 of file alternates.c.

51 {
53 
56 }
struct RegexList UnAlternates
List of regexes to blacklist false matches in Alternates.
Definition: alternates.c:44
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition: notify.c:73
static struct Notify * AlternatesNotify
Definition: alternates.c:45
struct RegexList Alternates
List of regexes to match the user&#39;s alternate email addresses.
Definition: alternates.c:43
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition: regex.c:171
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alternates_init()

void alternates_init ( void  )

Set up the alternates lists.

Definition at line 61 of file alternates.c.

62 {
63  if (AlternatesNotify)
64  return;
65 
68 }
Container for Accounts, Notifications.
Definition: neomutt.h:36
struct Notify * notify_new(void)
Create a new notifications handler.
Definition: notify.c:60
static struct Notify * AlternatesNotify
Definition: alternates.c:45
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition: notify.c:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_alternates_reset()

void mutt_alternates_reset ( struct Mailbox m)

Clear the recipient valid flag of all emails.

Definition at line 73 of file alternates.c.

74 {
75  if (!m)
76  return;
77 
78  for (int i = 0; i < m->msg_count; i++)
79  {
80  struct Email *e = m->emails[i];
81  if (!e)
82  break;
83  e->recip_valid = false;
84  }
85 }
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
int msg_count
Total number of messages.
Definition: mailbox.h:91
The envelope/body of an email.
Definition: email.h:37
bool recip_valid
Is_recipient is valid.
Definition: email.h:58
+ Here is the caller graph for this function:

◆ mutt_alternates_match()

bool mutt_alternates_match ( const char *  addr)

Compare an Address to the Un/Alternates lists.

Parameters
addrAddress to check
Return values
trueAddress matches

Definition at line 153 of file alternates.c.

154 {
155  if (!addr)
156  return false;
157 
158  if (mutt_regexlist_match(&Alternates, addr))
159  {
160  mutt_debug(LL_DEBUG5, "yes, %s matched by alternates\n", addr);
162  mutt_debug(LL_DEBUG5, "but, %s matched by unalternates\n", addr);
163  else
164  return true;
165  }
166 
167  return false;
168 }
struct RegexList UnAlternates
List of regexes to blacklist false matches in Alternates.
Definition: alternates.c:44
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition: regex.c:192
struct RegexList Alternates
List of regexes to match the user&#39;s alternate email addresses.
Definition: alternates.c:43
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Log at debug level 5.
Definition: logging.h:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Alternates

struct RegexList Alternates = STAILQ_HEAD_INITIALIZER(Alternates)

List of regexes to match the user's alternate email addresses.

Definition at line 43 of file alternates.c.

◆ UnAlternates

struct RegexList UnAlternates = STAILQ_HEAD_INITIALIZER(UnAlternates)

List of regexes to blacklist false matches in Alternates.

Definition at line 44 of file alternates.c.

◆ AlternatesNotify

struct Notify* AlternatesNotify = NULL
static

Definition at line 45 of file alternates.c.