*
* | Function | Description
* | :--------------------------- | :---------------------------------------------------------
- * | addrcmp() | compare two e-mail addresses
- * | addrsrc() | Search for an e-mail address in a list
- * | has_recips() | Count the number of Addresses with valid recipients
- * | mutt_parse_adrlist() | Parse a list of email addresses
+ * | mutt_addr_cmp() | compare two e-mail addresses
+ * | mutt_addr_search() | Search for an e-mail address in a list
+ * | mutt_addr_has_recips() | Count the number of Addresses with valid recipients
+ * | mutt_addr_parse_list2() | Parse a list of email addresses
* | mutt_addr_append() | Append one list of addresses onto another
* | mutt_addr_cat() | Copy a string and escape the specified characters
* | mutt_addr_copy_list() | Copy an Address
return top;
}
+/**
+ * mutt_addr_parse_list2 - Parse a list of email addresses
+ * @param p Add to this List of Addresses
+ * @param s String to parse
+ * @retval ptr Head of the list of addresses
+ *
+ * The email addresses can be separated by whitespace or commas.
+ */
+struct Address *mutt_addr_parse_list2(struct Address *p, const char *s)
+{
+ const char *q = NULL;
+
+ /* check for a simple whitespace separated list of addresses */
+ q = strpbrk(s, "\"<>():;,\\");
+ if (!q)
+ {
+ char tmp[HUGE_STRING];
+ char *r = NULL;
+
+ mutt_str_strfcpy(tmp, s, sizeof(tmp));
+ r = tmp;
+ while ((r = strtok(r, " \t")) != NULL)
+ {
+ p = mutt_addr_parse_list(p, r);
+ r = NULL;
+ }
+ }
+ else
+ p = mutt_addr_parse_list(p, s);
+
+ return p;
+}
+
/**
* mutt_addr_qualify - Expand local names in an Address list using a hostname
* @param addr Address list
return true;
}
+
+/**
+ * mutt_addr_cmp_strict - Strictly compare two Address lists
+ * @param a First Address
+ * @param b Second Address
+ * @retval true Address lists are strictly identical
+ */
+int mutt_addr_cmp_strict(const struct Address *a, const struct Address *b)
+{
+ while (a && b)
+ {
+ if ((mutt_str_strcmp(a->mailbox, b->mailbox) != 0) ||
+ (mutt_str_strcmp(a->personal, b->personal) != 0))
+ {
+ return 0;
+ }
+
+ a = a->next;
+ b = b->next;
+ }
+ if (a || b)
+ return 0;
+
+ return 1;
+}
+
+/**
+ * mutt_addr_has_recips - Count the number of Addresses with valid recipients
+ * @param a Address list
+ * @retval num Number of valid Addresses
+ *
+ * An Address has a recipient if the mailbox or group is set.
+ */
+int mutt_addr_has_recips(struct Address *a)
+{
+ int c = 0;
+
+ for (; a; a = a->next)
+ {
+ if (!a->mailbox || a->group)
+ continue;
+ c++;
+ }
+ return c;
+}
+
+/**
+ * mutt_addr_cmp - compare two e-mail addresses
+ * @param a Address 1
+ * @param b Address 2
+ * @retval true if they are equivalent
+ */
+bool mutt_addr_cmp(struct Address *a, struct Address *b)
+{
+ if (!a->mailbox || !b->mailbox)
+ return false;
+ if (mutt_str_strcasecmp(a->mailbox, b->mailbox) != 0)
+ return false;
+ return true;
+}
+
+/**
+ * mutt_addr_search - Search for an e-mail address in a list
+ * @param a Address containing the search email
+ * @param lst Address List
+ * @retval true If the Address is in the list
+ */
+int mutt_addr_search(struct Address *a, struct Address *lst)
+{
+ for (; lst; lst = lst->next)
+ {
+ if (mutt_addr_cmp(a, lst))
+ return 1;
+ }
+ return 0;
+}
ERR_BAD_ADDR_SPEC
};
-struct Address *mutt_addr_new(void);
-void mutt_addr_free(struct Address **p);
-void mutt_addr_qualify(struct Address *addr, const char *host);
-struct Address *mutt_addr_parse_list(struct Address *top, const char *s);
+struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune);
+void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials);
+int mutt_addr_cmp_strict(const struct Address *a, const struct Address *b);
+bool mutt_addr_cmp(struct Address *a, struct Address *b);
struct Address *mutt_addr_copy_list(struct Address *addr, int prune);
struct Address *mutt_addr_copy(struct Address *addr);
-struct Address *mutt_addr_append(struct Address **a, struct Address *b, int prune);
-int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display);
-void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, int display);
-void mutt_addr_cat(char *buf, size_t buflen, const char *value, const char *specials);
-bool mutt_addr_valid_msgid(const char *msgid);
-int mutt_addr_remove_from_list(struct Address **a, const char *mailbox);
+void mutt_addr_free(struct Address **p);
+int mutt_addr_has_recips(struct Address *a);
+struct Address *mutt_addr_new(void);
+struct Address *mutt_addr_parse_list2(struct Address *p, const char *s);
+struct Address *mutt_addr_parse_list(struct Address *top, const char *s);
+void mutt_addr_qualify(struct Address *addr, const char *host);
+int mutt_addr_remove_from_list(struct Address **a, const char *mailbox);
+int mutt_addr_search(struct Address *a, struct Address *lst);
+bool mutt_addr_valid_msgid(const char *msgid);
extern int RFC822Error;
extern const char *const RFC822Errors[];
if (rc || !buf[0])
return;
- adr = mutt_parse_adrlist(adr, buf);
+ adr = mutt_addr_parse_list2(adr, buf);
if (!adr)
{
mutt_error(_("Error parsing address!"));
if (mutt_get_field(_(Prompts[line]), buf, sizeof(buf), MUTT_ALIAS) == 0)
{
mutt_addr_free(addr);
- *addr = mutt_parse_adrlist(*addr, buf);
+ *addr = mutt_addr_parse_list2(*addr, buf);
*addr = mutt_expand_aliases(*addr);
}
if (mutt_enter_string(tmp, sizeof(tmp), 4, 0) == 0)
{
mutt_addr_free(&e->to);
- e->to = mutt_parse_adrlist(e->to, tmp);
+ e->to = mutt_addr_parse_list2(e->to, tmp);
e->to = mutt_expand_aliases(e->to);
mutt_addrlist_to_intl(e->to, NULL); /* XXX - IDNA error reporting? */
tmp[0] = '\0';
if (mutt_enter_string(tmp, sizeof(tmp), 4, 0) == 0)
{
mutt_addr_free(&e->cc);
- e->cc = mutt_parse_adrlist(e->cc, tmp);
+ e->cc = mutt_addr_parse_list2(e->cc, tmp);
e->cc = mutt_expand_aliases(e->cc);
tmp[0] = '\0';
mutt_addrlist_to_intl(e->cc, NULL);
if (mutt_enter_string(tmp, sizeof(tmp), 5, 0) == 0)
{
mutt_addr_free(&e->bcc);
- e->bcc = mutt_parse_adrlist(e->bcc, tmp);
+ e->bcc = mutt_addr_parse_list2(e->bcc, tmp);
e->bcc = mutt_expand_aliases(e->bcc);
mutt_addrlist_to_intl(e->bcc, NULL);
tmp[0] = '\0';
addstr(_(EditorHelp2));
break;
case 'b':
- msg->env->bcc = mutt_parse_adrlist(msg->env->bcc, p);
+ msg->env->bcc = mutt_addr_parse_list2(msg->env->bcc, p);
msg->env->bcc = mutt_expand_aliases(msg->env->bcc);
break;
case 'c':
- msg->env->cc = mutt_parse_adrlist(msg->env->cc, p);
+ msg->env->cc = mutt_addr_parse_list2(msg->env->cc, p);
msg->env->cc = mutt_expand_aliases(msg->env->cc);
break;
case 'h':
break;
case GS_ADDR:
- addr = mutt_parse_adrlist(NULL, buf->data);
+ addr = mutt_addr_parse_list2(NULL, buf->data);
if (!addr)
goto bail;
if (mutt_addrlist_to_intl(addr, &estr))
mutt_extract_token(buf, s, MUTT_TOKEN_QUOTE | MUTT_TOKEN_SPACE | MUTT_TOKEN_SEMICOLON);
mutt_debug(3, "Second token is '%s'.\n", buf->data);
- tmp->addr = mutt_parse_adrlist(tmp->addr, buf->data);
+ tmp->addr = mutt_addr_parse_list2(tmp->addr, buf->data);
if (last)
last->next = tmp;
return 0;
}
-/**
- * strict_addrcmp - Strictly compare two Address lists
- * @param a First Address
- * @param b Second Address
- * @retval true Address lists are strictly identical
- */
-static int strict_addrcmp(const struct Address *a, const struct Address *b)
-{
- while (a && b)
- {
- if ((mutt_str_strcmp(a->mailbox, b->mailbox) != 0) ||
- (mutt_str_strcmp(a->personal, b->personal) != 0))
- {
- return 0;
- }
-
- a = a->next;
- b = b->next;
- }
- if (a || b)
- return 0;
-
- return 1;
-}
-
static int strict_cmp_envelopes(const struct Envelope *e1, const struct Envelope *e2)
{
if (e1 && e2)
if ((mutt_str_strcmp(e1->message_id, e2->message_id) != 0) ||
(mutt_str_strcmp(e1->subject, e2->subject) != 0) ||
!mutt_list_compare(&e1->references, &e2->references) ||
- !strict_addrcmp(e1->from, e2->from) || !strict_addrcmp(e1->sender, e2->sender) ||
- !strict_addrcmp(e1->reply_to, e2->reply_to) ||
- !strict_addrcmp(e1->to, e2->to) || !strict_addrcmp(e1->cc, e2->cc) ||
- !strict_addrcmp(e1->return_path, e2->return_path))
+ !mutt_addr_cmp_strict(e1->from, e2->from) ||
+ !mutt_addr_cmp_strict(e1->sender, e2->sender) ||
+ !mutt_addr_cmp_strict(e1->reply_to, e2->reply_to) ||
+ !mutt_addr_cmp_strict(e1->to, e2->to) || !mutt_addr_cmp_strict(e1->cc, e2->cc) ||
+ !mutt_addr_cmp_strict(e1->return_path, e2->return_path))
return 0;
else
return 1;
return e;
}
-/**
- * mutt_parse_adrlist - Parse a list of email addresses
- * @param p Add to this List of Addresses
- * @param s String to parse
- * @retval ptr Head of the list of addresses
- *
- * The email addresses can be separated by whitespace or commas.
- */
-struct Address *mutt_parse_adrlist(struct Address *p, const char *s)
-{
- const char *q = NULL;
-
- /* check for a simple whitespace separated list of addresses */
- q = strpbrk(s, "\"<>():;,\\");
- if (!q)
- {
- char tmp[HUGE_STRING];
- char *r = NULL;
-
- mutt_str_strfcpy(tmp, s, sizeof(tmp));
- r = tmp;
- while ((r = strtok(r, " \t")) != NULL)
- {
- p = mutt_addr_parse_list(p, r);
- r = NULL;
- }
- }
- else
- p = mutt_addr_parse_list(p, s);
-
- return p;
-}
-
/**
* count_body_parts_check - Compares mime types to the ok and except lists
*/
struct Address *mutt_default_from(void);
struct Address *mutt_remove_duplicates(struct Address *addr);
struct Address *mutt_remove_xrefs(struct Address *a, struct Address *b);
-struct Address *mutt_parse_adrlist(struct Address *p, const char *s);
+struct Address *mutt_addr_parse_list2(struct Address *p, const char *s);
struct Body *mutt_make_file_attach(const char *path);
struct Body *mutt_make_message_attach(struct Context *ctx, struct Header *hdr, int attach_msg);
bool message_is_tagged(struct Context *ctx, int index);
bool message_is_visible(struct Context *ctx, int index);
+int rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display);
+void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, int display);
+
#endif /* _MUTT_PROTOS_H */
}
}
-/**
- * addrcmp - compare two e-mail addresses
- * @param a Address 1
- * @param b Address 2
- * @retval true if they are equivalent
- */
-static bool addrcmp(struct Address *a, struct Address *b)
-{
- if (!a->mailbox || !b->mailbox)
- return false;
- if (mutt_str_strcasecmp(a->mailbox, b->mailbox) != 0)
- return false;
- return true;
-}
-
-/**
- * addrsrc - Search for an e-mail address in a list
- * @param a Address containing the search email
- * @param lst Address List
- * @retval true If the Address is in the list
- */
-static int addrsrc(struct Address *a, struct Address *lst)
-{
- for (; lst; lst = lst->next)
- {
- if (addrcmp(a, lst))
- return 1;
- }
- return 0;
-}
-
/**
* mutt_remove_xrefs - Remove cross-references
*
{
for (p = a; p; p = p->next)
{
- if (addrcmp(p, b))
+ if (mutt_addr_cmp(p, b))
break;
}
if (p)
if (mutt_get_field(field, buf, sizeof(buf), MUTT_ALIAS) != 0)
return -1;
mutt_addr_free(a);
- *a = mutt_expand_aliases(mutt_parse_adrlist(NULL, buf));
+ *a = mutt_expand_aliases(mutt_addr_parse_list2(NULL, buf));
idna_ok = mutt_addrlist_to_intl(*a, &err);
if (idna_ok != 0)
{
}
else if (env->reply_to)
{
- if ((addrcmp(env->from, env->reply_to) && !env->reply_to->next &&
+ if ((mutt_addr_cmp(env->from, env->reply_to) && !env->reply_to->next &&
!env->reply_to->personal) ||
(option(OPT_IGNORE_LIST_REPLY_TO) && mutt_is_mail_list(env->reply_to) &&
- (addrsrc(env->reply_to, env->to) || addrsrc(env->reply_to, env->cc))))
+ (mutt_addr_search(env->reply_to, env->to) ||
+ mutt_addr_search(env->reply_to, env->cc))))
{
/* If the Reply-To: address is a mailing list, assume that it was
* put there by the mailing list, and use the From: address
*/
mutt_addr_append(to, env->from, 0);
}
- else if (!(addrcmp(env->from, env->reply_to) && !env->reply_to->next) &&
+ else if (!(mutt_addr_cmp(env->from, env->reply_to) && !env->reply_to->next) &&
quadoption(OPT_REPLY_TO) != MUTT_YES)
{
/* There are quite a few mailing lists which set the Reply-To:
mutt_list_find(&orig->env->in_reply_to, reply->env->message_id);
}
-/**
- * has_recips - Count the number of Addresses with valid recipients
- * @param a Address list
- * @retval num Number of valid Addresses
- *
- * An Address has a recipient if the mailbox or group is set.
- */
-static int has_recips(struct Address *a)
-{
- int c = 0;
-
- for (; a; a = a->next)
- {
- if (!a->mailbox || a->group)
- continue;
- c++;
- }
- return c;
-}
-
static int search_attach_keyword(char *filename)
{
/* Search for the regex in AttachKeyword within a file */
#ifdef USE_NNTP
if (!(flags & SENDNEWS))
#endif
- if (!has_recips(msg->env->to) && !has_recips(msg->env->cc) &&
- !has_recips(msg->env->bcc))
+ if (!mutt_addr_has_recips(msg->env->to) && !mutt_addr_has_recips(msg->env->cc) &&
+ !mutt_addr_has_recips(msg->env->bcc))
{
if (!(flags & SENDBATCH))
{