return rc;
}
+/**
+ * mutt_addr_to_local - Convert an Address from Punycode
+ * @param a Address to convert
+ * @param bool True on success, false otherwise
+ */
+bool mutt_addr_to_local(struct Address *a)
+{
+ if (!a->mailbox)
+ {
+ return false;
+ }
+
+ if (addr_is_local(a))
+ {
+ return true;
+ }
+
+ char *user = NULL;
+ char *domain = NULL;
+ if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
+ {
+ return false;
+ }
+
+ char *local_mailbox = mutt_idna_intl_to_local(user, domain, 0);
+ FREE(&user);
+ FREE(&domain);
+
+ if (!local_mailbox)
+ {
+ return false;
+ }
+
+ addr_set_local(a, local_mailbox);
+ return true;
+}
+
/**
* mutt_addrlist_to_local - Convert an Address list from Punycode
* @param al Address list to modify
struct Address *a = NULL;
TAILQ_FOREACH(a, al, entries)
{
- if (!a->mailbox || addr_is_local(a))
- continue;
-
- char *user = NULL;
- char *domain = NULL;
- if (addr_mbox_to_udomain(a->mailbox, &user, &domain) == -1)
- continue;
-
- char *local_mailbox = mutt_idna_intl_to_local(user, domain, 0);
-
- FREE(&user);
- FREE(&domain);
-
- if (local_mailbox)
- addr_set_local(a, local_mailbox);
+ mutt_addr_to_local(a);
}
return 0;
}
const char * mutt_addr_for_display(const struct Address *a);
void mutt_addr_free(struct Address **a);
struct Address *mutt_addr_new(void);
+bool mutt_addr_to_local(struct Address *a);
size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display);
/* Functions that work on struct AddressList */
addr->personal = NULL;
*tmp = '\0';
- struct AddressList alist = TAILQ_HEAD_INITIALIZER(alist);
- mutt_addrlist_append(&alist, addr);
- mutt_addrlist_to_local(&alist);
+ mutt_addr_to_local(addr);
mutt_addr_write(tmp, sizeof(tmp), addr, false);
mutt_buffer_quote_filename(buf, tmp, true);