NeoMutt  2020-06-26-89-g172cd3
Teaching an old dog new tricks
DOXYGEN
maillist.c File Reference

Handle mailing lists. More...

#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "email/lib.h"
#include "maillist.h"
#include "hdrline.h"
#include "muttlib.h"
#include "sort.h"
+ Include dependency graph for maillist.c:

Go to the source code of this file.

Functions

bool mutt_is_mail_list (const struct Address *addr)
 Is this the email address of a mailing list? - Implements addr_predicate_t. More...
 
bool mutt_is_subscribed_list (const struct Address *addr)
 Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t. More...
 
bool check_for_mailing_list (struct AddressList *al, const char *pfx, char *buf, int buflen)
 Search list of addresses for a mailing list. More...
 
bool check_for_mailing_list_addr (struct AddressList *al, char *buf, int buflen)
 Check an address list for a mailing list. More...
 
bool first_mailing_list (char *buf, size_t buflen, struct AddressList *al)
 Get the first mailing list in the list of addresses. More...
 

Detailed Description

Handle mailing lists.

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

Function Documentation

◆ mutt_is_mail_list()

bool mutt_is_mail_list ( const struct Address addr)

Is this the email address of a mailing list? - Implements addr_predicate_t.

Parameters
addrAddress to test
Return values
trueIf it's a mailing list

Definition at line 45 of file maillist.c.

46 {
48  return mutt_regexlist_match(&MailLists, addr->mailbox);
49  return false;
50 }
struct RegexList MailLists
List of regexes to match mailing lists.
Definition: globals.c:50
char * mailbox
Mailbox and host address.
Definition: address.h:37
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition: regex.c:190
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: globals.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_is_subscribed_list()

bool mutt_is_subscribed_list ( const struct Address addr)

Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t.

Parameters
addrAddress to test
Return values
trueIf it's a subscribed mailing list

Definition at line 57 of file maillist.c.

58 {
61  {
63  }
64  return false;
65 }
struct RegexList SubscribedLists
List of regexes to match subscribed mailing lists.
Definition: globals.c:52
struct RegexList UnSubscribedLists
List of regexes to blacklist false matches in SubscribedLists.
Definition: globals.c:49
char * mailbox
Mailbox and host address.
Definition: address.h:37
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition: regex.c:190
struct RegexList UnMailLists
List of regexes to blacklist false matches in MailLists.
Definition: globals.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_for_mailing_list()

bool check_for_mailing_list ( struct AddressList *  al,
const char *  pfx,
char *  buf,
int  buflen 
)

Search list of addresses for a mailing list.

Parameters
alAddressList to search
pfxPrefix string
bufBuffer to store results
buflenBuffer length
Return values
1Mailing list found
0No list found

Search for a mailing list in the list of addresses pointed to by addr. If one is found, print pfx and the name of the list into buf.

Definition at line 79 of file maillist.c.

80 {
81  struct Address *a = NULL;
82  TAILQ_FOREACH(a, al, entries)
83  {
85  {
86  if (pfx && buf && buflen)
87  snprintf(buf, buflen, "%s%s", pfx, mutt_get_name(a));
88  return true;
89  }
90  }
91  return false;
92 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
bool mutt_is_subscribed_list(const struct Address *addr)
Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t.
Definition: maillist.c:57
An email address.
Definition: address.h:34
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition: sort.c:157
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_for_mailing_list_addr()

bool check_for_mailing_list_addr ( struct AddressList *  al,
char *  buf,
int  buflen 
)

Check an address list for a mailing list.

Parameters
alAddressList
bufBuffer for the result
buflenLength of buffer
Return values
trueMailing list found

If one is found, print the address of the list into buf.

Definition at line 103 of file maillist.c.

104 {
105  struct Address *a = NULL;
106  TAILQ_FOREACH(a, al, entries)
107  {
109  {
110  if (buf && buflen)
111  snprintf(buf, buflen, "%s", a->mailbox);
112  return true;
113  }
114  }
115  return false;
116 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
bool mutt_is_subscribed_list(const struct Address *addr)
Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t.
Definition: maillist.c:57
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ first_mailing_list()

bool first_mailing_list ( char *  buf,
size_t  buflen,
struct AddressList *  al 
)

Get the first mailing list in the list of addresses.

Parameters
bufBuffer for the result
buflenLength of buffer
alAddressList
Return values
trueIf a mailing list was found

Definition at line 125 of file maillist.c.

126 {
127  struct Address *a = NULL;
128  TAILQ_FOREACH(a, al, entries)
129  {
131  {
132  mutt_save_path(buf, buflen, a);
133  return true;
134  }
135  }
136  return false;
137 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
bool mutt_is_subscribed_list(const struct Address *addr)
Is this the email address of a user-subscribed mailing list? - Implements addr_predicate_t.
Definition: maillist.c:57
An email address.
Definition: address.h:34
void mutt_save_path(char *buf, size_t buflen, const struct Address *addr)
Turn an email address into a filename (for saving)
Definition: muttlib.c:704
+ Here is the call graph for this function:
+ Here is the caller graph for this function: