]> granicus.if.org Git - neomutt/commitdiff
Cleanup Address API: mutt_addresslist_qualify
authorPietro Cerutti <gahr@gahr.ch>
Thu, 16 May 2019 12:07:25 +0000 (12:07 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 23 May 2019 10:57:10 +0000 (11:57 +0100)
address/address.c
address/address.h
sendlib.c
test/Makefile.autosetup
test/address/mutt_addresslist_qualify.c [moved from test/address/mutt_addr_qualify.c with 66% similarity]
test/main.c

index d9b3e12d4f539473a97a016e0b7dba97798e33fd..5087300de9bd062fb03b8e7d1d172899d3c45fff 100644 (file)
@@ -631,8 +631,8 @@ int mutt_addresslist_parse2(struct AddressList *al, const char *s)
 }
 
 /**
- * mutt_addr_qualify - Expand local names in an Address list using a hostname
- * @param addr Address list
+ * mutt_addresslist_qualify - Expand local names in an Address list using a hostname
+ * @param al Address list
  * @param host Hostname
  *
  * Any addresses containing a bare name will be expanded using the hostname.
@@ -641,7 +641,7 @@ int mutt_addresslist_parse2(struct AddressList *al, const char *s)
  */
 void mutt_addresslist_qualify(struct AddressList *al, const char *host)
 {
-  if (!host || !*host)
+  if (!al || !host || !*host)
     return;
 
   struct AddressNode *an = NULL;
@@ -658,14 +658,6 @@ void mutt_addresslist_qualify(struct AddressList *al, const char *host)
   }
 }
 
-void mutt_addr_qualify(struct Address *addr, const char *host)
-{
-  struct AddressList *al = mutt_addr_to_addresslist(addr);
-  mutt_addresslist_qualify(al, host);
-  mutt_addresslist_to_addr(al); // addr does not change
-  FREE(&al);
-}
-
 /**
  * mutt_addr_cat - Copy a string and escape the specified characters
  * @param buf      Buffer for the result
index b2927634a09beb30fa6c8736737c1f152082265b..a0962d56e4c8445cabd8fe58bc13436aa6c07c00 100644 (file)
@@ -76,7 +76,6 @@ bool            mutt_addr_is_intl(const struct Address *a);
 bool            mutt_addr_is_local(const struct Address *a);
 int             mutt_addr_mbox_to_udomain(const char *mbox, char **user, char **domain);
 struct Address *mutt_addr_new(void);
-void            mutt_addr_qualify(struct Address *addr, const char *host);
 int             mutt_addr_remove_from_list(struct AddressList *a, const char *mailbox);
 void            mutt_addr_remove_xrefs(const struct AddressList *a, struct AddressList *b);
 void            mutt_addr_set_intl(struct Address *a, char *intl_mailbox);
index f3316c0a6cfc520d27605d1a87e7da7ff2200138..e5b75beacf68675bb324091a86807da6173af4bc 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -3056,8 +3056,7 @@ int mutt_bounce_message(FILE *fp, struct Email *e, struct AddressList *to)
   if (!from->personal)
     from->personal = mutt_str_strdup(C_Realname);
 
-  if (fqdn)
-    mutt_addr_qualify(from, fqdn);
+  mutt_addresslist_qualify(&from_list, fqdn);
 
   rfc2047_encode_addrlist(&from_list, "Resent-From");
   if (mutt_addresslist_to_intl(&from_list, &err))
index 296f68593f1d4620e574ac66fce884584f9a24ed..82a540046693a94c12f1b9278f46a8d8bf254b27 100644 (file)
@@ -11,12 +11,12 @@ ADDRESS_OBJS        = test/address/mutt_addr_append.o \
                  test/address/mutt_addresslist_equal.o \
                  test/address/mutt_addresslist_parse2.o \
                  test/address/mutt_addresslist_parse.o \
+                 test/address/mutt_addresslist_qualify.o \
                  test/address/mutt_addrlist_dedupe.o \
                  test/address/mutt_addrlist_to_intl.o \
                  test/address/mutt_addrlist_to_local.o \
                  test/address/mutt_addr_mbox_to_udomain.o \
                  test/address/mutt_addr_new.o \
-                 test/address/mutt_addr_qualify.o \
                  test/address/mutt_addr_remove_from_list.o \
                  test/address/mutt_addr_remove_xrefs.o \
                  test/address/mutt_addr_search.o \
similarity index 66%
rename from test/address/mutt_addr_qualify.c
rename to test/address/mutt_addresslist_qualify.c
index 2e724513b2eb3fde611b4223ea963556330b33c1..7960a9809f54f9dc029d6c189c1842b3d5436a2c 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @file
- * Test code for mutt_addr_qualify()
+ * Test code for mutt_addresslist_qualify()
  *
  * @authors
  * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
 #include "mutt/mutt.h"
 #include "address/lib.h"
 
-void test_mutt_addr_qualify(void)
+void test_mutt_addresslist_qualify(void)
 {
-  // void mutt_addr_qualify(struct Address *addr, const char *host);
+  // void mutt_addresslist_qualify(struct Address *addr, const char *host);
 
   {
-    mutt_addr_qualify(NULL, "example.com");
-    TEST_CHECK_(1, "mutt_addr_qualify(NULL, \"example.com\")");
+    mutt_addresslist_qualify(NULL, "example.com");
+    TEST_CHECK_(1, "mutt_addresslist_qualify(NULL, \"example.com\")");
   }
 
   {
-    struct Address addr = { 0 };
-    mutt_addr_qualify(&addr, NULL);
-    TEST_CHECK_(1, "mutt_addr_qualify(&addr, NULL)");
+    struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
+    mutt_addresslist_qualify(&al, NULL);
+    TEST_CHECK_(1, "mutt_addresslist_qualify(&addr, NULL)");
   }
 }
index 12c75b102ac7824f26791e324062012a05e2dd15..cc15ac512f7988d616fea9b47721ddc1b71e4f4b 100644 (file)
@@ -38,7 +38,6 @@
   NEOMUTT_TEST_ITEM(test_mutt_addr_is_local)                                   \
   NEOMUTT_TEST_ITEM(test_mutt_addr_mbox_to_udomain)                            \
   NEOMUTT_TEST_ITEM(test_mutt_addr_new)                                        \
-  NEOMUTT_TEST_ITEM(test_mutt_addr_qualify)                                    \
   NEOMUTT_TEST_ITEM(test_mutt_addr_remove_from_list)                           \
   NEOMUTT_TEST_ITEM(test_mutt_addr_remove_xrefs)                               \
   NEOMUTT_TEST_ITEM(test_mutt_addr_search)                                     \
@@ -50,6 +49,7 @@
   NEOMUTT_TEST_ITEM(test_mutt_addresslist_equal)                               \
   NEOMUTT_TEST_ITEM(test_mutt_addresslist_parse)                               \
   NEOMUTT_TEST_ITEM(test_mutt_addresslist_parse2)                              \
+  NEOMUTT_TEST_ITEM(test_mutt_addresslist_qualify)                             \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_intl)                                \
   NEOMUTT_TEST_ITEM(test_mutt_addrlist_to_local)                               \
   NEOMUTT_TEST_ITEM(test_mutt_actx_add_attach)                                 \