if (!addr)
return 0;
- buflen--; /* save room for the terminal nul */
-
if (addr->personal) {
pos = rfc822_strcpy(buf, buflen, addr->personal, RFC822Specials);
- if (pos + 2 >= buflen)
- goto done;
-
- buf[pos++] = ' ';
- buf[pos++] = '<';
+ pos += m_strcpy(buf + pos, buflen - pos, " <");
}
if (addr->mailbox) {
}
if (addr->personal) {
- if (pos + 1 >= buflen)
- goto done;
- buf[pos++] = '>';
+ pos += m_strcpy(buf + pos, buflen - pos, ">");
}
if (addr->group) {
- if (pos + 1 >= buflen)
- goto done;
- buf[pos++] = ':';
+ pos += m_strcpy(buf + pos, buflen - pos, ":");
}
} else {
- if (pos + 1 >= buflen)
- goto done;
- buf[pos++] = ';';
+ pos += m_strcpy(buf + pos, buflen - pos, ";");
}
- done:
- /* no need to check for length here since we already save space at the
- beginning of this routine */
- buf[pos] = 0;
return pos;
}
{
ssize_t pos;
- buflen--; /* save room for the terminal nul */
pos = m_strnlen(buf, buflen);
if (pos) {
- if (pos + 2 >= buflen)
- goto done;
-
- buf[pos++] = ',';
- buf[pos++] = ' ';
+ pos += m_strcpy(buf + pos, buflen - pos, ", ");
}
for (; addr; addr = addr->next) {
- pos += rfc822_write_address_single(buf + pos, buflen + 1 - pos,
+ pos += rfc822_write_address_single(buf + pos, buflen - pos,
addr, display);
if (!addr->group && addr->next && addr->next->mailbox) {
/* if there is another address, and its not a group mailbox name or
group terminator, add a comma to separate the addresses */
- if (pos + 2 >= buflen)
- break;
-
- buf[pos++] = ',';
- buf[pos++] = ' ';
+ pos += m_strcpy(buf + pos, buflen - pos, ", ");
}
}
- done:
- buf[pos] = '\0';
return pos;
}
static int get_toplevel_encoding (BODY * a)
{
- int e = ENC7BIT;
+ int e = ENC7BIT;
- for (; a; a = a->next) {
- if (a->encoding == ENCBINARY)
- return (ENCBINARY);
- else if (a->encoding == ENC8BIT)
- e = ENC8BIT;
- }
+ for (; a; a = a->next) {
+ if (a->encoding == ENCBINARY)
+ return ENCBINARY;
+
+ if (a->encoding == ENC8BIT)
+ e = ENC8BIT;
+ }
- return (e);
+ return e;
}
BODY *mutt_make_multipart (BODY * b)
/* wrapper around mutt_write_address() so we can handle very large
recipient lists without needing a huge temporary buffer in memory */
-void mutt_write_address_list (address_t * adr, FILE * fp, int linelen,
- int display)
+void
+mutt_write_address_list(address_t *addr, FILE *fp, int linelen, int display)
{
- address_t *tmp;
- char buf[LONG_STRING];
- int count = 0;
- int len;
+ int first = 1;
+
+ while (addr) {
+ char buf[LONG_STRING];
+ int len;
+
+ len = rfc822_write_address_single(buf, ssizeof(buf), addr, display);
+
+ if (!first) {
+ if (linelen + len > 74) {
+ fputs("\n\t", fp);
+ linelen = 8; /* tab is usually about 8 spaces... */
+ } else
+ if (addr->mailbox) {
+ fputc(' ', fp);
+ linelen++;
+ }
+ }
+ first = 0;
- while (adr) {
- tmp = adr->next;
- adr->next = NULL;
- buf[0] = 0;
- rfc822_write_address (buf, sizeof (buf), adr, display);
- len = m_strlen(buf);
- if (count && linelen + len > 74) {
- fputs ("\n\t", fp);
- linelen = len + 8; /* tab is usually about 8 spaces... */
- }
- else {
- if (count && adr->mailbox) {
- fputc (' ', fp);
- linelen++;
- }
- linelen += len;
- }
- fputs (buf, fp);
- adr->next = tmp;
- if (!adr->group && adr->next && adr->next->mailbox) {
- linelen++;
- fputc (',', fp);
+ linelen += len + 1;
+ fputs(buf, fp);
+
+ if (!addr->group && addr->next && addr->next->mailbox) {
+ fputc(',', fp);
+ linelen++;
+ }
+
+ addr = addr->next;
}
- adr = adr->next;
- count++;
- }
- fputc ('\n', fp);
+ fputc ('\n', fp);
}
/* need to write the list in reverse because they are stored in reverse order
* anonymous remailer chains.
*
*/
-
int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach,
int mode, int privacy)
{
args = add_option(args, &argslen, &argsmax, "-B8BITMIME");
if (option (OPTENVFROM)) {
- address_t *f = NULL;
+ address_t *f = EnvFrom;
if (EnvFrom)
f = EnvFrom;
else if (from && !from->next)
}
#endif
- if (argslen == argsmax)
+ if (argslen >= argsmax)
p_realloc(&args, ++argsmax);
args[argslen++] = NULL;
if (childout) {
struct stat st;
- if (stat (childout, &st) == 0 && st.st_size > 0)
- mutt_do_pager (_("Output of the delivery process"), childout, 0,
- NULL);
+ if (!stat(childout, &st) && st.st_size > 0)
+ mutt_do_pager(_("Output of the delivery process"), childout, 0,
+ NULL);
}
}
- }
- else
+ } else {
unlink (childout);
+ }
p_delete(&childout);
p_delete(&path);
/* For postponing (!final) do the necessary encodings only */
void mutt_prepare_envelope (ENVELOPE * env, int final)
{
- char buffer[LONG_STRING];
-
if (final) {
if (env->bcc && !(env->to || env->cc)) {
/* some MTA's will put an Apparently-To: header field showing the Bcc:
* recipients if there is no To: or Cc: field, so attempt to suppress
* it by using an empty To: field.
*/
- env->to = address_new ();
+ env->to = address_new();
env->to->group = 1;
- env->to->next = address_new ();
-
- buffer[0] = 0;
- rfc822_strcpy(buffer, sizeof(buffer), "undisclosed-recipients",
- RFC822Specials);
-
- env->to->mailbox = m_strdup(buffer);
+ env->to->next = address_new();
+ env->to->mailbox = m_strdup("undisclosed-recipients");
}
- mutt_set_followup_to (env);
+ mutt_set_followup_to(env);
- if (!env->message_id && MsgIdFormat && *MsgIdFormat)
- env->message_id = mutt_gen_msgid ();
+ if (!env->message_id && !m_strisempty(MsgIdFormat))
+ env->message_id = mutt_gen_msgid();
}
/* Take care of 8-bit => 7-bit conversion. */
- rfc2047_encode_adrlist (env->to, "To");
- rfc2047_encode_adrlist (env->cc, "Cc");
- rfc2047_encode_adrlist (env->bcc, "Bcc");
- rfc2047_encode_adrlist (env->from, "From");
- rfc2047_encode_adrlist (env->mail_followup_to, "Mail-Followup-To");
- rfc2047_encode_adrlist (env->reply_to, "Reply-To");
+ rfc2047_encode_adrlist(env->to, "To");
+ rfc2047_encode_adrlist(env->cc, "Cc");
+ rfc2047_encode_adrlist(env->bcc, "Bcc");
+ rfc2047_encode_adrlist(env->from, "From");
+ rfc2047_encode_adrlist(env->mail_followup_to, "Mail-Followup-To");
+ rfc2047_encode_adrlist(env->reply_to, "Reply-To");
if (env->subject)
#ifdef USE_NNTP
fseeko (fp, h->offset, 0);
fprintf (f, "Resent-From: %s", resent_from);
fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof (date)));
- if (MsgIdFormat && *MsgIdFormat)
- fprintf (f, "Resent-Message-ID: %s\n", mutt_gen_msgid ());
+ if (!m_strisempty(MsgIdFormat))
+ fprintf (f, "Resent-Message-ID: %s\n", mutt_gen_msgid());
fputs ("Resent-To: ", f);
mutt_write_address_list (to, f, 11, 0);
mutt_copy_header (fp, h, f, ch_flags, NULL);