static int edit_address (ADDRESS **a, /* const */ char *field) { char buf[HUGE_STRING]; char *err = NULL; int idna_ok = 0; do { buf[0] = 0; mutt_addrlist_to_local (*a); rfc822_write_address (buf, sizeof (buf), *a, 0); if (mutt_get_field (field, buf, sizeof (buf), M_ALIAS) != 0) return (-1); rfc822_free_address (a); *a = mutt_expand_aliases (mutt_parse_adrlist (NULL, buf)); if ((idna_ok = mutt_addrlist_to_idna (*a, &err)) != 0) { mutt_error (_("Error: '%s' is a bad IDN."), err); mutt_refresh (); mutt_sleep (2); FREE (&err); } } while (idna_ok != 0); return 0; }
static int edit_address_list (int line, ADDRESS **addr) { char buf[HUGE_STRING] = ""; /* needs to be large for alias expansion */ char *err = NULL; mutt_addrlist_to_local (*addr); rfc822_write_address (buf, sizeof (buf), *addr, 0); if (mutt_get_field (Prompts[line - 1], buf, sizeof (buf), M_ALIAS) == 0) { rfc822_free_address (addr); *addr = mutt_parse_adrlist (*addr, buf); *addr = mutt_expand_aliases (*addr); } if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); return (REDRAW_FULL); } if (mutt_addrlist_to_idna (*addr, &err) != 0) { mutt_error (_("Warning: '%s' is a bad IDN."), err); mutt_refresh(); FREE (&err); } /* redraw the expanded list so the user can see the result */ buf[0] = 0; rfc822_write_address (buf, sizeof (buf), *addr, 1); move (line, HDR_XOFFSET); mutt_paddstr (W, buf); return 0; }
static ADDRESS *result_to_addr (QUERY *r) { static ADDRESS *tmp; if (!(tmp = rfc822_cpy_adr (r->addr, 0))) return NULL; if(!tmp->next && !tmp->personal) tmp->personal = safe_strdup (r->name); mutt_addrlist_to_idna (tmp, NULL); return tmp; }
void ci_bounce_message (HEADER *h, int *redraw) { char prompt[SHORT_STRING]; char scratch[SHORT_STRING]; char buf[HUGE_STRING] = { 0 }; ADDRESS *adr = NULL; char *err = NULL; int rc; /* RfC 5322 mandates a From: header, so warn before bouncing * messages without one */ if (h) { if (!h->env->from) { mutt_error _("Warning: message has no From: header"); mutt_sleep (2); } } else if (Context) { for (rc = 0; rc < Context->msgcount; rc++) { if (Context->hdrs[rc]->tagged && !Context->hdrs[rc]->env->from) { mutt_error ("Warning: message has no From: header"); mutt_sleep (2); break; } } } if(h) strfcpy(prompt, _("Bounce message to: "), sizeof(prompt)); else strfcpy(prompt, _("Bounce tagged messages to: "), sizeof(prompt)); rc = mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS); if (option (OPTNEEDREDRAW)) { unset_option (OPTNEEDREDRAW); *redraw = REDRAW_FULL; } if (rc || !buf[0]) return; if (!(adr = rfc822_parse_adrlist (adr, buf))) { mutt_error _("Error parsing address!"); return; } adr = mutt_expand_aliases (adr); if (mutt_addrlist_to_idna (adr, &err) < 0) { mutt_error (_("Bad IDN: '%s'"), err); FREE (&err); rfc822_free_address (&adr); return; } buf[0] = 0; rfc822_write_address (buf, sizeof (buf), adr, 1); #define extra_space (15 + 7 + 2) snprintf (scratch, sizeof (scratch), (h ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); if (mutt_strwidth (prompt) > COLS - extra_space) { mutt_format_string (prompt, sizeof (prompt), 0, COLS-extra_space, FMT_LEFT, 0, scratch, sizeof (scratch), 0); safe_strcat (prompt, sizeof (prompt), "...?"); } else snprintf (prompt, sizeof (prompt), "%s?", scratch); if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) { rfc822_free_address (&adr); CLEARLINE (LINES - 1); mutt_message (h ? _("Message not bounced.") : _("Messages not bounced.")); return; } CLEARLINE (LINES - 1); rc = mutt_bounce_message (NULL, h, adr); rfc822_free_address (&adr); /* If no error, or background, display message. */ if ((rc == 0) || (rc == S_BKG)) mutt_message (h ? _("Message bounced.") : _("Messages bounced.")); }
void mutt_attach_bounce (FILE * fp, HEADER * hdr, ATTACHPTR ** idx, short idxlen, BODY * cur) { short i; char prompt[STRING]; char buf[HUGE_STRING]; char *err = NULL; ADDRESS *adr = NULL; int ret = 0; int p = 0; if (check_all_msg (idx, idxlen, cur, 1) == -1) return; /* one or more messages? */ p = (cur || count_tagged (idx, idxlen) == 1); if (p) strfcpy (prompt, _("Bounce message to: "), sizeof (prompt)); else strfcpy (prompt, _("Bounce tagged messages to: "), sizeof (prompt)); buf[0] = '\0'; if (mutt_get_field (prompt, buf, sizeof (buf), M_ALIAS) || buf[0] == '\0') return; if (!(adr = rfc822_parse_adrlist (adr, buf))) { mutt_error _("Error parsing address!"); return; } adr = mutt_expand_aliases (adr); if (mutt_addrlist_to_idna (adr, &err) < 0) { mutt_error (_("Bad IDN: '%s'"), err); mem_free (&err); rfc822_free_address (&adr); return; } buf[0] = 0; rfc822_write_address (buf, sizeof (buf), adr, 1); #define extra_space (15+7+2) /* * See commands.c. */ snprintf (prompt, sizeof (prompt) - 4, (p ? _("Bounce message to %s") : _("Bounce messages to %s")), buf); if (mutt_strwidth (prompt) > COLS - extra_space) { mutt_format_string (prompt, sizeof (prompt) - 4, 0, COLS - extra_space, 0, 0, prompt, sizeof (prompt), 0); str_cat (prompt, sizeof (prompt), "...?"); } else str_cat (prompt, sizeof (prompt), "?"); if (query_quadoption (OPT_BOUNCE, prompt) != M_YES) { rfc822_free_address (&adr); CLEARLINE (LINES - 1); mutt_message (p ? _("Message not bounced.") : _("Messages not bounced.")); return; } CLEARLINE (LINES - 1); if (cur) ret = mutt_bounce_message (fp, cur->hdr, adr); else { for (i = 0; i < idxlen; i++) { if (idx[i]->content->tagged) if (mutt_bounce_message (fp, idx[i]->content->hdr, adr)) ret = 1; } } if (!ret) mutt_message (p ? _("Message bounced.") : _("Messages bounced.")); else mutt_error (p ? _("Error bouncing message!") : _("Error bouncing messages!")); }