typedef struct
{
HEADER *msg;
- char *fcc;
+ BUFFER *fcc;
#ifdef USE_AUTOCRYPT
autocrypt_rec_t autocrypt_rec;
int autocrypt_rec_override;
static void draw_envelope (compose_redraw_data_t *rd)
{
HEADER *msg = rd->msg;
- char *fcc = rd->fcc;
+ const char *fcc = mutt_b2s (rd->fcc);
draw_envelope_addr (HDR_FROM, msg->env->from);
draw_envelope_addr (HDR_TO, msg->env->to);
* -1 abort message
*/
int mutt_compose_menu (HEADER *msg, /* structure for new message */
- char *fcc, /* where to save a copy of the message */
- size_t fcclen,
+ BUFFER *fcc, /* where to save a copy of the message */
HEADER *cur, /* current message */
int flags)
{
mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
break;
case OP_COMPOSE_EDIT_FCC:
- strfcpy (buf, fcc, sizeof (buf));
- if (mutt_get_field (_("Fcc: "), buf, sizeof (buf), MUTT_FILE | MUTT_CLEAR) == 0)
+ mutt_buffer_strcpy (fname, mutt_b2s (fcc));
+ if (mutt_buffer_get_field (_("Fcc: "), fname, MUTT_FILE | MUTT_CLEAR) == 0)
{
- strfcpy (fcc, buf, fcclen);
- mutt_pretty_mailbox (fcc, fcclen);
+ mutt_buffer_strcpy (fcc, mutt_b2s (fname));
+ mutt_buffer_pretty_mailbox (fcc);
mutt_window_move (MuttIndexWindow, HDR_FCC, HDR_XOFFSET);
- mutt_paddstr (W, fcc);
+ mutt_paddstr (W, mutt_b2s (fcc));
fccSet = 1;
}
mutt_message_hook (NULL, msg, MUTT_SEND2HOOK);
char *tag = NULL, *err = NULL;
mutt_env_to_local (msg->env);
mutt_edit_headers (NONULL (Editor), msg->content->filename, msg,
- fcc, fcclen);
+ fcc);
if (mutt_env_to_intl (msg->env, &tag, &err))
{
mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err);
break;
#endif
- if (!fccSet && *fcc)
+ if (!fccSet && mutt_buffer_len (fcc))
{
if ((i = query_quadoption (OPT_COPY,
_("Save a copy of this message?"))) == -1)
break;
else if (i == MUTT_NO)
- *fcc = 0;
+ mutt_buffer_clear (fcc);
}
loop = 0;
if (option (OPTEDITHDRS))
{
mutt_env_to_local (msg->env);
- mutt_edit_headers (NONULL(Visual), path, msg, NULL, 0);
+ mutt_edit_headers (NONULL(Visual), path, msg, NULL);
if (mutt_env_to_intl (msg->env, &tag, &err))
printw (_("Bad IDN in %s: '%s'\n"), tag, err);
}
void mutt_edit_headers (const char *editor,
const char *body,
HEADER *msg,
- char *fcc,
- size_t fcclen)
+ BUFFER *fcc)
{
BUFFER *path = NULL; /* tempfile used to edit headers + body */
char buffer[LONG_STRING];
p = skip_email_wsp(cur->data + 4);
if (*p)
{
- strfcpy (fcc, p, fcclen);
- mutt_pretty_mailbox (fcc, fcclen);
+ mutt_buffer_strcpy (fcc, p);
+ mutt_buffer_pretty_mailbox (fcc);
}
keep = 0;
}
}
}
-void mutt_select_fcc (char *path, size_t pathlen, HEADER *hdr)
+void mutt_select_fcc (BUFFER *path, HEADER *hdr)
{
ADDRESS *adr;
BUFFER *buf = NULL;
ENVELOPE *env = hdr->env;
- if (mutt_addr_hook (path, pathlen, MUTT_FCCHOOK, NULL, hdr) != 0)
+ mutt_buffer_increase_size (path, _POSIX_PATH_MAX);
+
+ if (mutt_addr_hook (path->data, path->dsize, MUTT_FCCHOOK, NULL, hdr) != 0)
{
if ((option (OPTSAVENAME) || option (OPTFORCENAME)) &&
(env->to || env->cc || env->bcc))
adr = env->to ? env->to : (env->cc ? env->cc : env->bcc);
buf = mutt_buffer_pool_get ();
mutt_safe_path (buf, adr);
- mutt_concat_path (path, NONULL(Maildir), mutt_b2s (buf), pathlen);
+ mutt_buffer_concat_path (path, NONULL(Maildir), mutt_b2s (buf));
mutt_buffer_pool_release (&buf);
- if (!option (OPTFORCENAME) && mx_access (path, W_OK) != 0)
- strfcpy (path, NONULL (Outbox), pathlen);
+ if (!option (OPTFORCENAME) && mx_access (mutt_b2s (path), W_OK) != 0)
+ mutt_buffer_strcpy (path, NONULL (Outbox));
}
else
- strfcpy (path, NONULL (Outbox), pathlen);
+ mutt_buffer_strcpy (path, NONULL (Outbox));
}
- mutt_pretty_mailbox (path, pathlen);
+ else
+ mutt_buffer_fix_dptr (path);
+
+ mutt_buffer_pretty_mailbox (path);
}
static char *_mutt_string_hook (const char *match, int hook)
* cur if message was a reply, `cur' is set to the message which
* `hdr' is in reply to
* fcc fcc for the recalled message
- * fcclen max length of fcc
*
* return vals:
* -1 error/no messages
* 0 normal exit
* SENDREPLY recalled message is a reply
*/
-int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, char *fcc, size_t fcclen)
+int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER **cur, BUFFER *fcc)
{
HEADER *h;
int code = SENDPOSTPONED;
else if (ascii_strncasecmp ("X-Mutt-Fcc:", tmp->data, 11) == 0)
{
p = skip_email_wsp(tmp->data + 11);
- strfcpy (fcc, p, fcclen);
- mutt_pretty_mailbox (fcc, fcclen);
+ mutt_buffer_strcpy (fcc, p);
+ mutt_buffer_pretty_mailbox (fcc);
/* remove the X-Mutt-Fcc: header field */
next = tmp->next;
void mutt_display_sanitize (char *);
int mutt_edit_content_type (HEADER *, BODY *, FILE *);
void mutt_edit_file (const char *, const char *);
-void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
+void mutt_edit_headers (const char *, const char *, HEADER *, BUFFER *);
char **mutt_envlist (void);
void mutt_envlist_set (const char *name, const char *value, int overwrite);
int mutt_filter_unprintable (char **);
void mutt_save_path (char *s, size_t l, ADDRESS *a);
void mutt_buffer_save_path (BUFFER *dest, ADDRESS *a);
void mutt_score_message (CONTEXT *, HEADER *, int);
-void mutt_select_fcc (char *, size_t, HEADER *);
+void mutt_select_fcc (BUFFER *, HEADER *);
#define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,NULL,NULL)
void _mutt_select_file (char *, size_t, int, char ***, int *);
#define mutt_buffer_select_file(A,B) _mutt_buffer_select_file(A,B,NULL,NULL)
int mutt_get_hook_type (const char *);
int mutt_get_field_unbuffered (char *, char *, size_t, int);
#define mutt_get_password(A,B,C) mutt_get_field_unbuffered(A,B,C,MUTT_PASS)
-int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, size_t);
+int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, BUFFER *);
int mutt_get_tmp_attachment (BODY *);
int mutt_index_menu (void);
int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
size_t mutt_wstr_trunc (const char *, size_t, size_t, size_t *);
int mutt_charlen (const char *s, int *);
int mutt_strwidth (const char *);
-int mutt_compose_menu (HEADER *, char *, size_t, HEADER *, int);
+int mutt_compose_menu (HEADER *, BUFFER *, HEADER *, int);
int mutt_thread_set_flag (HEADER *, int, int, int);
int mutt_user_is_recipient (HEADER *);
void mutt_update_num_postponed (void);
int mutt_wait_filter (pid_t);
int mutt_wait_interactive_filter (pid_t);
int mutt_which_case (const char *);
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *);
+int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, const char *);
int mutt_write_mime_body (BODY *, FILE *);
int mutt_write_mime_header (BODY *, FILE *);
int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, int flags);
return (i);
}
-static int save_fcc (HEADER *msg, char *fcc, size_t fcc_len,
+static int save_fcc (HEADER *msg, BUFFER *fcc,
BODY *clear_content, char *pgpkeylist,
int flags)
{
BODY *save_parts = NULL;
int choice;
- mutt_expand_path (fcc, fcc_len);
+ mutt_buffer_expand_path (fcc);
/* Don't save a copy when we are in batch-mode, and the FCC
* folder is on an IMAP server: This would involve possibly lots
*/
#ifdef USE_IMAP
- if ((flags & SENDBATCH) && fcc[0] && mx_is_imap (fcc))
+ if ((flags & SENDBATCH) &&
+ mutt_buffer_len (fcc) &&
+ mx_is_imap (mutt_b2s (fcc)))
{
mutt_error _ ("Fcc to an IMAP mailbox is not supported in batch mode");
return rc;
}
#endif
- if (!(*fcc && mutt_strcmp ("/dev/null", fcc)))
+ if (!(mutt_buffer_len (fcc) &&
+ mutt_strcmp ("/dev/null", mutt_b2s (fcc))))
return rc;
/* Before sending, we don't allow message manipulation because it
* message was first postponed.
*/
msg->received = time (NULL);
- rc = mutt_write_fcc (fcc, msg, NULL, 0, NULL);
+ rc = mutt_write_fcc (mutt_b2s (fcc), msg, NULL, 0, NULL);
while (rc && !(flags & SENDBATCH))
{
mutt_clear_error ();
This is the prompt to enter an "alternate (m)ailbox" when the
initial Fcc fails.
*/
- rc = mutt_enter_fname (_("Fcc mailbox"), fcc, fcc_len, 1);
- if ((rc == -1) || !fcc[0])
+ rc = mutt_buffer_enter_fname (_("Fcc mailbox"), fcc, 1);
+ if ((rc == -1) || !mutt_buffer_len (fcc))
{
rc = 0;
break;
/* fall through */
case 1: /* (r)etry */
- rc = mutt_write_fcc (fcc, msg, NULL, 0, NULL);
+ rc = mutt_write_fcc (mutt_b2s (fcc), msg, NULL, 0, NULL);
break;
case -1: /* abort */
return match;
}
-static int postpone_message (HEADER *msg, HEADER *cur, char *fcc, int flags)
+static int postpone_message (HEADER *msg, HEADER *cur, const char *fcc, int flags)
{
char *pgpkeylist = NULL;
char *encrypt_as = NULL;
HEADER *cur) /* current message */
{
char buffer[LONG_STRING];
- char fcc[_POSIX_PATH_MAX] = ""; /* where to copy this message */
+ BUFFER *fcc; /* where to copy this message */
FILE *tempfp = NULL;
BODY *pbody;
int i, killfrom = 0;
flags |= SENDPOSTPONED;
}
+ /* Allocate the buffer due to the long lifetime, but
+ * pre-resize it to ensure there are no NULL data field issues */
+ fcc = mutt_buffer_new ();
+ mutt_buffer_increase_size (fcc, LONG_STRING);
if (flags & SENDPOSTPONED)
{
if (flags == SENDPOSTPONED)
{
- if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc, sizeof (fcc))) < 0)
+ if ((flags = mutt_get_postponed (ctx, msg, &cur, fcc)) < 0)
{
flags = SENDPOSTPONED;
goto cleanup;
else if (option (OPTEDITHDRS))
{
mutt_env_to_local (msg->env);
- mutt_edit_headers (Editor, msg->content->filename, msg, fcc, sizeof (fcc));
+ mutt_edit_headers (Editor, msg->content->filename, msg, fcc);
mutt_env_to_intl (msg->env, NULL, NULL);
}
else
/* specify a default fcc. if we are in batchmode, only save a copy of
* the message if the value of $copy is yes or ask-yes */
- if (!fcc[0] && !(flags & (SENDPOSTPONEDFCC)) && (!(flags & SENDBATCH) || (quadoption (OPT_COPY) & 0x1)))
+ if (!mutt_buffer_len (fcc) &&
+ !(flags & (SENDPOSTPONEDFCC)) &&
+ (!(flags & SENDBATCH) || (quadoption (OPT_COPY) & 0x1)))
{
/* set the default FCC */
if (!msg->env->from)
killfrom = 1; /* no need to check $use_from because if the user specified
a from address it would have already been set by now */
}
- mutt_select_fcc (fcc, sizeof (fcc), msg);
+ mutt_select_fcc (fcc, msg);
if (killfrom)
{
rfc822_free_address (&msg->env->from);
{
main_loop:
- mutt_pretty_mailbox (fcc, sizeof (fcc));
- i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur,
+ mutt_buffer_pretty_mailbox (fcc);
+ i = mutt_compose_menu (msg, fcc, cur,
(flags & SENDNOFREEHEADER ? MUTT_COMPOSE_NOFREEHEADER : 0));
if (i == -1)
{
}
else if (i == 1)
{
- if (postpone_message (msg, cur, fcc, flags) != 0)
+ if (postpone_message (msg, cur, mutt_b2s (fcc), flags) != 0)
goto main_loop;
mutt_message _("Message postponed.");
rv = 1;
mutt_prepare_envelope (msg->env, 1);
if (option (OPTFCCBEFORESEND))
- save_fcc (msg, fcc, sizeof(fcc), clear_content, pgpkeylist, flags);
+ save_fcc (msg, fcc, clear_content, pgpkeylist, flags);
if ((i = send_message (msg)) < 0)
{
}
if (!option (OPTFCCBEFORESEND))
- save_fcc (msg, fcc, sizeof(fcc), clear_content, pgpkeylist, flags);
+ save_fcc (msg, fcc, clear_content, pgpkeylist, flags);
if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
{
rv = 0;
cleanup:
+ mutt_buffer_free (&fcc);
if (flags & SENDPOSTPONED)
{
}
}
-int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, char *fcc)
+int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, const char *fcc)
{
CONTEXT f;
MESSAGE *msg;