]> granicus.if.org Git - neomutt/commitdiff
move address functions
authorRichard Russon <rich@flatcap.org>
Sat, 30 Dec 2017 16:25:01 +0000 (16:25 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 31 Dec 2017 00:40:51 +0000 (00:40 +0000)
18 files changed:
addrbook.c
address.c
address.h
alias.c
commands.c
compose.c
copy.c
edit.c
hdrline.c
init.c
mutt_address.c
mutt_lua.c
ncrypt/pgpinvoke.c
protos.h
query.c
recvcmd.c
send.c
sendlib.c

index 74da70e86f964e1a41a81b0f5b469f3a7e475f2e..163d43a2ed385dc0830b06cde6148187d7f98d2c 100644 (file)
@@ -94,7 +94,7 @@ static const char *alias_format_str(char *buf, size_t buflen, size_t col, int co
       break;
     case 'r':
       adr[0] = '\0';
-      rfc822_write_address(adr, sizeof(adr), alias->addr, 1);
+      mutt_addr_write(adr, sizeof(adr), alias->addr, true);
       snprintf(fmt, sizeof(fmt), "%%%ss", prec);
       snprintf(buf, buflen, fmt, adr);
       break;
@@ -269,14 +269,14 @@ new_aliases:
   {
     if (AliasTable[i]->tagged)
     {
-      rfc822_write_address(buf, buflen, AliasTable[i]->addr, 1);
+      mutt_addr_write(buf, buflen, AliasTable[i]->addr, true);
       t = -1;
     }
   }
 
   if (t != -1)
   {
-    rfc822_write_address(buf, buflen, AliasTable[t]->addr, 1);
+    mutt_addr_write(buf, buflen, AliasTable[t]->addr, true);
   }
 
   mutt_pop_current_menu(menu);
index 44c68e8052f6c79864422f90c28f53039843eb73..47515000c185f194842901588dcf982a241cb766 100644 (file)
--- a/address.c
+++ b/address.c
@@ -55,6 +55,8 @@
  * | mutt_addr_set_intl()         | Mark an Address as having IDN components
  * | mutt_addr_set_local()        | Mark an Address as having NO IDN components
  * | mutt_addr_valid_msgid()      | Is this a valid Message ID?
+ * | mutt_addr_write()            | Write an Address to a buffer
+ * | mutt_addr_write_single()     | Write a single Address to a buffer
  */
 
 #include "config.h"
@@ -1040,3 +1042,195 @@ const char *mutt_addr_for_display(struct Address *a)
   FREE(&local_mailbox);
   return buf;
 }
+
+/**
+ * mutt_addr_write_single - Write a single Address to a buffer
+ * @param buf     Buffer for the Address
+ * @param buflen  Length of the buffer
+ * @param addr    Address to display
+ * @param display This address will be displayed to the user
+ *
+ * If 'display' is set, then it doesn't matter if the transformation isn't
+ * reversible.
+ */
+void mutt_addr_write_single(char *buf, size_t buflen, struct Address *addr, bool display)
+{
+  size_t len;
+  char *pbuf = buf;
+  char *pc = NULL;
+
+  if (!addr)
+    return;
+
+  buflen--; /* save room for the terminal nul */
+
+  if (addr->personal)
+  {
+    if (strpbrk(addr->personal, AddressSpecials))
+    {
+      if (!buflen)
+        goto done;
+      *pbuf++ = '"';
+      buflen--;
+      for (pc = addr->personal; *pc && buflen > 0; pc++)
+      {
+        if (*pc == '"' || *pc == '\\')
+        {
+          *pbuf++ = '\\';
+          buflen--;
+        }
+        if (!buflen)
+          goto done;
+        *pbuf++ = *pc;
+        buflen--;
+      }
+      if (!buflen)
+        goto done;
+      *pbuf++ = '"';
+      buflen--;
+    }
+    else
+    {
+      if (!buflen)
+        goto done;
+      mutt_str_strfcpy(pbuf, addr->personal, buflen);
+      len = mutt_str_strlen(pbuf);
+      pbuf += len;
+      buflen -= len;
+    }
+
+    if (!buflen)
+      goto done;
+    *pbuf++ = ' ';
+    buflen--;
+  }
+
+  if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
+  {
+    if (!buflen)
+      goto done;
+    *pbuf++ = '<';
+    buflen--;
+  }
+
+  if (addr->mailbox)
+  {
+    if (!buflen)
+      goto done;
+    if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && !display)
+    {
+      mutt_str_strfcpy(pbuf, addr->mailbox, buflen);
+      len = mutt_str_strlen(pbuf);
+    }
+    else if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && display)
+    {
+      mutt_str_strfcpy(pbuf, mutt_addr_for_display(addr), buflen);
+      len = mutt_str_strlen(pbuf);
+    }
+    else
+    {
+      *pbuf = '\0';
+      len = 0;
+    }
+    pbuf += len;
+    buflen -= len;
+
+    if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
+    {
+      if (!buflen)
+        goto done;
+      *pbuf++ = '>';
+      buflen--;
+    }
+
+    if (addr->group)
+    {
+      if (!buflen)
+        goto done;
+      *pbuf++ = ':';
+      buflen--;
+      if (!buflen)
+        goto done;
+      *pbuf++ = ' ';
+      buflen--;
+    }
+  }
+  else
+  {
+    if (!buflen)
+      goto done;
+    *pbuf++ = ';';
+    buflen--;
+  }
+done:
+  /* no need to check for length here since we already save space at the
+     beginning of this routine */
+  *pbuf = 0;
+}
+
+/**
+ * mutt_addr_write - Write an Address to a buffer
+ * @param buf     Buffer for the Address
+ * @param buflen  Length of the buffer
+ * @param addr    Address to display
+ * @param display This address will be displayed to the user
+ *
+ * If 'display' is set, then it doesn't matter if the transformation isn't
+ * reversible.
+ *
+ * @note It is assumed that `buf` is nul terminated!
+ */
+size_t mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display)
+{
+  char *pbuf = buf;
+  size_t len = mutt_str_strlen(buf);
+
+  buflen--; /* save room for the terminal nul */
+
+  if (len > 0)
+  {
+    if (len > buflen)
+      return 0; /* safety check for bogus arguments */
+
+    pbuf += len;
+    buflen -= len;
+    if (!buflen)
+      goto done;
+    *pbuf++ = ',';
+    buflen--;
+    if (!buflen)
+      goto done;
+    *pbuf++ = ' ';
+    buflen--;
+  }
+
+  for (; addr && buflen > 0; addr = addr->next)
+  {
+    /* use buflen+1 here because we already saved space for the trailing
+       nul char, and the subroutine can make use of it */
+    mutt_addr_write_single(pbuf, buflen + 1, addr, display);
+
+    /* this should be safe since we always have at least 1 char passed into
+       the above call, which means `pbuf' should always be nul terminated */
+    len = mutt_str_strlen(pbuf);
+    pbuf += len;
+    buflen -= len;
+
+    /* if there is another address, and it's not a group mailbox name or
+       group terminator, add a comma to separate the addresses */
+    if (addr->next && addr->next->mailbox && !addr->group)
+    {
+      if (!buflen)
+        goto done;
+      *pbuf++ = ',';
+      buflen--;
+      if (!buflen)
+        goto done;
+      *pbuf++ = ' ';
+      buflen--;
+    }
+  }
+done:
+  *pbuf = 0;
+  return pbuf - buf;
+}
index 03d6afe5715a857e88cbddb4f4d370b403d5f587..fda20b6c15512929f1505ada720747dc30302495 100644 (file)
--- a/address.h
+++ b/address.h
@@ -79,5 +79,7 @@ bool            mutt_addr_search(struct Address *a, struct Address *lst);
 void            mutt_addr_set_intl(struct Address *a, char *intl_mailbox);
 void            mutt_addr_set_local(struct Address *a, char *local_mailbox);
 bool            mutt_addr_valid_msgid(const char *msgid);
+size_t          mutt_addr_write(char *buf, size_t buflen, struct Address *addr, bool display);
+void            mutt_addr_write_single(char *buf, size_t buflen, struct Address *addr, bool display);
 
 #endif /* _MUTT_ADDRESS_H */
diff --git a/alias.c b/alias.c
index e3baccafc18c75e1de6a414663c4a730c46d2f18..cd90b24a88e945dbdb633527ce15576dcafc8157 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -378,7 +378,7 @@ retry_name:
   new->addr->personal = mutt_str_strdup(buf);
 
   buf[0] = '\0';
-  rfc822_write_address(buf, sizeof(buf), new->addr, 1);
+  mutt_addr_write(buf, sizeof(buf), new->addr, true);
   snprintf(prompt, sizeof(prompt), _("[%s = %s] Accept?"), new->name, buf);
   if (mutt_yesorno(prompt, MUTT_YES) != MUTT_YES)
   {
@@ -431,7 +431,7 @@ retry_name:
     recode_buf(buf, sizeof(buf));
     fprintf(rc, "alias %s ", buf);
     buf[0] = '\0';
-    rfc822_write_address(buf, sizeof(buf), new->addr, 0);
+    mutt_addr_write(buf, sizeof(buf), new->addr, false);
     recode_buf(buf, sizeof(buf));
     write_safe_address(rc, buf);
     fputc('\n', rc);
index 9a0e8de1c9e1a58aade6137fe9ee2165fc3cde49..86521726271f11c339c0ab24ed42095a4522fea6 100644 (file)
@@ -316,7 +316,7 @@ void ci_bounce_message(struct Header *h)
   }
 
   buf[0] = '\0';
-  rfc822_write_address(buf, sizeof(buf), adr, 1);
+  mutt_addr_write(buf, sizeof(buf), adr, true);
 
 #define EXTRA_SPACE (15 + 7 + 2)
   snprintf(scratch, sizeof(scratch),
@@ -684,7 +684,7 @@ void mutt_display_address(struct Envelope *env)
    */
 
   buf[0] = '\0';
-  rfc822_write_address(buf, sizeof(buf), adr, 0);
+  mutt_addr_write(buf, sizeof(buf), adr, false);
   mutt_message("%s: %s", pfx, buf);
 }
 
index fee1b2f56cc0a7928a1e8e49596a0c05b02d6167..3f0ae74ce0fb4c6a7bc19309f90363b284f711aa 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -399,7 +399,7 @@ static void draw_envelope_addr(int line, struct Address *addr)
   char buf[LONG_STRING];
 
   buf[0] = 0;
-  rfc822_write_address(buf, sizeof(buf), addr, 1);
+  mutt_addr_write(buf, sizeof(buf), addr, true);
   SETCOLOR(MT_COLOR_COMPOSE_HEADER);
   mutt_window_mvprintw(MuttIndexWindow, line, 0, "%*s", HeaderPadding[line],
                        _(Prompts[line]));
@@ -470,7 +470,7 @@ static void edit_address_list(int line, struct Address **addr)
   char *err = NULL;
 
   mutt_addrlist_to_local(*addr);
-  rfc822_write_address(buf, sizeof(buf), *addr, 0);
+  mutt_addr_write(buf, sizeof(buf), *addr, false);
   if (mutt_get_field(_(Prompts[line]), buf, sizeof(buf), MUTT_ALIAS) == 0)
   {
     mutt_addr_free(addr);
@@ -487,7 +487,7 @@ static void edit_address_list(int line, struct Address **addr)
 
   /* redraw the expanded list so the user can see the result */
   buf[0] = 0;
-  rfc822_write_address(buf, sizeof(buf), *addr, 1);
+  mutt_addr_write(buf, sizeof(buf), *addr, true);
   mutt_window_move(MuttIndexWindow, line, HDR_XOFFSET);
   mutt_paddstr(W, buf);
 }
diff --git a/copy.c b/copy.c
index 1ea14168eb2af1c8f4e9c0c3af780ad5dc99b7de..5371f33d98469d7ddac1b5a1ea0739f6c1f420b7 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -909,7 +909,7 @@ static void format_address_header(char **h, struct Address *a)
     struct Address *tmp = a->next;
     a->next = NULL;
     *buf = *cbuf = *c2buf = '\0';
-    l = rfc822_write_address(buf, sizeof(buf), a, 0);
+    l = mutt_addr_write(buf, sizeof(buf), a, false);
     a->next = tmp;
 
     if (count && linelen + l > 74)
diff --git a/edit.c b/edit.c
index 3f2676c3cb131ef36b5b358962df10c8759e4fdd..42fdf945315fa1a6ee15eaeb272a19a6beb0f332 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -214,7 +214,7 @@ static void be_print_header(struct Envelope *env)
   {
     addstr("To: ");
     tmp[0] = '\0';
-    rfc822_write_address(tmp, sizeof(tmp), env->to, 1);
+    mutt_addr_write(tmp, sizeof(tmp), env->to, true);
     addstr(tmp);
     addch('\n');
   }
@@ -222,7 +222,7 @@ static void be_print_header(struct Envelope *env)
   {
     addstr("Cc: ");
     tmp[0] = '\0';
-    rfc822_write_address(tmp, sizeof(tmp), env->cc, 1);
+    mutt_addr_write(tmp, sizeof(tmp), env->cc, true);
     addstr(tmp);
     addch('\n');
   }
@@ -230,7 +230,7 @@ static void be_print_header(struct Envelope *env)
   {
     addstr("Bcc: ");
     tmp[0] = '\0';
-    rfc822_write_address(tmp, sizeof(tmp), env->bcc, 1);
+    mutt_addr_write(tmp, sizeof(tmp), env->bcc, true);
     addstr(tmp);
     addch('\n');
   }
@@ -257,7 +257,7 @@ static void be_edit_header(struct Envelope *e, int force)
   addstr("To: ");
   tmp[0] = '\0';
   mutt_addrlist_to_local(e->to);
-  rfc822_write_address(tmp, sizeof(tmp), e->to, 0);
+  mutt_addr_write(tmp, sizeof(tmp), e->to, false);
   if (!e->to || force)
   {
     if (mutt_enter_string(tmp, sizeof(tmp), 4, 0) == 0)
@@ -267,7 +267,7 @@ static void be_edit_header(struct Envelope *e, int force)
       e->to = mutt_expand_aliases(e->to);
       mutt_addrlist_to_intl(e->to, NULL); /* XXX - IDNA error reporting? */
       tmp[0] = '\0';
-      rfc822_write_address(tmp, sizeof(tmp), e->to, 1);
+      mutt_addr_write(tmp, sizeof(tmp), e->to, true);
       mutt_window_mvaddstr(MuttMessageWindow, 0, 4, tmp);
     }
   }
@@ -292,7 +292,7 @@ static void be_edit_header(struct Envelope *e, int force)
     addstr("Cc: ");
     tmp[0] = '\0';
     mutt_addrlist_to_local(e->cc);
-    rfc822_write_address(tmp, sizeof(tmp), e->cc, 0);
+    mutt_addr_write(tmp, sizeof(tmp), e->cc, false);
     if (mutt_enter_string(tmp, sizeof(tmp), 4, 0) == 0)
     {
       mutt_addr_free(&e->cc);
@@ -300,7 +300,7 @@ static void be_edit_header(struct Envelope *e, int force)
       e->cc = mutt_expand_aliases(e->cc);
       tmp[0] = '\0';
       mutt_addrlist_to_intl(e->cc, NULL);
-      rfc822_write_address(tmp, sizeof(tmp), e->cc, 1);
+      mutt_addr_write(tmp, sizeof(tmp), e->cc, true);
       mutt_window_mvaddstr(MuttMessageWindow, 0, 4, tmp);
     }
     else
@@ -313,7 +313,7 @@ static void be_edit_header(struct Envelope *e, int force)
     addstr("Bcc: ");
     tmp[0] = '\0';
     mutt_addrlist_to_local(e->bcc);
-    rfc822_write_address(tmp, sizeof(tmp), e->bcc, 0);
+    mutt_addr_write(tmp, sizeof(tmp), e->bcc, false);
     if (mutt_enter_string(tmp, sizeof(tmp), 5, 0) == 0)
     {
       mutt_addr_free(&e->bcc);
@@ -321,7 +321,7 @@ static void be_edit_header(struct Envelope *e, int force)
       e->bcc = mutt_expand_aliases(e->bcc);
       mutt_addrlist_to_intl(e->bcc, NULL);
       tmp[0] = '\0';
-      rfc822_write_address(tmp, sizeof(tmp), e->bcc, 1);
+      mutt_addr_write(tmp, sizeof(tmp), e->bcc, true);
       mutt_window_mvaddstr(MuttMessageWindow, 0, 5, tmp);
     }
     else
index e5c30b1705a6c1084821f3083d0fa4bcb40b9f80..cdb8c71b5008a7a0fa3d590d03e7ffb2a4b78853 100644 (file)
--- a/hdrline.c
+++ b/hdrline.c
@@ -795,7 +795,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
 
     case 'f':
       tmp[0] = 0;
-      rfc822_write_address(tmp, sizeof(tmp), hdr->env->from, 1);
+      mutt_addr_write(tmp, sizeof(tmp), hdr->env->from, true);
       mutt_format_s(buf, buflen, prec, tmp);
       break;
 
@@ -1020,7 +1020,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
 
     case 'r':
       tmp[0] = 0;
-      rfc822_write_address(tmp, sizeof(tmp), hdr->env->to, 1);
+      mutt_addr_write(tmp, sizeof(tmp), hdr->env->to, true);
       if (optional && tmp[0] == '\0')
         optional = 0;
       mutt_format_s(buf, buflen, prec, tmp);
@@ -1028,7 +1028,7 @@ static const char *index_format_str(char *buf, size_t buflen, size_t col, int co
 
     case 'R':
       tmp[0] = 0;
-      rfc822_write_address(tmp, sizeof(tmp), hdr->env->cc, 1);
+      mutt_addr_write(tmp, sizeof(tmp), hdr->env->cc, true);
       if (optional && tmp[0] == '\0')
         optional = 0;
       mutt_format_s(buf, buflen, prec, tmp);
diff --git a/init.c b/init.c
index 193d3275e0b5780fb673928fb30fbadd5e73bad4..e4b4a1b7e9ca0906318ea6edca0b08ef8fa8a8dc 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1915,7 +1915,7 @@ static void set_default(struct Option *p)
       {
         char tmp[HUGE_STRING];
         *tmp = '\0';
-        rfc822_write_address(tmp, sizeof(tmp), *((struct Address **) p->var), 0);
+        mutt_addr_write(tmp, sizeof(tmp), *((struct Address **) p->var), false);
         p->initial = (unsigned long) mutt_str_strdup(tmp);
       }
       break;
@@ -2529,8 +2529,8 @@ static int parse_set(struct Buffer *tmp, struct Buffer *s, unsigned long data,
         else if (DTYPE(MuttVars[idx].type) == DT_ADDRESS)
         {
           tmp2[0] = '\0';
-          rfc822_write_address(tmp2, sizeof(tmp2),
-                               *((struct Address **) MuttVars[idx].var), 0);
+          mutt_addr_write(tmp2, sizeof(tmp2),
+                          *((struct Address **) MuttVars[idx].var), false);
           val = tmp2;
         }
         else if (DTYPE(MuttVars[idx].type) == DT_PATH)
@@ -3642,7 +3642,7 @@ int var_to_string(int idx, char *val, size_t len)
   }
   else if (DTYPE(MuttVars[idx].type) == DT_ADDRESS)
   {
-    rfc822_write_address(tmp, sizeof(tmp), *((struct Address **) MuttVars[idx].var), 0);
+    mutt_addr_write(tmp, sizeof(tmp), *((struct Address **) MuttVars[idx].var), false);
   }
   else if (DTYPE(MuttVars[idx].type) == DT_QUAD)
     mutt_str_strfcpy(tmp, vals[*(unsigned char *) MuttVars[idx].var], sizeof(tmp));
index f90f0dcf90d90a593457cbf7c791ffe8d5e03712..e5f155d41ade003557b46587d1c7cb7b8174e2e2 100644 (file)
@@ -91,178 +91,3 @@ int mutt_addrlist_to_local(struct Address *a)
 
   return 0;
 }
-
-void rfc822_write_address_single(char *buf, size_t buflen, struct Address *addr, int display)
-{
-  size_t len;
-  char *pbuf = buf;
-  char *pc = NULL;
-
-  if (!addr)
-    return;
-
-  buflen--; /* save room for the terminal nul */
-
-  if (addr->personal)
-  {
-    if (strpbrk(addr->personal, AddressSpecials))
-    {
-      if (!buflen)
-        goto done;
-      *pbuf++ = '"';
-      buflen--;
-      for (pc = addr->personal; *pc && buflen > 0; pc++)
-      {
-        if (*pc == '"' || *pc == '\\')
-        {
-          *pbuf++ = '\\';
-          buflen--;
-        }
-        if (!buflen)
-          goto done;
-        *pbuf++ = *pc;
-        buflen--;
-      }
-      if (!buflen)
-        goto done;
-      *pbuf++ = '"';
-      buflen--;
-    }
-    else
-    {
-      if (!buflen)
-        goto done;
-      mutt_str_strfcpy(pbuf, addr->personal, buflen);
-      len = mutt_str_strlen(pbuf);
-      pbuf += len;
-      buflen -= len;
-    }
-
-    if (!buflen)
-      goto done;
-    *pbuf++ = ' ';
-    buflen--;
-  }
-
-  if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
-  {
-    if (!buflen)
-      goto done;
-    *pbuf++ = '<';
-    buflen--;
-  }
-
-  if (addr->mailbox)
-  {
-    if (!buflen)
-      goto done;
-    if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && !display)
-    {
-      mutt_str_strfcpy(pbuf, addr->mailbox, buflen);
-      len = mutt_str_strlen(pbuf);
-    }
-    else if ((mutt_str_strcmp(addr->mailbox, "@") != 0) && display)
-    {
-      mutt_str_strfcpy(pbuf, mutt_addr_for_display(addr), buflen);
-      len = mutt_str_strlen(pbuf);
-    }
-    else
-    {
-      *pbuf = '\0';
-      len = 0;
-    }
-    pbuf += len;
-    buflen -= len;
-
-    if (addr->personal || (addr->mailbox && *addr->mailbox == '@'))
-    {
-      if (!buflen)
-        goto done;
-      *pbuf++ = '>';
-      buflen--;
-    }
-
-    if (addr->group)
-    {
-      if (!buflen)
-        goto done;
-      *pbuf++ = ':';
-      buflen--;
-      if (!buflen)
-        goto done;
-      *pbuf++ = ' ';
-      buflen--;
-    }
-  }
-  else
-  {
-    if (!buflen)
-      goto done;
-    *pbuf++ = ';';
-    buflen--;
-  }
-done:
-  /* no need to check for length here since we already save space at the
-     beginning of this routine */
-  *pbuf = 0;
-}
-
-/**
- * rfc822_write_address - Write an address to a buffer
- *
- * Note: it is assumed that `buf' is nul terminated!
- */
-size_t rfc822_write_address(char *buf, size_t buflen, struct Address *addr, int display)
-{
-  char *pbuf = buf;
-  size_t len = mutt_str_strlen(buf);
-
-  buflen--; /* save room for the terminal nul */
-
-  if (len > 0)
-  {
-    if (len > buflen)
-      return 0; /* safety check for bogus arguments */
-
-    pbuf += len;
-    buflen -= len;
-    if (!buflen)
-      goto done;
-    *pbuf++ = ',';
-    buflen--;
-    if (!buflen)
-      goto done;
-    *pbuf++ = ' ';
-    buflen--;
-  }
-
-  for (; addr && buflen > 0; addr = addr->next)
-  {
-    /* use buflen+1 here because we already saved space for the trailing
-       nul char, and the subroutine can make use of it */
-    rfc822_write_address_single(pbuf, buflen + 1, addr, display);
-
-    /* this should be safe since we always have at least 1 char passed into
-       the above call, which means `pbuf' should always be nul terminated */
-    len = mutt_str_strlen(pbuf);
-    pbuf += len;
-    buflen -= len;
-
-    /* if there is another address, and it's not a group mailbox name or
-       group terminator, add a comma to separate the addresses */
-    if (addr->next && addr->next->mailbox && !addr->group)
-    {
-      if (!buflen)
-        goto done;
-      *pbuf++ = ',';
-      buflen--;
-      if (!buflen)
-        goto done;
-      *pbuf++ = ' ';
-      buflen--;
-    }
-  }
-done:
-  *pbuf = 0;
-  return pbuf - buf;
-}
index 547da42045f815b77c936b37e5bdd0c0a0bed91c..e1bb1449e9905669084df3df3a70a16e2ffbf291 100644 (file)
@@ -205,7 +205,7 @@ static int lua_mutt_get(lua_State *l)
       case DT_ADDRESS:
       {
         char value[LONG_STRING] = "";
-        rfc822_write_address(value, LONG_STRING, *((struct Address **) opt.var), 0);
+        mutt_addr_write(value, LONG_STRING, *((struct Address **) opt.var), false);
         lua_pushstring(l, value);
         return 1;
       }
index a42b31175182743f685275e54c6ba6129f6a50e4..750c7f4e71efb52e83927b2b135256df26e83247 100644 (file)
@@ -273,7 +273,7 @@ void pgp_invoke_getkeys(struct Address *addr)
 
   *tmp = '\0';
   mutt_addrlist_to_local(addr);
-  rfc822_write_address_single(tmp, sizeof(tmp), addr, 0);
+  mutt_addr_write_single(tmp, sizeof(tmp), addr, false);
   mutt_file_quote_filename(buf, sizeof(buf), tmp);
 
   addr->personal = personal;
index 4841d52f107c16abcbb40890d858354b74383e30..fa1c6c9a4b9571cc0cbad4a5aded27a356af8dfa 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -221,7 +221,7 @@ void mutt_tag_set_flag(int flag, int bf);
 void mutt_update_encoding(struct Body *a);
 void mutt_version(void);
 void mutt_view_attachments(struct Header *hdr);
-void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int display);
+void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, bool display);
 bool mutt_addr_is_user(struct Address *addr);
 int mutt_addwch(wchar_t wc);
 int mutt_alias_complete(char *s, size_t buflen);
@@ -364,7 +364,5 @@ int mutt_addrlist_to_local(struct Address *a);
 int mutt_addrlist_to_intl(struct Address *a, char **err);
 int mutt_env_to_intl(struct Envelope *env, char **tag, char **err);
 void mutt_env_to_local(struct Envelope *e);
-size_t 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 */
diff --git a/query.c b/query.c
index 56de2b0cf9308c7ba26300f7bc1c34dc42dfcd7c..a33b04a9e7abe7f25625d95a61c4f2bc8492c49c 100644 (file)
--- a/query.c
+++ b/query.c
@@ -245,7 +245,7 @@ static const char *query_format_str(char *buf, size_t buflen, size_t col, int co
   switch (op)
   {
     case 'a':
-      rfc822_write_address(tmp, sizeof(tmp), query->addr, 1);
+      mutt_addr_write(tmp, sizeof(tmp), query->addr, true);
       snprintf(fmt, sizeof(fmt), "%%%ss", prec);
       snprintf(buf, buflen, fmt, tmp);
       break;
@@ -507,7 +507,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb
             struct Address *tmpa = result_to_addr(QueryTable[i].data);
             mutt_addrlist_to_local(tmpa);
             tagged = true;
-            rfc822_write_address(buf, buflen, tmpa, 0);
+            mutt_addr_write(buf, buflen, tmpa, false);
             curpos = mutt_str_strlen(buf);
             mutt_addr_free(&tmpa);
           }
@@ -516,7 +516,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb
             struct Address *tmpa = result_to_addr(QueryTable[i].data);
             mutt_addrlist_to_local(tmpa);
             strcat(buf, ", ");
-            rfc822_write_address((char *) buf + curpos + 1, buflen - curpos - 1, tmpa, 0);
+            mutt_addr_write((char *) buf + curpos + 1, buflen - curpos - 1, tmpa, false);
             curpos = mutt_str_strlen(buf);
             mutt_addr_free(&tmpa);
           }
@@ -527,7 +527,7 @@ static void query_menu(char *buf, size_t buflen, struct Query *results, int retb
       {
         struct Address *tmpa = result_to_addr(QueryTable[menu->current].data);
         mutt_addrlist_to_local(tmpa);
-        rfc822_write_address(buf, buflen, tmpa, 0);
+        mutt_addr_write(buf, buflen, tmpa, false);
         mutt_addr_free(&tmpa);
       }
     }
@@ -559,7 +559,7 @@ int mutt_query_complete(char *buf, size_t buflen)
       tmpa = result_to_addr(results);
       mutt_addrlist_to_local(tmpa);
       buf[0] = '\0';
-      rfc822_write_address(buf, buflen, tmpa, 0);
+      mutt_addr_write(buf, buflen, tmpa, false);
       mutt_addr_free(&tmpa);
       free_query(&results);
       mutt_clear_error();
index 8c23d77975ff9807604ccad43bd2df93bec89e61..d5be3d932debffd271505d0f75ffaceab38fb8d5 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -188,7 +188,7 @@ void mutt_attach_bounce(FILE *fp, struct AttachCtx *actx, struct Body *cur)
   }
 
   buf[0] = 0;
-  rfc822_write_address(buf, sizeof(buf), adr, 1);
+  mutt_addr_write(buf, sizeof(buf), adr, true);
 
 #define EXTRA_SPACE (15 + 7 + 2)
   /*
diff --git a/send.c b/send.c
index 4c93cb1c62cd660315c3c204e3a1354b89e5c918..92ced756a885145031489664f9225f776fe742f4 100644 (file)
--- a/send.c
+++ b/send.c
@@ -199,7 +199,7 @@ static int edit_address(struct Address **a, /* const */ char *field)
   {
     buf[0] = 0;
     mutt_addrlist_to_local(*a);
-    rfc822_write_address(buf, sizeof(buf), *a, 0);
+    mutt_addr_write(buf, sizeof(buf), *a, false);
     if (mutt_get_field(field, buf, sizeof(buf), MUTT_ALIAS) != 0)
       return -1;
     mutt_addr_free(a);
index 52ad7b037fc5c898ef7205e5b996e516e55f31fc..88a0745cf6c6f3e225cb24eadc58b06707e78077 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1607,7 +1607,7 @@ struct Body *mutt_remove_multipart(struct Body *b)
  * So we can handle very large recipient lists without needing a huge temporary
  * buffer in memory
  */
-void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int display)
+void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, bool display)
 {
   struct Address *tmp = NULL;
   char buf[LONG_STRING];
@@ -1619,7 +1619,7 @@ void mutt_write_address_list(struct Address *adr, FILE *fp, int linelen, int dis
     tmp = adr->next;
     adr->next = NULL;
     buf[0] = 0;
-    rfc822_write_address(buf, sizeof(buf), adr, display);
+    mutt_addr_write(buf, sizeof(buf), adr, display);
     len = mutt_str_strlen(buf);
     if (count && linelen + len > 74)
     {
@@ -2037,14 +2037,14 @@ int mutt_write_rfc822_header(FILE *fp, struct Envelope *env,
   if (env->from && !privacy)
   {
     buffer[0] = 0;
-    rfc822_write_address(buffer, sizeof(buffer), env->from, 0);
+    mutt_addr_write(buffer, sizeof(buffer), env->from, false);
     fprintf(fp, "From: %s\n", buffer);
   }
 
   if (env->sender && !privacy)
   {
     buffer[0] = 0;
-    rfc822_write_address(buffer, sizeof(buffer), env->sender, 0);
+    mutt_addr_write(buffer, sizeof(buffer), env->sender, false);
     fprintf(fp, "Sender: %s\n", buffer);
   }
 
@@ -2810,7 +2810,7 @@ int mutt_bounce_message(FILE *fp, struct Header *h, struct Address *to)
     mutt_addr_free(&from);
     return -1;
   }
-  rfc822_write_address(resent_from, sizeof(resent_from), from, 0);
+  mutt_addr_write(resent_from, sizeof(resent_from), from, false);
 
 #ifdef USE_NNTP
   OPT_NEWS_SEND = false;