NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
maillist.c
Go to the documentation of this file.
1
23
29
30#include "config.h"
31#include <stdbool.h>
32#include <stdio.h>
33#include "mutt/lib.h"
34#include "email/lib.h"
35#include "core/lib.h"
36#include "alias/module_data.h"
37#include "maillist.h"
38#include "address.h"
39#include "muttlib.h"
40
46bool mutt_is_mail_list(const struct Address *addr)
47{
49 ASSERT(mod_data);
50
51 if (!mutt_regexlist_match(&mod_data->unmail, buf_string(addr->mailbox)))
52 return mutt_regexlist_match(&mod_data->mail, buf_string(addr->mailbox));
53 return false;
54}
55
61bool mutt_is_subscribed_list(const struct Address *addr)
62{
64 ASSERT(mod_data);
65
66 if (!mutt_regexlist_match(&mod_data->unmail, buf_string(addr->mailbox)) &&
68 {
69 return mutt_regexlist_match(&mod_data->subscribed, buf_string(addr->mailbox));
70 }
71 return false;
72}
73
86bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
87{
88 struct Address *a = NULL;
89 TAILQ_FOREACH(a, al, entries)
90 {
92 {
93 if (pfx && buf && buflen)
94 snprintf(buf, buflen, "%s%s", pfx, mutt_get_name(a));
95 return true;
96 }
97 }
98 return false;
99}
100
110bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
111{
112 struct Address *a = NULL;
113 TAILQ_FOREACH(a, al, entries)
114 {
116 {
117 if (buf && buflen)
118 snprintf(buf, buflen, "%s", buf_string(a->mailbox));
119 return true;
120 }
121 }
122 return false;
123}
124
131bool first_mailing_list(struct AddressList *al, struct Buffer *buf)
132{
133 struct Address *a = NULL;
134 TAILQ_FOREACH(a, al, entries)
135 {
137 {
138 generate_save_path(buf, a);
139 return true;
140 }
141 }
142 return false;
143}
Representation of an email address.
Alias private Module data.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
Convenience wrapper for the core headers.
Structs that make up an email.
const char * mutt_get_name(const struct Address *a)
Pick the best name to display from an address.
Definition sort.c:138
bool mutt_is_mail_list(const struct Address *addr)
Is this the email address of a mailing list?
Definition maillist.c:46
bool mutt_is_subscribed_list(const struct Address *addr)
Is this the email address of a user-subscribed mailing list?
Definition maillist.c:61
bool check_for_mailing_list(struct AddressList *al, const char *pfx, char *buf, int buflen)
Search list of addresses for a mailing list.
Definition maillist.c:86
bool check_for_mailing_list_addr(struct AddressList *al, char *buf, int buflen)
Check an address list for a mailing list.
Definition maillist.c:110
bool first_mailing_list(struct AddressList *al, struct Buffer *buf)
Get the first mailing list in the list of addresses.
Definition maillist.c:131
Handle mailing lists.
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
Convenience wrapper for the library headers.
bool mutt_regexlist_match(struct RegexList *rl, const char *str)
Does a string match any Regex in the list?
Definition regex.c:200
void generate_save_path(struct Buffer *dest, const struct Address *a)
Make a safe filename from an email address.
Definition muttlib.c:608
Some miscellaneous functions.
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
#define ASSERT(COND)
Definition signal2.h:59
An email address.
Definition address.h:35
struct Buffer * mailbox
Mailbox and host address.
Definition address.h:37
Alias private Module data.
Definition module_data.h:33
struct RegexList subscribed
Regexes to match subscribed mailing lists.
Definition module_data.h:49
struct RegexList mail
Regexes to match mailing lists.
Definition module_data.h:48
struct RegexList unmail
Regexes to exclude false matches in mail.
Definition module_data.h:50
struct RegexList unsubscribed
Regexes to exclude false matches in subscribed.
Definition module_data.h:51
String manipulation buffer.
Definition buffer.h:36
Container for Accounts, Notifications.
Definition neomutt.h:41