From bb37a977a70f99ac74ece02f8b494eadd03905ab Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 30 Dec 2017 16:25:01 +0000 Subject: [PATCH] move address functions --- addrbook.c | 6 +- address.c | 194 +++++++++++++++++++++++++++++++++++++++++++++ address.h | 2 + alias.c | 4 +- commands.c | 4 +- compose.c | 6 +- copy.c | 2 +- edit.c | 18 ++--- hdrline.c | 6 +- init.c | 8 +- mutt_address.c | 175 ---------------------------------------- mutt_lua.c | 2 +- ncrypt/pgpinvoke.c | 2 +- protos.h | 4 +- query.c | 10 +-- recvcmd.c | 2 +- send.c | 2 +- sendlib.c | 10 +-- 18 files changed, 238 insertions(+), 219 deletions(-) diff --git a/addrbook.c b/addrbook.c index 74da70e86..163d43a2e 100644 --- a/addrbook.c +++ b/addrbook.c @@ -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); diff --git a/address.c b/address.c index 44c68e805..47515000c 100644 --- 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; +} diff --git a/address.h b/address.h index 03d6afe57..fda20b6c1 100644 --- 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 e3baccafc..cd90b24a8 100644 --- 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); diff --git a/commands.c b/commands.c index 9a0e8de1c..865217262 100644 --- a/commands.c +++ b/commands.c @@ -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); } diff --git a/compose.c b/compose.c index fee1b2f56..3f0ae74ce 100644 --- 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 1ea14168e..5371f33d9 100644 --- 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 3f2676c3c..42fdf9453 100644 --- 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 diff --git a/hdrline.c b/hdrline.c index e5c30b170..cdb8c71b5 100644 --- 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 193d3275e..e4b4a1b7e 100644 --- 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)); diff --git a/mutt_address.c b/mutt_address.c index f90f0dcf9..e5f155d41 100644 --- a/mutt_address.c +++ b/mutt_address.c @@ -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; -} diff --git a/mutt_lua.c b/mutt_lua.c index 547da4204..e1bb1449e 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -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; } diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index a42b31175..750c7f4e7 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -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; diff --git a/protos.h b/protos.h index 4841d52f1..fa1c6c9a4 100644 --- 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 56de2b0cf..a33b04a9e 100644 --- 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(); diff --git a/recvcmd.c b/recvcmd.c index 8c23d7797..d5be3d932 100644 --- 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 4c93cb1c6..92ced756a 100644 --- 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); diff --git a/sendlib.c b/sendlib.c index 52ad7b037..88a0745cf 100644 --- 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; -- 2.40.0