return NULL;
}
+static int string_is_address(const char *str, const char *u, const char *d)
+{
+ char buf[LONG_STRING];
+ snprintf(buf, sizeof (buf), "%s@%s", NONULL(u), NONULL(d));
+ return !ascii_strcasecmp(str, buf);
+}
+
+/* returns TRUE if the given address belongs to the user. */
+int mutt_addr_is_user(address_t *addr)
+{
+ /* NULL address is assumed to be the user. */
+ if (!addr)
+ return 1;
+
+ if (!addr->mailbox)
+ return 0;
+
+ if (!ascii_strcasecmp(addr->mailbox, Username)
+ || string_is_address(addr->mailbox, Username, Hostname)
+ || string_is_address(addr->mailbox, Username, mutt_fqdn(0))
+ || string_is_address(addr->mailbox, Username, mutt_fqdn(1))
+ || (From && !ascii_strcasecmp(From->mailbox, addr->mailbox)))
+ {
+ return 1;
+ }
+
+ return rx_list_match(Alternates, addr->mailbox)
+ && !rx_list_match(UnAlternates, addr->mailbox);
+}
+
+address_t *mutt_get_address(ENVELOPE *env, const char **pfxp)
+{
+#define RETURN(s, adr) do { if (pfxp) *pfxp = s; return adr; } while (0)
+
+ if (mutt_addr_is_user(env->from)) {
+ if (env->to && !mutt_is_mail_list(env->to)) {
+ RETURN("To", env->to);
+ } else {
+ RETURN("Cc", env->cc);
+ }
+ } else {
+ if (env->reply_to && !mutt_is_mail_list(env->reply_to)) {
+ RETURN("Reply-To", env->reply_to);
+ } else {
+ RETURN("From", env->from);
+ }
+ }
+
+#undef RETURN
+}
+
/* Only characters which are non-special to both the RFC 822 and the mutt
configuration parser are permitted. */
static int alias_sanitize(const char *s, char *d)
/************* READ MARK *********************/
-
static address_t *mutt_expand_aliases_r (address_t * a, LIST ** expn)
{
address_t *head = NULL, *last = NULL, *t, *w;
}
-address_t *mutt_get_address (ENVELOPE * env, const char **pfxp)
-{
- address_t *adr;
- const char *pfx = NULL;
-
- if (mutt_addr_is_user (env->from)) {
- if (env->to && !mutt_is_mail_list (env->to)) {
- pfx = "To";
- adr = env->to;
- }
- else {
- pfx = "Cc";
- adr = env->cc;
- }
- }
- else if (env->reply_to && !mutt_is_mail_list (env->reply_to)) {
- pfx = "Reply-To";
- adr = env->reply_to;
- }
- else {
- adr = env->from;
- pfx = "From";
- }
-
- if (pfxp)
- *pfxp = pfx;
-
- return adr;
-}
-
/*
* This routine looks to see if the user has an alias defined for the given
* address.
return 0;
}
-static int string_is_address (const char *str, const char *u, const char *d)
-{
- char buf[LONG_STRING];
-
- snprintf (buf, sizeof (buf), "%s@%s", NONULL (u), NONULL (d));
- if (ascii_strcasecmp (str, buf) == 0)
- return 1;
-
- return 0;
-}
-
-/* returns TRUE if the given address belongs to the user. */
-int mutt_addr_is_user (address_t * addr)
-{
- /* NULL address is assumed to be the user. */
- if (!addr) {
- debug_print(5, ("yes, NULL address\n"));
- return 1;
- }
- if (!addr->mailbox) {
- debug_print(5, ("no, no mailbox\n"));
- return 0;
- }
-
- if (ascii_strcasecmp (addr->mailbox, Username) == 0) {
- debug_print(5, ("yes, %s = %s\n", addr->mailbox, Username));
- return 1;
- }
- if (string_is_address (addr->mailbox, Username, Hostname)) {
- debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, Hostname));
- return 1;
- }
- if (string_is_address (addr->mailbox, Username, mutt_fqdn (0))) {
- debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (0)));
- return 1;
- }
- if (string_is_address (addr->mailbox, Username, mutt_fqdn (1))) {
- debug_print(5, ("yes, %s = %s @ %s \n", addr->mailbox, Username, mutt_fqdn (1)));
- return 1;
- }
-
- if (From && !ascii_strcasecmp (From->mailbox, addr->mailbox)) {
- debug_print(5, ("yes, %s = %s\n", addr->mailbox, From->mailbox));
- return 1;
- }
-
- if (rx_list_match (Alternates, addr->mailbox)) {
- debug_print(5, ("yes, %s matched by alternates.\n", addr->mailbox));
- if (rx_list_match (UnAlternates, addr->mailbox))
- debug_print(5, ("but, %s matched by unalternates.\n", addr->mailbox));
- else
- return 1;
- }
-
- debug_print(5, ("no, all failed.\n"));
- return 0;
-}
-
static const format_t *alias_format_str (char *dest, size_t destlen, char op,
const format_t *src, const char *fmt,
const char *ifstring __attribute__ ((unused)),