bool builtin = false;
CopyMessageFlags cmflags = MUTT_CM_DECODE | MUTT_CM_DISPLAY | MUTT_CM_CHARCONV;
CopyHeaderFlags chflags;
- FILE *fpout = NULL;
- FILE *fpfilterout = NULL;
pid_t filterpid = -1;
int res;
}
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w");
- if (!fpout)
+ FILE *fp_filter_out = NULL;
+ FILE *fp_out = mutt_file_fopen(tempfile, "w");
+ if (!fp_out)
{
mutt_error(_("Could not create temporary file"));
return 0;
if (C_DisplayFilter && *C_DisplayFilter)
{
- fpfilterout = fpout;
- fpout = NULL;
- filterpid = mutt_create_filter_fd(C_DisplayFilter, &fpout, NULL, NULL, -1,
- fileno(fpfilterout), -1);
+ fp_filter_out = fp_out;
+ fp_out = NULL;
+ filterpid = mutt_create_filter_fd(C_DisplayFilter, &fp_out, NULL, NULL, -1,
+ fileno(fp_filter_out), -1);
if (filterpid < 0)
{
mutt_error(_("Cannot create display filter"));
- mutt_file_fclose(&fpfilterout);
+ mutt_file_fclose(&fp_filter_out);
unlink(tempfile);
return 0;
}
hfi.email = cur;
mutt_make_string_info(buf, sizeof(buf), MuttIndexWindow->cols,
NONULL(C_PagerFormat), &hfi, 0);
- fputs(buf, fpout);
- fputs("\n\n", fpout);
+ fputs(buf, fp_out);
+ fputs("\n\n", fp_out);
}
chflags = (C_Weed ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM | CH_DISPLAY;
if (Context->mailbox->magic == MUTT_NOTMUCH)
chflags |= CH_VIRTUAL;
#endif
- res = mutt_copy_message_ctx(fpout, Context->mailbox, cur, cmflags, chflags);
+ res = mutt_copy_message_ctx(fp_out, Context->mailbox, cur, cmflags, chflags);
- if ((mutt_file_fclose(&fpout) != 0 && errno != EPIPE) || res < 0)
+ if ((mutt_file_fclose(&fp_out) != 0 && errno != EPIPE) || res < 0)
{
mutt_error(_("Could not copy message"));
- if (fpfilterout)
+ if (fp_filter_out)
{
mutt_wait_filter(filterpid);
- mutt_file_fclose(&fpfilterout);
+ mutt_file_fclose(&fp_filter_out);
}
mutt_file_unlink(tempfile);
return 0;
}
- if (fpfilterout && mutt_wait_filter(filterpid) != 0)
+ if (fp_filter_out && mutt_wait_filter(filterpid) != 0)
mutt_any_key_to_continue(NULL);
- mutt_file_fclose(&fpfilterout); /* XXX - check result? */
+ mutt_file_fclose(&fp_filter_out); /* XXX - check result? */
if (WithCrypto)
{
int rc = 0;
pid_t pid;
- FILE *fpout = NULL;
+ FILE *fp_out = NULL;
if (!STAILQ_NEXT(en, entries))
{
}
mutt_endwin();
- pid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter process"));
}
OptKeepQuiet = true;
- pipe_msg(m, en->email, fpout, decode, print);
- mutt_file_fclose(&fpout);
+ pipe_msg(m, en->email, fp_out, decode, print);
+ mutt_file_fclose(&fp_out);
rc = mutt_wait_filter(pid);
OptKeepQuiet = false;
}
{
mutt_message_hook(m, en->email, MUTT_MESSAGE_HOOK);
mutt_endwin();
- pid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter process"));
return 1;
}
OptKeepQuiet = true;
- pipe_msg(m, en->email, fpout, decode, print);
+ pipe_msg(m, en->email, fp_out, decode, print);
/* add the message separator */
if (sep)
- fputs(sep, fpout);
- mutt_file_fclose(&fpout);
+ fputs(sep, fp_out);
+ mutt_file_fclose(&fp_out);
if (mutt_wait_filter(pid) != 0)
rc = 1;
OptKeepQuiet = false;
else
{
mutt_endwin();
- pid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter process"));
STAILQ_FOREACH(en, el, entries)
{
mutt_message_hook(m, en->email, MUTT_MESSAGE_HOOK);
- pipe_msg(m, en->email, fpout, decode, print);
+ pipe_msg(m, en->email, fp_out, decode, print);
/* add the message separator */
if (sep)
- fputs(sep, fpout);
+ fputs(sep, fp_out);
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
if (mutt_wait_filter(pid) != 0)
rc = 1;
OptKeepQuiet = false;
return true;
if (excl)
- ci->lockfp = fopen(m->realpath, "a");
+ ci->fp_lock = fopen(m->realpath, "a");
else
- ci->lockfp = fopen(m->realpath, "r");
- if (!ci->lockfp)
+ ci->fp_lock = fopen(m->realpath, "r");
+ if (!ci->fp_lock)
{
mutt_perror(m->realpath);
return false;
}
- int r = mutt_file_lock(fileno(ci->lockfp), excl, true);
+ int r = mutt_file_lock(fileno(ci->fp_lock), excl, true);
if (r == 0)
ci->locked = true;
else if (excl)
{
- mutt_file_fclose(&ci->lockfp);
+ mutt_file_fclose(&ci->fp_lock);
m->readonly = true;
return true;
}
if (!ci->locked)
return;
- mutt_file_unlock(fileno(ci->lockfp));
+ mutt_file_unlock(fileno(ci->fp_lock));
ci->locked = false;
- mutt_file_fclose(&ci->lockfp);
+ mutt_file_fclose(&ci->fp_lock);
}
/**
long size; /**< size of the compressed file */
const struct MxOps *child_ops; /**< callbacks of de-compressed file */
bool locked; /**< if realpath is locked */
- FILE *lockfp; /**< fp used for locking */
+ FILE *fp_lock; /**< fp used for locking */
};
bool mutt_comp_can_append(struct Mailbox *m);
{
gnutls_datum_t cert;
unsigned char *ptr = NULL;
- FILE *fd1 = NULL;
gnutls_datum_t b64_data;
unsigned char *b64_data_data = NULL;
struct stat filestat;
b64_data_data[b64_data.size - 1] = '\0';
b64_data.data = b64_data_data;
- fd1 = fopen(C_CertificateFile, "r");
- if (!fd1)
- {
+ FILE *fp = fopen(C_CertificateFile, "r");
+ if (!fp)
return 0;
- }
- b64_data.size = fread(b64_data.data, 1, b64_data.size, fd1);
- mutt_file_fclose(&fd1);
+ b64_data.size = fread(b64_data.data, 1, b64_data.size, fp);
+ mutt_file_fclose(&fp);
do
{
#endif
static int address_header_decode(char **h);
-static int copy_delete_attach(struct Body *b, FILE *fpin, FILE *fpout, char *date);
+static int copy_delete_attach(struct Body *b, FILE *fp_in, FILE *fp_out, char *date);
/**
* mutt_copy_hdr - Copy header from one file to another
- * @param in FILE pointer to read from
- * @param out FILE pointer to write to
+ * @param fp_in FILE pointer to read from
+ * @param fp_out FILE pointer to write to
* @param off_start Offset to start from
* @param off_end Offset to finish at
* @param chflags Flags, see #CopyHeaderFlags
* avoid creating a Header structure in message_handler(). Also, this one will
* wrap headers much more aggressively than the other one.
*/
-int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end,
+int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end,
CopyHeaderFlags chflags, const char *prefix)
{
bool from = false;
if (off_start < 0)
return -1;
- if (ftello(in) != off_start)
- if (fseeko(in, off_start, SEEK_SET) < 0)
+ if (ftello(fp_in) != off_start)
+ if (fseeko(fp_in, off_start, SEEK_SET) < 0)
return -1;
buf[0] = '\n';
/* Without these flags to complicate things
* we can do a more efficient line to line copying
*/
- while (ftello(in) < off_end)
+ while (ftello(fp_in) < off_end)
{
nl = strchr(buf, '\n');
- if (!fgets(buf, sizeof(buf), in))
+ if (!fgets(buf, sizeof(buf), fp_in))
break;
/* Is it the beginning of a header? */
ignore = false;
}
- if (!ignore && fputs(buf, out) == EOF)
+ if (!ignore && fputs(buf, fp_out) == EOF)
return -1;
}
return 0;
headers = mutt_mem_calloc(hdr_count, sizeof(char *));
/* Read all the headers into the array */
- while (ftello(in) < off_end)
+ while (ftello(fp_in) < off_end)
{
nl = strchr(buf, '\n');
/* Read a line */
- if (!fgets(buf, sizeof(buf), in))
+ if (!fgets(buf, sizeof(buf), fp_in))
break;
/* Is it the beginning of a header? */
this_one_len += blen;
}
}
- } /* while (ftello (in) < off_end) */
+ } /* while (ftello (fp_in) < off_end) */
/* Do we have anything pending? -- XXX, same code as in above in the loop. */
if (this_one)
if (chflags & (CH_DECODE | CH_PREFIX))
{
- if (mutt_write_one_header(out, 0, headers[x], (chflags & CH_PREFIX) ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap),
- chflags) == -1)
+ if (mutt_write_one_header(
+ fp_out, 0, headers[x], (chflags & CH_PREFIX) ? prefix : 0,
+ mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
{
error = true;
break;
}
else
{
- if (fputs(headers[x], out) == EOF)
+ if (fputs(headers[x], fp_out) == EOF)
{
error = true;
break;
/**
* mutt_copy_header - Copy Email header
- * @param in FILE pointer to read from
+ * @param fp_in FILE pointer to read from
* @param e Email
- * @param out FILE pointer to write to
+ * @param fp_out FILE pointer to write to
* @param chflags See #CopyHeaderFlags
* @param prefix Prefix for quoting headers (if #CH_PREFIX is set)
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_copy_header(FILE *in, struct Email *e, FILE *out,
+int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out,
CopyHeaderFlags chflags, const char *prefix)
{
char *temp_hdr = NULL;
((e->env->changed & MUTT_ENV_CHANGED_SUBJECT) ? CH_UPDATE_SUBJECT : 0);
}
- if (mutt_copy_hdr(in, out, e->offset, e->content->offset, chflags, prefix) == -1)
+ if (mutt_copy_hdr(fp_in, fp_out, e->offset, e->content->offset, chflags, prefix) == -1)
return -1;
if (chflags & CH_TXTPLAIN)
{
char chsbuf[128];
char buf[128];
- fputs("MIME-Version: 1.0\n", out);
- fputs("Content-Transfer-Encoding: 8bit\n", out);
- fputs("Content-Type: text/plain; charset=", out);
+ fputs("MIME-Version: 1.0\n", fp_out);
+ fputs("Content-Transfer-Encoding: 8bit\n", fp_out);
+ fputs("Content-Type: text/plain; charset=", fp_out);
mutt_ch_canonical_charset(chsbuf, sizeof(chsbuf), C_Charset ? C_Charset : "us-ascii");
mutt_addr_cat(buf, sizeof(buf), chsbuf, MimeSpecials);
- fputs(buf, out);
- fputc('\n', out);
+ fputs(buf, fp_out);
+ fputc('\n', fp_out);
}
if ((chflags & CH_UPDATE_IRT) && !STAILQ_EMPTY(&e->env->in_reply_to))
{
- fputs("In-Reply-To:", out);
+ fputs("In-Reply-To:", fp_out);
struct ListNode *np = NULL;
STAILQ_FOREACH(np, &e->env->in_reply_to, entries)
{
- fputc(' ', out);
- fputs(np->data, out);
+ fputc(' ', fp_out);
+ fputs(np->data, fp_out);
}
- fputc('\n', out);
+ fputc('\n', fp_out);
}
if ((chflags & CH_UPDATE_REFS) && !STAILQ_EMPTY(&e->env->references))
{
- fputs("References:", out);
- mutt_write_references(&e->env->references, out, 0);
- fputc('\n', out);
+ fputs("References:", fp_out);
+ mutt_write_references(&e->env->references, fp_out, 0);
+ fputc('\n', fp_out);
}
if ((chflags & CH_UPDATE) && (chflags & CH_NOSTATUS) == 0)
{
if (e->old || e->read)
{
- fputs("Status: ", out);
+ fputs("Status: ", fp_out);
if (e->read)
- fputs("RO", out);
+ fputs("RO", fp_out);
else if (e->old)
- fputc('O', out);
- fputc('\n', out);
+ fputc('O', fp_out);
+ fputc('\n', fp_out);
}
if (e->flagged || e->replied)
{
- fputs("X-Status: ", out);
+ fputs("X-Status: ", fp_out);
if (e->replied)
- fputc('A', out);
+ fputc('A', fp_out);
if (e->flagged)
- fputc('F', out);
- fputc('\n', out);
+ fputc('F', fp_out);
+ fputc('\n', fp_out);
}
}
if (chflags & CH_UPDATE_LEN && (chflags & CH_NOLEN) == 0)
{
- fprintf(out, "Content-Length: " OFF_T_FMT "\n", e->content->length);
+ fprintf(fp_out, "Content-Length: " OFF_T_FMT "\n", e->content->length);
if (e->lines != 0 || e->content->length == 0)
- fprintf(out, "Lines: %d\n", e->lines);
+ fprintf(fp_out, "Lines: %d\n", e->lines);
}
#ifdef USE_NOTMUCH
mutt_str_strfcpy(buf, folder, sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
- fputs("Folder: ", out);
- fputs(buf, out);
- fputc('\n', out);
+ fputs("Folder: ", fp_out);
+ fputs(buf, fp_out);
+ fputc('\n', fp_out);
}
}
#endif
char *tags = driver_tags_get(&e->tags);
if (tags && !(C_Weed && mutt_matches_ignore("tags")))
{
- fputs("Tags: ", out);
- fputs(tags, out);
- fputc('\n', out);
+ fputs("Tags: ", fp_out);
+ fputs(tags, fp_out);
+ fputc('\n', fp_out);
}
FREE(&tags);
temp_hdr = mutt_str_strdup(temp_hdr);
rfc2047_encode(&temp_hdr, NULL, sizeof("X-Label:"), C_SendCharset);
}
- if (mutt_write_one_header(out, "X-Label", temp_hdr, chflags & CH_PREFIX ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
+ if (mutt_write_one_header(
+ fp_out, "X-Label", temp_hdr, chflags & CH_PREFIX ? prefix : 0,
+ mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
{
return -1;
}
temp_hdr = mutt_str_strdup(temp_hdr);
rfc2047_encode(&temp_hdr, NULL, sizeof("Subject:"), C_SendCharset);
}
- if (mutt_write_one_header(out, "Subject", temp_hdr, chflags & CH_PREFIX ? prefix : 0,
- mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
+ if (mutt_write_one_header(
+ fp_out, "Subject", temp_hdr, chflags & CH_PREFIX ? prefix : 0,
+ mutt_window_wrap_cols(MuttIndexWindow, C_Wrap), chflags) == -1)
return -1;
if (!(chflags & CH_DECODE))
FREE(&temp_hdr);
if ((chflags & CH_NONEWLINE) == 0)
{
if (chflags & CH_PREFIX)
- fputs(prefix, out);
- fputc('\n', out); /* add header terminator */
+ fputs(prefix, fp_out);
+ fputc('\n', fp_out); /* add header terminator */
}
- if (ferror(out) || feof(out))
+ if (ferror(fp_out) || feof(fp_out))
return -1;
return 0;
/**
* mutt_copy_message_fp - make a copy of a message from a FILE pointer
- * @param fpout Where to write output
- * @param fpin Where to get input
+ * @param fp_out Where to write output
+ * @param fp_in Where to get input
* @param e Email being copied
* @param cmflags Flags, see #CopyMessageFlags
* @param chflags Flags, see #CopyHeaderFlags
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e,
+int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
CopyMessageFlags cmflags, CopyHeaderFlags chflags)
{
struct Body *body = e->content;
date[dlen - 1] = '\"';
/* Count the number of lines and bytes to be deleted */
- fseeko(fpin, body->offset, SEEK_SET);
- new_lines = e->lines - count_delete_lines(fpin, body, &new_length, dlen);
+ fseeko(fp_in, body->offset, SEEK_SET);
+ new_lines = e->lines - count_delete_lines(fp_in, body, &new_length, dlen);
/* Copy the headers */
- if (mutt_copy_header(fpin, e, fpout, chflags | CH_NOLEN | CH_NONEWLINE, NULL))
+ if (mutt_copy_header(fp_in, e, fp_out, chflags | CH_NOLEN | CH_NONEWLINE, NULL))
return -1;
- fprintf(fpout, "Content-Length: " OFF_T_FMT "\n", new_length);
+ fprintf(fp_out, "Content-Length: " OFF_T_FMT "\n", new_length);
if (new_lines <= 0)
new_lines = 0;
else
- fprintf(fpout, "Lines: %d\n", new_lines);
+ fprintf(fp_out, "Lines: %d\n", new_lines);
- putc('\n', fpout);
- if (ferror(fpout) || feof(fpout))
+ putc('\n', fp_out);
+ if (ferror(fp_out) || feof(fp_out))
return -1;
- new_offset = ftello(fpout);
+ new_offset = ftello(fp_out);
/* Copy the body */
- if (fseeko(fpin, body->offset, SEEK_SET) < 0)
+ if (fseeko(fp_in, body->offset, SEEK_SET) < 0)
return -1;
- if (copy_delete_attach(body, fpin, fpout, date))
+ if (copy_delete_attach(body, fp_in, fp_out, date))
return -1;
- LOFF_T fail = ((ftello(fpout) - new_offset) - new_length);
+ LOFF_T fail = ((ftello(fp_out) - new_offset) - new_length);
if (fail)
{
mutt_error(ngettext("The length calculation was wrong by %ld byte",
return 0;
}
- if (mutt_copy_header(fpin, e, fpout, chflags, (chflags & CH_PREFIX) ? prefix : NULL) == -1)
+ if (mutt_copy_header(fp_in, e, fp_out, chflags,
+ (chflags & CH_PREFIX) ? prefix : NULL) == -1)
{
return -1;
}
- new_offset = ftello(fpout);
+ new_offset = ftello(fp_out);
}
if (cmflags & MUTT_CM_DECODE)
{
/* now make a text/plain version of the message */
struct State s = { 0 };
- s.fp_in = fpin;
- s.fp_out = fpout;
+ s.fp_in = fp_in;
+ s.fp_out = fp_out;
if (cmflags & MUTT_CM_PREFIX)
s.prefix = prefix;
if (cmflags & MUTT_CM_DISPLAY)
if (((WithCrypto & APPLICATION_PGP) != 0) && (cmflags & MUTT_CM_DECODE_PGP) &&
(e->security & APPLICATION_PGP) && e->content->type == TYPE_MULTIPART)
{
- if (crypt_pgp_decrypt_mime(fpin, &fp, e->content, &cur))
+ if (crypt_pgp_decrypt_mime(fp_in, &fp, e->content, &cur))
return -1;
- fputs("MIME-Version: 1.0\n", fpout);
+ fputs("MIME-Version: 1.0\n", fp_out);
}
if (((WithCrypto & APPLICATION_SMIME) != 0) && (cmflags & MUTT_CM_DECODE_SMIME) &&
(e->security & APPLICATION_SMIME) && e->content->type == TYPE_APPLICATION)
{
- if (crypt_smime_decrypt_mime(fpin, &fp, e->content, &cur))
+ if (crypt_smime_decrypt_mime(fp_in, &fp, e->content, &cur))
return -1;
}
return -1;
}
- mutt_write_mime_header(cur, fpout);
- fputc('\n', fpout);
+ mutt_write_mime_header(cur, fp_out);
+ fputc('\n', fp_out);
if (fseeko(fp, cur->offset, SEEK_SET) < 0)
return -1;
- if (mutt_file_copy_bytes(fp, fpout, cur->length) == -1)
+ if (mutt_file_copy_bytes(fp, fp_out, cur->length) == -1)
{
mutt_file_fclose(&fp);
mutt_body_free(&cur);
}
else
{
- if (fseeko(fpin, body->offset, SEEK_SET) < 0)
+ if (fseeko(fp_in, body->offset, SEEK_SET) < 0)
return -1;
if (cmflags & MUTT_CM_PREFIX)
{
int c;
size_t bytes = body->length;
- fputs(prefix, fpout);
+ fputs(prefix, fp_out);
- while ((c = fgetc(fpin)) != EOF && bytes--)
+ while ((c = fgetc(fp_in)) != EOF && bytes--)
{
- fputc(c, fpout);
+ fputc(c, fp_out);
if (c == '\n')
{
- fputs(prefix, fpout);
+ fputs(prefix, fp_out);
}
}
}
- else if (mutt_file_copy_bytes(fpin, fpout, body->length) == -1)
+ else if (mutt_file_copy_bytes(fp_in, fp_out, body->length) == -1)
return -1;
}
/**
* mutt_copy_message_ctx - Copy a message from a Context
- * @param fpout FILE pointer to write to
+ * @param fp_out FILE pointer to write to
* @param src Source mailbox
* @param e Email
* @param cmflags Flags, see #CopyMessageFlags
* should be made to return -1 on fatal errors, and 1 on non-fatal errors
* like partial decode, where it is worth displaying as much as possible
*/
-int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e,
+int mutt_copy_message_ctx(FILE *fp_out, struct Mailbox *src, struct Email *e,
CopyMessageFlags cmflags, CopyHeaderFlags chflags)
{
struct Message *msg = mx_msg_open(src, e->msgno);
return -1;
if (!e->content)
return -1;
- int r = mutt_copy_message_fp(fpout, msg->fp, e, cmflags, chflags);
- if ((r == 0) && (ferror(fpout) || feof(fpout)))
+ int r = mutt_copy_message_fp(fp_out, msg->fp, e, cmflags, chflags);
+ if ((r == 0) && (ferror(fp_out) || feof(fp_out)))
{
mutt_debug(LL_DEBUG1, "failed to detect EOF!\n");
r = -1;
/**
* append_message - appends a copy of the given message to a mailbox
* @param dest destination mailbox
- * @param fpin where to get input
+ * @param fp_in where to get input
* @param src source mailbox
* @param e Email being copied
* @param cmflags Flags, see #CopyMessageFlags
* @retval 0 Success
* @retval -1 Error
*/
-static int append_message(struct Mailbox *dest, FILE *fpin, struct Mailbox *src,
+static int append_message(struct Mailbox *dest, FILE *fp_in, struct Mailbox *src,
struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
{
char buf[256];
struct Message *msg = NULL;
int r;
- if (fseeko(fpin, e->offset, SEEK_SET) < 0)
+ if (fseeko(fp_in, e->offset, SEEK_SET) < 0)
return -1;
- if (!fgets(buf, sizeof(buf), fpin))
+ if (!fgets(buf, sizeof(buf), fp_in))
return -1;
msg = mx_msg_open_new(dest, e, is_from(buf, NULL, 0, NULL) ? 0 : MUTT_ADD_FROM);
if (dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF)
chflags |= CH_FROM | CH_FORCE_FROM;
chflags |= (dest->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
- r = mutt_copy_message_fp(msg->fp, fpin, e, cmflags, chflags);
+ r = mutt_copy_message_fp(msg->fp, fp_in, e, cmflags, chflags);
if (mx_msg_commit(dest, msg) != 0)
r = -1;
/**
* copy_delete_attach - Copy a message, deleting marked attachments
* @param b Email Body
- * @param fpin FILE pointer to read from
- * @param fpout FILE pointer to write to
+ * @param fp_in FILE pointer to read from
+ * @param fp_out FILE pointer to write to
* @param date Date stamp
* @retval 0 Success
* @retval -1 Failure
* any attachments which are marked for deletion.
* Nothing is changed in the original message -- this is left to the caller.
*/
-static int copy_delete_attach(struct Body *b, FILE *fpin, FILE *fpout, char *date)
+static int copy_delete_attach(struct Body *b, FILE *fp_in, FILE *fp_out, char *date)
{
struct Body *part = NULL;
if (part->deleted || part->parts)
{
/* Copy till start of this part */
- if (mutt_file_copy_bytes(fpin, fpout, part->hdr_offset - ftello(fpin)))
+ if (mutt_file_copy_bytes(fp_in, fp_out, part->hdr_offset - ftello(fp_in)))
return -1;
if (part->deleted)
{
fprintf(
- fpout,
+ fp_out,
"Content-Type: message/external-body; access-type=x-mutt-deleted;\n"
"\texpiration=%s; length=" OFF_T_FMT "\n"
"\n",
date + 5, part->length);
- if (ferror(fpout))
+ if (ferror(fp_out))
return -1;
/* Copy the original mime headers */
- if (mutt_file_copy_bytes(fpin, fpout, part->offset - ftello(fpin)))
+ if (mutt_file_copy_bytes(fp_in, fp_out, part->offset - ftello(fp_in)))
return -1;
/* Skip the deleted body */
- fseeko(fpin, part->offset + part->length, SEEK_SET);
+ fseeko(fp_in, part->offset + part->length, SEEK_SET);
}
else
{
- if (copy_delete_attach(part, fpin, fpout, date))
+ if (copy_delete_attach(part, fp_in, fp_out, date))
return -1;
}
}
}
/* Copy the last parts */
- if (mutt_file_copy_bytes(fpin, fpout, b->offset + b->length - ftello(fpin)))
+ if (mutt_file_copy_bytes(fp_in, fp_out, b->offset + b->length - ftello(fp_in)))
return -1;
return 0;
#define CH_UPDATE_SUBJECT (1 << 20) ///< Update Subject: protected header update
#define CH_VIRTUAL (1 << 21) ///< Write virtual header lines too
-int mutt_copy_hdr(FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix);
+int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix);
-int mutt_copy_header(FILE *in, struct Email *e, FILE *out, CopyHeaderFlags chflags, const char *prefix);
+int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out, CopyHeaderFlags chflags, const char *prefix);
-int mutt_copy_message_fp(FILE *fpout, FILE *fpin, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
-int mutt_copy_message_ctx(FILE *fpout, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
+int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
+int mutt_copy_message_ctx(FILE *fp_out, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
/**
* be_snarf_data - Read data from a file into a buffer
- * @param[in] f File to read from
+ * @param[in] fp File to read from
* @param[out] buf Buffer allocated to save data
* @param[out] bufmax Allocated size of buffer
* @param[out] buflen Bytes of buffer used
* @param[in] prefix If true, prefix the lines with the #C_IndentString
* @retval ptr Pointer to allocated buffer
*/
-static char **be_snarf_data(FILE *f, char **buf, int *bufmax, int *buflen,
+static char **be_snarf_data(FILE *fp, char **buf, int *bufmax, int *buflen,
LOFF_T offset, int bytes, int prefix)
{
char tmp[8192];
tmplen = sizeof(tmp) - tmplen;
}
- fseeko(f, offset, SEEK_SET);
+ fseeko(fp, offset, SEEK_SET);
while (bytes > 0)
{
- if (!fgets(p, tmplen - 1, f))
+ if (!fgets(p, tmplen - 1, fp))
break;
bytes -= mutt_str_strlen(p);
if (*bufmax == *buflen)
char tmp[1024];
struct stat sb;
- FILE *f = fopen(path, "r");
- if (f)
+ FILE *fp = fopen(path, "r");
+ if (fp)
{
- fstat(fileno(f), &sb);
- buf = be_snarf_data(f, buf, max, len, 0, sb.st_size, 0);
+ fstat(fileno(fp), &sb);
+ buf = be_snarf_data(fp, buf, max, len, 0, sb.st_size, 0);
if (verbose)
{
snprintf(tmp, sizeof(tmp), "\"%s\" %lu bytes\n", path, (unsigned long) sb.st_size);
addstr(tmp);
}
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
}
else
{
*/
static int be_barf_file(const char *path, char **buf, int buflen)
{
- FILE *f = fopen(path, "w");
- if (!f)
+ FILE *fp = fopen(path, "w");
+ if (!fp)
{
addstr(strerror(errno));
addch('\n');
return -1;
}
for (int i = 0; i < buflen; i++)
- fputs(buf[i], f);
- if (fclose(f) == 0)
+ fputs(buf[i], fp);
+ if (fclose(fp) == 0)
return 0;
printw("fclose: %s\n", strerror(errno));
return -1;
/**
* mutt_actx_add_fp - Save a File handle to the Attachment Context
* @param actx Attachment context
- * @param new_fp File handle to save
+ * @param fp_new File handle to save
*/
-void mutt_actx_add_fp(struct AttachCtx *actx, FILE *new_fp)
+void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new)
{
if (actx->fp_len == actx->fp_max)
{
actx->fp_idx[i] = NULL;
}
- actx->fp_idx[actx->fp_len++] = new_fp;
+ actx->fp_idx[actx->fp_len++] = fp_new;
}
/**
struct AttachCtx
{
struct Email *email; /**< used by recvattach for updating */
- FILE *root_fp; /**< used by recvattach for updating */
+ FILE *fp_root; /**< used by recvattach for updating */
struct AttachPtr **idx;
short idxlen;
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach);
void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body);
-void mutt_actx_add_fp(struct AttachCtx *actx, FILE *new_fp);
+void mutt_actx_add_fp(struct AttachCtx *actx, FILE *fp_new);
void mutt_actx_free(struct AttachCtx **pactx);
void mutt_actx_free_entries(struct AttachCtx *actx);
/**
* mutt_rfc822_read_line - Read a header line from a file
- * @param f File to read from
+ * @param fp File to read from
* @param line Buffer to store the result
* @param linelen Length of buffer
* @retval ptr Line read from file
* lines. "line" must point to a dynamically allocated string; it is
* increased if more space is required to fit the whole line.
*/
-char *mutt_rfc822_read_line(FILE *f, char *line, size_t *linelen)
+char *mutt_rfc822_read_line(FILE *fp, char *line, size_t *linelen)
{
char *buf = line;
int ch;
while (true)
{
- if (!fgets(buf, *linelen - offset, f) || /* end of file or */
- (ISSPACE(*line) && !offset)) /* end of headers */
+ if (!fgets(buf, *linelen - offset, fp) || /* end of file or */
+ (ISSPACE(*line) && !offset)) /* end of headers */
{
*line = 0;
return line;
}
/* check to see if the next line is a continuation line */
- ch = fgetc(f);
+ ch = fgetc(fp);
if ((ch != ' ') && (ch != '\t'))
{
- ungetc(ch, f);
+ ungetc(ch, fp);
return line; /* next line is a separate header field or EOH */
}
/* eat tabs and spaces from the beginning of the continuation line */
- while (((ch = fgetc(f)) == ' ') || (ch == '\t'))
+ while (((ch = fgetc(fp)) == ' ') || (ch == '\t'))
;
- ungetc(ch, f);
+ ungetc(ch, fp);
*++buf = ' '; /* string is still terminated because we removed
at least one whitespace char above */
}
/**
* mutt_rfc822_read_header - parses an RFC822 header
- * @param f Stream to read from
+ * @param fp Stream to read from
* @param e Current Email (optional)
* @param user_hdrs If set, store user headers
* Used for recall-message and postpone modes
*
* Caller should free the Envelope using mutt_env_free().
*/
-struct Envelope *mutt_rfc822_read_header(FILE *f, struct Email *e, bool user_hdrs, bool weed)
+struct Envelope *mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed)
{
struct Envelope *env = mutt_env_new();
char *p = NULL;
}
}
- while ((loc = ftello(f)) != -1)
+ while ((loc = ftello(fp)) != -1)
{
- line = mutt_rfc822_read_line(f, line, &linelen);
+ line = mutt_rfc822_read_line(fp, line, &linelen);
if (*line == '\0')
break;
p = strpbrk(line, ": \t");
continue;
}
- fseeko(f, loc, SEEK_SET);
+ fseeko(fp, loc, SEEK_SET);
break; /* end of header */
}
if (e)
{
e->content->hdr_offset = e->offset;
- e->content->offset = ftello(f);
+ e->content->offset = ftello(fp);
rfc2047_decode_envelope(env);
struct Body * mutt_read_mime_header(FILE *fp, bool digest);
int mutt_rfc822_parse_line(struct Envelope *env, struct Email *e, char *line, char *p, bool user_hdrs, bool weed, bool do_2047);
struct Body * mutt_rfc822_parse_message(FILE *fp, struct Body *parent);
-struct Envelope *mutt_rfc822_read_header(FILE *f, struct Email *e, bool user_hdrs, bool weed);
-char * mutt_rfc822_read_line(FILE *f, char *line, size_t *linelen);
+struct Envelope *mutt_rfc822_read_header(FILE *fp, struct Email *e, bool user_hdrs, bool weed);
+char * mutt_rfc822_read_line(FILE *fp, char *line, size_t *linelen);
#endif /* MUTT_EMAIL_PARSE_H */
/**
* mutt_create_filter_fd - Run a command on a pipe (optionally connect stdin/stdout)
- * @param[in] cmd Command line to invoke using `sh -c`
- * @param[out] in File stream pointing to stdin for the command process, can be NULL
- * @param[out] out File stream pointing to stdout for the command process, can be NULL
- * @param[out] err File stream pointing to stderr for the command process, can be NULL
- * @param[in] fdin If `in` is NULL and fdin is not -1 then fdin will be used as stdin for the command process
- * @param[in] fdout If `out` is NULL and fdout is not -1 then fdout will be used as stdout for the command process
- * @param[in] fderr If `error` is NULL and fderr is not -1 then fderr will be used as stderr for the command process
+ * @param[in] cmd Command line to invoke using `sh -c`
+ * @param[out] fp_in File stream pointing to stdin for the command process, can be NULL
+ * @param[out] fp_out File stream pointing to stdout for the command process, can be NULL
+ * @param[out] fp_err File stream pointing to stderr for the command process, can be NULL
+ * @param[in] fdin If `in` is NULL and fdin is not -1 then fdin will be used as stdin for the command process
+ * @param[in] fdout If `out` is NULL and fdout is not -1 then fdout will be used as stdout for the command process
+ * @param[in] fderr If `error` is NULL and fderr is not -1 then fderr will be used as stderr for the command process
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
* mutt_create_filter_fd(commandline, NULL, NULL, NULL, -1, -1, -1);
* @endcode
*
- * Additionally, in, out, and err will point to FILE* streams representing the
- * processes stdin, stdout, and stderr.
+ * Additionally, fp_in, fp_out, and fp_err will point to FILE* streams
+ * representing the processes stdin, stdout, and stderr.
*/
-pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err,
- int fdin, int fdout, int fderr)
+pid_t mutt_create_filter_fd(const char *cmd, FILE **fp_in, FILE **fp_out,
+ FILE **fp_err, int fdin, int fdout, int fderr)
{
int pin[2], pout[2], perr[2], pid;
- if (in)
+ if (fp_in)
{
- *in = 0;
+ *fp_in = 0;
if (pipe(pin) == -1)
return -1;
}
- if (out)
+ if (fp_out)
{
- *out = 0;
+ *fp_out = 0;
if (pipe(pout) == -1)
{
- if (in)
+ if (fp_in)
{
close(pin[0]);
close(pin[1]);
}
}
- if (err)
+ if (fp_err)
{
- *err = 0;
+ *fp_err = 0;
if (pipe(perr) == -1)
{
- if (in)
+ if (fp_in)
{
close(pin[0]);
close(pin[1]);
}
- if (out)
+ if (fp_out)
{
close(pout[0]);
close(pout[1]);
{
mutt_sig_unblock_system(false);
- if (in)
+ if (fp_in)
{
close(pin[1]);
dup2(pin[0], 0);
close(fdin);
}
- if (out)
+ if (fp_out)
{
close(pout[0]);
dup2(pout[1], 1);
close(fdout);
}
- if (err)
+ if (fp_err)
{
close(perr[0]);
dup2(perr[1], 2);
{
mutt_sig_unblock_system(true);
- if (in)
+ if (fp_in)
{
close(pin[0]);
close(pin[1]);
}
- if (out)
+ if (fp_out)
{
close(pout[0]);
close(pout[1]);
}
- if (err)
+ if (fp_err)
{
close(perr[0]);
close(perr[1]);
return -1;
}
- if (out)
+ if (fp_out)
{
close(pout[1]);
- *out = fdopen(pout[0], "r");
+ *fp_out = fdopen(pout[0], "r");
}
- if (in)
+ if (fp_in)
{
close(pin[0]);
- *in = fdopen(pin[1], "w");
+ *fp_in = fdopen(pin[1], "w");
}
- if (err)
+ if (fp_err)
{
close(perr[1]);
- *err = fdopen(perr[0], "r");
+ *fp_err = fdopen(perr[0], "r");
}
return pid;
/**
* mutt_create_filter - Set up filter program
- * @param[in] s Command string
- * @param[out] in FILE pointer of stdin
- * @param[out] out FILE pointer of stdout
- * @param[out] err FILE pointer of stderr
+ * @param[in] s Command string
+ * @param[out] fp_in FILE pointer of stdin
+ * @param[out] fp_out FILE pointer of stdout
+ * @param[out] fp_err FILE pointer of stderr
* @retval num PID of filter
*/
-pid_t mutt_create_filter(const char *s, FILE **in, FILE **out, FILE **err)
+pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err)
{
- return mutt_create_filter_fd(s, in, out, err, -1, -1, -1);
+ return mutt_create_filter_fd(s, fp_in, fp_out, fp_err, -1, -1, -1);
}
/**
#include <stdio.h>
#include <unistd.h>
-pid_t mutt_create_filter_fd(const char *cmd, FILE **in, FILE **out, FILE **err,
- int fdin, int fdout, int fderr);
-pid_t mutt_create_filter(const char *s, FILE **in, FILE **out, FILE **err);
+pid_t mutt_create_filter_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr);
+pid_t mutt_create_filter(const char *s, FILE **fp_in, FILE **fp_out, FILE **fp_err);
int mutt_wait_filter(pid_t pid);
int mutt_wait_interactive_filter (pid_t pid);
--- /dev/null
+s/\<attf\>/fp_att/g
+s/\<bfp\>/fp_body/g
+s/\<decoded_fp\>/fp_decoded/g
+s/\<devnull\>/fp_null/g
+s/\<err\>/fp_err/g
+s/\<fd1\>/fp/g
+s/\<file\>/fp_file/g
+s/\<filter\>/fp_filter/g
+s/\<fin\>/fp_in/g
+s/\<fout\>/fp_out/g
+s/\<fperr\>/fp_err/g
+s/\<fpfilterout\>/fp_filter_out/g
+s/\<fpin\>/fp_in/g
+s/\<fpout\>/fp_out/g
+s/\<fptmp\>/fp_tmp/g
+s/\<frandom\>/fp_random/g
+s/\<f\>/fp/g
+s/\<ifp\>/fp_in/g
+s/\<in\>/fp_in/g
+s/\<lockfp\>/fp_lock/g
+s/\<newsrc_fp\>/fp_newsrc/g
+s/\<new_fp\>/fp_new/g
+s/\<nfp\>/fp_new/g
+s/\<ofp\>/fp_old/g
+s/\<ofp\>/fp_out/g
+s/\<out\>/fp_out/g
+s/\<parent_fp\>/fp_parent/g
+s/\<pgperr\>/fp_pgp_err/g
+s/\<pgpin\>/fp_pgp_in/g
+s/\<pgpout\>/fp_pgp_out/g
+s/\<pgptmp\>/fp_pgp_tmp/g
+s/\<ret_fp\>/fp_ret/g
+s/\<root_fp\>/fp_root/g
+s/\<savefp\>/fp_save/g
+s/\<sfp\>/fp_signed/g
+s/\<smimeerr\>/fp_smime_err/g
+s/\<smimein\>/fp_smime_in/g
+s/\<smimeout\>/fp_smime_out/g
+s/\<tempfp\>/fp_tmp/g
+s/\<tfp\>/fp_tmp/g
+s/\<tmpfp2\>/fp_tmp2/g
+s/\<tmpfp\>/fp_tmp/g
+s/\<tmpfp_buffer\>/fp_tmp_buffer/g
char cmd[STR_COMMAND];
char tempfile[PATH_MAX] = "";
char *fname = NULL;
- FILE *fpin = NULL;
- FILE *fpout = NULL;
- FILE *fperr = NULL;
+ FILE *fp_in = NULL;
+ FILE *fp_out = NULL;
+ FILE *fp_err = NULL;
int piped = false;
pid_t pid;
int rc = 0;
mutt_message(_("Invoking autoview command: %s"), cmd);
}
- fpin = mutt_file_fopen(tempfile, "w+");
- if (!fpin)
+ fp_in = mutt_file_fopen(tempfile, "w+");
+ if (!fp_in)
{
mutt_perror("fopen");
rfc1524_free_entry(&entry);
return -1;
}
- mutt_file_copy_bytes(s->fp_in, fpin, a->length);
+ mutt_file_copy_bytes(s->fp_in, fp_in, a->length);
if (!piped)
{
- mutt_file_fclose(&fpin);
- pid = mutt_create_filter(cmd, NULL, &fpout, &fperr);
+ mutt_file_fclose(&fp_in);
+ pid = mutt_create_filter(cmd, NULL, &fp_out, &fp_err);
}
else
{
unlink(tempfile);
- fflush(fpin);
- rewind(fpin);
- pid = mutt_create_filter_fd(cmd, NULL, &fpout, &fperr, fileno(fpin), -1, -1);
+ fflush(fp_in);
+ rewind(fp_in);
+ pid = mutt_create_filter_fd(cmd, NULL, &fp_out, &fp_err, fileno(fp_in), -1, -1);
}
if (pid < 0)
if (s->prefix)
{
- while (fgets(buf, sizeof(buf), fpout))
+ while (fgets(buf, sizeof(buf), fp_out))
{
state_puts(s->prefix, s);
state_puts(buf, s);
}
/* check for data on stderr */
- if (fgets(buf, sizeof(buf), fperr))
+ if (fgets(buf, sizeof(buf), fp_err))
{
if (s->flags & MUTT_DISPLAY)
{
state_puts(s->prefix, s);
state_puts(buf, s);
- while (fgets(buf, sizeof(buf), fperr))
+ while (fgets(buf, sizeof(buf), fp_err))
{
state_puts(s->prefix, s);
state_puts(buf, s);
}
else
{
- mutt_file_copy_stream(fpout, s->fp_out);
+ mutt_file_copy_stream(fp_out, s->fp_out);
/* Check for stderr messages */
- if (fgets(buf, sizeof(buf), fperr))
+ if (fgets(buf, sizeof(buf), fp_err))
{
if (s->flags & MUTT_DISPLAY)
{
}
state_puts(buf, s);
- mutt_file_copy_stream(fperr, s->fp_out);
+ mutt_file_copy_stream(fp_err, s->fp_out);
}
}
bail:
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
mutt_wait_filter(pid);
if (piped)
- mutt_file_fclose(&fpin);
+ mutt_file_fclose(&fp_in);
else
mutt_file_unlink(tempfile);
/**
* print_macro - Print a macro string to a file
- * @param[in] f File to write to
+ * @param[in] fp File to write to
* @param[in] maxwidth Maximum width in screen columns
* @param[out] macro Macro string
* @retval num Number of screen columns used
*
* The `macro` pointer is move past the string we've printed
*/
-static int print_macro(FILE *f, int maxwidth, const char **macro)
+static int print_macro(FILE *fp, int maxwidth, const char **macro)
{
int n = maxwidth;
wchar_t wc;
if ((n1 = wcrtomb(buf, wc, &mbstate2)) != (size_t)(-1) &&
(n2 = wcrtomb(buf + n1, 0, &mbstate2)) != (size_t)(-1))
{
- fputs(buf, f);
+ fputs(buf, fp);
}
}
}
break;
n -= 2;
if (wc == '\033')
- fprintf(f, "\\e");
+ fprintf(fp, "\\e");
else if (wc == '\n')
- fprintf(f, "\\n");
+ fprintf(fp, "\\n");
else if (wc == '\r')
- fprintf(f, "\\r");
+ fprintf(fp, "\\r");
else if (wc == '\t')
- fprintf(f, "\\t");
+ fprintf(fp, "\\t");
else
- fprintf(f, "^%c", (char) ((wc + '@') & 0x7f));
+ fprintf(fp, "^%c", (char) ((wc + '@') & 0x7f));
}
else
{
if (n < 1)
break;
n -= 1;
- fprintf(f, "?");
+ fprintf(fp, "?");
}
}
return maxwidth - n;
/**
* pad - Write some padding to a file
- * @param f File to write to
+ * @param fp File to write to
* @param col Current screen column
* @param i Screen column to pad until
* @retval col Padding was added
* @retval i Content was already wider than col
*/
-static int pad(FILE *f, int col, int i)
+static int pad(FILE *fp, int col, int i)
{
if (col < i)
{
char fmt[32] = "";
snprintf(fmt, sizeof(fmt), "%%-%ds", i - col);
- fprintf(f, fmt, "");
+ fprintf(fp, fmt, "");
return i;
}
- fputc(' ', f);
+ fputc(' ', fp);
return col + 1;
}
/**
* format_line - Write a formatted line to a file
- * @param f File to write to
+ * @param fp File to write to
* @param ismacro Layout mode, see below
* @param t1 Text part 1
* @param t2 Text part 2
* * 0 : Non-macro
* * -1 : Macro with no description
*/
-static void format_line(FILE *f, int ismacro, const char *t1, const char *t2, const char *t3)
+static void format_line(FILE *fp, int ismacro, const char *t1, const char *t2, const char *t3)
{
int col;
int col_b;
bool split;
- fputs(t1, f);
+ fputs(t1, fp);
/* don't try to press string into one line with less than 40 characters. */
split = (MuttIndexWindow->cols < 40);
{
col = 0;
col_b = 1024;
- fputc('\n', f);
+ fputc('\n', fp);
}
else
{
const int col_a = MuttIndexWindow->cols > 83 ? (MuttIndexWindow->cols - 32) >> 2 : 12;
col_b = MuttIndexWindow->cols > 49 ? (MuttIndexWindow->cols - 10) >> 1 : 19;
- col = pad(f, mutt_strwidth(t1), col_a);
+ col = pad(fp, mutt_strwidth(t1), col_a);
}
if (ismacro > 0)
{
if (mutt_str_strcmp(C_Pager, "builtin") == 0)
- fputs("_\010", f);
- fputs("M ", f);
+ fputs("_\010", fp);
+ fputs("M ", fp);
col += 2;
if (!split)
{
- col += print_macro(f, col_b - col - 4, &t2);
+ col += print_macro(fp, col_b - col - 4, &t2);
if (mutt_strwidth(t2) > col_b - col)
t2 = "...";
}
}
- col += print_macro(f, col_b - col - 1, &t2);
+ col += print_macro(fp, col_b - col - 1, &t2);
if (split)
- fputc('\n', f);
+ fputc('\n', fp);
else
- col = pad(f, col, col_b);
+ col = pad(fp, col, col_b);
if (split)
{
- print_macro(f, 1024, &t3);
- fputc('\n', f);
+ print_macro(fp, 1024, &t3);
+ fputc('\n', fp);
}
else
{
n = get_wrapped_width(t3, n);
}
- n = print_macro(f, n, &t3);
+ n = print_macro(fp, n, &t3);
if (*t3)
{
if (mutt_str_strcmp(C_Pager, "builtin") != 0)
{
- fputc('\n', f);
+ fputc('\n', fp);
n = 0;
}
else
if (C_Markers)
n++;
}
- col = pad(f, n, col_b);
+ col = pad(fp, n, col_b);
}
}
}
- fputc('\n', f);
+ fputc('\n', fp);
}
/**
* dump_menu - Write all the key bindings to a file
- * @param f File to write to
+ * @param fp File to write to
* @param menu Current Menu
*/
-static void dump_menu(FILE *f, int menu)
+static void dump_menu(FILE *fp, int menu)
{
struct Keymap *map = NULL;
const struct Binding *b = NULL;
if (map->op == OP_MACRO)
{
if (!map->desc)
- format_line(f, -1, buf, "macro", map->macro);
+ format_line(fp, -1, buf, "macro", map->macro);
else
- format_line(f, 1, buf, map->macro, map->desc);
+ format_line(fp, 1, buf, map->macro, map->desc);
}
else
{
b = help_lookup_function(map->op, menu);
- format_line(f, 0, buf, b ? b->name : "UNKNOWN",
+ format_line(fp, 0, buf, b ? b->name : "UNKNOWN",
b ? _(HelpStrings[b->op]) : _("ERROR: please report this bug"));
}
}
/**
* dump_unbound - Write out all the operations with no key bindings
- * @param f File to write to
+ * @param fp File to write to
* @param funcs All the bindings for the current menu
* @param map First key map to consider
* @param aux Second key map to consider
*/
-static void dump_unbound(FILE *f, const struct Binding *funcs,
+static void dump_unbound(FILE *fp, const struct Binding *funcs,
struct Keymap *map, struct Keymap *aux)
{
for (int i = 0; funcs[i].name; i++)
{
if (!is_bound(map, funcs[i].op) && (!aux || !is_bound(aux, funcs[i].op)))
- format_line(f, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]));
+ format_line(fp, 0, funcs[i].name, "", _(HelpStrings[funcs[i].op]));
}
}
{
char t[PATH_MAX];
char buf[128];
- FILE *f = NULL;
+ FILE *fp = NULL;
mutt_mktemp(t, sizeof(t));
do
{
- f = mutt_file_fopen(t, "w");
- if (!f)
+ fp = mutt_file_fopen(t, "w");
+ if (!fp)
{
mutt_perror(t);
return;
}
- dump_menu(f, menu);
+ dump_menu(fp, menu);
if (menu != MENU_EDITOR && menu != MENU_PAGER)
{
- fprintf(f, "\n%s\n\n", _("Generic bindings:"));
- dump_menu(f, MENU_GENERIC);
+ fprintf(fp, "\n%s\n\n", _("Generic bindings:"));
+ dump_menu(fp, MENU_GENERIC);
}
- fprintf(f, "\n%s\n\n", _("Unbound functions:"));
+ fprintf(fp, "\n%s\n\n", _("Unbound functions:"));
if (funcs)
- dump_unbound(f, funcs, Keymaps[menu], NULL);
+ dump_unbound(fp, funcs, Keymaps[menu], NULL);
if (menu != MENU_PAGER)
- dump_unbound(f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
+ dump_unbound(fp, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
snprintf(buf, sizeof(buf), _("Help for %s"), desc);
} while (mutt_do_pager(buf, t, MUTT_PAGER_RETWINCH | MUTT_PAGER_MARKER | MUTT_PAGER_NSKIP | MUTT_PAGER_NOWRAP,
static enum CommandResult icmd_bind(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
- FILE *fpout = NULL;
+ FILE *fp_out = NULL;
char tempfile[PATH_MAX];
bool dump_all = false, bind = (data == 0);
}
mutt_mktemp(tempfile, sizeof(tempfile));
- fpout = mutt_file_fopen(tempfile, "w");
- if (!fpout)
+ fp_out = mutt_file_fopen(tempfile, "w");
+ if (!fp_out)
{
mutt_buffer_printf(err, _("Could not create temporary file %s"), tempfile);
mutt_buffer_free(&filebuf);
return MUTT_CMD_ERROR;
}
- fputs(filebuf->data, fpout);
+ fputs(filebuf->data, fp_out);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
mutt_buffer_free(&filebuf);
struct Pager info = { 0 };
char tempfile[PATH_MAX];
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *fpout = mutt_file_fopen(tempfile, "w");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfile, "w");
+ if (!fp_out)
{
mutt_buffer_addstr(err, _("Could not create temporary file"));
return MUTT_CMD_ERROR;
if (mutt_str_strcmp(s->data, "set all") == 0)
{
- dump_config(Config, CS_DUMP_STYLE_NEO, 0, fpout);
+ dump_config(Config, CS_DUMP_STYLE_NEO, 0, fp_out);
}
else if (mutt_str_strcmp(s->data, "set") == 0)
{
- dump_config(Config, CS_DUMP_STYLE_NEO, CS_DUMP_ONLY_CHANGED, fpout);
+ dump_config(Config, CS_DUMP_STYLE_NEO, CS_DUMP_ONLY_CHANGED, fp_out);
}
else
{
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
return MUTT_CMD_ERROR;
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
struct Pager info = { 0 };
if (mutt_pager("set", tempfile, 0, &info) == -1)
char tempfile[PATH_MAX];
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *fpout = mutt_file_fopen(tempfile, "w");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfile, "w");
+ if (!fp_out)
{
mutt_buffer_addstr(err, _("Could not create temporary file"));
return MUTT_CMD_ERROR;
}
- print_version(fpout);
- mutt_file_fclose(&fpout);
+ print_version(fp_out);
+ mutt_file_fclose(&fp_out);
struct Pager info = { 0 };
if (mutt_pager("version", tempfile, 0, &info) == -1)
for (size_t i = 0; i < mutt_array_size(mn_files); i++)
{
- FILE *f = mutt_file_fopen(mn_files[i], "r");
- if (!f)
+ FILE *fp = mutt_file_fopen(mn_files[i], "r");
+ if (!fp)
continue;
size_t len = 0;
- mailname = mutt_file_read_line(NULL, &len, f, NULL, 0);
- mutt_file_fclose(&f);
+ mailname = mutt_file_read_line(NULL, &len, fp, NULL, 0);
+ mutt_file_fclose(&fp);
if (mailname && *mailname)
break;
*/
static int source_rc(const char *rcfile_path, struct Buffer *err)
{
- FILE *f = NULL;
int line = 0, rc = 0, warnings = 0;
enum CommandResult line_rc;
struct Buffer token;
mutt_debug(LL_DEBUG2, "Reading configuration file '%s'.\n", rcfile);
- f = mutt_open_read(rcfile, &pid);
- if (!f)
+ FILE *fp = mutt_open_read(rcfile, &pid);
+ if (!fp)
{
mutt_buffer_printf(err, "%s: %s", rcfile, strerror(errno));
return -1;
}
mutt_buffer_init(&token);
- while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, MUTT_CONT)))
+ while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, MUTT_CONT)))
{
const int conv = C_ConfigCharset && (*C_ConfigCharset) && C_Charset;
if (conv)
}
FREE(&token.data);
FREE(&linebuf);
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
if (pid != -1)
mutt_wait_filter(pid);
if (rc)
FILE * maildir_open_find_message(const char *folder, const char *msg, char **newname);
void maildir_parse_flags (struct Email *e, const char *path);
struct Email *maildir_parse_message (enum MailboxType magic, const char *fname, bool is_old, struct Email *e);
-struct Email *maildir_parse_stream (enum MailboxType magic, FILE *f, const char *fname, bool is_old, struct Email *e);
+struct Email *maildir_parse_stream (enum MailboxType magic, FILE *fp, const char *fname, bool is_old, struct Email *e);
bool maildir_update_flags (struct Mailbox *m, struct Email *o, struct Email *n);
int mh_check_empty (const char *path);
#ifdef USE_HCACHE
*/
void mh_update_sequences(struct Mailbox *m)
{
- FILE *ofp = NULL, *nfp = NULL;
-
char sequences[PATH_MAX];
char *tmpfname = NULL;
char *buf = NULL;
snprintf(seq_replied, sizeof(seq_replied), "%s:", NONULL(C_MhSeqReplied));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(C_MhSeqFlagged));
- if (mh_mkstemp(m, &nfp, &tmpfname) != 0)
+ FILE *fp_new = NULL;
+ if (mh_mkstemp(m, &fp_new, &tmpfname) != 0)
{
/* error message? */
return;
snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", m->path);
/* first, copy unknown sequences */
- ofp = fopen(sequences, "r");
- if (ofp)
+ FILE *fp_old = fopen(sequences, "r");
+ if (fp_old)
{
- while ((buf = mutt_file_read_line(buf, &s, ofp, &l, 0)))
+ while ((buf = mutt_file_read_line(buf, &s, fp_old, &l, 0)))
{
if (mutt_str_startswith(buf, seq_unseen, CASE_MATCH) ||
mutt_str_startswith(buf, seq_flagged, CASE_MATCH) ||
mutt_str_startswith(buf, seq_replied, CASE_MATCH))
continue;
- fprintf(nfp, "%s\n", buf);
+ fprintf(fp_new, "%s\n", buf);
}
}
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_old);
/* now, update our unseen, flagged, and replied sequences */
for (l = 0; l < m->msg_count; l++)
/* write out the new sequences */
if (unseen)
- mhs_write_one_sequence(nfp, &mhs, MH_SEQ_UNSEEN, NONULL(C_MhSeqUnseen));
+ mhs_write_one_sequence(fp_new, &mhs, MH_SEQ_UNSEEN, NONULL(C_MhSeqUnseen));
if (flagged)
- mhs_write_one_sequence(nfp, &mhs, MH_SEQ_FLAGGED, NONULL(C_MhSeqFlagged));
+ mhs_write_one_sequence(fp_new, &mhs, MH_SEQ_FLAGGED, NONULL(C_MhSeqFlagged));
if (replied)
- mhs_write_one_sequence(nfp, &mhs, MH_SEQ_REPLIED, NONULL(C_MhSeqReplied));
+ mhs_write_one_sequence(fp_new, &mhs, MH_SEQ_REPLIED, NONULL(C_MhSeqReplied));
mhs_free_sequences(&mhs);
/* try to commit the changes - no guarantee here */
- mutt_file_fclose(&nfp);
+ mutt_file_fclose(&fp_new);
unlink(sequences);
if (mutt_file_safe_rename(tmpfname, sequences) != 0)
bool flagged_done = false;
bool replied_done = false;
- FILE *ofp = NULL, *nfp = NULL;
-
char *tmpfname = NULL;
char sequences[PATH_MAX];
int line = 0;
size_t sz;
- if (mh_mkstemp(m, &nfp, &tmpfname) == -1)
+ FILE *fp_new = NULL;
+ if (mh_mkstemp(m, &fp_new, &tmpfname) == -1)
return;
snprintf(seq_unseen, sizeof(seq_unseen), "%s:", NONULL(C_MhSeqUnseen));
snprintf(seq_flagged, sizeof(seq_flagged), "%s:", NONULL(C_MhSeqFlagged));
snprintf(sequences, sizeof(sequences), "%s/.mh_sequences", m->path);
- ofp = fopen(sequences, "r");
- if (ofp)
+ FILE *fp_old = fopen(sequences, "r");
+ if (fp_old)
{
- while ((buf = mutt_file_read_line(buf, &sz, ofp, &line, 0)))
+ while ((buf = mutt_file_read_line(buf, &sz, fp_old, &line, 0)))
{
if (unseen && (strncmp(buf, seq_unseen, mutt_str_strlen(seq_unseen)) == 0))
{
- fprintf(nfp, "%s %d\n", buf, n);
+ fprintf(fp_new, "%s %d\n", buf, n);
unseen_done = true;
}
else if (flagged && (strncmp(buf, seq_flagged, mutt_str_strlen(seq_flagged)) == 0))
{
- fprintf(nfp, "%s %d\n", buf, n);
+ fprintf(fp_new, "%s %d\n", buf, n);
flagged_done = true;
}
else if (replied && (strncmp(buf, seq_replied, mutt_str_strlen(seq_replied)) == 0))
{
- fprintf(nfp, "%s %d\n", buf, n);
+ fprintf(fp_new, "%s %d\n", buf, n);
replied_done = true;
}
else
- fprintf(nfp, "%s\n", buf);
+ fprintf(fp_new, "%s\n", buf);
}
}
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_old);
FREE(&buf);
if (!unseen_done && unseen)
- fprintf(nfp, "%s: %d\n", NONULL(C_MhSeqUnseen), n);
+ fprintf(fp_new, "%s: %d\n", NONULL(C_MhSeqUnseen), n);
if (!flagged_done && flagged)
- fprintf(nfp, "%s: %d\n", NONULL(C_MhSeqFlagged), n);
+ fprintf(fp_new, "%s: %d\n", NONULL(C_MhSeqFlagged), n);
if (!replied_done && replied)
- fprintf(nfp, "%s: %d\n", NONULL(C_MhSeqReplied), n);
+ fprintf(fp_new, "%s: %d\n", NONULL(C_MhSeqReplied), n);
- mutt_file_fclose(&nfp);
+ mutt_file_fclose(&fp_new);
unlink(sequences);
if (mutt_file_safe_rename(tmpfname, sequences) != 0)
/**
* maildir_parse_stream - Parse a Maildir message
* @param magic Mailbox type, e.g. #MUTT_MAILDIR
- * @param f Message file handle
+ * @param fp Message file handle
* @param fname Message filename
* @param is_old true, if the email is old (read)
* @param e Email
* Actually parse a maildir message. This may also be used to fill
* out a fake header structure generated by lazy maildir parsing.
*/
-struct Email *maildir_parse_stream(enum MailboxType magic, FILE *f,
+struct Email *maildir_parse_stream(enum MailboxType magic, FILE *fp,
const char *fname, bool is_old, struct Email *e)
{
struct stat st;
if (!e)
e = mutt_email_new();
- e->env = mutt_rfc822_read_header(f, e, false, false);
+ e->env = mutt_rfc822_read_header(fp, e, false, false);
- fstat(fileno(f), &st);
+ fstat(fileno(fp), &st);
if (!e->received)
e->received = e->date_sent;
struct Email *maildir_parse_message(enum MailboxType magic, const char *fname,
bool is_old, struct Email *e)
{
- FILE *f = fopen(fname, "r");
- if (!f)
+ FILE *fp = fopen(fname, "r");
+ if (!fp)
return NULL;
- e = maildir_parse_stream(magic, f, fname, is_old, e);
- mutt_file_fclose(&f);
+ e = maildir_parse_stream(magic, fp, fname, is_old, e);
+ mutt_file_fclose(&fp);
return e;
}
else if (subject || msg || sendflags || draft_file || include_file ||
!STAILQ_EMPTY(&attach) || optind < argc)
{
- FILE *fin = NULL;
- FILE *fout = NULL;
+ FILE *fp_in = NULL;
+ FILE *fp_out = NULL;
char *tempfile = NULL, *infile = NULL;
char *bodytext = NULL, *bodyfile = NULL;
int rv = 0;
if (infile || bodytext)
{
- /* Prepare fin and expanded_infile. */
+ /* Prepare fp_in and expanded_infile. */
if (infile)
{
if (mutt_str_strcmp("-", infile) == 0)
mutt_error(_("Cannot use -E flag with stdin"));
goto main_curses; // TEST27: neomutt -E -H -
}
- fin = stdin;
+ fp_in = stdin;
}
else
{
mutt_str_strfcpy(expanded_infile, infile, sizeof(expanded_infile));
mutt_expand_path(expanded_infile, sizeof(expanded_infile));
- fin = fopen(expanded_infile, "r");
- if (!fin)
+ fp_in = fopen(expanded_infile, "r");
+ if (!fp_in)
{
mutt_perror(expanded_infile);
goto main_curses; // TEST28: neomutt -E -H missing
}
}
- /* Copy input to a tempfile, and re-point fin to the tempfile.
+ /* Copy input to a tempfile, and re-point fp_in to the tempfile.
* Note: stdin is always copied to a tempfile, ensuring draft_file
* can stat and get the correct st_size below.
*/
mutt_mktemp(buf, sizeof(buf));
tempfile = mutt_str_strdup(buf);
- fout = mutt_file_fopen(tempfile, "w");
- if (!fout)
+ fp_out = mutt_file_fopen(tempfile, "w");
+ if (!fp_out)
{
- mutt_file_fclose(&fin);
+ mutt_file_fclose(&fp_in);
mutt_perror(tempfile);
FREE(&tempfile);
goto main_curses; // TEST29: neomutt -H existing-file (where tmpdir=/path/to/FILE blocking tmpdir)
}
- if (fin)
+ if (fp_in)
{
- mutt_file_copy_stream(fin, fout);
- if (fin != stdin)
- mutt_file_fclose(&fin);
+ mutt_file_copy_stream(fp_in, fp_out);
+ if (fp_in != stdin)
+ mutt_file_fclose(&fp_in);
}
else if (bodytext)
- fputs(bodytext, fout);
- mutt_file_fclose(&fout);
+ fputs(bodytext, fp_out);
+ mutt_file_fclose(&fp_out);
- fin = fopen(tempfile, "r");
- if (!fin)
+ fp_in = fopen(tempfile, "r");
+ if (!fp_in)
{
mutt_perror(tempfile);
FREE(&tempfile);
sendflags |= SEND_DRAFT_FILE;
/* Set up a "context" header with just enough information so that
- * mutt_prepare_template() can parse the message in fin.
+ * mutt_prepare_template() can parse the message in fp_in.
*/
struct Email *context_hdr = mutt_email_new();
context_hdr->offset = 0;
context_hdr->content = mutt_body_new();
- if (fstat(fileno(fin), &st) != 0)
+ if (fstat(fileno(fp_in), &st) != 0)
{
mutt_perror(draft_file);
goto main_curses; // TEST31: can't test
}
context_hdr->content->length = st.st_size;
- if (mutt_prepare_template(fin, NULL, msg, context_hdr, false) < 0)
+ if (mutt_prepare_template(fp_in, NULL, msg, context_hdr, false) < 0)
{
mutt_error(_("Cannot parse message template: %s"), draft_file);
mutt_env_free(&opts_env);
else
bodyfile = tempfile;
- mutt_file_fclose(&fin);
+ mutt_file_fclose(&fp_in);
}
FREE(&bodytext);
mutt_perror(expanded_infile);
goto main_curses; // TEST33: neomutt -H read-only -s test john@example.com -E
}
- fout = mutt_file_fopen(expanded_infile, "a");
- if (!fout)
+ fp_out = mutt_file_fopen(expanded_infile, "a");
+ if (!fp_out)
{
mutt_perror(expanded_infile);
goto main_curses; // TEST34: can't test
}
mutt_rfc822_write_header(
- fout, msg->env, msg->content, MUTT_WRITE_HEADER_POSTPONE, false,
+ fp_out, msg->env, msg->content, MUTT_WRITE_HEADER_POSTPONE, false,
C_CryptProtectedHeadersRead && mutt_should_hide_protected_subject(msg));
if (C_ResumeEditedDraftFiles)
- fprintf(fout, "X-Mutt-Resume-Draft: 1\n");
- fputc('\n', fout);
- if ((mutt_write_mime_body(msg->content, fout) == -1))
+ fprintf(fp_out, "X-Mutt-Resume-Draft: 1\n");
+ fputc('\n', fp_out);
+ if ((mutt_write_mime_body(msg->content, fp_out) == -1))
{
- mutt_file_fclose(&fout);
+ mutt_file_fclose(&fp_out);
goto main_curses; // TEST35: can't test
}
- mutt_file_fclose(&fout);
+ mutt_file_fclose(&fp_out);
}
mutt_email_free(&msg);
/**
* fseek_last_message - Find the last message in the file
- * @param f File to search
+ * @param fp File to search
* @retval 0 Success
* @retval -1 No message found
*/
-static int fseek_last_message(FILE *f)
+static int fseek_last_message(FILE *fp)
{
LOFF_T pos;
char buf[BUFSIZ + 9] = { 0 }; /* 7 for "\n\nFrom " */
size_t bytes_read;
- fseek(f, 0, SEEK_END);
- pos = ftello(f);
+ fseek(fp, 0, SEEK_END);
+ pos = ftello(fp);
/* Set 'bytes_read' to the size of the last, probably partial, buf;
* 0 < 'bytes_read' <= 'BUFSIZ'. */
{
/* we save in the buf at the end the first 7 chars from the last read */
strncpy(buf + BUFSIZ, buf, 5 + 2); /* 2 == 2 * mutt_str_strlen(CRLF) */
- fseeko(f, pos, SEEK_SET);
- bytes_read = fread(buf, sizeof(char), bytes_read, f);
+ fseeko(fp, pos, SEEK_SET);
+ bytes_read = fread(buf, sizeof(char), bytes_read, fp);
if (bytes_read == 0)
return -1;
/* 'i' is Index into 'buf' for scanning. */
{
if (mutt_str_startswith(buf + i, "\n\nFrom ", CASE_MATCH))
{ /* found it - go to the beginning of the From */
- fseeko(f, pos + i + 2, SEEK_SET);
+ fseeko(fp, pos + i + 2, SEEK_SET);
return 0;
}
}
/* here we are at the beginning of the file */
if (mutt_str_startswith(buf, "From ", CASE_MATCH))
{
- fseek(f, 0, SEEK_SET);
+ fseek(fp, 0, SEEK_SET);
return 0;
}
/**
* test_last_status_new - Is the last message new
- * @param f File to check
+ * @param fp File to check
* @retval true if the last message is new
*/
-static bool test_last_status_new(FILE *f)
+static bool test_last_status_new(FILE *fp)
{
struct Email *e = NULL;
struct Envelope *tmp_envelope = NULL;
bool result = false;
- if (fseek_last_message(f) == -1)
+ if (fseek_last_message(fp) == -1)
return false;
e = mutt_email_new();
- tmp_envelope = mutt_rfc822_read_header(f, e, false, false);
+ tmp_envelope = mutt_rfc822_read_header(fp, e, false, false);
if (!(e->read || e->old))
result = true;
*/
bool mbox_test_new_folder(const char *path)
{
- FILE *f = NULL;
bool rc = false;
enum MailboxType magic = mx_path_probe(path, NULL);
if ((magic != MUTT_MBOX) && (magic != MUTT_MMDF))
return false;
- f = fopen(path, "rb");
- if (f)
+ FILE *fp = fopen(path, "rb");
+ if (fp)
{
- rc = test_last_status_new(f);
- mutt_file_fclose(&f);
+ rc = test_last_status_new(fp);
+ mutt_file_fclose(&fp);
}
return rc;
/**
* mutt_ch_fgetconv_open - Prepare a file for charset conversion
- * @param file FILE ptr to prepare
+ * @param fp FILE ptr to prepare
* @param from Current character set
* @param to Destination character set
* @param flags Flags, e.g. MUTT_ICONV_HOOK_FROM
*
* Parameter flags is given as-is to mutt_ch_iconv_open().
*/
-struct FgetConv *mutt_ch_fgetconv_open(FILE *file, const char *from, const char *to, int flags)
+struct FgetConv *mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, int flags)
{
struct FgetConv *fc = NULL;
iconv_t cd = (iconv_t) -1;
}
else
fc = mutt_mem_malloc(sizeof(struct FgetConvNot));
- fc->fp = file;
+ fc->fp = fp;
fc->cd = cd;
return fc;
}
int mutt_ch_convert_string(char **ps, const char *from, const char *to, int flags);
int mutt_ch_fgetconv(struct FgetConv *fc);
void mutt_ch_fgetconv_close(struct FgetConv **fc);
-struct FgetConv *mutt_ch_fgetconv_open(FILE *file, const char *from, const char *to, int flags);
+struct FgetConv *mutt_ch_fgetconv_open(FILE *fp, const char *from, const char *to, int flags);
char * mutt_ch_fgetconvs(char *buf, size_t buflen, struct FgetConv *fc);
char * mutt_ch_get_default_charset(void);
char * mutt_ch_get_langinfo_charset(void);
/**
* mutt_file_fclose - Close a FILE handle (and NULL the pointer)
- * @param[out] f FILE handle to close
+ * @param[out] fp FILE handle to close
* @retval 0 Success
* @retval EOF Error, see errno
*/
-int mutt_file_fclose(FILE **f)
+int mutt_file_fclose(FILE **fp)
{
- if (!f || !*f)
+ if (!fp || !*fp)
return 0;
- int r = fclose(*f);
- *f = NULL;
+ int r = fclose(*fp);
+ *fp = NULL;
return r;
}
/**
* mutt_file_fsync_close - Flush the data, before closing a file (and NULL the pointer)
- * @param[out] f FILE handle to close
+ * @param[out] fp FILE handle to close
* @retval 0 Success
* @retval EOF Error, see errno
*/
-int mutt_file_fsync_close(FILE **f)
+int mutt_file_fsync_close(FILE **fp)
{
- if (!f || !*f)
+ if (!fp || !*fp)
return 0;
int r = 0;
- if (fflush(*f) || fsync(fileno(*f)))
+ if (fflush(*fp) || fsync(fileno(*fp)))
{
int save_errno = errno;
r = -1;
- mutt_file_fclose(f);
+ mutt_file_fclose(fp);
errno = save_errno;
}
else
- r = mutt_file_fclose(f);
+ r = mutt_file_fclose(fp);
return r;
}
return;
}
- FILE *f = fdopen(fd, "r+");
- if (f)
+ FILE *fp = fdopen(fd, "r+");
+ if (fp)
{
unlink(s);
char buf[2048] = { 0 };
while (sb.st_size > 0)
{
- fwrite(buf, 1, MIN(sizeof(buf), sb.st_size), f);
+ fwrite(buf, 1, MIN(sizeof(buf), sb.st_size), fp);
sb.st_size -= MIN(sizeof(buf), sb.st_size);
}
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
}
}
/**
* mutt_file_copy_bytes - Copy some content from one file to another
- * @param in Source file
- * @param out Destination file
- * @param size Maximum number of bytes to copy
+ * @param fp_in Source file
+ * @param fp_out Destination file
+ * @param size Maximum number of bytes to copy
* @retval 0 Success
* @retval -1 Error, see errno
*/
-int mutt_file_copy_bytes(FILE *in, FILE *out, size_t size)
+int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size)
{
while (size > 0)
{
char buf[2048];
size_t chunk = (size > sizeof(buf)) ? sizeof(buf) : size;
- chunk = fread(buf, 1, chunk, in);
+ chunk = fread(buf, 1, chunk, fp_in);
if (chunk < 1)
break;
- if (fwrite(buf, 1, chunk, out) != chunk)
+ if (fwrite(buf, 1, chunk, fp_out) != chunk)
return -1;
size -= chunk;
}
- if (fflush(out) != 0)
+ if (fflush(fp_out) != 0)
return -1;
return 0;
}
/**
* mutt_file_copy_stream - Copy the contents of one file into another
- * @param fin Source file
- * @param fout Destination file
+ * @param fp_in Source file
+ * @param fp_out Destination file
* @retval 0 Success
* @retval -1 Error, see errno
*/
-int mutt_file_copy_stream(FILE *fin, FILE *fout)
+int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
{
size_t l;
char buf[1024];
- while ((l = fread(buf, 1, sizeof(buf), fin)) > 0)
+ while ((l = fread(buf, 1, sizeof(buf), fp_in)) > 0)
{
- if (fwrite(buf, 1, l, fout) != l)
+ if (fwrite(buf, 1, l, fp_out) != l)
return -1;
}
- if (fflush(fout) != 0)
+ if (fflush(fp_out) != 0)
return -1;
return 0;
}
/**
* mutt_file_sanitize_filename - Replace unsafe characters in a filename
- * @param f Filename to make safe
+ * @param fp Filename to make safe
* @param slash Replace '/' characters too
*/
-void mutt_file_sanitize_filename(char *f, bool slash)
+void mutt_file_sanitize_filename(char *fp, bool slash)
{
- if (!f)
+ if (!fp)
return;
- for (; *f; f++)
+ for (; *fp; fp++)
{
- if ((slash && (*f == '/')) || !strchr(safe_chars, *f))
- *f = '_';
+ if ((slash && (*fp == '/')) || !strchr(safe_chars, *fp))
+ *fp = '_';
}
}
/**
* mutt_file_decrease_mtime - Decrease a file's modification time by 1 second
- * @param f Filename
+ * @param fp Filename
* @param st struct stat for the file (optional)
* @retval num Updated Unix mtime
* @retval -1 Error, see errno
*
* If a file's mtime is NOW, then set it to 1 second in the past.
*/
-time_t mutt_file_decrease_mtime(const char *f, struct stat *st)
+time_t mutt_file_decrease_mtime(const char *fp, struct stat *st)
{
struct utimbuf utim;
struct stat st2;
if (!st)
{
- if (stat(f, &st2) == -1)
+ if (stat(fp, &st2) == -1)
return -1;
st = &st2;
}
mtime -= 1;
utim.actime = mtime;
utim.modtime = mtime;
- utime(f, &utim);
+ utime(fp, &utim);
}
return mtime;
*/
int mutt_file_rename(const char *oldfile, const char *newfile)
{
- FILE *ofp = NULL, *nfp = NULL;
-
if (access(oldfile, F_OK) != 0)
return 1;
if (access(newfile, F_OK) == 0)
return 2;
- ofp = fopen(oldfile, "r");
- if (!ofp)
+
+ FILE *fp_old = fopen(oldfile, "r");
+ if (!fp_old)
return 3;
- nfp = mutt_file_fopen(newfile, "w");
- if (!nfp)
+ FILE *fp_new = mutt_file_fopen(newfile, "w");
+ if (!fp_new)
{
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_old);
return 3;
}
- mutt_file_copy_stream(ofp, nfp);
- mutt_file_fclose(&nfp);
- mutt_file_fclose(&ofp);
+ mutt_file_copy_stream(fp_old, fp_new);
+ mutt_file_fclose(&fp_new);
+ mutt_file_fclose(&fp_old);
mutt_file_unlink(oldfile);
return 0;
}
int mutt_file_chmod_add_stat(const char *path, mode_t mode, struct stat *st);
int mutt_file_chmod_rm(const char *path, mode_t mode);
int mutt_file_chmod_rm_stat(const char *path, mode_t mode, struct stat *st);
-int mutt_file_copy_bytes(FILE *in, FILE *out, size_t size);
-int mutt_file_copy_stream(FILE *fin, FILE *fout);
-time_t mutt_file_decrease_mtime(const char *f, struct stat *st);
+int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size);
+int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out);
+time_t mutt_file_decrease_mtime(const char *fp, struct stat *st);
void mutt_file_expand_fmt(char *dest, size_t destlen, const char *fmt, const char *src);
void mutt_file_expand_fmt_quote(char *dest, size_t destlen, const char *fmt, const char *src);
-int mutt_file_fclose(FILE **f);
+int mutt_file_fclose(FILE **fp);
FILE * mutt_file_fopen(const char *path, const char *mode);
-int mutt_file_fsync_close(FILE **f);
+int mutt_file_fsync_close(FILE **fp);
long mutt_file_get_size(const char *path);
void mutt_file_get_stat_timespec(struct timespec *dest, struct stat *sb, enum MuttStatType type);
bool mutt_file_iter_line(struct MuttFileIter *iter, FILE *fp, int flags);
int mutt_file_rename(const char *oldfile, const char *newfile);
int mutt_file_rmtree(const char *path);
int mutt_file_safe_rename(const char *src, const char *target);
-void mutt_file_sanitize_filename(char *f, bool slash);
+void mutt_file_sanitize_filename(char *fp, bool slash);
int mutt_file_sanitize_regex(char *dest, size_t destlen, const char *src);
void mutt_file_set_mtime(const char *from, const char *to);
int mutt_file_stat_compare(struct stat *sba, enum MuttStatType sba_type, struct stat *sbb, enum MuttStatType sbb_type);
*/
static void shrink_histfile(void)
{
- FILE *tmpfp = NULL;
+ FILE *fp_tmp = NULL;
int n[HC_MAX] = { 0 };
int line, hclass, read;
char *linebuf = NULL, *p = NULL;
bool regen_file = false;
struct Hash *dup_hashes[HC_MAX] = { 0 };
- FILE *f = fopen(C_HistoryFile, "r");
- if (!f)
+ FILE *fp = fopen(C_HistoryFile, "r");
+ if (!fp)
return;
if (C_HistoryRemoveDups)
dup_hashes[hclass] = mutt_hash_new(MAX(10, C_SaveHistory * 2), MUTT_HASH_STRDUP_KEYS);
line = 0;
- while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)))
+ while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, 0)))
{
if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 ||
*(p = linebuf + strlen(linebuf) - 1) != '|' || hclass < 0)
if (regen_file)
{
- tmpfp = mutt_file_mkstemp();
- if (!tmpfp)
+ fp_tmp = mutt_file_mkstemp();
+ if (!fp_tmp)
{
mutt_perror(_("Can't create temporary file"));
goto cleanup;
}
- rewind(f);
+ rewind(fp);
line = 0;
- while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)))
+ while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, 0)))
{
if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 ||
*(p = linebuf + strlen(linebuf) - 1) != '|' || hclass < 0)
}
*p = '|';
if (n[hclass]-- <= C_SaveHistory)
- fprintf(tmpfp, "%s\n", linebuf);
+ fprintf(fp_tmp, "%s\n", linebuf);
}
}
cleanup:
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
FREE(&linebuf);
- if (tmpfp)
+ if (fp_tmp)
{
- if ((fflush(tmpfp) == 0) && (f = fopen(C_HistoryFile, "w")))
+ if ((fflush(fp_tmp) == 0) && (fp = fopen(C_HistoryFile, "w")))
{
- rewind(tmpfp);
- mutt_file_copy_stream(tmpfp, f);
- mutt_file_fclose(&f);
+ rewind(fp_tmp);
+ mutt_file_copy_stream(fp_tmp, fp);
+ mutt_file_fclose(&fp);
}
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
}
if (C_HistoryRemoveDups)
for (hclass = 0; hclass < HC_MAX; hclass++)
static void save_history(enum HistoryClass hclass, const char *str)
{
static int n = 0;
- FILE *f = NULL;
char *tmp = NULL;
if (!str || !*str) /* This shouldn't happen, but it's safer. */
return;
- f = fopen(C_HistoryFile, "a");
- if (!f)
+ FILE *fp = fopen(C_HistoryFile, "a");
+ if (!fp)
{
mutt_perror("fopen");
return;
/* Format of a history item (1 line): "<histclass>:<string>|".
* We add a '|' in order to avoid lines ending with '\'. */
- fprintf(f, "%d:", (int) hclass);
+ fprintf(fp, "%d:", (int) hclass);
for (char *p = tmp; *p; p++)
{
/* Don't copy \n as a history item must fit on one line. The string
* shouldn't contain such a character anyway, but as this can happen
* in practice, we must deal with that. */
if (*p != '\n')
- putc((unsigned char) *p, f);
+ putc((unsigned char) *p, fp);
}
- fputs("|\n", f);
+ fputs("|\n", fp);
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
FREE(&tmp);
if (--n < 0)
char *linebuf = NULL, *p = NULL;
size_t buflen;
- FILE *f = fopen(C_HistoryFile, "r");
- if (!f)
+ FILE *fp = fopen(C_HistoryFile, "r");
+ if (!fp)
return;
- while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)))
+ while ((linebuf = mutt_file_read_line(linebuf, &buflen, fp, &line, 0)))
{
read = 0;
if (sscanf(linebuf, "%d:%n", &hclass, &read) < 1 || read == 0 ||
}
}
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
FREE(&linebuf);
}
{
char type[256];
char tempfile[PATH_MAX];
- FILE *fpin = NULL, *fpout = NULL;
struct stat st;
if (a->unlink)
if (stat(a->filename, &st) == -1)
return -1;
- if ((fpin = fopen(a->filename, "r")) && (fpout = mutt_file_fopen(tempfile, "w")))
+ FILE *fp_in = NULL, *fp_out = NULL;
+ if ((fp_in = fopen(a->filename, "r")) && (fp_out = mutt_file_fopen(tempfile, "w")))
{
- mutt_file_copy_stream(fpin, fpout);
+ mutt_file_copy_stream(fp_in, fp_out);
mutt_str_replace(&a->filename, tempfile);
a->unlink = true;
mutt_stamp_attachment(a);
}
else
- mutt_perror(fpin ? tempfile : a->filename);
+ mutt_perror(fp_in ? tempfile : a->filename);
- mutt_file_fclose(&fpin);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_in);
+ mutt_file_fclose(&fp_out);
return a->unlink ? 0 : -1;
}
fseeko(fp, b->offset, SEEK_SET);
mutt_body_free(&b);
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *tfp = mutt_file_fopen(tempfile, "w");
- if (!tfp)
+ FILE *fp_tmp = mutt_file_fopen(tempfile, "w");
+ if (!fp_tmp)
{
mutt_perror(_("Failure to open file to strip headers"));
mutt_file_fclose(&fp);
goto bailout;
}
- mutt_file_copy_stream(fp, tfp);
+ mutt_file_copy_stream(fp, fp_tmp);
mutt_file_fclose(&fp);
- mutt_file_fclose(&tfp);
+ mutt_file_fclose(&fp_tmp);
mutt_file_unlink(a->filename);
if (mutt_file_rename(tempfile, a->filename) != 0)
{
else
{
/* send case */
-
- FILE *ofp = NULL;
-
- FILE *ifp = fopen(b->filename, "r");
- if (!ifp)
+ FILE *fp_in = fopen(b->filename, "r");
+ if (!fp_in)
{
mutt_perror("fopen");
if (outfile && *outfile)
return 0;
}
+ FILE *fp_out = NULL;
if (outfile && *outfile)
- pid = mutt_create_filter_fd(path, &ofp, NULL, NULL, -1, out, -1);
+ pid = mutt_create_filter_fd(path, &fp_out, NULL, NULL, -1, out, -1);
else
- pid = mutt_create_filter(path, &ofp, NULL, NULL);
+ pid = mutt_create_filter(path, &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter"));
- mutt_file_fclose(&ifp);
+ mutt_file_fclose(&fp_in);
goto bail;
}
- mutt_file_copy_stream(ifp, ofp);
- mutt_file_fclose(&ofp);
- mutt_file_fclose(&ifp);
+ mutt_file_copy_stream(fp_in, fp_out);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_in);
}
rc = 1;
/* In send mode, just copy file */
- FILE *ofp = fopen(m->filename, "r");
- if (!ofp)
+ FILE *fp_old = fopen(m->filename, "r");
+ if (!fp_old)
{
mutt_perror("fopen");
return -1;
}
- FILE *nfp = save_attachment_open(path, flags);
- if (!nfp)
+ FILE *fp_new = save_attachment_open(path, flags);
+ if (!fp_new)
{
mutt_perror("fopen");
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_old);
return -1;
}
- if (mutt_file_copy_stream(ofp, nfp) == -1)
+ if (mutt_file_copy_stream(fp_old, fp_new) == -1)
{
mutt_error(_("Write fault"));
- mutt_file_fclose(&ofp);
- mutt_file_fclose(&nfp);
+ mutt_file_fclose(&fp_old);
+ mutt_file_fclose(&fp_new);
return -1;
}
- mutt_file_fclose(&ofp);
- if (mutt_file_fsync_close(&nfp) != 0)
+ mutt_file_fclose(&fp_old);
+ if (mutt_file_fsync_close(&fp_new) != 0)
{
mutt_error(_("Write fault"));
return -1;
char newfile[PATH_MAX] = "";
char type[256];
pid_t pid;
- FILE *ifp = NULL, *fpout = NULL;
+ FILE *fp_in = NULL, *fp_out = NULL;
bool unlink_newfile = false;
snprintf(type, sizeof(type), "%s/%s", TYPE(a), a->subtype);
/* interactive program */
if (piped)
{
- ifp = fopen(newfile, "r");
- if (!ifp)
+ fp_in = fopen(newfile, "r");
+ if (!fp_in)
{
mutt_perror("fopen");
rfc1524_free_entry(&entry);
return 0;
}
- pid = mutt_create_filter(cmd, &fpout, NULL, NULL);
+ pid = mutt_create_filter(cmd, &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter"));
rfc1524_free_entry(&entry);
- mutt_file_fclose(&ifp);
+ mutt_file_fclose(&fp_in);
return 0;
}
- mutt_file_copy_stream(ifp, fpout);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&ifp);
+ mutt_file_copy_stream(fp_in, fp_out);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_in);
if (mutt_wait_filter(pid) || C_WaitKey)
mutt_any_key_to_continue(NULL);
}
int rc = 0;
- ifp = NULL;
- fpout = NULL;
+ fp_in = NULL;
+ fp_out = NULL;
mutt_mktemp(newfile, sizeof(newfile));
if (mutt_decode_save_attachment(fp, a, newfile, MUTT_PRINTING, 0) == 0)
{
mutt_debug(LL_DEBUG2, "successfully decoded %s type attachment to %s\n", type, newfile);
- ifp = fopen(newfile, "r");
- if (!ifp)
+ fp_in = fopen(newfile, "r");
+ if (!fp_in)
{
mutt_perror("fopen");
goto bail0;
mutt_debug(LL_DEBUG2, "successfully opened %s read-only\n", newfile);
mutt_endwin();
- pid = mutt_create_filter(NONULL(C_PrintCommand), &fpout, NULL, NULL);
+ pid = mutt_create_filter(NONULL(C_PrintCommand), &fp_out, NULL, NULL);
if (pid < 0)
{
mutt_perror(_("Can't create filter"));
mutt_debug(LL_DEBUG2, "Filter created.\n");
- mutt_file_copy_stream(ifp, fpout);
+ mutt_file_copy_stream(fp_in, fp_out);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&ifp);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_in);
if (mutt_wait_filter(pid) != 0 || C_WaitKey)
mutt_any_key_to_continue(NULL);
rc = 1;
}
bail0:
- mutt_file_fclose(&ifp);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_in);
+ mutt_file_fclose(&fp_out);
mutt_file_unlink(newfile);
return rc;
}
struct stat st;
mutt_mktemp(path, sizeof(path));
- FILE *ofp = mutt_file_fopen(path, "w");
- if (!ofp)
+ FILE *fp_out = mutt_file_fopen(path, "w");
+ if (!fp_out)
{
mutt_perror(path);
return;
}
mutt_env_to_local(msg->env);
- mutt_rfc822_write_header(ofp, msg->env, NULL, MUTT_WRITE_HEADER_EDITHDRS, false, false);
- fputc('\n', ofp); /* tie off the header. */
+ mutt_rfc822_write_header(fp_out, msg->env, NULL, MUTT_WRITE_HEADER_EDITHDRS, false, false);
+ fputc('\n', fp_out); /* tie off the header. */
/* now copy the body of the message. */
- FILE *ifp = fopen(body, "r");
- if (!ifp)
+ FILE *fp_in = fopen(body, "r");
+ if (!fp_in)
{
mutt_perror(body);
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_out);
return;
}
- mutt_file_copy_stream(ifp, ofp);
+ mutt_file_copy_stream(fp_in, fp_out);
- mutt_file_fclose(&ifp);
- mutt_file_fclose(&ofp);
+ mutt_file_fclose(&fp_in);
+ mutt_file_fclose(&fp_out);
if (stat(path, &st) == -1)
{
mutt_list_free(&msg->env->userhdrs);
/* Read the temp file back in */
- ifp = fopen(path, "r");
- if (!ifp)
+ fp_in = fopen(path, "r");
+ if (!fp_in)
{
mutt_perror(path);
return;
}
- ofp = mutt_file_fopen(body, "w");
- if (!ofp)
+ fp_out = mutt_file_fopen(body, "w");
+ if (!fp_out)
{
/* intentionally leak a possible temporary file here */
- mutt_file_fclose(&ifp);
+ mutt_file_fclose(&fp_in);
mutt_perror(body);
return;
}
- n = mutt_rfc822_read_header(ifp, NULL, true, false);
- while ((i = fread(buf, 1, sizeof(buf), ifp)) > 0)
- fwrite(buf, 1, i, ofp);
- mutt_file_fclose(&ofp);
- mutt_file_fclose(&ifp);
+ n = mutt_rfc822_read_header(fp_in, NULL, true, false);
+ while ((i = fread(buf, 1, sizeof(buf), fp_in)) > 0)
+ fwrite(buf, 1, i, fp_out);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_in);
mutt_file_unlink(path);
/* in case the user modifies/removes the In-Reply-To header with
return false;
}
-static FILE *frandom;
+static FILE *fp_random;
/**
* mutt_randbuf - Fill a buffer with randomness
#endif
/* let's try urandom in case we're on an old kernel, or the user has
* configured selinux, seccomp or something to not allow getrandom */
- if (!frandom)
+ if (!fp_random)
{
- frandom = fopen("/dev/urandom", "rb");
- if (!frandom)
+ fp_random = fopen("/dev/urandom", "rb");
+ if (!fp_random)
{
mutt_error(_("open /dev/urandom: %s"), strerror(errno));
return -1;
}
- setbuf(frandom, NULL);
+ setbuf(fp_random, NULL);
}
- if (fread(buf, 1, buflen, frandom) != buflen)
+ if (fread(buf, 1, buflen, fp_random) != buflen)
{
mutt_error(_("read /dev/urandom: %s"), strerror(errno));
return -1;
char prefix[128], tmp[1024], *cp = NULL, *wptr = buf, ch;
char if_str[128], else_str[128];
size_t wlen, count, len, wid;
- FILE *filter = NULL;
+ FILE *fp_filter = NULL;
char *recycler = NULL;
char src2[256];
col -= wlen; /* reset to passed in value */
wptr = buf; /* reset write ptr */
- pid_t pid = mutt_create_filter(cmd->data, NULL, &filter, NULL);
+ pid_t pid = mutt_create_filter(cmd->data, NULL, &fp_filter, NULL);
if (pid != -1)
{
int rc;
- n = fread(buf, 1, buflen /* already decremented */, filter);
- mutt_file_fclose(&filter);
+ n = fread(buf, 1, buflen /* already decremented */, fp_filter);
+ mutt_file_fclose(&fp_filter);
rc = mutt_wait_filter(pid);
if (rc != 0)
mutt_debug(LL_DEBUG1, "format pipe cmd exited code %d\n", rc);
*/
FILE *mutt_open_read(const char *path, pid_t *thepid)
{
- FILE *f = NULL;
+ FILE *fp = NULL;
struct stat s;
size_t len = mutt_str_strlen(path);
p[len - 1] = 0;
mutt_endwin();
- *thepid = mutt_create_filter(p, NULL, &f, NULL);
+ *thepid = mutt_create_filter(p, NULL, &fp, NULL);
FREE(&p);
}
else
errno = EINVAL;
return NULL;
}
- f = fopen(path, "r");
+ fp = fopen(path, "r");
*thepid = -1;
}
- return f;
+ return fp;
}
/**
{
char tempfname[PATH_MAX], *mbox = NULL;
struct Address *tmp = NULL;
- FILE *fpout = NULL;
if (!WithCrypto)
return;
mutt_mktemp(tempfname, sizeof(tempfname));
- fpout = mutt_file_fopen(tempfname, "w");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfname, "w");
+ if (!fp_out)
{
mutt_perror(tempfname);
return;
mutt_parse_mime_message(Context->mailbox, e);
if (e->security & SEC_ENCRYPT && !crypt_valid_passphrase(e->security))
{
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
break;
}
if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
{
- mutt_copy_message_ctx(fpout, Context->mailbox, e,
+ mutt_copy_message_ctx(fp_out, Context->mailbox, e,
MUTT_CM_DECODE | MUTT_CM_CHARCONV, 0);
- fflush(fpout);
+ fflush(fp_out);
mutt_endwin();
puts(_("Trying to extract PGP keys...\n"));
{
if (e->security & SEC_ENCRYPT)
{
- mutt_copy_message_ctx(fpout, Context->mailbox, e,
+ mutt_copy_message_ctx(fp_out, Context->mailbox, e,
MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
0);
}
else
- mutt_copy_message_ctx(fpout, Context->mailbox, e, 0, 0);
- fflush(fpout);
+ mutt_copy_message_ctx(fp_out, Context->mailbox, e, 0, 0);
+ fflush(fp_out);
if (e->env->from)
tmp = mutt_expand_aliases(e->env->from);
}
}
- rewind(fpout);
+ rewind(fp_out);
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
if (isendwin())
mutt_any_key_to_continue(NULL);
gpgme_data_t data;
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *fptmp = mutt_file_fopen(tempfile, "w+");
- if (!fptmp)
+ FILE *fp_tmp = mutt_file_fopen(tempfile, "w+");
+ if (!fp_tmp)
{
mutt_perror(tempfile);
return NULL;
}
- mutt_write_mime_header(a, fptmp);
- fputc('\n', fptmp);
- mutt_write_mime_body(a, fptmp);
+ mutt_write_mime_header(a, fp_tmp);
+ fputc('\n', fp_tmp);
+ mutt_write_mime_body(a, fp_tmp);
if (convert)
{
unsigned char buf[1];
data = create_gpgme_data();
- rewind(fptmp);
- while ((c = fgetc(fptmp)) != EOF)
+ rewind(fp_tmp);
+ while ((c = fgetc(fp_tmp)) != EOF)
{
if (c == '\r')
hadcr = 1;
buf[0] = c;
gpgme_data_write(data, buf, 1);
}
- mutt_file_fclose(&fptmp);
+ mutt_file_fclose(&fp_tmp);
gpgme_data_seek(data, 0, SEEK_SET);
}
else
{
- mutt_file_fclose(&fptmp);
+ mutt_file_fclose(&fp_tmp);
err = gpgme_data_new_from_file(&data, tempfile, 1);
}
unlink(tempfile);
/**
* data_object_to_tempfile - Copy a data object to a temporary file
* @param[in] data GPGME data object
- * @param[out] ret_fp Temporary file
+ * @param[out] fp_ret Temporary file
* @retval ptr Name of temporary file
*
- * If ret_fp is passed in, the file will be rewound, left open, and returned
+ * If fp_ret is passed in, the file will be rewound, left open, and returned
* via that parameter.
*
* @note The caller must free the returned file name
*/
-static char *data_object_to_tempfile(gpgme_data_t data, FILE **ret_fp)
+static char *data_object_to_tempfile(gpgme_data_t data, FILE **fp_ret)
{
int err;
char tempf[PATH_MAX];
}
}
}
- if (ret_fp)
+ if (fp_ret)
rewind(fp);
else
mutt_file_fclose(&fp);
mutt_file_fclose(&fp);
return NULL;
}
- if (ret_fp)
- *ret_fp = fp;
+ if (fp_ret)
+ *fp_ret = fp;
return mutt_str_strdup(tempf);
}
* decrypt_part - Decrypt a PGP or SMIME message
* @param[in] a Body of message
* @param[in] s State to use
- * @param[in] fpout File to write to
+ * @param[in] fp_out File to write to
* @param[in] is_smime True if an SMIME message
* @param[out] r_is_signed Flag, R_IS_SIGNED (PGP only)
* @retval ptr Newly allocated Body
* encrypted and signed message, for S/MIME it returns true when it is not a
* encrypted but a signed message.
*/
-static struct Body *decrypt_part(struct Body *a, struct State *s, FILE *fpout,
+static struct Body *decrypt_part(struct Body *a, struct State *s, FILE *fp_out,
bool is_smime, int *r_is_signed)
{
- if (!a || !s || !fpout)
+ if (!a || !s || !fp_out)
return NULL;
struct stat info;
/* Read the output from GPGME, and make sure to change CRLF to LF,
otherwise read_mime_header has a hard time parsing the message. */
- if (data_object_to_stream(plaintext, fpout))
+ if (data_object_to_stream(plaintext, fp_out))
{
gpgme_data_release(plaintext);
gpgme_release(ctx);
gpgme_release(ctx);
ctx = NULL;
- fflush(fpout);
- rewind(fpout);
- tattach = mutt_read_mime_header(fpout, 0);
+ fflush(fp_out);
+ rewind(fp_out);
+ tattach = mutt_read_mime_header(fp_out, 0);
if (tattach)
{
/* Need to set the length of this body part. */
- fstat(fileno(fpout), &info);
+ fstat(fileno(fp_out), &info);
tattach->length = info.st_size - tattach->offset;
tattach->warnsig = anywarn;
/* See if we need to recurse on this MIME part. */
- mutt_parse_part(fpout, tattach);
+ mutt_parse_part(fp_out, tattach);
}
return tattach;
/**
* pgp_gpgme_decrypt_mime - Implements CryptModuleSpecs::decrypt_mime()
*/
-int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
+int pgp_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
struct State s = { 0 };
struct Body *first_part = b;
int saved_type = 0;
LOFF_T saved_offset = 0;
size_t saved_length = 0;
- FILE *decoded_fp = NULL;
+ FILE *fp_decoded = NULL;
int rc = 0;
first_part->goodsig = false;
else
return -1;
- s.fp_in = fpin;
+ s.fp_in = fp_in;
if (need_decode)
{
saved_offset = b->offset;
saved_length = b->length;
- decoded_fp = mutt_file_mkstemp();
- if (!decoded_fp)
+ fp_decoded = mutt_file_mkstemp();
+ if (!fp_decoded)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
fseeko(s.fp_in, b->offset, SEEK_SET);
- s.fp_out = decoded_fp;
+ s.fp_out = fp_decoded;
mutt_decode_attachment(b, &s);
- fflush(decoded_fp);
- b->length = ftello(decoded_fp);
+ fflush(fp_decoded);
+ b->length = ftello(fp_decoded);
b->offset = 0;
- rewind(decoded_fp);
- s.fp_in = decoded_fp;
+ rewind(fp_decoded);
+ s.fp_in = fp_decoded;
s.fp_out = 0;
}
- *fpout = mutt_file_mkstemp();
- if (!*fpout)
+ *fp_out = mutt_file_mkstemp();
+ if (!*fp_out)
{
mutt_perror(_("Can't create temporary file"));
rc = -1;
goto bail;
}
- *cur = decrypt_part(b, &s, *fpout, false, &is_signed);
+ *cur = decrypt_part(b, &s, *fp_out, false, &is_signed);
if (!*cur)
rc = -1;
- rewind(*fpout);
+ rewind(*fp_out);
if (is_signed > 0)
first_part->goodsig = true;
b->type = saved_type;
b->length = saved_length;
b->offset = saved_offset;
- mutt_file_fclose(&decoded_fp);
+ mutt_file_fclose(&fp_decoded);
}
return rc;
/**
* smime_gpgme_decrypt_mime - Implements CryptModuleSpecs::decrypt_mime()
*/
-int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
+int smime_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
struct State s = { 0 };
int is_signed;
saved_b_type = b->type;
saved_b_offset = b->offset;
saved_b_length = b->length;
- s.fp_in = fpin;
+ s.fp_in = fp_in;
fseeko(s.fp_in, b->offset, SEEK_SET);
- FILE *tmpfp = mutt_file_mkstemp();
- if (!tmpfp)
+ FILE *fp_tmp = mutt_file_mkstemp();
+ if (!fp_tmp)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
- s.fp_out = tmpfp;
+ s.fp_out = fp_tmp;
mutt_decode_attachment(b, &s);
- fflush(tmpfp);
+ fflush(fp_tmp);
b->length = ftello(s.fp_out);
b->offset = 0;
- rewind(tmpfp);
+ rewind(fp_tmp);
memset(&s, 0, sizeof(s));
- s.fp_in = tmpfp;
+ s.fp_in = fp_tmp;
s.fp_out = 0;
- *fpout = mutt_file_mkstemp();
- if (!*fpout)
+ *fp_out = mutt_file_mkstemp();
+ if (!*fp_out)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
- *cur = decrypt_part(b, &s, *fpout, true, &is_signed);
+ *cur = decrypt_part(b, &s, *fp_out, true, &is_signed);
if (*cur)
(*cur)->goodsig = is_signed > 0;
b->type = saved_b_type;
b->length = saved_b_length;
b->offset = saved_b_offset;
- mutt_file_fclose(&tmpfp);
- rewind(*fpout);
+ mutt_file_fclose(&fp_tmp);
+ rewind(*fp_out);
if (*cur && !is_signed && !(*cur)->parts && mutt_is_application_smime(*cur))
{
/* Assume that this is a opaque signed s/mime message. This is
saved_b_offset = bb->offset;
saved_b_length = bb->length;
memset(&s, 0, sizeof(s));
- s.fp_in = *fpout;
+ s.fp_in = *fp_out;
fseeko(s.fp_in, bb->offset, SEEK_SET);
- FILE *tmpfp2 = mutt_file_mkstemp();
- if (!tmpfp2)
+ FILE *fp_tmp2 = mutt_file_mkstemp();
+ if (!fp_tmp2)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
- s.fp_out = tmpfp2;
+ s.fp_out = fp_tmp2;
mutt_decode_attachment(bb, &s);
- fflush(tmpfp2);
+ fflush(fp_tmp2);
bb->length = ftello(s.fp_out);
bb->offset = 0;
- rewind(tmpfp2);
- mutt_file_fclose(fpout);
+ rewind(fp_tmp2);
+ mutt_file_fclose(fp_out);
memset(&s, 0, sizeof(s));
- s.fp_in = tmpfp2;
+ s.fp_in = fp_tmp2;
s.fp_out = 0;
- *fpout = mutt_file_mkstemp();
- if (!*fpout)
+ *fp_out = mutt_file_mkstemp();
+ if (!*fp_out)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
- tmp_b = decrypt_part(bb, &s, *fpout, true, &is_signed);
+ tmp_b = decrypt_part(bb, &s, *fp_out, true, &is_signed);
if (tmp_b)
tmp_b->goodsig = is_signed > 0;
bb->type = saved_b_type;
bb->length = saved_b_length;
bb->offset = saved_b_offset;
- mutt_file_fclose(&tmpfp2);
- rewind(*fpout);
+ mutt_file_fclose(&fp_tmp2);
+ rewind(*fp_out);
mutt_body_free(cur);
*cur = tmp_b;
}
{
char tempfile[PATH_MAX];
char buf[8192];
- FILE *tfp = NULL;
bool sgn = false;
bool enc = false;
return 0;
}
- tfp = fopen(tempfile, "r");
- if (!tfp)
+ FILE *fp_tmp = fopen(tempfile, "r");
+ if (!fp_tmp)
{
unlink(tempfile);
return 0;
}
- while (fgets(buf, sizeof(buf), tfp))
+ while (fgets(buf, sizeof(buf), fp_tmp))
{
size_t plen = mutt_str_startswith(buf, "-----BEGIN PGP ", CASE_MATCH);
if (plen != 0)
}
}
}
- mutt_file_fclose(&tfp);
+ mutt_file_fclose(&fp_tmp);
unlink(tempfile);
if (!enc && !sgn)
gpgme_import_status_t st;
int any;
- FILE *in = mutt_file_fopen(fname, "r");
- if (!in)
+ FILE *fp_in = mutt_file_fopen(fname, "r");
+ if (!fp_in)
{
mutt_perror(fname);
goto leave;
}
- /* Note that the stream, "in", needs to be kept open while the keydata
+ /* Note that the stream, "fp_in", needs to be kept open while the keydata
* is used.
*/
- gpgme_error_t err = gpgme_data_new_from_stream(&keydata, in);
+ gpgme_error_t err = gpgme_data_new_from_stream(&keydata, fp_in);
if (err != GPG_ERR_NO_ERROR)
{
mutt_error(_("error allocating data object: %s"), gpgme_strerror(err));
leave:
gpgme_release(ctx);
gpgme_data_release(keydata);
- mutt_file_fclose(&in);
+ mutt_file_fclose(&fp_in);
}
/**
long bytes;
LOFF_T last_pos;
char buf[8192];
- FILE *pgpout = NULL;
+ FILE *fp_out = NULL;
gpgme_error_t err = 0;
gpgme_data_t armored_data = NULL;
/* Invoke PGP if needed */
if (pgp_keyblock)
{
- pgp_gpgme_extract_keys(armored_data, &pgpout);
+ pgp_gpgme_extract_keys(armored_data, &fp_out);
}
else if (!clearsign || (s->flags & MUTT_VERIFY))
{
s);
}
- tmpfname = data_object_to_tempfile(plaintext, &pgpout);
+ tmpfname = data_object_to_tempfile(plaintext, &fp_out);
if (!tmpfname)
{
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_out);
state_puts(_("Error: copy data failed\n"), s);
}
else
{
copy_clearsigned(armored_data, s, body_charset);
}
- else if (pgpout)
+ else if (fp_out)
{
int c;
- rewind(pgpout);
- struct FgetConv *fc = mutt_ch_fgetconv_open(pgpout, "utf-8", C_Charset, 0);
+ rewind(fp_out);
+ struct FgetConv *fc = mutt_ch_fgetconv_open(fp_out, "utf-8", C_Charset, 0);
while ((c = mutt_ch_fgetconv(fc)) != EOF)
{
state_putc(c, s);
}
gpgme_data_release(armored_data);
- if (pgpout)
+ if (fp_out)
{
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_out);
}
}
else
mutt_debug(LL_DEBUG2, "Entering handler\n");
- FILE *fpout = mutt_file_mkstemp();
- if (!fpout)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
mutt_perror(_("Can't create temporary file"));
if (s->flags & MUTT_DISPLAY)
return -1;
}
- struct Body *tattach = decrypt_part(a, s, fpout, false, &is_signed);
+ struct Body *tattach = decrypt_part(a, s, fp_out, false, &is_signed);
if (tattach)
{
tattach->goodsig = is_signed > 0;
tattach->mime_headers = NULL;
{
- FILE *savefp = s->fp_in;
- s->fp_in = fpout;
+ FILE *fp_save = s->fp_in;
+ s->fp_in = fp_out;
rc = mutt_body_handler(tattach, s);
- s->fp_in = savefp;
+ s->fp_in = fp_save;
}
/* Embedded multipart signed protected headers override the
rc = -1;
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
mutt_debug(LL_DEBUG2, "Leaving handler\n");
return rc;
/* clear out any mime headers before the handler, so they can't be spoofed. */
mutt_env_free(&a->mime_headers);
a->warnsig = false;
- FILE *fpout = mutt_file_mkstemp();
- if (!fpout)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
mutt_perror(_("Can't create temporary file"));
if (s->flags & MUTT_DISPLAY)
return -1;
}
- struct Body *tattach = decrypt_part(a, s, fpout, true, &is_signed);
+ struct Body *tattach = decrypt_part(a, s, fp_out, true, &is_signed);
if (tattach)
{
tattach->goodsig = is_signed > 0;
tattach->mime_headers = NULL;
{
- FILE *savefp = s->fp_in;
- s->fp_in = fpout;
+ FILE *fp_save = s->fp_in;
+ s->fp_in = fp_out;
rc = mutt_body_handler(tattach, s);
- s->fp_in = savefp;
+ s->fp_in = fp_save;
}
/* Embedded multipart signed protected headers override the
mutt_body_free(&tattach);
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
mutt_debug(LL_DEBUG2, "Leaving handler\n");
return rc;
int pgp_gpgme_application_handler(struct Body *m, struct State *s);
int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one);
-int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
+int pgp_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s);
struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, bool sign);
char * pgp_gpgme_find_keys(struct Address *addrlist, bool oppenc_mode);
int smime_gpgme_application_handler(struct Body *a, struct State *s);
struct Body *smime_gpgme_build_smime_entity(struct Body *a, char *keylist);
-int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
+int smime_gpgme_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
char * smime_gpgme_find_keys(struct Address *addrlist, bool oppenc_mode);
void smime_gpgme_init(void);
int smime_gpgme_send_menu(struct Email *msg);
int (*valid_passphrase)(void);
/**
* decrypt_mime - Decrypt an encrypted MIME part
- * @param[in] fpin File containing the encrypted part
- * @param[out] fpout File containing the decrypted part
- * @param[in] b Body of the email
- * @param[out] cur Body containing the decrypted part
+ * @param[in] fp_in File containing the encrypted part
+ * @param[out] fp_out File containing the decrypted part
+ * @param[in] b Body of the email
+ * @param[out] cur Body containing the decrypted part
* @retval 0 Success
* @retval -1 Failure
*/
- int (*decrypt_mime)(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
+ int (*decrypt_mime)(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
/**
* application_handler - Manage the MIME type "application/pgp" or "application/smime"
* @param m Body of the email
/**
* crypt_pgp_decrypt_mime - Wrapper for CryptModuleSpecs::decrypt_mime()
*/
-int crypt_pgp_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
+int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
if (CRYPT_MOD_CALL_CHECK(PGP, decrypt_mime))
- return CRYPT_MOD_CALL(PGP, decrypt_mime)(fpin, fpout, b, cur);
+ return CRYPT_MOD_CALL(PGP, decrypt_mime)(fp_in, fp_out, b, cur);
return -1;
}
/**
* crypt_smime_decrypt_mime - Wrapper for CryptModuleSpecs::decrypt_mime()
*/
-int crypt_smime_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Body **d)
+int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
if (CRYPT_MOD_CALL_CHECK(SMIME, decrypt_mime))
- return CRYPT_MOD_CALL(SMIME, decrypt_mime)(a, b, c, d);
+ return CRYPT_MOD_CALL(SMIME, decrypt_mime)(fp_in, fp_out, b, cur);
return -1;
}
void crypt_invoke_message(SecurityFlags type);
int crypt_pgp_application_handler(struct Body *m, struct State *s);
int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one);
-int crypt_pgp_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Body **d);
+int crypt_pgp_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
int crypt_pgp_encrypted_handler(struct Body *a, struct State *s);
void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *top);
void crypt_pgp_invoke_getkeys(struct Address *addr);
struct Body *crypt_pgp_make_key_attachment(void);
int crypt_pgp_send_menu(struct Email *msg);
int crypt_smime_application_handler(struct Body *m, struct State *s);
-int crypt_smime_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Body **d);
+int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
void crypt_smime_getkeys(struct Envelope *env);
int crypt_smime_send_menu(struct Email *msg);
int crypt_smime_verify_sender(struct Email *e);
/**
* pgp_copy_checksig - Copy PGP output and look for signs of a good signature
- * @param fpin File to read from
- * @param fpout File to write to
+ * @param fp_in File to read from
+ * @param fp_out File to write to
* @retval 0 Success
* @retval -1 Error
*/
-static int pgp_copy_checksig(FILE *fpin, FILE *fpout)
+static int pgp_copy_checksig(FILE *fp_in, FILE *fp_out)
{
- if (!fpin || !fpout)
+ if (!fp_in || !fp_out)
return -1;
int rc = -1;
int lineno = 0;
size_t linelen;
- while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)))
+ while ((line = mutt_file_read_line(line, &linelen, fp_in, &lineno, 0)))
{
if (regexec(C_PgpGoodSign->regex, line, 0, NULL, 0) == 0)
{
if (strncmp(line, "[GNUPG:] ", 9) == 0)
continue;
- fputs(line, fpout);
- fputc('\n', fpout);
+ fputs(line, fp_out);
+ fputc('\n', fp_out);
}
FREE(&line);
}
else
{
mutt_debug(LL_DEBUG2, "No pattern.\n");
- mutt_file_copy_stream(fpin, fpout);
+ mutt_file_copy_stream(fp_in, fp_out);
rc = 1;
}
/**
* pgp_check_pgp_decryption_okay_regex - Check PGP output to look for successful outcome
- * @param fpin File to read from
+ * @param fp_in File to read from
* @retval 0 Success
* @retval -1 Error
*
* This protects against messages with multipart/encrypted headers but which
* aren't actually encrypted. See ticket #3770
*/
-static int pgp_check_pgp_decryption_okay_regex(FILE *fpin)
+static int pgp_check_pgp_decryption_okay_regex(FILE *fp_in)
{
int rc = -1;
int lineno = 0;
size_t linelen;
- while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)))
+ while ((line = mutt_file_read_line(line, &linelen, fp_in, &lineno, 0)))
{
if (regexec(C_PgpDecryptionOkay->regex, line, 0, NULL, 0) == 0)
{
/**
* pgp_check_decryption_okay - Check GPG output for status codes
- * @param fpin File to read from
+ * @param fp_in File to read from
* @retval 1 - no patterns were matched (if delegated to decryption_okay_regex)
* @retval 0 - DECRYPTION_OKAY was seen, with no PLAINTEXT outside
* @retval -1 - No decryption status codes were encountered
* "BEGIN PGP MESSAGE" could indicate a signed and armored message.
* For that we allow -1 and -2 as "valid" (with a warning).
*/
-static int pgp_check_decryption_okay(FILE *fpin)
+static int pgp_check_decryption_okay(FILE *fp_in)
{
int rv = -1;
char *line = NULL, *s = NULL;
int inside_decrypt = 0;
if (!C_PgpCheckGpgDecryptStatusFd)
- return pgp_check_pgp_decryption_okay_regex(fpin);
+ return pgp_check_pgp_decryption_okay_regex(fp_in);
- while ((line = mutt_file_read_line(line, &linelen, fpin, &lineno, 0)))
+ while ((line = mutt_file_read_line(line, &linelen, fp_in, &lineno, 0)))
{
size_t plen = mutt_str_startswith(line, "[GNUPG:]", CASE_MATCH);
if (plen == 0)
/**
* pgp_copy_clearsigned - Copy a clearsigned message, stripping the signature
- * @param fpin File to read from
+ * @param fp_in File to read from
* @param s State to use
* @param charset Charset of file
*
* (Note that we aren't worse than Outlook &c in this, and also note that we
* can successfully handle anything produced by any existing versions of neomutt.)
*/
-static void pgp_copy_clearsigned(FILE *fpin, struct State *s, char *charset)
+static void pgp_copy_clearsigned(FILE *fp_in, struct State *s, char *charset)
{
char buf[8192];
bool complete, armor_header;
- rewind(fpin);
+ rewind(fp_in);
/* fromcode comes from the MIME Content-Type charset label. It might
* be a wrong label, so we want the ability to do corrections via
* charset-hooks. Therefore we set flags to MUTT_ICONV_HOOK_FROM.
*/
struct FgetConv *fc =
- mutt_ch_fgetconv_open(fpin, charset, C_Charset, MUTT_ICONV_HOOK_FROM);
+ mutt_ch_fgetconv_open(fp_in, charset, C_Charset, MUTT_ICONV_HOOK_FROM);
for (complete = true, armor_header = true;
mutt_ch_fgetconvs(buf, sizeof(buf), fc); complete = (strchr(buf, '\n')))
LOFF_T last_pos, offset;
char buf[8192];
char tmpfname[PATH_MAX];
- FILE *pgpout = NULL, *pgpin = NULL, *pgperr = NULL;
- FILE *tmpfp = NULL;
+ FILE *fp_pgp_out = NULL, *fp_pgp_in = NULL, *fp_pgp_err = NULL;
+ FILE *fp_tmp = NULL;
pid_t pid;
bool maybe_goodsig = true;
/* Copy PGP material to temporary file */
mutt_mktemp(tmpfname, sizeof(tmpfname));
- tmpfp = mutt_file_fopen(tmpfname, "w+");
- if (!tmpfp)
+ fp_tmp = mutt_file_fopen(tmpfname, "w+");
+ if (!fp_tmp)
{
mutt_perror(tmpfname);
FREE(&gpgcharset);
return -1;
}
- fputs(buf, tmpfp);
+ fputs(buf, fp_tmp);
while (bytes > 0 && fgets(buf, sizeof(buf) - 1, s->fp_in))
{
offset = ftello(s->fp_in);
bytes -= (offset - last_pos); /* don't rely on mutt_str_strlen(buf) */
last_pos = offset;
- fputs(buf, tmpfp);
+ fputs(buf, fp_tmp);
if ((needpass && (mutt_str_strcmp("-----END PGP MESSAGE-----\n", buf) == 0)) ||
(!needpass &&
}
}
- /* leave tmpfp open in case we still need it - but flush it! */
- fflush(tmpfp);
+ /* leave fp_tmp open in case we still need it - but flush it! */
+ fflush(fp_tmp);
/* Invoke PGP if needed */
if (!clearsign || (s->flags & MUTT_VERIFY))
{
- pgpout = mutt_file_mkstemp();
- if (!pgpout)
+ fp_pgp_out = mutt_file_mkstemp();
+ if (!fp_pgp_out)
{
mutt_perror(_("Can't create temporary file"));
rc = -1;
goto out;
}
- pgperr = mutt_file_mkstemp();
- if (!pgperr)
+ fp_pgp_err = mutt_file_mkstemp();
+ if (!fp_pgp_err)
{
mutt_perror(_("Can't create temporary file"));
rc = -1;
goto out;
}
- pid = pgp_invoke_decode(&pgpin, NULL, NULL, -1, fileno(pgpout),
- fileno(pgperr), tmpfname, (needpass != 0));
+ pid = pgp_invoke_decode(&fp_pgp_in, NULL, NULL, -1, fileno(fp_pgp_out),
+ fileno(fp_pgp_err), tmpfname, (needpass != 0));
if (pid == -1)
{
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_pgp_out);
maybe_goodsig = false;
- pgpin = NULL;
+ fp_pgp_in = NULL;
state_attach_puts(
_("[-- Error: unable to create PGP subprocess --]\n"), s);
}
pgp_class_void_passphrase();
if (pgp_use_gpg_agent())
*PgpPass = 0;
- fprintf(pgpin, "%s\n", PgpPass);
+ fprintf(fp_pgp_in, "%s\n", PgpPass);
}
- mutt_file_fclose(&pgpin);
+ mutt_file_fclose(&fp_pgp_in);
rv = mutt_wait_filter(pid);
- fflush(pgperr);
+ fflush(fp_pgp_err);
/* If we are expecting an encrypted message, verify status fd output.
* Note that BEGIN PGP MESSAGE does not guarantee the content is encrypted,
* so we need to be more selective about the value of decrypt_okay_rc.
*/
if (needpass)
{
- rewind(pgperr);
- decrypt_okay_rc = pgp_check_decryption_okay(pgperr);
+ rewind(fp_pgp_err);
+ decrypt_okay_rc = pgp_check_decryption_okay(fp_pgp_err);
if (decrypt_okay_rc <= -3)
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_pgp_out);
}
if (s->flags & MUTT_DISPLAY)
{
- rewind(pgperr);
+ rewind(fp_pgp_err);
crypt_current_time(s, "PGP");
- rc = pgp_copy_checksig(pgperr, s->fp_out);
+ rc = pgp_copy_checksig(fp_pgp_err, s->fp_out);
if (rc == 0)
have_any_sigs = true;
/* treat empty result as sign of failure */
/* TODO: maybe on failure neomutt should include the original undecoded text. */
- if (pgpout)
+ if (fp_pgp_out)
{
- rewind(pgpout);
- c = fgetc(pgpout);
- ungetc(c, pgpout);
+ rewind(fp_pgp_out);
+ c = fgetc(fp_pgp_out);
+ ungetc(c, fp_pgp_out);
}
- if (!clearsign && (!pgpout || c == EOF))
+ if (!clearsign && (!fp_pgp_out || c == EOF))
{
could_not_decrypt = true;
pgp_class_void_passphrase();
if (clearsign)
{
- rewind(tmpfp);
- if (tmpfp)
- pgp_copy_clearsigned(tmpfp, s, body_charset);
+ rewind(fp_tmp);
+ if (fp_tmp)
+ pgp_copy_clearsigned(fp_tmp, s, body_charset);
}
- else if (pgpout)
+ else if (fp_pgp_out)
{
struct FgetConv *fc = NULL;
int ch;
mutt_debug(LL_DEBUG3, "pgp: recoding inline from [%s] to [%s]\n",
expected_charset, C_Charset);
- rewind(pgpout);
+ rewind(fp_pgp_out);
state_set_prefix(s);
- fc = mutt_ch_fgetconv_open(pgpout, expected_charset, C_Charset, MUTT_ICONV_HOOK_FROM);
+ fc = mutt_ch_fgetconv_open(fp_pgp_out, expected_charset, C_Charset, MUTT_ICONV_HOOK_FROM);
while ((ch = mutt_ch_fgetconv(fc)) != EOF)
state_prefix_putc(ch, s);
mutt_ch_fgetconv_close(&fc);
/* Multiple PGP blocks can exist, so these need to be closed and
* unlinked inside the loop.
*/
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
mutt_file_unlink(tmpfname);
- mutt_file_fclose(&pgpout);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_out);
+ mutt_file_fclose(&fp_pgp_err);
if (s->flags & MUTT_DISPLAY)
{
out:
m->goodsig = (maybe_goodsig && have_any_sigs);
- if (tmpfp)
+ if (fp_tmp)
{
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
mutt_file_unlink(tmpfname);
}
- mutt_file_fclose(&pgpout);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_out);
+ mutt_file_fclose(&fp_pgp_err);
FREE(&gpgcharset);
{
char tempfile[PATH_MAX];
char buf[8192];
- FILE *tfp = NULL;
bool sgn = false;
bool enc = false;
return 0;
}
- tfp = fopen(tempfile, "r");
- if (!tfp)
+ FILE *fp_tmp = fopen(tempfile, "r");
+ if (!fp_tmp)
{
unlink(tempfile);
return 0;
}
- while (fgets(buf, sizeof(buf), tfp))
+ while (fgets(buf, sizeof(buf), fp_tmp))
{
size_t plen = mutt_str_startswith(buf, "-----BEGIN PGP ", CASE_MATCH);
if (plen != 0)
key = true;
}
}
- mutt_file_fclose(&tfp);
+ mutt_file_fclose(&fp_tmp);
unlink(tempfile);
if (!enc && !sgn && !key)
int pgp_class_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
{
char sigfile[PATH_MAX];
- FILE *pgpout = NULL;
+ FILE *fp_pgp_out = NULL;
pid_t pid;
int badsig = -1;
snprintf(sigfile, sizeof(sigfile), "%s.asc", tempfile);
- FILE *fp = mutt_file_fopen(sigfile, "w");
- if (!fp)
+ FILE *fp_sig = mutt_file_fopen(sigfile, "w");
+ if (!fp_sig)
{
mutt_perror(sigfile);
return -1;
}
fseeko(s->fp_in, sigbdy->offset, SEEK_SET);
- mutt_file_copy_bytes(s->fp_in, fp, sigbdy->length);
- mutt_file_fclose(&fp);
+ mutt_file_copy_bytes(s->fp_in, fp_sig, sigbdy->length);
+ mutt_file_fclose(&fp_sig);
- FILE *pgperr = mutt_file_mkstemp();
- if (!pgperr)
+ FILE *fp_pgp_err = mutt_file_mkstemp();
+ if (!fp_pgp_err)
{
mutt_perror(_("Can't create temporary file"));
unlink(sigfile);
crypt_current_time(s, "PGP");
- pid = pgp_invoke_verify(NULL, &pgpout, NULL, -1, -1, fileno(pgperr), tempfile, sigfile);
+ pid = pgp_invoke_verify(NULL, &fp_pgp_out, NULL, -1, -1, fileno(fp_pgp_err),
+ tempfile, sigfile);
if (pid != -1)
{
- if (pgp_copy_checksig(pgpout, s->fp_out) >= 0)
+ if (pgp_copy_checksig(fp_pgp_out, s->fp_out) >= 0)
badsig = 0;
- mutt_file_fclose(&pgpout);
- fflush(pgperr);
- rewind(pgperr);
+ mutt_file_fclose(&fp_pgp_out);
+ fflush(fp_pgp_err);
+ rewind(fp_pgp_err);
- if (pgp_copy_checksig(pgperr, s->fp_out) >= 0)
+ if (pgp_copy_checksig(fp_pgp_err, s->fp_out) >= 0)
badsig = 0;
const int rv = mutt_wait_filter(pid);
mutt_debug(LL_DEBUG1, "mutt_wait_filter returned %d.\n", rv);
}
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
state_attach_puts(_("[-- End of PGP output --]\n\n"), s);
char tempfname[PATH_MAX];
mutt_mktemp(tempfname, sizeof(tempfname));
- FILE *tempfp = mutt_file_fopen(tempfname, "w");
- if (!tempfp)
+ FILE *fp_tmp = mutt_file_fopen(tempfname, "w");
+ if (!fp_tmp)
{
mutt_perror(tempfname);
return;
}
s.fp_in = fp;
- s.fp_out = tempfp;
+ s.fp_out = fp_tmp;
mutt_body_handler(top, &s);
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
pgp_class_invoke_import(tempfname);
mutt_any_key_to_continue(NULL);
/**
* pgp_decrypt_part - Decrypt part of a PGP message
- * @param a Body of attachment
- * @param s State to use
- * @param fpout File to write to
- * @param p Body of parent (main email)
+ * @param a Body of attachment
+ * @param s State to use
+ * @param fp_out File to write to
+ * @param p Body of parent (main email)
* @retval ptr New Body for the attachment
*/
static struct Body *pgp_decrypt_part(struct Body *a, struct State *s,
- FILE *fpout, struct Body *p)
+ FILE *fp_out, struct Body *p)
{
- if (!a || !s || !fpout || !p)
+ if (!a || !s || !fp_out || !p)
return NULL;
char buf[1024];
- FILE *pgpin = NULL, *pgpout = NULL, *pgptmp = NULL;
+ FILE *fp_pgp_in = NULL, *fp_pgp_out = NULL, *fp_pgp_tmp = NULL;
struct stat info;
struct Body *tattach = NULL;
char pgptmpfile[PATH_MAX];
pid_t pid;
int rv;
- FILE *pgperr = mutt_file_mkstemp();
- if (!pgperr)
+ FILE *fp_pgp_err = mutt_file_mkstemp();
+ if (!fp_pgp_err)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
mutt_mktemp(pgptmpfile, sizeof(pgptmpfile));
- pgptmp = mutt_file_fopen(pgptmpfile, "w");
- if (!pgptmp)
+ fp_pgp_tmp = mutt_file_fopen(pgptmpfile, "w");
+ if (!fp_pgp_tmp)
{
mutt_perror(pgptmpfile);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
return NULL;
}
*/
fseeko(s->fp_in, a->offset, SEEK_SET);
- mutt_file_copy_bytes(s->fp_in, pgptmp, a->length);
- mutt_file_fclose(&pgptmp);
+ mutt_file_copy_bytes(s->fp_in, fp_pgp_tmp, a->length);
+ mutt_file_fclose(&fp_pgp_tmp);
- pid = pgp_invoke_decrypt(&pgpin, &pgpout, NULL, -1, -1, fileno(pgperr), pgptmpfile);
+ pid = pgp_invoke_decrypt(&fp_pgp_in, &fp_pgp_out, NULL, -1, -1,
+ fileno(fp_pgp_err), pgptmpfile);
if (pid == -1)
{
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
unlink(pgptmpfile);
if (s->flags & MUTT_DISPLAY)
{
agent is active, because this might lead to a passphrase send as
the message. */
if (!pgp_use_gpg_agent())
- fputs(PgpPass, pgpin);
- fputc('\n', pgpin);
- mutt_file_fclose(&pgpin);
+ fputs(PgpPass, fp_pgp_in);
+ fputc('\n', fp_pgp_in);
+ mutt_file_fclose(&fp_pgp_in);
/* Read the output from PGP, and make sure to change CRLF to LF, otherwise
* read_mime_header has a hard time parsing the message.
*/
- while (fgets(buf, sizeof(buf) - 1, pgpout))
+ while (fgets(buf, sizeof(buf) - 1, fp_pgp_out))
{
size_t len = mutt_str_strlen(buf);
if (len > 1 && buf[len - 2] == '\r')
strcpy(buf + len - 2, "\n");
- fputs(buf, fpout);
+ fputs(buf, fp_out);
}
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_pgp_out);
rv = mutt_wait_filter(pid);
mutt_file_unlink(pgptmpfile);
- fflush(pgperr);
- rewind(pgperr);
- if (pgp_check_decryption_okay(pgperr) < 0)
+ fflush(fp_pgp_err);
+ rewind(fp_pgp_err);
+ if (pgp_check_decryption_okay(fp_pgp_err) < 0)
{
mutt_error(_("Decryption failed"));
pgp_class_void_passphrase();
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
return NULL;
}
if (s->flags & MUTT_DISPLAY)
{
- rewind(pgperr);
- if (pgp_copy_checksig(pgperr, s->fp_out) == 0 && !rv)
+ rewind(fp_pgp_err);
+ if (pgp_copy_checksig(fp_pgp_err, s->fp_out) == 0 && !rv)
p->goodsig = true;
else
p->goodsig = false;
state_attach_puts(_("[-- End of PGP output --]\n\n"), s);
}
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
- fflush(fpout);
- rewind(fpout);
+ fflush(fp_out);
+ rewind(fp_out);
if (pgp_use_gpg_agent())
mutt_need_hard_redraw();
- if (fgetc(fpout) == EOF)
+ if (fgetc(fp_out) == EOF)
{
mutt_error(_("Decryption failed"));
pgp_class_void_passphrase();
return NULL;
}
- rewind(fpout);
+ rewind(fp_out);
- tattach = mutt_read_mime_header(fpout, 0);
+ tattach = mutt_read_mime_header(fp_out, 0);
if (tattach)
{
/* Need to set the length of this body part. */
- fstat(fileno(fpout), &info);
+ fstat(fileno(fp_out), &info);
tattach->length = info.st_size - tattach->offset;
/* See if we need to recurse on this MIME part. */
- mutt_parse_part(fpout, tattach);
+ mutt_parse_part(fp_out, tattach);
}
return tattach;
/**
* pgp_class_decrypt_mime - Implements CryptModuleSpecs::decrypt_mime()
*/
-int pgp_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
+int pgp_class_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
struct State s = { 0 };
struct Body *p = b;
int saved_type = 0;
LOFF_T saved_offset = 0;
size_t saved_length = 0;
- FILE *decoded_fp = NULL;
+ FILE *fp_decoded = NULL;
int rc = 0;
if (mutt_is_valid_multipart_pgp_encrypted(b))
else
return -1;
- s.fp_in = fpin;
+ s.fp_in = fp_in;
if (need_decode)
{
saved_offset = b->offset;
saved_length = b->length;
- decoded_fp = mutt_file_mkstemp();
- if (!decoded_fp)
+ fp_decoded = mutt_file_mkstemp();
+ if (!fp_decoded)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
fseeko(s.fp_in, b->offset, SEEK_SET);
- s.fp_out = decoded_fp;
+ s.fp_out = fp_decoded;
mutt_decode_attachment(b, &s);
- fflush(decoded_fp);
- b->length = ftello(decoded_fp);
+ fflush(fp_decoded);
+ b->length = ftello(fp_decoded);
b->offset = 0;
- rewind(decoded_fp);
- s.fp_in = decoded_fp;
+ rewind(fp_decoded);
+ s.fp_in = fp_decoded;
s.fp_out = 0;
}
- *fpout = mutt_file_mkstemp();
- if (!*fpout)
+ *fp_out = mutt_file_mkstemp();
+ if (!*fp_out)
{
mutt_perror(_("Can't create temporary file"));
rc = -1;
goto bail;
}
- *cur = pgp_decrypt_part(b, &s, *fpout, p);
+ *cur = pgp_decrypt_part(b, &s, *fp_out, p);
if (!*cur)
rc = -1;
- rewind(*fpout);
+ rewind(*fp_out);
bail:
if (need_decode)
b->type = saved_type;
b->length = saved_length;
b->offset = saved_offset;
- mutt_file_fclose(&decoded_fp);
+ mutt_file_fclose(&fp_decoded);
}
return rc;
*/
int pgp_class_encrypted_handler(struct Body *a, struct State *s)
{
- FILE *fpin = NULL;
+ FILE *fp_in = NULL;
struct Body *tattach = NULL;
int rc = 0;
- FILE *fpout = mutt_file_mkstemp();
- if (!fpout)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
mutt_perror(_("Can't create temporary file"));
if (s->flags & MUTT_DISPLAY)
if (s->flags & MUTT_DISPLAY)
crypt_current_time(s, "PGP");
- tattach = pgp_decrypt_part(a, s, fpout, a);
+ tattach = pgp_decrypt_part(a, s, fp_out, a);
if (tattach)
{
if (s->flags & MUTT_DISPLAY)
a->mime_headers = tattach->mime_headers;
tattach->mime_headers = NULL;
- fpin = s->fp_in;
- s->fp_in = fpout;
+ fp_in = s->fp_in;
+ s->fp_in = fp_out;
rc = mutt_body_handler(tattach, s);
- s->fp_in = fpin;
+ s->fp_in = fp_in;
/* Embedded multipart signed protected headers override the
* encrypted headers. We need to do this after the handler so
rc = -1;
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
return rc;
}
struct Body *t = NULL;
char buf[1024];
char sigfile[PATH_MAX], signedfile[PATH_MAX];
- FILE *pgpin = NULL, *pgpout = NULL, *pgperr = NULL, *sfp = NULL;
+ FILE *fp_pgp_in = NULL, *fp_pgp_out = NULL, *fp_pgp_err = NULL, *fp_signed = NULL;
bool err = false;
bool empty = true;
pid_t pid;
crypt_convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp(sigfile, sizeof(sigfile));
- FILE *fp = mutt_file_fopen(sigfile, "w");
- if (!fp)
+ FILE *fp_sig = mutt_file_fopen(sigfile, "w");
+ if (!fp_sig)
{
return NULL;
}
mutt_mktemp(signedfile, sizeof(signedfile));
- sfp = mutt_file_fopen(signedfile, "w");
- if (!sfp)
+ fp_signed = mutt_file_fopen(signedfile, "w");
+ if (!fp_signed)
{
mutt_perror(signedfile);
- mutt_file_fclose(&fp);
+ mutt_file_fclose(&fp_sig);
unlink(sigfile);
return NULL;
}
- mutt_write_mime_header(a, sfp);
- fputc('\n', sfp);
- mutt_write_mime_body(a, sfp);
- mutt_file_fclose(&sfp);
+ mutt_write_mime_header(a, fp_signed);
+ fputc('\n', fp_signed);
+ mutt_write_mime_body(a, fp_signed);
+ mutt_file_fclose(&fp_signed);
- pid = pgp_invoke_sign(&pgpin, &pgpout, &pgperr, -1, -1, -1, signedfile);
+ pid = pgp_invoke_sign(&fp_pgp_in, &fp_pgp_out, &fp_pgp_err, -1, -1, -1, signedfile);
if (pid == -1)
{
mutt_perror(_("Can't open PGP subprocess"));
- mutt_file_fclose(&fp);
+ mutt_file_fclose(&fp_sig);
unlink(sigfile);
unlink(signedfile);
return NULL;
}
if (!pgp_use_gpg_agent())
- fputs(PgpPass, pgpin);
- fputc('\n', pgpin);
- mutt_file_fclose(&pgpin);
+ fputs(PgpPass, fp_pgp_in);
+ fputc('\n', fp_pgp_in);
+ mutt_file_fclose(&fp_pgp_in);
/* Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as
* recommended for future releases of PGP.
*/
- while (fgets(buf, sizeof(buf) - 1, pgpout))
+ while (fgets(buf, sizeof(buf) - 1, fp_pgp_out))
{
if (mutt_str_strcmp("-----BEGIN PGP MESSAGE-----\n", buf) == 0)
- fputs("-----BEGIN PGP SIGNATURE-----\n", fp);
+ fputs("-----BEGIN PGP SIGNATURE-----\n", fp_sig);
else if (mutt_str_strcmp("-----END PGP MESSAGE-----\n", buf) == 0)
- fputs("-----END PGP SIGNATURE-----\n", fp);
+ fputs("-----END PGP SIGNATURE-----\n", fp_sig);
else
- fputs(buf, fp);
+ fputs(buf, fp_sig);
empty = false; /* got some output, so we're ok */
}
/* check for errors from PGP */
err = false;
- while (fgets(buf, sizeof(buf) - 1, pgperr))
+ while (fgets(buf, sizeof(buf) - 1, fp_pgp_err))
{
err = true;
fputs(buf, stdout);
if (mutt_wait_filter(pid) && C_PgpCheckExit)
empty = true;
- mutt_file_fclose(&pgperr);
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_pgp_err);
+ mutt_file_fclose(&fp_pgp_out);
unlink(signedfile);
- if (fclose(fp) != 0)
+ if (fclose(fp_sig) != 0)
{
mutt_perror("fclose");
unlink(sigfile);
char buf[1024];
char tempfile[PATH_MAX];
char pgpinfile[PATH_MAX];
- FILE *pgpin = NULL, *fptmp = NULL;
+ FILE *fp_pgp_in = NULL, *fp_tmp = NULL;
struct Body *t = NULL;
int err = 0;
int empty = 0;
pid_t pid;
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *fpout = mutt_file_fopen(tempfile, "w+");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfile, "w+");
+ if (!fp_out)
{
mutt_perror(tempfile);
return NULL;
}
- FILE *pgperr = mutt_file_mkstemp();
- if (!pgperr)
+ FILE *fp_pgp_err = mutt_file_mkstemp();
+ if (!fp_pgp_err)
{
mutt_perror(_("Can't create temporary file"));
unlink(tempfile);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
return NULL;
}
mutt_mktemp(pgpinfile, sizeof(pgpinfile));
- fptmp = mutt_file_fopen(pgpinfile, "w");
- if (!fptmp)
+ fp_tmp = mutt_file_fopen(pgpinfile, "w");
+ if (!fp_tmp)
{
mutt_perror(pgpinfile);
unlink(tempfile);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_pgp_err);
return NULL;
}
if (sign)
crypt_convert_to_7bit(a);
- mutt_write_mime_header(a, fptmp);
- fputc('\n', fptmp);
- mutt_write_mime_body(a, fptmp);
- mutt_file_fclose(&fptmp);
+ mutt_write_mime_header(a, fp_tmp);
+ fputc('\n', fp_tmp);
+ mutt_write_mime_body(a, fp_tmp);
+ mutt_file_fclose(&fp_tmp);
- pid = pgp_invoke_encrypt(&pgpin, NULL, NULL, -1, fileno(fpout),
- fileno(pgperr), pgpinfile, keylist, sign);
+ pid = pgp_invoke_encrypt(&fp_pgp_in, NULL, NULL, -1, fileno(fp_out),
+ fileno(fp_pgp_err), pgpinfile, keylist, sign);
if (pid == -1)
{
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_pgp_err);
unlink(pgpinfile);
return NULL;
}
if (sign)
{
if (!pgp_use_gpg_agent())
- fputs(PgpPass, pgpin);
- fputc('\n', pgpin);
+ fputs(PgpPass, fp_pgp_in);
+ fputc('\n', fp_pgp_in);
}
- mutt_file_fclose(&pgpin);
+ mutt_file_fclose(&fp_pgp_in);
if (mutt_wait_filter(pid) && C_PgpCheckExit)
empty = 1;
unlink(pgpinfile);
- fflush(fpout);
- rewind(fpout);
+ fflush(fp_out);
+ rewind(fp_out);
if (!empty)
- empty = (fgetc(fpout) == EOF);
- mutt_file_fclose(&fpout);
+ empty = (fgetc(fp_out) == EOF);
+ mutt_file_fclose(&fp_out);
- fflush(pgperr);
- rewind(pgperr);
- while (fgets(buf, sizeof(buf) - 1, pgperr))
+ fflush(fp_pgp_err);
+ rewind(fp_pgp_err);
+ while (fgets(buf, sizeof(buf) - 1, fp_pgp_err))
{
err = 1;
fputs(buf, stdout);
}
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
/* pause if there is any error output from PGP */
if (err)
char *from_charset = NULL;
const char *send_charset = NULL;
- FILE *fp = NULL;
-
bool empty = false;
bool err;
if (mutt_str_strcasecmp(a->subtype, "plain") != 0)
return NULL;
- fp = fopen(a->filename, "r");
- if (!fp)
+ FILE *fp_body = fopen(a->filename, "r");
+ if (!fp_body)
{
mutt_perror(a->filename);
return NULL;
}
mutt_mktemp(pgpinfile, sizeof(pgpinfile));
- FILE *pgpin = mutt_file_fopen(pgpinfile, "w");
- if (!pgpin)
+ FILE *fp_pgp_in = mutt_file_fopen(pgpinfile, "w");
+ if (!fp_pgp_in)
{
mutt_perror(pgpinfile);
- mutt_file_fclose(&fp);
+ mutt_file_fclose(&fp_body);
return NULL;
}
send_charset = "utf-8";
/* fromcode is assumed to be correct: we set flags to 0 */
- fc = mutt_ch_fgetconv_open(fp, from_charset, "utf-8", 0);
+ fc = mutt_ch_fgetconv_open(fp_body, from_charset, "utf-8", 0);
while ((c = mutt_ch_fgetconv(fc)) != EOF)
- fputc(c, pgpin);
+ fputc(c, fp_pgp_in);
mutt_ch_fgetconv_close(&fc);
}
else
{
send_charset = "us-ascii";
- mutt_file_copy_stream(fp, pgpin);
+ mutt_file_copy_stream(fp_body, fp_pgp_in);
}
- mutt_file_fclose(&fp);
- mutt_file_fclose(&pgpin);
+ mutt_file_fclose(&fp_body);
+ mutt_file_fclose(&fp_pgp_in);
mutt_mktemp(pgpoutfile, sizeof(pgpoutfile));
- FILE *pgpout = mutt_file_fopen(pgpoutfile, "w+");
- FILE *pgperr = mutt_file_mkstemp();
- if (!pgpout || !pgperr)
+ FILE *fp_pgp_out = mutt_file_fopen(pgpoutfile, "w+");
+ FILE *fp_pgp_err = mutt_file_mkstemp();
+ if (!fp_pgp_out || !fp_pgp_err)
{
- mutt_perror(pgpout ? "Can't create temporary file" : pgpoutfile);
+ mutt_perror(fp_pgp_out ? "Can't create temporary file" : pgpoutfile);
unlink(pgpinfile);
- if (pgpout)
+ if (fp_pgp_out)
{
- mutt_file_fclose(&pgpout);
+ mutt_file_fclose(&fp_pgp_out);
unlink(pgpoutfile);
}
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
return NULL;
}
- pid = pgp_invoke_traditional(&pgpin, NULL, NULL, -1, fileno(pgpout),
- fileno(pgperr), pgpinfile, keylist, flags);
+ pid = pgp_invoke_traditional(&fp_pgp_in, NULL, NULL, -1, fileno(fp_pgp_out),
+ fileno(fp_pgp_err), pgpinfile, keylist, flags);
if (pid == -1)
{
mutt_perror(_("Can't invoke PGP"));
- mutt_file_fclose(&pgpout);
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_out);
+ mutt_file_fclose(&fp_pgp_err);
mutt_file_unlink(pgpinfile);
unlink(pgpoutfile);
return NULL;
if (pgp_use_gpg_agent())
*PgpPass = 0;
if (flags & SEC_SIGN)
- fprintf(pgpin, "%s\n", PgpPass);
- mutt_file_fclose(&pgpin);
+ fprintf(fp_pgp_in, "%s\n", PgpPass);
+ mutt_file_fclose(&fp_pgp_in);
if (mutt_wait_filter(pid) && C_PgpCheckExit)
empty = true;
mutt_file_unlink(pgpinfile);
- fflush(pgpout);
- fflush(pgperr);
+ fflush(fp_pgp_out);
+ fflush(fp_pgp_err);
- rewind(pgpout);
- rewind(pgperr);
+ rewind(fp_pgp_out);
+ rewind(fp_pgp_err);
if (!empty)
- empty = (fgetc(pgpout) == EOF);
- mutt_file_fclose(&pgpout);
+ empty = (fgetc(fp_pgp_out) == EOF);
+ mutt_file_fclose(&fp_pgp_out);
err = false;
- while (fgets(buf, sizeof(buf), pgperr))
+ while (fgets(buf, sizeof(buf), fp_pgp_err))
{
err = true;
fputs(buf, stdout);
}
- mutt_file_fclose(&pgperr);
+ mutt_file_fclose(&fp_pgp_err);
if (err)
mutt_any_key_to_continue(NULL);
char *pgp_long_keyid(struct PgpKeyInfo * k);
char *pgp_fpr_or_lkeyid(struct PgpKeyInfo * k);
-int pgp_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
+int pgp_class_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
char *pgp_class_find_keys(struct Address *addrlist, bool oppenc_mode);
/**
* pgp_invoke - Run a PGP command
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
* @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
* @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
* @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-static pid_t pgp_invoke(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd,
- int pgperrfd, bool need_passphrase, const char *fname,
+static pid_t pgp_invoke(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ bool need_passphrase, const char *fname,
const char *sig_fname, const char *ids, const char *format)
{
struct PgpCommandContext cctx = { 0 };
mutt_pgp_command(cmd, sizeof(cmd), &cctx, format);
- return mutt_create_filter_fd(cmd, pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd);
+ return mutt_create_filter_fd(cmd, fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd,
+ pgpoutfd, pgperrfd);
}
/*
/**
* pgp_invoke_decode - Use PGP to decode a message
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
* @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
* @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
* @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_decode(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *fname, bool need_passphrase)
+pid_t pgp_invoke_decode(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, bool need_passphrase)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd, pgperrfd,
need_passphrase, fname, NULL, NULL, C_PgpDecodeCommand);
}
/**
* pgp_invoke_verify - Use PGP to verify a message
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] fname Filename to pass to the command
- * @param[in] sig_fname Signature filename to pass to the command
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] fname Filename to pass to the command
+ * @param[in] sig_fname Signature filename to pass to the command
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_verify(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *fname, const char *sig_fname)
+pid_t pgp_invoke_verify(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, const char *sig_fname)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, false,
- fname, sig_fname, NULL, C_PgpVerifyCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, false, fname, sig_fname, NULL, C_PgpVerifyCommand);
}
/**
* pgp_invoke_decrypt - Use PGP to decrypt a file
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] fname Filename to pass to the command
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] fname Filename to pass to the command
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_decrypt(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *fname)
+pid_t pgp_invoke_decrypt(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, true,
- fname, NULL, NULL, C_PgpDecryptCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, true, fname, NULL, NULL, C_PgpDecryptCommand);
}
/**
* pgp_invoke_sign - Use PGP to sign a file
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] fname Filename to pass to the command
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] fname Filename to pass to the command
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_sign(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *fname)
+pid_t pgp_invoke_sign(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, true,
- fname, NULL, NULL, C_PgpSignCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, true, fname, NULL, NULL, C_PgpSignCommand);
}
/**
* pgp_invoke_encrypt - Use PGP to encrypt a file
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] fname Filename to pass to the command
- * @param[in] uids List of IDs/fingerprints, space separated
- * @param[in] sign If true, also sign the file
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] fname Filename to pass to the command
+ * @param[in] uids List of IDs/fingerprints, space separated
+ * @param[in] sign If true, also sign the file
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_encrypt(FILE **pgpin, FILE **pgpout, FILE **pgperr,
+pid_t pgp_invoke_encrypt(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
int pgpinfd, int pgpoutfd, int pgperrfd,
const char *fname, const char *uids, bool sign)
{
if (sign)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, true,
- fname, NULL, uids, C_PgpEncryptSignCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, true, fname, NULL, uids, C_PgpEncryptSignCommand);
}
else
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, false,
- fname, NULL, uids, C_PgpEncryptOnlyCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, false, fname, NULL, uids, C_PgpEncryptOnlyCommand);
}
}
/**
* pgp_invoke_traditional - Use PGP to create in inline-signed message
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] fname Filename to pass to the command
- * @param[in] uids List of IDs/fingerprints, space separated
- * @param[in] flags Flags, see #SecurityFlags
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] fname Filename to pass to the command
+ * @param[in] uids List of IDs/fingerprints, space separated
+ * @param[in] flags Flags, see #SecurityFlags
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_traditional(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *fname,
- const char *uids, SecurityFlags flags)
+pid_t pgp_invoke_traditional(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd,
+ const char *fname, const char *uids, SecurityFlags flags)
{
if (flags & SEC_ENCRYPT)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd,
- (flags & SEC_SIGN), fname, NULL, uids,
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, (flags & SEC_SIGN), fname, NULL, uids,
(flags & SEC_SIGN) ? C_PgpEncryptSignCommand : C_PgpEncryptOnlyCommand);
}
else
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, true,
- fname, NULL, NULL, C_PgpClearsignCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, true, fname, NULL, NULL, C_PgpClearsignCommand);
}
}
/**
* pgp_invoke_export - Use PGP to export a key from the user's keyring
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] uids List of IDs/fingerprints, space separated
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] uids List of IDs/fingerprints, space separated
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_export(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *uids)
+pid_t pgp_invoke_export(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, false,
- NULL, NULL, uids, C_PgpExportCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, false, NULL, NULL, uids, C_PgpExportCommand);
}
/**
* pgp_invoke_verify_key - Use PGP to verify a key
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] uids List of IDs/fingerprints, space separated
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] uids List of IDs/fingerprints, space separated
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_verify_key(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd,
- int pgpoutfd, int pgperrfd, const char *uids)
+pid_t pgp_invoke_verify_key(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
+ int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids)
{
- return pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, false,
- NULL, NULL, uids, C_PgpVerifyKeyCommand);
+ return pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, false, NULL, NULL, uids, C_PgpVerifyKeyCommand);
}
/**
* pgp_invoke_list_keys - Find matching PGP Keys
- * @param[out] pgpin stdin for the command, or NULL (OPTIONAL)
- * @param[out] pgpout stdout for the command, or NULL (OPTIONAL)
- * @param[out] pgperr stderr for the command, or NULL (OPTIONAL)
- * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
- * @param[in] keyring Keyring type, e.g. #PGP_SECRING
- * @param[in] hints Match keys to these strings
+ * @param[out] fp_pgp_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_pgp_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] pgpinfd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] pgpoutfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] pgperrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[in] keyring Keyring type, e.g. #PGP_SECRING
+ * @param[in] hints Match keys to these strings
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `pgpin` has priority over `pgpinfd`.
- * Likewise `pgpout` and `pgperr`.
+ * @note `fp_pgp_in` has priority over `pgpinfd`.
+ * Likewise `fp_pgp_out` and `fp_pgp_err`.
*/
-pid_t pgp_invoke_list_keys(FILE **pgpin, FILE **pgpout, FILE **pgperr,
+pid_t pgp_invoke_list_keys(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err,
int pgpinfd, int pgpoutfd, int pgperrfd,
enum PgpRing keyring, struct ListHead *hints)
{
mutt_buffer_addch(uids, ' ');
}
- pid_t rc = pgp_invoke(pgpin, pgpout, pgperr, pgpinfd, pgpoutfd, pgperrfd, 0,
- NULL, NULL, mutt_b2s(uids),
+ pid_t rc = pgp_invoke(fp_pgp_in, fp_pgp_out, fp_pgp_err, pgpinfd, pgpoutfd,
+ pgperrfd, 0, NULL, NULL, mutt_b2s(uids),
keyring == PGP_SECRING ? C_PgpListSecringCommand : C_PgpListPubringCommand);
mutt_buffer_pool_release(&uids);
void pgp_class_invoke_import(const char *fname);
void pgp_class_invoke_getkeys(struct Address *addr);
-pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, bool need_passphrase);
-pid_t pgp_invoke_decrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname);
-pid_t pgp_invoke_encrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, bool sign);
-pid_t pgp_invoke_export (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids);
-pid_t pgp_invoke_list_keys (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, enum PgpRing keyring, struct ListHead *hints);
-pid_t pgp_invoke_sign (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname);
-pid_t pgp_invoke_traditional(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, int flags);
-pid_t pgp_invoke_verify (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *sig_fname);
-pid_t pgp_invoke_verify_key (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids);
+pid_t pgp_invoke_decode (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, bool need_passphrase);
+pid_t pgp_invoke_decrypt (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname);
+pid_t pgp_invoke_encrypt (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, bool sign);
+pid_t pgp_invoke_export (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids);
+pid_t pgp_invoke_list_keys (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, enum PgpRing keyring, struct ListHead *hints);
+pid_t pgp_invoke_sign (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname);
+pid_t pgp_invoke_traditional(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, int flags);
+pid_t pgp_invoke_verify (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *sig_fname);
+pid_t pgp_invoke_verify_key (FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids);
#endif /* MUTT_NCRYPT_PGPINVOKE_H */
case OP_VERIFY_KEY:
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *devnull = fopen("/dev/null", "w");
- if (!devnull)
+ FILE *fp_null = fopen("/dev/null", "w");
+ if (!fp_null)
{
mutt_perror(_("Can't open /dev/null"));
break;
}
- FILE *fp = mutt_file_fopen(tempfile, "w");
- if (!fp)
+ FILE *fp_tmp = mutt_file_fopen(tempfile, "w");
+ if (!fp_tmp)
{
- mutt_file_fclose(&devnull);
+ mutt_file_fclose(&fp_null);
mutt_perror(_("Can't create temporary file"));
break;
}
snprintf(tmpbuf, sizeof(tmpbuf), "0x%s",
pgp_fpr_or_lkeyid(pgp_principal_key(key_table[menu->current]->parent)));
- pid_t pid = pgp_invoke_verify_key(NULL, NULL, NULL, -1, fileno(fp),
- fileno(devnull), tmpbuf);
+ pid_t pid = pgp_invoke_verify_key(NULL, NULL, NULL, -1, fileno(fp_tmp),
+ fileno(fp_null), tmpbuf);
if (pid == -1)
{
mutt_perror(_("Can't create filter"));
unlink(tempfile);
- mutt_file_fclose(&fp);
- mutt_file_fclose(&devnull);
+ mutt_file_fclose(&fp_tmp);
+ mutt_file_fclose(&fp_null);
}
mutt_wait_filter(pid);
- mutt_file_fclose(&fp);
- mutt_file_fclose(&devnull);
+ mutt_file_fclose(&fp_tmp);
+ mutt_file_fclose(&fp_null);
mutt_clear_error();
snprintf(cmd, sizeof(cmd), _("Key ID: 0x%s"),
pgp_keyid(pgp_principal_key(key_table[menu->current]->parent)));
struct Body *att = NULL;
char buf[1024];
char tempf[PATH_MAX], tmp[256];
- FILE *tempfp = NULL;
- FILE *devnull = NULL;
struct stat sb;
pid_t pid;
OptPgpCheckTrust = false;
mutt_mktemp(tempf, sizeof(tempf));
- tempfp = mutt_file_fopen(tempf, "w");
- if (!tempfp)
+ FILE *fp_tmp = mutt_file_fopen(tempf, "w");
+ if (!fp_tmp)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
- devnull = fopen("/dev/null", "w");
- if (!devnull)
+ FILE *fp_null = fopen("/dev/null", "w");
+ if (!fp_null)
{
mutt_perror(_("Can't open /dev/null"));
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
unlink(tempf);
return NULL;
}
mutt_message(_("Invoking PGP..."));
- pid = pgp_invoke_export(NULL, NULL, NULL, -1, fileno(tempfp), fileno(devnull), tmp);
+ pid = pgp_invoke_export(NULL, NULL, NULL, -1, fileno(fp_tmp), fileno(fp_null), tmp);
if (pid == -1)
{
mutt_perror(_("Can't create filter"));
unlink(tempf);
- mutt_file_fclose(&tempfp);
- mutt_file_fclose(&devnull);
+ mutt_file_fclose(&fp_tmp);
+ mutt_file_fclose(&fp_null);
return NULL;
}
mutt_wait_filter(pid);
- mutt_file_fclose(&tempfp);
- mutt_file_fclose(&devnull);
+ mutt_file_fclose(&fp_tmp);
+ mutt_file_fclose(&fp_null);
att = mutt_body_new();
att->filename = mutt_str_strdup(tempf);
/**
* pgp_dearmor - Unwrap an armoured PGP block
- * @param in File to read from
- * @param out File to write to
+ * @param fp_in File to read from
+ * @param fp_out File to write to
*/
-static void pgp_dearmor(FILE *in, FILE *out)
+static void pgp_dearmor(FILE *fp_in, FILE *fp_out)
{
char line[8192];
LOFF_T start;
char *r = NULL;
struct State state = { 0 };
- state.fp_in = in;
- state.fp_out = out;
+ state.fp_in = fp_in;
+ state.fp_out = fp_out;
/* find the beginning of ASCII armor */
- while ((r = fgets(line, sizeof(line), in)))
+ while ((r = fgets(line, sizeof(line), fp_in)))
{
if (strncmp(line, "-----BEGIN", 10) == 0)
break;
/* skip the armor header */
- while ((r = fgets(line, sizeof(line), in)))
+ while ((r = fgets(line, sizeof(line), fp_in)))
{
SKIPWS(r);
if (!*r)
}
/* actual data starts here */
- start = ftello(in);
+ start = ftello(fp_in);
if (start < 0)
return;
/* find the checksum */
- while ((r = fgets(line, sizeof(line), in)))
+ while ((r = fgets(line, sizeof(line), fp_in)))
{
if (*line == '=' || (strncmp(line, "-----END", 8) == 0))
break;
return;
}
- end = ftello(in) - strlen(line);
+ end = ftello(fp_in) - strlen(line);
if (end < start)
{
mutt_debug(LL_DEBUG1, "end < start???\n");
return;
}
- if (fseeko(in, start, SEEK_SET) == -1)
+ if (fseeko(fp_in, start, SEEK_SET) == -1)
{
mutt_debug(LL_DEBUG1, "Can't seekto start.\n");
return;
size_t l;
short rc = -1;
- FILE *out = mutt_file_mkstemp();
- if (!out)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
mutt_perror(_("Can't create temporary file"));
goto bye;
}
- FILE *in = fopen(fname, "r");
- if (!in)
+ FILE *fp_in = fopen(fname, "r");
+ if (!fp_in)
{
mutt_perror(fname);
goto bye;
}
- pgp_dearmor(in, out);
- rewind(out);
+ pgp_dearmor(fp_in, fp_out);
+ rewind(fp_out);
- unsigned char *p = pgp_read_packet(out, &l);
+ unsigned char *p = pgp_read_packet(fp_out, &l);
if (p)
{
rc = pgp_mic_from_packet(p, l);
bye:
- mutt_file_fclose(&in);
- mutt_file_fclose(&out);
+ mutt_file_fclose(&fp_in);
+ mutt_file_fclose(&fp_out);
pgp_release_packet();
return rc;
}
static char SmimeKeyToUse[PATH_MAX] = { 0 };
static char SmimeCertToUse[PATH_MAX];
-static char SmimeIntermediateToUse[PATH_MAX];
+static char fp_smime_intermediateToUse[PATH_MAX];
/**
* smime_free_key - Free a list of SMIME keys
/**
* smime_invoke - Run an SMIME command
- * @param[out] smimein stdin for the command, or NULL (OPTIONAL)
- * @param[out] smimeout stdout for the command, or NULL (OPTIONAL)
- * @param[out] smimeerr stderr for the command, or NULL (OPTIONAL)
- * @param[in] smimeinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] smimeoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] smimeerrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[out] fp_smime_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] fp_smime_infd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_outfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_errfd stderr for the command, or -1 (OPTIONAL)
* @param[in] fname Filename to pass to the command
* @param[in] sig_fname Signature filename to pass to the command
* @param[in] cryptalg Encryption algorithm
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `smimein` has priority over `smimeinfd`.
- * Likewise `smimeout` and `smimeerr`.
+ * @note `fp_smime_in` has priority over `fp_smime_infd`.
+ * Likewise `fp_smime_out` and `fp_smime_err`.
*/
-static pid_t smime_invoke(FILE **smimein, FILE **smimeout, FILE **smimeerr,
- int smimeinfd, int smimeoutfd, int smimeerrfd,
+static pid_t smime_invoke(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err,
+ int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd,
const char *fname, const char *sig_fname, const char *cryptalg,
const char *digestalg, const char *key, const char *certificates,
const char *intermediates, const char *format)
smime_command(cmd, sizeof(cmd), &cctx, format);
- return mutt_create_filter_fd(cmd, smimein, smimeout, smimeerr, smimeinfd,
- smimeoutfd, smimeerrfd);
+ return mutt_create_filter_fd(cmd, fp_smime_in, fp_smime_out, fp_smime_err,
+ fp_smime_infd, fp_smime_outfd, fp_smime_errfd);
}
/*
pid_t pid;
size_t len = 0;
- FILE *fperr = mutt_file_mkstemp();
- if (!fperr)
+ FILE *fp_err = mutt_file_mkstemp();
+ if (!fp_err)
{
mutt_perror(_("Can't create temporary file"));
return 1;
}
- FILE *fpout = mutt_file_mkstemp();
- if (!fpout)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_perror(_("Can't create temporary file"));
return 1;
}
- pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), certificate,
+ pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), certificate,
NULL, NULL, NULL, NULL, NULL, NULL, C_SmimeGetCertEmailCommand);
if (pid == -1)
{
mutt_message(_("Error: unable to create OpenSSL subprocess"));
- mutt_file_fclose(&fperr);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_err);
+ mutt_file_fclose(&fp_out);
return 1;
}
mutt_wait_filter(pid);
- fflush(fpout);
- rewind(fpout);
- fflush(fperr);
- rewind(fperr);
+ fflush(fp_out);
+ rewind(fp_out);
+ fflush(fp_err);
+ rewind(fp_err);
- while ((fgets(email, sizeof(email), fpout)))
+ while ((fgets(email, sizeof(email), fp_out)))
{
len = mutt_str_strlen(email);
if (len && (email[len - 1] == '\n'))
if (rc == -1)
{
mutt_endwin();
- mutt_file_copy_stream(fperr, stdout);
+ mutt_file_copy_stream(fp_err, stdout);
mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess"));
rc = 1;
}
*buffer = mutt_mem_calloc(count, sizeof(char *));
count = 0;
- rewind(fpout);
- while ((fgets(email, sizeof(email), fpout)))
+ rewind(fp_out);
+ while ((fgets(email, sizeof(email), fp_out)))
{
len = mutt_str_strlen(email);
if (len && (email[len - 1] == '\n'))
else if (copy)
rc = 2;
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
return rc;
}
pid_t pid;
int empty;
- FILE *fperr = mutt_file_mkstemp();
- if (!fperr)
+ FILE *fp_err = mutt_file_mkstemp();
+ if (!fp_err)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
mutt_mktemp(pk7out, sizeof(pk7out));
- FILE *fpout = mutt_file_fopen(pk7out, "w+");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(pk7out, "w+");
+ if (!fp_out)
{
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_perror(pk7out);
return NULL;
}
/* Step 1: Convert the signature to a PKCS#7 structure, as we can't
extract the full set of certificates directly.
*/
- pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), infile,
+ pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), infile,
NULL, NULL, NULL, NULL, NULL, NULL, C_SmimePk7outCommand);
if (pid == -1)
{
mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess"));
- mutt_file_fclose(&fperr);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_err);
+ mutt_file_fclose(&fp_out);
mutt_file_unlink(pk7out);
return NULL;
}
mutt_wait_filter(pid);
- fflush(fpout);
- rewind(fpout);
- fflush(fperr);
- rewind(fperr);
- empty = (fgetc(fpout) == EOF);
+ fflush(fp_out);
+ rewind(fp_out);
+ fflush(fp_err);
+ rewind(fp_err);
+ empty = (fgetc(fp_out) == EOF);
if (empty)
{
mutt_perror(pk7out);
- mutt_file_copy_stream(fperr, stdout);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_copy_stream(fp_err, stdout);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
mutt_file_unlink(pk7out);
return NULL;
}
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
mutt_mktemp(certfile, sizeof(certfile));
- fpout = mutt_file_fopen(certfile, "w+");
- if (!fpout)
+ fp_out = mutt_file_fopen(certfile, "w+");
+ if (!fp_out)
{
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_file_unlink(pk7out);
mutt_perror(certfile);
return NULL;
/* Step 2: Extract the certificates from a PKCS#7 structure.
*/
- pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fpout), fileno(fperr), pk7out,
+ pid = smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), pk7out,
NULL, NULL, NULL, NULL, NULL, NULL, C_SmimeGetCertCommand);
if (pid == -1)
{
mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess"));
- mutt_file_fclose(&fperr);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_err);
+ mutt_file_fclose(&fp_out);
mutt_file_unlink(pk7out);
mutt_file_unlink(certfile);
return NULL;
mutt_file_unlink(pk7out);
- fflush(fpout);
- rewind(fpout);
- fflush(fperr);
- rewind(fperr);
- empty = (fgetc(fpout) == EOF);
+ fflush(fp_out);
+ rewind(fp_out);
+ fflush(fp_err);
+ rewind(fp_err);
+ empty = (fgetc(fp_out) == EOF);
if (empty)
{
- mutt_file_copy_stream(fperr, stdout);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_copy_stream(fp_err, stdout);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
mutt_file_unlink(certfile);
return NULL;
}
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
return mutt_str_strdup(certfile);
}
pid_t pid;
int empty;
- FILE *fperr = mutt_file_mkstemp();
- if (!fperr)
+ FILE *fp_err = mutt_file_mkstemp();
+ if (!fp_err)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
mutt_mktemp(certfile, sizeof(certfile));
- FILE *fpout = mutt_file_fopen(certfile, "w+");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(certfile, "w+");
+ if (!fp_out)
{
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_perror(certfile);
return NULL;
}
/* Extract signer's certificate
*/
- pid = smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fperr), infile, NULL, NULL,
+ pid = smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fp_err), infile, NULL, NULL,
NULL, NULL, certfile, NULL, C_SmimeGetSignerCertCommand);
if (pid == -1)
{
mutt_any_key_to_continue(_("Error: unable to create OpenSSL subprocess"));
- mutt_file_fclose(&fperr);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_err);
+ mutt_file_fclose(&fp_out);
mutt_file_unlink(certfile);
return NULL;
}
mutt_wait_filter(pid);
- fflush(fpout);
- rewind(fpout);
- fflush(fperr);
- rewind(fperr);
- empty = (fgetc(fpout) == EOF);
+ fflush(fp_out);
+ rewind(fp_out);
+ fflush(fp_err);
+ rewind(fp_err);
+ empty = (fgetc(fp_out) == EOF);
if (empty)
{
mutt_endwin();
- mutt_file_copy_stream(fperr, stdout);
+ mutt_file_copy_stream(fp_err, stdout);
mutt_any_key_to_continue(NULL);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
mutt_file_unlink(certfile);
return NULL;
}
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
return mutt_str_strdup(certfile);
}
void smime_class_invoke_import(char *infile, char *mailbox)
{
char *certfile = NULL, buf[256];
- FILE *smimein = NULL;
+ FILE *fp_smime_in = NULL;
- FILE *fperr = mutt_file_mkstemp();
- if (!fperr)
+ FILE *fp_err = mutt_file_mkstemp();
+ if (!fp_err)
{
mutt_perror(_("Can't create temporary file"));
return;
}
- FILE *fpout = mutt_file_mkstemp();
- if (!fpout)
+ FILE *fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_perror(_("Can't create temporary file"));
return;
}
if ((mutt_get_field(_("Label for certificate: "), buf, sizeof(buf), 0) != 0) ||
(buf[0] == 0))
{
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
return;
}
}
{
mutt_endwin();
- pid_t pid = smime_invoke(&smimein, NULL, NULL, -1, fileno(fpout),
- fileno(fperr), certfile, NULL, NULL, NULL, NULL,
+ pid_t pid = smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
+ fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
NULL, NULL, C_SmimeImportCertCommand);
if (pid == -1)
{
mutt_message(_("Error: unable to create OpenSSL subprocess"));
return;
}
- fputs(buf, smimein);
- fputc('\n', smimein);
- mutt_file_fclose(&smimein);
+ fputs(buf, fp_smime_in);
+ fputc('\n', fp_smime_in);
+ mutt_file_fclose(&fp_smime_in);
mutt_wait_filter(pid);
FREE(&certfile);
}
- fflush(fpout);
- rewind(fpout);
- fflush(fperr);
- rewind(fperr);
+ fflush(fp_out);
+ rewind(fp_out);
+ fflush(fp_err);
+ rewind(fp_err);
- mutt_file_copy_stream(fpout, stdout);
- mutt_file_copy_stream(fperr, stdout);
+ mutt_file_copy_stream(fp_out, stdout);
+ mutt_file_copy_stream(fp_err, stdout);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_err);
}
/**
int retval = 1;
mutt_mktemp(tempfname, sizeof(tempfname));
- FILE *fpout = mutt_file_fopen(tempfname, "w");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfname, "w");
+ if (!fp_out)
{
mutt_perror(tempfname);
return 1;
if (e->security & SEC_ENCRYPT)
{
- mutt_copy_message_ctx(fpout, Context->mailbox, e, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME,
+ mutt_copy_message_ctx(fp_out, Context->mailbox, e, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME,
CH_MIME | CH_WEED | CH_NONEWLINE);
}
else
- mutt_copy_message_ctx(fpout, Context->mailbox, e, 0, 0);
+ mutt_copy_message_ctx(fp_out, Context->mailbox, e, 0, 0);
- fflush(fpout);
- mutt_file_fclose(&fpout);
+ fflush(fp_out);
+ mutt_file_fclose(&fp_out);
if (e->env->from)
{
/**
* smime_invoke_encrypt - Use SMIME to encrypt a file
- * @param[out] smimein stdin for the command, or NULL (OPTIONAL)
- * @param[out] smimeout stdout for the command, or NULL (OPTIONAL)
- * @param[out] smimeerr stderr for the command, or NULL (OPTIONAL)
- * @param[in] smimeinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] smimeoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] smimeerrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[out] fp_smime_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] fp_smime_infd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_outfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_errfd stderr for the command, or -1 (OPTIONAL)
* @param[in] fname Filename to pass to the command
* @param[in] uids List of IDs/fingerprints, space separated
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `smimein` has priority over `smimeinfd`.
- * Likewise `smimeout` and `smimeerr`.
+ * @note `fp_smime_in` has priority over `fp_smime_infd`.
+ * Likewise `fp_smime_out` and `fp_smime_err`.
*/
-static pid_t smime_invoke_encrypt(FILE **smimein, FILE **smimeout, FILE **smimeerr,
- int smimeinfd, int smimeoutfd, int smimeerrfd,
+static pid_t smime_invoke_encrypt(FILE **fp_smime_in, FILE **fp_smime_out,
+ FILE **fp_smime_err, int fp_smime_infd,
+ int fp_smime_outfd, int fp_smime_errfd,
const char *fname, const char *uids)
{
- return smime_invoke(smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, NULL, C_SmimeEncryptWith, NULL, NULL,
- uids, NULL, C_SmimeEncryptCommand);
+ return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
+ fp_smime_outfd, fp_smime_errfd, fname, NULL, C_SmimeEncryptWith,
+ NULL, NULL, uids, NULL, C_SmimeEncryptCommand);
}
/**
* smime_invoke_sign - Use SMIME to sign a file
- * @param[out] smimein stdin for the command, or NULL (OPTIONAL)
- * @param[out] smimeout stdout for the command, or NULL (OPTIONAL)
- * @param[out] smimeerr stderr for the command, or NULL (OPTIONAL)
- * @param[in] smimeinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] smimeoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] smimeerrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[out] fp_smime_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] fp_smime_infd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_outfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_errfd stderr for the command, or -1 (OPTIONAL)
* @param[in] fname Filename to pass to the command
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `smimein` has priority over `smimeinfd`.
- * Likewise `smimeout` and `smimeerr`.
+ * @note `fp_smime_in` has priority over `fp_smime_infd`.
+ * Likewise `fp_smime_out` and `fp_smime_err`.
*/
-static pid_t smime_invoke_sign(FILE **smimein, FILE **smimeout, FILE **smimeerr, int smimeinfd,
- int smimeoutfd, int smimeerrfd, const char *fname)
+static pid_t smime_invoke_sign(FILE **fp_smime_in, FILE **fp_smime_out,
+ FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd,
+ int fp_smime_errfd, const char *fname)
{
- return smime_invoke(smimein, smimeout, smimeerr, smimeinfd, smimeoutfd, smimeerrfd,
- fname, NULL, NULL, C_SmimeSignDigestAlg, SmimeKeyToUse,
- SmimeCertToUse, SmimeIntermediateToUse, C_SmimeSignCommand);
+ return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
+ fp_smime_outfd, fp_smime_errfd, fname, NULL, NULL,
+ C_SmimeSignDigestAlg, SmimeKeyToUse, SmimeCertToUse,
+ fp_smime_intermediateToUse, C_SmimeSignCommand);
}
/**
{
char buf[1024], certfile[PATH_MAX];
char tempfile[PATH_MAX];
- char smimeinfile[PATH_MAX];
+ char fp_smime_infile[PATH_MAX];
char *cert_end = NULL;
- FILE *smimein = NULL;
+ FILE *fp_smime_in = NULL;
int err = 0, empty, off;
pid_t pid;
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *fpout = mutt_file_fopen(tempfile, "w+");
- if (!fpout)
+ FILE *fp_out = mutt_file_fopen(tempfile, "w+");
+ if (!fp_out)
{
mutt_perror(tempfile);
return NULL;
}
- FILE *smimeerr = mutt_file_mkstemp();
- if (!smimeerr)
+ FILE *fp_smime_err = mutt_file_mkstemp();
+ if (!fp_smime_err)
{
mutt_perror(_("Can't create temporary file"));
mutt_file_unlink(tempfile);
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
return NULL;
}
- mutt_mktemp(smimeinfile, sizeof(smimeinfile));
- FILE *fptmp = mutt_file_fopen(smimeinfile, "w+");
- if (!fptmp)
+ mutt_mktemp(fp_smime_infile, sizeof(fp_smime_infile));
+ FILE *fp_tmp = mutt_file_fopen(fp_smime_infile, "w+");
+ if (!fp_tmp)
{
- mutt_perror(smimeinfile);
+ mutt_perror(fp_smime_infile);
mutt_file_unlink(tempfile);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_smime_err);
return NULL;
}
}
/* write a MIME entity */
- mutt_write_mime_header(a, fptmp);
- fputc('\n', fptmp);
- mutt_write_mime_body(a, fptmp);
- mutt_file_fclose(&fptmp);
+ mutt_write_mime_header(a, fp_tmp);
+ fputc('\n', fp_tmp);
+ mutt_write_mime_body(a, fp_tmp);
+ mutt_file_fclose(&fp_tmp);
- pid = smime_invoke_encrypt(&smimein, NULL, NULL, -1, fileno(fpout),
- fileno(smimeerr), smimeinfile, certfile);
+ pid = smime_invoke_encrypt(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
+ fileno(fp_smime_err), fp_smime_infile, certfile);
if (pid == -1)
{
mutt_file_unlink(tempfile);
- mutt_file_fclose(&fpout);
- mutt_file_fclose(&smimeerr);
- mutt_file_unlink(smimeinfile);
+ mutt_file_fclose(&fp_out);
+ mutt_file_fclose(&fp_smime_err);
+ mutt_file_unlink(fp_smime_infile);
return NULL;
}
- mutt_file_fclose(&smimein);
+ mutt_file_fclose(&fp_smime_in);
mutt_wait_filter(pid);
- mutt_file_unlink(smimeinfile);
+ mutt_file_unlink(fp_smime_infile);
- fflush(fpout);
- rewind(fpout);
- empty = (fgetc(fpout) == EOF);
- mutt_file_fclose(&fpout);
+ fflush(fp_out);
+ rewind(fp_out);
+ empty = (fgetc(fp_out) == EOF);
+ mutt_file_fclose(&fp_out);
- fflush(smimeerr);
- rewind(smimeerr);
- while (fgets(buf, sizeof(buf) - 1, smimeerr))
+ fflush(fp_smime_err);
+ rewind(fp_smime_err);
+ while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
{
err = 1;
fputs(buf, stdout);
}
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_err);
/* pause if there is any error output from SMIME */
if (err)
{
char buf[1024];
char signedfile[PATH_MAX], filetosign[PATH_MAX];
- FILE *smimein = NULL, *smimeout = NULL, *smimeerr = NULL, *sfp = NULL;
+ FILE *fp_smime_in = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL, *fp_sign = NULL;
int err = 0;
int empty = 0;
pid_t pid;
crypt_convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
mutt_mktemp(filetosign, sizeof(filetosign));
- sfp = mutt_file_fopen(filetosign, "w+");
- if (!sfp)
+ fp_sign = mutt_file_fopen(filetosign, "w+");
+ if (!fp_sign)
{
mutt_perror(filetosign);
return NULL;
}
mutt_mktemp(signedfile, sizeof(signedfile));
- smimeout = mutt_file_fopen(signedfile, "w+");
- if (!smimeout)
+ fp_smime_out = mutt_file_fopen(signedfile, "w+");
+ if (!fp_smime_out)
{
mutt_perror(signedfile);
- mutt_file_fclose(&sfp);
+ mutt_file_fclose(&fp_sign);
mutt_file_unlink(filetosign);
return NULL;
}
- mutt_write_mime_header(a, sfp);
- fputc('\n', sfp);
- mutt_write_mime_body(a, sfp);
- mutt_file_fclose(&sfp);
+ mutt_write_mime_header(a, fp_sign);
+ fputc('\n', fp_sign);
+ mutt_write_mime_body(a, fp_sign);
+ mutt_file_fclose(&fp_sign);
snprintf(SmimeKeyToUse, sizeof(SmimeKeyToUse), "%s/%s", NONULL(C_SmimeKeys), signas);
else
intermediates = signas_key->issuer;
- snprintf(SmimeIntermediateToUse, sizeof(SmimeIntermediateToUse), "%s/%s",
- NONULL(C_SmimeCertificates), intermediates);
+ snprintf(fp_smime_intermediateToUse, sizeof(fp_smime_intermediateToUse),
+ "%s/%s", NONULL(C_SmimeCertificates), intermediates);
smime_free_key(&signas_key);
- pid = smime_invoke_sign(&smimein, NULL, &smimeerr, -1, fileno(smimeout), -1, filetosign);
+ pid = smime_invoke_sign(&fp_smime_in, NULL, &fp_smime_err, -1,
+ fileno(fp_smime_out), -1, filetosign);
if (pid == -1)
{
mutt_perror(_("Can't open OpenSSL subprocess"));
- mutt_file_fclose(&smimeout);
+ mutt_file_fclose(&fp_smime_out);
mutt_file_unlink(signedfile);
mutt_file_unlink(filetosign);
return NULL;
}
- fputs(SmimePass, smimein);
- fputc('\n', smimein);
- mutt_file_fclose(&smimein);
+ fputs(SmimePass, fp_smime_in);
+ fputc('\n', fp_smime_in);
+ mutt_file_fclose(&fp_smime_in);
mutt_wait_filter(pid);
/* check for errors from OpenSSL */
err = 0;
- fflush(smimeerr);
- rewind(smimeerr);
- while (fgets(buf, sizeof(buf) - 1, smimeerr))
+ fflush(fp_smime_err);
+ rewind(fp_smime_err);
+ while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
{
err = 1;
fputs(buf, stdout);
}
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_err);
- fflush(smimeout);
- rewind(smimeout);
- empty = (fgetc(smimeout) == EOF);
- mutt_file_fclose(&smimeout);
+ fflush(fp_smime_out);
+ rewind(fp_smime_out);
+ empty = (fgetc(fp_smime_out) == EOF);
+ mutt_file_fclose(&fp_smime_out);
mutt_file_unlink(filetosign);
/**
* smime_invoke_verify - Use SMIME to verify a file
- * @param[out] smimein stdin for the command, or NULL (OPTIONAL)
- * @param[out] smimeout stdout for the command, or NULL (OPTIONAL)
- * @param[out] smimeerr stderr for the command, or NULL (OPTIONAL)
- * @param[in] smimeinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] smimeoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] smimeerrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[out] fp_smime_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] fp_smime_infd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_outfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_errfd stderr for the command, or -1 (OPTIONAL)
* @param[in] fname Filename to pass to the command
* @param[in] sig_fname Signature filename to pass to the command
* @param[in] opaque If true, use `$smime_verify_opaque_command` else `$smime_verify_command`
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `smimein` has priority over `smimeinfd`.
- * Likewise `smimeout` and `smimeerr`.
+ * @note `fp_smime_in` has priority over `fp_smime_infd`.
+ * Likewise `fp_smime_out` and `fp_smime_err`.
*/
-static pid_t smime_invoke_verify(FILE **smimein, FILE **smimeout, FILE **smimeerr,
- int smimeinfd, int smimeoutfd, int smimeerrfd,
+static pid_t smime_invoke_verify(FILE **fp_smime_in, FILE **fp_smime_out,
+ FILE **fp_smime_err, int fp_smime_infd,
+ int fp_smime_outfd, int fp_smime_errfd,
const char *fname, const char *sig_fname, int opaque)
{
- return smime_invoke(smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
+ return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
+ fp_smime_errfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
(opaque ? C_SmimeVerifyOpaqueCommand : C_SmimeVerifyCommand));
}
/**
* smime_invoke_decrypt - Use SMIME to decrypt a file
- * @param[out] smimein stdin for the command, or NULL (OPTIONAL)
- * @param[out] smimeout stdout for the command, or NULL (OPTIONAL)
- * @param[out] smimeerr stderr for the command, or NULL (OPTIONAL)
- * @param[in] smimeinfd stdin for the command, or -1 (OPTIONAL)
- * @param[in] smimeoutfd stdout for the command, or -1 (OPTIONAL)
- * @param[in] smimeerrfd stderr for the command, or -1 (OPTIONAL)
+ * @param[out] fp_smime_in stdin for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_out stdout for the command, or NULL (OPTIONAL)
+ * @param[out] fp_smime_err stderr for the command, or NULL (OPTIONAL)
+ * @param[in] fp_smime_infd stdin for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_outfd stdout for the command, or -1 (OPTIONAL)
+ * @param[in] fp_smime_errfd stderr for the command, or -1 (OPTIONAL)
* @param[in] fname Filename to pass to the command
* @retval num PID of the created process
* @retval -1 Error creating pipes or forking
*
- * @note `smimein` has priority over `smimeinfd`.
- * Likewise `smimeout` and `smimeerr`.
+ * @note `fp_smime_in` has priority over `fp_smime_infd`.
+ * Likewise `fp_smime_out` and `fp_smime_err`.
*/
-static pid_t smime_invoke_decrypt(FILE **smimein, FILE **smimeout,
- FILE **smimeerr, int smimeinfd, int smimeoutfd,
- int smimeerrfd, const char *fname)
+static pid_t smime_invoke_decrypt(FILE **fp_smime_in, FILE **fp_smime_out,
+ FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd,
+ int fp_smime_errfd, const char *fname)
{
- return smime_invoke(smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, NULL, NULL, NULL, SmimeKeyToUse,
- SmimeCertToUse, NULL, C_SmimeDecryptCommand);
+ return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
+ fp_smime_outfd, fp_smime_errfd, fname, NULL, NULL, NULL,
+ SmimeKeyToUse, SmimeCertToUse, NULL, C_SmimeDecryptCommand);
}
/**
int smime_class_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile)
{
char signedfile[PATH_MAX];
- FILE *smimeout = NULL;
+ FILE *fp_smime_out = NULL;
pid_t pid;
int badsig = -1;
sigbdy->type = orig_type;
- FILE *smimeerr = mutt_file_mkstemp();
- if (!smimeerr)
+ FILE *fp_smime_err = mutt_file_mkstemp();
+ if (!fp_smime_err)
{
mutt_perror(_("Can't create temporary file"));
mutt_file_unlink(signedfile);
crypt_current_time(s, "OpenSSL");
- pid = smime_invoke_verify(NULL, &smimeout, NULL, -1, -1, fileno(smimeerr),
- tempfile, signedfile, 0);
+ pid = smime_invoke_verify(NULL, &fp_smime_out, NULL, -1, -1,
+ fileno(fp_smime_err), tempfile, signedfile, 0);
if (pid != -1)
{
- fflush(smimeout);
- mutt_file_fclose(&smimeout);
+ fflush(fp_smime_out);
+ mutt_file_fclose(&fp_smime_out);
if (mutt_wait_filter(pid))
badsig = -1;
int lineno = 0;
size_t linelen;
- fflush(smimeerr);
- rewind(smimeerr);
+ fflush(fp_smime_err);
+ rewind(fp_smime_err);
- line = mutt_file_read_line(line, &linelen, smimeerr, &lineno, 0);
+ line = mutt_file_read_line(line, &linelen, fp_smime_err, &lineno, 0);
if (linelen && (mutt_str_strcasecmp(line, "verification successful") == 0))
badsig = 0;
}
}
- fflush(smimeerr);
- rewind(smimeerr);
- mutt_file_copy_stream(smimeerr, s->fp_out);
- mutt_file_fclose(&smimeerr);
+ fflush(fp_smime_err);
+ rewind(fp_smime_err);
+ mutt_file_copy_stream(fp_smime_err, s->fp_out);
+ mutt_file_fclose(&fp_smime_err);
state_attach_puts(_("[-- End of OpenSSL output --]\n\n"), s);
/**
* smime_handle_entity - Handle type application/pkcs7-mime
- * @param m Body to handle
- * @param s State to use
- * @param out_file File for the result
+ * @param m Body to handle
+ * @param s State to use
+ * @param fp_out_file File for the result
* @retval ptr Body for parsed MIME part
*
* This can either be a signed or an encrypted message.
*/
-static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *out_file)
+static struct Body *smime_handle_entity(struct Body *m, struct State *s, FILE *fp_out_file)
{
char tmpfname[PATH_MAX];
- FILE *tmpfp = NULL, *tmpfp_buffer = NULL, *fpout = NULL;
+ FILE *fp_tmp = NULL, *fp_tmp_buffer = NULL, *fp_out = NULL;
struct stat info;
struct Body *p = NULL;
pid_t pid = -1;
if (!(type & APPLICATION_SMIME))
return NULL;
- FILE *smimeout = mutt_file_mkstemp();
- if (!smimeout)
+ FILE *fp_smime_out = mutt_file_mkstemp();
+ if (!fp_smime_out)
{
mutt_perror(_("Can't create temporary file"));
return NULL;
}
- FILE *smimeerr = mutt_file_mkstemp();
- if (!smimeerr)
+ FILE *fp_smime_err = mutt_file_mkstemp();
+ if (!fp_smime_err)
{
mutt_perror(_("Can't create temporary file"));
- mutt_file_fclose(&smimeout);
+ mutt_file_fclose(&fp_smime_out);
return NULL;
}
mutt_mktemp(tmpfname, sizeof(tmpfname));
- tmpfp = mutt_file_fopen(tmpfname, "w+");
- if (!tmpfp)
+ fp_tmp = mutt_file_fopen(tmpfname, "w+");
+ if (!fp_tmp)
{
mutt_perror(tmpfname);
- mutt_file_fclose(&smimeout);
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_out);
+ mutt_file_fclose(&fp_smime_err);
return NULL;
}
fseeko(s->fp_in, m->offset, SEEK_SET);
- mutt_file_copy_bytes(s->fp_in, tmpfp, m->length);
+ mutt_file_copy_bytes(s->fp_in, fp_tmp, m->length);
- fflush(tmpfp);
- mutt_file_fclose(&tmpfp);
+ fflush(fp_tmp);
+ mutt_file_fclose(&fp_tmp);
- FILE *smimein = NULL;
+ FILE *fp_smime_in = NULL;
if ((type & SEC_ENCRYPT) &&
- (pid = smime_invoke_decrypt(&smimein, NULL, NULL, -1, fileno(smimeout),
- fileno(smimeerr), tmpfname)) == -1)
+ (pid = smime_invoke_decrypt(&fp_smime_in, NULL, NULL, -1, fileno(fp_smime_out),
+ fileno(fp_smime_err), tmpfname)) == -1)
{
- mutt_file_fclose(&smimeout);
+ mutt_file_fclose(&fp_smime_out);
mutt_file_unlink(tmpfname);
if (s->flags & MUTT_DISPLAY)
{
state_attach_puts(
_("[-- Error: unable to create OpenSSL subprocess --]\n"), s);
}
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_err);
return NULL;
}
else if ((type & SEC_SIGNOPAQUE) &&
- (pid = smime_invoke_verify(&smimein, NULL, NULL, -1, fileno(smimeout), fileno(smimeerr),
+ (pid = smime_invoke_verify(&fp_smime_in, NULL, NULL, -1,
+ fileno(fp_smime_out), fileno(fp_smime_err),
NULL, tmpfname, SEC_SIGNOPAQUE)) == -1)
{
- mutt_file_fclose(&smimeout);
+ mutt_file_fclose(&fp_smime_out);
mutt_file_unlink(tmpfname);
if (s->flags & MUTT_DISPLAY)
{
state_attach_puts(
_("[-- Error: unable to create OpenSSL subprocess --]\n"), s);
}
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_err);
return NULL;
}
{
if (!smime_class_valid_passphrase())
smime_class_void_passphrase();
- fputs(SmimePass, smimein);
- fputc('\n', smimein);
+ fputs(SmimePass, fp_smime_in);
+ fputc('\n', fp_smime_in);
}
- mutt_file_fclose(&smimein);
+ mutt_file_fclose(&fp_smime_in);
mutt_wait_filter(pid);
mutt_file_unlink(tmpfname);
if (s->flags & MUTT_DISPLAY)
{
- fflush(smimeerr);
- rewind(smimeerr);
+ fflush(fp_smime_err);
+ rewind(fp_smime_err);
- const int c = fgetc(smimeerr);
+ const int c = fgetc(fp_smime_err);
if (c != EOF)
{
- ungetc(c, smimeerr);
+ ungetc(c, fp_smime_err);
crypt_current_time(s, "OpenSSL");
- mutt_file_copy_stream(smimeerr, s->fp_out);
+ mutt_file_copy_stream(fp_smime_err, s->fp_out);
state_attach_puts(_("[-- End of OpenSSL output --]\n\n"), s);
}
state_attach_puts(_("[-- The following data is S/MIME signed --]\n"), s);
}
- fflush(smimeout);
- rewind(smimeout);
+ fflush(fp_smime_out);
+ rewind(fp_smime_out);
if (type & SEC_ENCRYPT)
{
/* void the passphrase, even if that wasn't the problem */
- if (fgetc(smimeout) == EOF)
+ if (fgetc(fp_smime_out) == EOF)
{
mutt_error(_("Decryption failed"));
smime_class_void_passphrase();
}
- rewind(smimeout);
+ rewind(fp_smime_out);
}
- if (out_file)
- fpout = out_file;
+ if (fp_out_file)
+ fp_out = fp_out_file;
else
{
- fpout = mutt_file_mkstemp();
- if (!fpout)
+ fp_out = mutt_file_mkstemp();
+ if (!fp_out)
{
mutt_perror(_("Can't create temporary file"));
- mutt_file_fclose(&smimeout);
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_out);
+ mutt_file_fclose(&fp_smime_err);
return NULL;
}
}
char buf[8192];
- while (fgets(buf, sizeof(buf) - 1, smimeout))
+ while (fgets(buf, sizeof(buf) - 1, fp_smime_out))
{
const size_t len = mutt_str_strlen(buf);
if (len > 1 && buf[len - 2] == '\r')
buf[len - 2] = '\n';
buf[len - 1] = '\0';
}
- fputs(buf, fpout);
+ fputs(buf, fp_out);
}
- fflush(fpout);
- rewind(fpout);
+ fflush(fp_out);
+ rewind(fp_out);
- p = mutt_read_mime_header(fpout, 0);
+ p = mutt_read_mime_header(fp_out, 0);
if (p)
{
- fstat(fileno(fpout), &info);
+ fstat(fileno(fp_out), &info);
p->length = info.st_size - p->offset;
- mutt_parse_part(fpout, p);
+ mutt_parse_part(fp_out, p);
if (s->flags & MUTT_DISPLAY)
mutt_protected_headers_handler(p, s);
if (s->fp_out)
{
- rewind(fpout);
- tmpfp_buffer = s->fp_in;
- s->fp_in = fpout;
+ rewind(fp_out);
+ fp_tmp_buffer = s->fp_in;
+ s->fp_in = fp_out;
mutt_body_handler(p, s);
- s->fp_in = tmpfp_buffer;
+ s->fp_in = fp_tmp_buffer;
}
/* Embedded multipart signed protected headers override the
p->parts->mime_headers = NULL;
}
}
- mutt_file_fclose(&smimeout);
+ mutt_file_fclose(&fp_smime_out);
- if (!out_file)
+ if (!fp_out_file)
{
- mutt_file_fclose(&fpout);
+ mutt_file_fclose(&fp_out);
}
- fpout = NULL;
+ fp_out = NULL;
if (s->flags & MUTT_DISPLAY)
{
int lineno = 0;
size_t linelen;
- rewind(smimeerr);
+ rewind(fp_smime_err);
- line = mutt_file_read_line(line, &linelen, smimeerr, &lineno, 0);
+ line = mutt_file_read_line(line, &linelen, fp_smime_err, &lineno, 0);
if (linelen && (mutt_str_strcasecmp(line, "verification successful") == 0))
m->goodsig = true;
FREE(&line);
m->goodsig = p->goodsig;
m->badsig = p->badsig;
}
- mutt_file_fclose(&smimeerr);
+ mutt_file_fclose(&fp_smime_err);
return p;
}
/**
* smime_class_decrypt_mime - Implements CryptModuleSpecs::decrypt_mime()
*/
-int smime_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur)
+int smime_class_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
{
struct State s = { 0 };
LOFF_T tmpoffset = b->offset;
if (b->parts)
return -1;
- s.fp_in = fpin;
+ s.fp_in = fp_in;
fseeko(s.fp_in, b->offset, SEEK_SET);
- FILE *tmpfp = mutt_file_mkstemp();
- if (!tmpfp)
+ FILE *fp_tmp = mutt_file_mkstemp();
+ if (!fp_tmp)
{
mutt_perror(_("Can't create temporary file"));
return -1;
}
- s.fp_out = tmpfp;
+ s.fp_out = fp_tmp;
mutt_decode_attachment(b, &s);
- fflush(tmpfp);
+ fflush(fp_tmp);
b->length = ftello(s.fp_out);
b->offset = 0;
- rewind(tmpfp);
- s.fp_in = tmpfp;
+ rewind(fp_tmp);
+ s.fp_in = fp_tmp;
s.fp_out = 0;
- *fpout = mutt_file_mkstemp();
- if (!*fpout)
+ *fp_out = mutt_file_mkstemp();
+ if (!*fp_out)
{
mutt_perror(_("Can't create temporary file"));
rc = -1;
goto bail;
}
- *cur = smime_handle_entity(b, &s, *fpout);
+ *cur = smime_handle_entity(b, &s, *fp_out);
if (!*cur)
{
rc = -1;
b->type = orig_type;
b->length = tmplength;
b->offset = tmpoffset;
- mutt_file_fclose(&tmpfp);
- if (*fpout)
- rewind(*fpout);
+ mutt_file_fclose(&fp_tmp);
+ if (*fp_out)
+ rewind(*fp_out);
return rc;
}
int smime_class_application_handler(struct Body *m, struct State *s);
struct Body *smime_class_build_smime_entity(struct Body *a, char *certlist);
-int smime_class_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur);
+int smime_class_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur);
char * smime_class_find_keys(struct Address *addrlist, bool oppenc_mode);
void smime_class_getkeys(struct Envelope *env);
void smime_class_invoke_import(char *infile, char *mailbox);
*/
void nntp_newsrc_close(struct NntpAccountData *adata)
{
- if (!adata->newsrc_fp)
+ if (!adata->fp_newsrc)
return;
mutt_debug(LL_DEBUG1, "Unlocking %s\n", adata->newsrc_file);
- mutt_file_unlock(fileno(adata->newsrc_fp));
- mutt_file_fclose(&adata->newsrc_fp);
+ mutt_file_unlock(fileno(adata->fp_newsrc));
+ mutt_file_fclose(&adata->fp_newsrc);
}
/**
char *line = NULL;
struct stat sb;
- if (adata->newsrc_fp)
+ if (adata->fp_newsrc)
{
/* if we already have a handle, close it and reopen */
- mutt_file_fclose(&adata->newsrc_fp);
+ mutt_file_fclose(&adata->fp_newsrc);
}
else
{
/* if file doesn't exist, create it */
- adata->newsrc_fp = mutt_file_fopen(adata->newsrc_file, "a");
- mutt_file_fclose(&adata->newsrc_fp);
+ adata->fp_newsrc = mutt_file_fopen(adata->newsrc_file, "a");
+ mutt_file_fclose(&adata->fp_newsrc);
}
/* open .newsrc */
- adata->newsrc_fp = mutt_file_fopen(adata->newsrc_file, "r");
- if (!adata->newsrc_fp)
+ adata->fp_newsrc = mutt_file_fopen(adata->newsrc_file, "r");
+ if (!adata->fp_newsrc)
{
mutt_perror(adata->newsrc_file);
return -1;
/* lock it */
mutt_debug(LL_DEBUG1, "Locking %s\n", adata->newsrc_file);
- if (mutt_file_lock(fileno(adata->newsrc_fp), false, true))
+ if (mutt_file_lock(fileno(adata->fp_newsrc), false, true))
{
- mutt_file_fclose(&adata->newsrc_fp);
+ mutt_file_fclose(&adata->fp_newsrc);
return -1;
}
}
line = mutt_mem_malloc(sb.st_size + 1);
- while (sb.st_size && fgets(line, sb.st_size + 1, adata->newsrc_fp))
+ while (sb.st_size && fgets(line, sb.st_size + 1, adata->fp_newsrc))
{
char *b = NULL, *h = NULL;
unsigned int j = 1;
unsigned int status : 3;
bool cacheable : 1;
bool newsrc_modified : 1;
- FILE *newsrc_fp;
+ FILE *fp_newsrc;
char *newsrc_file;
char *authenticators;
char *overview_fmt;
if (folder)
{
- FILE *f = maildir_open_find_message(folder, path, &newpath);
- if (f)
+ FILE *fp = maildir_open_find_message(folder, path, &newpath);
+ if (fp)
{
- e = maildir_parse_stream(MUTT_MAILDIR, f, newpath, false, NULL);
- fclose(f);
+ e = maildir_parse_stream(MUTT_MAILDIR, fp, newpath, false, NULL);
+ fclose(fp);
mutt_debug(LL_DEBUG1, "nm: not up-to-date: %s -> %s\n", path, newpath);
}
/**
* fill_buffer - Fill a buffer from a file
- * @param[in] f File to read from
+ * @param[in] fp File to read from
* @param[in,out] last_pos End of last read
* @param[in] offset Position start reading from
* @param[out] buf Buffer to fill
* @retval >=0 Bytes read
* @retval -1 Error
*/
-static int fill_buffer(FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char **buf,
+static int fill_buffer(FILE *fp, LOFF_T *last_pos, LOFF_T offset, unsigned char **buf,
unsigned char **fmt, size_t *blen, int *buf_ready)
{
unsigned char *p = NULL, *q = NULL;
if (*buf_ready == 0)
{
if (offset != *last_pos)
- fseeko(f, offset, SEEK_SET);
- *buf = (unsigned char *) mutt_file_read_line((char *) *buf, blen, f, &l, MUTT_EOL);
+ fseeko(fp, offset, SEEK_SET);
+ *buf = (unsigned char *) mutt_file_read_line((char *) *buf, blen, fp, &l, MUTT_EOL);
if (!*buf)
{
fmt[0] = 0;
return -1;
}
- *last_pos = ftello(f);
+ *last_pos = ftello(fp);
b_read = (int) (*last_pos - offset);
*buf_ready = 1;
/**
* display_line - Print a line on screen
- * @param[in] f File to read from
+ * @param[in] fp File to read from
* @param[out] last_pos Offset into file
* @param[out] line_info Line attributes
* @param[in] n Line number
* @retval 0 normal exit, line was not displayed
* @retval >0 normal exit, line was displayed
*/
-static int display_line(FILE *f, LOFF_T *last_pos, struct Line **line_info,
+static int display_line(FILE *fp, LOFF_T *last_pos, struct Line **line_info,
int n, int *last, int *max, PagerFlags flags,
struct QClass **quote_list, int *q_level, bool *force_redraw,
regex_t *search_re, struct MuttWindow *pager_window)
if (flags & MUTT_PAGER_LOGS)
{
/* determine the line class */
- if (fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
+ if (fill_buffer(fp, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
{
if (change_last)
(*last)--;
if ((*line_info)[n].type == -1)
{
/* determine the line class */
- if (fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
+ if (fill_buffer(fp, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
{
if (change_last)
(*last)--;
if ((flags & MUTT_SHOWCOLOR) && !(*line_info)[n].continuation &&
((*line_info)[n].type == MT_COLOR_QUOTED) && !(*line_info)[n].quote)
{
- if (fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
+ if (fill_buffer(fp, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
{
if (change_last)
(*last)--;
if ((flags & MUTT_SEARCH) && !(*line_info)[n].continuation &&
(*line_info)[n].search_cnt == -1)
{
- if (fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
+ if (fill_buffer(fp, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready) < 0)
{
if (change_last)
(*last)--;
goto out; /* fake display */
}
- b_read = fill_buffer(f, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready);
+ b_read = fill_buffer(fp, last_pos, (*line_info)[n].offset, &buf, &fmt, &buflen, &buf_ready);
if (b_read < 0)
{
if (change_last)
*/
static int fetch_message(char *line, void *file)
{
- FILE *f = file;
+ FILE *fp = file;
- fputs(line, f);
- if (fputc('\n', f) == EOF)
+ fputs(line, fp);
+ if (fputc('\n', fp) == EOF)
return -1;
return 0;
*/
static int pop_read_header(struct PopAccountData *adata, struct Email *e)
{
- FILE *f = mutt_file_mkstemp();
- if (!f)
+ FILE *fp = mutt_file_mkstemp();
+ if (!fp)
{
mutt_perror(_("Can't create temporary file"));
return -3;
sscanf(buf, "+OK %d %zu", &index, &length);
snprintf(buf, sizeof(buf), "TOP %d 0\r\n", e->refno);
- rc = pop_fetch_data(adata, buf, NULL, fetch_message, f);
+ rc = pop_fetch_data(adata, buf, NULL, fetch_message, fp);
if (adata->cmd_top == 2)
{
{
case 0:
{
- rewind(f);
- e->env = mutt_rfc822_read_header(f, e, false, false);
+ rewind(fp);
+ e->env = mutt_rfc822_read_header(fp, e, false, false);
e->content->length = length - e->content->offset + 1;
- rewind(f);
- while (!feof(f))
+ rewind(fp);
+ while (!feof(fp))
{
e->content->length--;
- fgets(buf, sizeof(buf), f);
+ fgets(buf, sizeof(buf), fp);
}
break;
}
}
}
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
return rc;
}
struct Message *msg = NULL;
char file[PATH_MAX];
struct Body *b = NULL;
- FILE *bfp = NULL;
+ FILE *fp_body = NULL;
int rc = -1;
struct State s = { 0 };
SecurityFlags sec_type;
if (!fp)
fp = msg->fp;
- bfp = fp;
+ fp_body = fp;
/* parse the message header and MIME structure */
goto bail;
mutt_message(_("Decrypting message..."));
- if ((crypt_pgp_decrypt_mime(fp, &bfp, newhdr->content, &b) == -1) || !b)
+ if ((crypt_pgp_decrypt_mime(fp, &fp_body, newhdr->content, &b) == -1) || !b)
{
goto bail;
}
if (newhdr->content->type == TYPE_MULTIPART)
newhdr->content = mutt_remove_multipart(newhdr->content);
- s.fp_in = bfp;
+ s.fp_in = fp_body;
/* create temporary files for all attachments */
for (b = newhdr->content; b; b = b->next)
bail:
/* that's it. */
- if (bfp != fp)
- mutt_file_fclose(&bfp);
+ if (fp_body != fp)
+ mutt_file_fclose(&fp_body);
if (msg)
mx_msg_close(m, &msg);
char *directory = NULL;
int rc = 1;
int last = menu ? menu->current : -1;
- FILE *fpout = NULL;
+ FILE *fp_out = NULL;
buf[0] = 0;
if (mutt_check_overwrite(top->filename, buf, tfile, sizeof(tfile), &append, NULL))
return;
rc = mutt_save_attachment(fp, top, tfile, append, e);
- if ((rc == 0) && C_AttachSep && (fpout = fopen(tfile, "a")))
+ if ((rc == 0) && C_AttachSep && (fp_out = fopen(tfile, "a")))
{
- fprintf(fpout, "%s", C_AttachSep);
- mutt_file_fclose(&fpout);
+ fprintf(fp_out, "%s", C_AttachSep);
+ mutt_file_fclose(&fp_out);
}
}
else
{
rc = mutt_save_attachment(fp, top, tfile, MUTT_SAVE_APPEND, e);
- if ((rc == 0) && C_AttachSep && (fpout = fopen(tfile, "a")))
+ if ((rc == 0) && C_AttachSep && (fp_out = fopen(tfile, "a")))
{
- fprintf(fpout, "%s", C_AttachSep);
- mutt_file_fclose(&fpout);
+ fprintf(fp_out, "%s", C_AttachSep);
+ mutt_file_fclose(&fp_out);
}
}
}
}
else
{
- FILE *ifp = fopen(b->filename, "r");
- if (!ifp)
+ FILE *fp_in = fopen(b->filename, "r");
+ if (!fp_in)
{
mutt_perror("fopen");
return;
}
- mutt_file_copy_stream(ifp, state->fp_out);
- mutt_file_fclose(&ifp);
+ mutt_file_copy_stream(fp_in, state->fp_out);
+ mutt_file_fclose(&fp_in);
if (C_AttachSep)
state_puts(C_AttachSep, state);
}
/* decode and print */
char newfile[PATH_MAX] = "";
- FILE *ifp = NULL;
+ FILE *fp_in = NULL;
mutt_mktemp(newfile, sizeof(newfile));
if (mutt_decode_save_attachment(fp, top, newfile, MUTT_PRINTING, 0) == 0)
return;
}
- ifp = fopen(newfile, "r");
- if (ifp)
+ fp_in = fopen(newfile, "r");
+ if (fp_in)
{
- mutt_file_copy_stream(ifp, state->fp_out);
- mutt_file_fclose(&ifp);
+ mutt_file_copy_stream(fp_in, state->fp_out);
+ mutt_file_fclose(&fp_in);
if (C_AttachSep)
state_puts(C_AttachSep, state);
}
struct AttachPtr *new = NULL;
struct Body *m = NULL;
struct Body *new_body = NULL;
- FILE *new_fp = NULL;
+ FILE *fp_new = NULL;
SecurityFlags type;
int need_secured, secured;
crypt_smime_getkeys(e->env);
}
- secured = !crypt_smime_decrypt_mime(fp, &new_fp, m, &new_body);
+ secured = !crypt_smime_decrypt_mime(fp, &fp_new, m, &new_body);
/* If the decrypt/verify-opaque doesn't generate mime output, an empty
* text/plain type will still be returned by mutt_read_mime_header().
* We can't distinguish an actual part from a failure, so only use a
((parts != m) || m->next))
{
mutt_body_free(&new_body);
- mutt_file_fclose(&new_fp);
+ mutt_file_fclose(&fp_new);
goto decrypt_failed;
}
if (!crypt_valid_passphrase(APPLICATION_PGP))
goto decrypt_failed;
- secured = !crypt_pgp_decrypt_mime(fp, &new_fp, m, &new_body);
+ secured = !crypt_pgp_decrypt_mime(fp, &fp_new, m, &new_body);
if (secured)
e->security |= PGP_ENCRYPT;
if (need_secured && secured)
{
- mutt_actx_add_fp(actx, new_fp);
+ mutt_actx_add_fp(actx, fp_new);
mutt_actx_add_body(actx, new_body);
- mutt_generate_recvattach_list(actx, e, new_body, new_fp, parent_type, level, 1);
+ mutt_generate_recvattach_list(actx, e, new_body, fp_new, parent_type, level, 1);
continue;
}
if (init)
{
mutt_generate_recvattach_list(actx, actx->email, actx->email->content,
- actx->root_fp, -1, 0, 0);
+ actx->fp_root, -1, 0, 0);
mutt_attach_init(actx);
menu->data = actx;
}
struct AttachCtx *actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
actx->email = e;
- actx->root_fp = msg->fp;
+ actx->fp_root = msg->fp;
mutt_update_recvattach_menu(actx, menu, true);
while (true)
/**
* include_header - Write an email header to a file, optionally quoting it
* @param quote If true, prefix the lines
- * @param ifp File to read from
- * @param e Email
- * @param ofp File to write to
+ * @param fp_in File to read from
+ * @param e Email
+ * @param fp_out File to write to
* @param prefix Prefix for each line (OPTIONAL)
*/
-static void include_header(bool quote, FILE *ifp, struct Email *e, FILE *ofp, char *prefix)
+static void include_header(bool quote, FILE *fp_in, struct Email *e, FILE *fp_out, char *prefix)
{
CopyHeaderFlags chflags = CH_DECODE;
char prefix2[128];
chflags |= CH_PREFIX;
}
- mutt_copy_header(ifp, e, ofp, chflags, quote ? prefix2 : NULL);
+ mutt_copy_header(fp_in, e, fp_out, chflags, quote ? prefix2 : NULL);
}
/**
bool mime_fwd_all = false;
bool mime_fwd_any = true;
struct Email *e_parent = NULL;
- FILE *parent_fp = NULL;
+ FILE *fp_parent = NULL;
char tmpbody[PATH_MAX];
char prefix[256];
int rc = 0;
if (parent)
{
e_parent = parent->content->email;
- parent_fp = parent->fp;
+ fp_parent = parent->fp;
}
else
{
e_parent = e;
- parent_fp = actx->root_fp;
+ fp_parent = actx->fp_root;
}
struct Email *e_tmp = mutt_email_new();
mutt_make_forward_subject(e_tmp->env, Context->mailbox, e_parent);
mutt_mktemp(tmpbody, sizeof(tmpbody));
- FILE *tmpfp = mutt_file_fopen(tmpbody, "w");
- if (!tmpfp)
+ FILE *fp_tmp = mutt_file_fopen(tmpbody, "w");
+ if (!fp_tmp)
{
mutt_error(_("Can't open temporary file %s"), tmpbody);
mutt_email_free(&e_tmp);
return;
}
- mutt_forward_intro(Context->mailbox, e_parent, tmpfp);
+ mutt_forward_intro(Context->mailbox, e_parent, fp_tmp);
/* prepare the prefix here since we'll need it later. */
mutt_str_strfcpy(prefix, ">", sizeof(prefix));
}
- include_header(C_ForwardQuote, parent_fp, e_parent, tmpfp, prefix);
+ include_header(C_ForwardQuote, fp_parent, e_parent, fp_tmp, prefix);
/* Now, we have prepared the first part of the message body: The
* original message's header.
st.flags = MUTT_CHARCONV;
if (C_Weed)
st.flags |= MUTT_WEED;
- st.fp_out = tmpfp;
+ st.fp_out = fp_tmp;
/* where do we append new MIME parts? */
struct Body **last = &e_tmp->content;
goto bail;
}
- mutt_forward_trailer(Context->mailbox, e_parent, tmpfp);
+ mutt_forward_trailer(Context->mailbox, e_parent, fp_tmp);
- mutt_file_fclose(&tmpfp);
- tmpfp = NULL;
+ mutt_file_fclose(&fp_tmp);
+ fp_tmp = NULL;
/* now that we have the template, send it. */
struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
bail:
- if (tmpfp)
+ if (fp_tmp)
{
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
mutt_file_unlink(tmpbody);
}
struct Body **last = NULL;
char tmpbody[PATH_MAX];
- FILE *tmpfp = NULL;
+ FILE *fp_tmp = NULL;
CopyHeaderFlags chflags = CH_XMIT;
/* no MIME encapsulation */
mutt_mktemp(tmpbody, sizeof(tmpbody));
- tmpfp = mutt_file_fopen(tmpbody, "w");
- if (!tmpfp)
+ fp_tmp = mutt_file_fopen(tmpbody, "w");
+ if (!fp_tmp)
{
mutt_error(_("Can't create %s"), tmpbody);
mutt_email_free(&e_tmp);
if (cur)
{
- mutt_forward_intro(Context->mailbox, cur->email, tmpfp);
- mutt_copy_message_fp(tmpfp, fp, cur->email, cmflags, chflags);
- mutt_forward_trailer(Context->mailbox, cur->email, tmpfp);
+ mutt_forward_intro(Context->mailbox, cur->email, fp_tmp);
+ mutt_copy_message_fp(fp_tmp, fp, cur->email, cmflags, chflags);
+ mutt_forward_trailer(Context->mailbox, cur->email, fp_tmp);
}
else
{
{
if (actx->idx[i]->content->tagged)
{
- mutt_forward_intro(Context->mailbox, actx->idx[i]->content->email, tmpfp);
- mutt_copy_message_fp(tmpfp, actx->idx[i]->fp,
+ mutt_forward_intro(Context->mailbox, actx->idx[i]->content->email, fp_tmp);
+ mutt_copy_message_fp(fp_tmp, actx->idx[i]->fp,
actx->idx[i]->content->email, cmflags, chflags);
- mutt_forward_trailer(Context->mailbox, actx->idx[i]->content->email, tmpfp);
+ mutt_forward_trailer(Context->mailbox, actx->idx[i]->content->email, fp_tmp);
}
}
}
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
}
else if (rc == MUTT_YES) /* do MIME encapsulation - we don't need to do much here */
{
/**
* attach_include_reply - This is _very_ similar to send.c's include_reply()
- * @param fp File handle to attachment
- * @param tmpfp File handle to temporary file
+ * @param fp File handle to attachment
+ * @param fp_tmp File handle to temporary file
* @param cur Email
*/
-static void attach_include_reply(FILE *fp, FILE *tmpfp, struct Email *cur)
+static void attach_include_reply(FILE *fp, FILE *fp_tmp, struct Email *cur)
{
CopyMessageFlags cmflags = MUTT_CM_PREFIX | MUTT_CM_DECODE | MUTT_CM_CHARCONV;
CopyHeaderFlags chflags = CH_DECODE;
- mutt_make_attribution(Context->mailbox, cur, tmpfp);
+ mutt_make_attribution(Context->mailbox, cur, fp_tmp);
if (!C_Header)
cmflags |= MUTT_CM_NOHEADER;
cmflags |= MUTT_CM_WEED;
}
- mutt_copy_message_fp(tmpfp, fp, cur, cmflags, chflags);
- mutt_make_post_indent(Context->mailbox, cur, tmpfp);
+ mutt_copy_message_fp(fp_tmp, fp, cur, cmflags, chflags);
+ mutt_make_post_indent(Context->mailbox, cur, fp_tmp);
}
/**
short nattach = 0;
struct AttachPtr *parent = NULL;
struct Email *e_parent = NULL;
- FILE *parent_fp = NULL;
+ FILE *fp_parent = NULL;
struct Email *e_tmp = NULL;
struct State st;
char tmpbody[PATH_MAX];
- FILE *tmpfp = NULL;
+ FILE *fp_tmp = NULL;
char prefix[128];
if (parent)
{
e_parent = parent->content->email;
- parent_fp = parent->fp;
+ fp_parent = parent->fp;
}
else
{
e_parent = e;
- parent_fp = actx->root_fp;
+ fp_parent = actx->fp_root;
}
}
}
mutt_mktemp(tmpbody, sizeof(tmpbody));
- tmpfp = mutt_file_fopen(tmpbody, "w");
- if (!tmpfp)
+ fp_tmp = mutt_file_fopen(tmpbody, "w");
+ if (!fp_tmp)
{
mutt_error(_("Can't create %s"), tmpbody);
mutt_email_free(&e_tmp);
if (!e_parent)
{
if (cur)
- attach_include_reply(fp, tmpfp, cur->email);
+ attach_include_reply(fp, fp_tmp, cur->email);
else
{
for (short i = 0; i < actx->idxlen; i++)
{
if (actx->idx[i]->content->tagged)
- attach_include_reply(actx->idx[i]->fp, tmpfp, actx->idx[i]->content->email);
+ attach_include_reply(actx->idx[i]->fp, fp_tmp, actx->idx[i]->content->email);
}
}
}
else
{
- mutt_make_attribution(Context->mailbox, e_parent, tmpfp);
+ mutt_make_attribution(Context->mailbox, e_parent, fp_tmp);
memset(&st, 0, sizeof(struct State));
- st.fp_out = tmpfp;
+ st.fp_out = fp_tmp;
if (!C_TextFlowed)
{
st.flags |= MUTT_WEED;
if (C_Header)
- include_header(true, parent_fp, e_parent, tmpfp, prefix);
+ include_header(true, fp_parent, e_parent, fp_tmp, prefix);
if (cur)
{
}
}
- mutt_make_post_indent(Context->mailbox, e_parent, tmpfp);
+ mutt_make_post_indent(Context->mailbox, e_parent, fp_tmp);
if (mime_reply_any && !cur && !copy_problematic_attachments(&e_tmp->content, actx, false))
{
mutt_email_free(&e_tmp);
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
return;
}
}
- mutt_file_fclose(&tmpfp);
+ mutt_file_fclose(&fp_tmp);
struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
el_add_email(&el, e_parent ? e_parent : (cur ? cur->email : NULL));
int lc = 0;
size_t len = 0;
unsigned char c = '\0';
- FILE *in = NULL, *out = NULL;
char buf[1024];
char tmpfile[PATH_MAX];
mutt_debug(LL_DEBUG2, "f=f: postprocess %s\n", e->content->filename);
- in = mutt_file_fopen(e->content->filename, "r");
- if (!in)
+ FILE *fp_in = mutt_file_fopen(e->content->filename, "r");
+ if (!fp_in)
return;
mutt_mktemp(tmpfile, sizeof(tmpfile));
- out = mutt_file_fopen(tmpfile, "w+");
- if (!out)
+ FILE *fp_out = mutt_file_fopen(tmpfile, "w+");
+ if (!fp_out)
{
- mutt_file_fclose(&in);
+ mutt_file_fclose(&fp_in);
return;
}
- while (fgets(buf, sizeof(buf), in))
+ while (fgets(buf, sizeof(buf), fp_in))
{
if (buf[0] == ' ' || mutt_str_startswith(buf, "From ", CASE_MATCH))
{
- fputc(' ', out);
+ fputc(' ', fp_out);
lc++;
len = mutt_str_strlen(buf);
if (len > 0)
if (len > 0)
buf[len - 1] = c;
}
- fputs(buf, out);
+ fputs(buf, fp_out);
}
- mutt_file_fclose(&in);
- mutt_file_fclose(&out);
+ mutt_file_fclose(&fp_in);
+ mutt_file_fclose(&fp_out);
mutt_file_set_mtime(e->content->filename, tmpfile);
unlink(e->content->filename);
mutt_str_replace(&e->content->filename, tmpfile);
/**
* append_signature - Append a signature to an email
- * @param f File to write to
+ * @param fp File to write to
*/
-static void append_signature(FILE *f)
+static void append_signature(FILE *fp)
{
- FILE *tmpfp = NULL;
+ FILE *fp_tmp = NULL;
pid_t pid;
- if (C_Signature && (tmpfp = mutt_open_read(C_Signature, &pid)))
+ if (C_Signature && (fp_tmp = mutt_open_read(C_Signature, &pid)))
{
if (C_SigDashes)
- fputs("\n-- \n", f);
- mutt_file_copy_stream(tmpfp, f);
- mutt_file_fclose(&tmpfp);
+ fputs("\n-- \n", fp);
+ mutt_file_copy_stream(fp_tmp, fp);
+ mutt_file_fclose(&fp_tmp);
if (pid != -1)
mutt_wait_filter(pid);
}
/**
* include_forward - Write out a forwarded message
- * @param m Mailbox
- * @param e Email
- * @param out File to write to
+ * @param m Mailbox
+ * @param e Email
+ * @param fp_out File to write to
* @retval 0 Success
* @retval -1 Failure
*/
-static int include_forward(struct Mailbox *m, struct Email *e, FILE *out)
+static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
{
CopyHeaderFlags chflags = CH_DECODE;
CopyMessageFlags cmflags = MUTT_CM_NO_FLAGS;
return -1;
}
- mutt_forward_intro(m, e, out);
+ mutt_forward_intro(m, e, fp_out);
if (C_ForwardDecode)
{
* rather than send action */
chflags |= CH_DISPLAY;
- mutt_copy_message_ctx(out, m, e, cmflags, chflags);
- mutt_forward_trailer(m, e, out);
+ mutt_copy_message_ctx(fp_out, m, e, cmflags, chflags);
+ mutt_forward_trailer(m, e, fp_out);
return 0;
}
/**
* mutt_make_attribution - Add "on DATE, PERSON wrote" header
- * @param m Mailbox
- * @param e Email
- * @param out File to write to
+ * @param m Mailbox
+ * @param e Email
+ * @param fp_out File to write to
*/
-void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *out)
+void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out)
{
- if (!C_Attribution || !out)
+ if (!C_Attribution || !fp_out)
return;
char buf[1024];
setlocale(LC_TIME, NONULL(C_AttributionLocale));
mutt_make_string(buf, sizeof(buf), C_Attribution, NULL, m, e);
setlocale(LC_TIME, "");
- fputs(buf, out);
- fputc('\n', out);
+ fputs(buf, fp_out);
+ fputc('\n', fp_out);
}
/**
* mutt_make_post_indent - Add suffix to replied email text
- * @param m Mailbox
- * @param e Email
- * @param out File to write to
+ * @param m Mailbox
+ * @param e Email
+ * @param fp_out File to write to
*/
-void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *out)
+void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out)
{
- if (!C_PostIndentString || !out)
+ if (!C_PostIndentString || !fp_out)
return;
char buf[256];
mutt_make_string(buf, sizeof(buf), C_PostIndentString, NULL, m, e);
- fputs(buf, out);
- fputc('\n', out);
+ fputs(buf, fp_out);
+ fputc('\n', fp_out);
}
/**
* include_reply - Generate the reply text for an email
- * @param m Mailbox
- * @param e Email
- * @param out File to write to
+ * @param m Mailbox
+ * @param e Email
+ * @param fp_out File to write to
* @retval 0 Success
* @retval -1 Failure
*/
-static int include_reply(struct Mailbox *m, struct Email *e, FILE *out)
+static int include_reply(struct Mailbox *m, struct Email *e, FILE *fp_out)
{
CopyMessageFlags cmflags =
MUTT_CM_PREFIX | MUTT_CM_DECODE | MUTT_CM_CHARCONV | MUTT_CM_REPLYING;
mutt_parse_mime_message(m, e);
mutt_message_hook(m, e, MUTT_MESSAGE_HOOK);
- mutt_make_attribution(m, e, out);
+ mutt_make_attribution(m, e, fp_out);
if (!C_Header)
cmflags |= MUTT_CM_NOHEADER;
cmflags |= MUTT_CM_WEED;
}
- mutt_copy_message_ctx(out, m, e, cmflags, chflags);
+ mutt_copy_message_ctx(fp_out, m, e, cmflags, chflags);
- mutt_make_post_indent(m, e, out);
+ mutt_make_post_indent(m, e, fp_out);
return 0;
}
/**
* generate_body - Create a new email body
- * @param tempfp Stream for outgoing message
+ * @param fp_tmp Stream for outgoing message
* @param msg Header for outgoing message
* @param flags Compose mode, see #SendFlags
* @param m Mailbox
* @retval 0 Success
* @retval -1 Error
*/
-static int generate_body(FILE *tempfp, struct Email *msg, SendFlags flags,
+static int generate_body(FILE *fp_tmp, struct Email *msg, SendFlags flags,
struct Mailbox *m, struct EmailList *el)
{
enum QuadOption ans;
{
STAILQ_FOREACH(en, el, entries)
{
- if (include_reply(m, en->email, tempfp) == -1)
+ if (include_reply(m, en->email, fp_tmp) == -1)
{
mutt_error(_("Could not include all requested messages"));
return -1;
}
- fputc('\n', tempfp);
+ fputc('\n', fp_tmp);
}
}
else
- include_reply(m, en->email, tempfp);
+ include_reply(m, en->email, fp_tmp);
}
}
else if (flags & SEND_FORWARD)
else if (ans != MUTT_ABORT)
{
if (single)
- include_forward(m, en->email, tempfp);
+ include_forward(m, en->email, fp_tmp);
else
{
STAILQ_FOREACH(en, el, entries)
{
- include_forward(m, en->email, tempfp);
+ include_forward(m, en->email, fp_tmp);
}
}
}
/* Write out the message in MIME form. */
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *tempfp = mutt_file_fopen(tempfile, "w");
- if (!tempfp)
+ FILE *fp_tmp = mutt_file_fopen(tempfile, "w");
+ if (!fp_tmp)
return -1;
#ifdef USE_SMTP
C_WriteBcc = false;
#endif
#ifdef MIXMASTER
- mutt_rfc822_write_header(tempfp, msg->env, msg->content,
+ mutt_rfc822_write_header(fp_tmp, msg->env, msg->content,
MUTT_WRITE_HEADER_NORMAL, !STAILQ_EMPTY(&msg->chain),
mutt_should_hide_protected_subject(msg));
#endif
#ifndef MIXMASTER
- mutt_rfc822_write_header(tempfp, msg->env, msg->content, MUTT_WRITE_HEADER_NORMAL,
+ mutt_rfc822_write_header(fp_tmp, msg->env, msg->content, MUTT_WRITE_HEADER_NORMAL,
false, mutt_should_hide_protected_subject(msg));
#endif
#ifdef USE_SMTP
C_WriteBcc = true;
#endif
- fputc('\n', tempfp); /* tie off the header. */
+ fputc('\n', fp_tmp); /* tie off the header. */
- if ((mutt_write_mime_body(msg->content, tempfp) == -1))
+ if ((mutt_write_mime_body(msg->content, fp_tmp) == -1))
{
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
unlink(tempfile);
return -1;
}
- if (fclose(tempfp) != 0)
+ if (fclose(fp_tmp) != 0)
{
mutt_perror(tempfile);
unlink(tempfile);
return false;
}
- FILE *attf = mutt_file_fopen(filename, "r");
- if (!attf)
+ FILE *fp_att = mutt_file_fopen(filename, "r");
+ if (!fp_att)
return false;
char *inputline = mutt_mem_malloc(1024);
bool found = false;
- while (!feof(attf))
+ while (!feof(fp_att))
{
- fgets(inputline, 1024, attf);
+ fgets(inputline, 1024, fp_att);
if (!mutt_is_quote_line(inputline, NULL) &&
regexec(C_AbortNoattachRegex->regex, inputline, 0, NULL, 0) == 0)
{
}
}
FREE(&inputline);
- mutt_file_fclose(&attf);
+ mutt_file_fclose(&fp_att);
return found;
}
{
char buf[1024];
char fcc[PATH_MAX] = ""; /* where to copy this message */
- FILE *tempfp = NULL;
+ FILE *fp_tmp = NULL;
struct Body *pbody = NULL;
int i;
bool killfrom = false;
if (flags & (SEND_POSTPONED | SEND_RESEND))
{
- tempfp = mutt_file_fopen(msg->content->filename, "a+");
- if (!tempfp)
+ fp_tmp = mutt_file_fopen(msg->content->filename, "a+");
+ if (!fp_tmp)
{
mutt_perror(msg->content->filename);
goto cleanup;
if (!tempfile)
{
mutt_mktemp(buf, sizeof(buf));
- tempfp = mutt_file_fopen(buf, "w+");
+ fp_tmp = mutt_file_fopen(buf, "w+");
msg->content->filename = mutt_str_strdup(buf);
}
else
{
- tempfp = mutt_file_fopen(tempfile, "a+");
+ fp_tmp = mutt_file_fopen(tempfile, "a+");
msg->content->filename = mutt_str_strdup(tempfile);
}
}
else
- tempfp = mutt_file_fopen(msg->content->filename, "a+");
+ fp_tmp = mutt_file_fopen(msg->content->filename, "a+");
- if (!tempfp)
+ if (!fp_tmp)
{
mutt_debug(LL_DEBUG1, "can't create tempfile %s (errno=%d)\n",
msg->content->filename, errno);
process_user_header(msg->env);
if (flags & SEND_BATCH)
- mutt_file_copy_stream(stdin, tempfp);
+ mutt_file_copy_stream(stdin, fp_tmp);
if (C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
{
- append_signature(tempfp);
+ append_signature(fp_tmp);
}
/* include replies/forwarded messages, unless we are given a template */
if (!tempfile && (ctx || !(flags & (SEND_REPLY | SEND_FORWARD))) &&
- generate_body(tempfp, msg, flags, ctx->mailbox, el) == -1)
+ generate_body(fp_tmp, msg, flags, ctx->mailbox, el) == -1)
{
goto cleanup;
}
if (!C_SigOnTop && !(flags & (SEND_MAILX | SEND_KEY | SEND_BATCH)) &&
C_Editor && (mutt_str_strcmp(C_Editor, "builtin") != 0))
{
- append_signature(tempfp);
+ append_signature(fp_tmp);
}
}
msg->env->from->personal = mutt_str_strdup(C_Realname);
if (!(((WithCrypto & APPLICATION_PGP) != 0) && (flags & SEND_KEY)))
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
if (flags & SEND_MAILX)
{
}
}
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
if (!(flags & SEND_NO_FREE_HEADER))
mutt_email_free(&msg);
void mutt_fix_reply_recipients(struct Envelope *env);
void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp);
void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp);
-void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *out);
+void mutt_make_attribution(struct Mailbox *m, struct Email *e, FILE *fp_out);
void mutt_make_forward_subject(struct Envelope *env, struct Mailbox *m, struct Email *e);
void mutt_make_misc_reply_headers(struct Envelope *env, struct Envelope *curenv);
-void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *out);
+void mutt_make_post_indent(struct Mailbox *m, struct Email *e, FILE *fp_out);
struct Address *mutt_remove_xrefs(struct Address *a, struct Address *b);
int mutt_resend_message(FILE *fp, struct Context *ctx, struct Email *cur);
void mutt_set_followup_to(struct Envelope *e);
/**
* encode_quoted - Encode text as quoted printable
* @param fc Cursor for converting a file's encoding
- * @param fout File to store the result
+ * @param fp_out File to store the result
* @param istext Is the input text?
*/
-static void encode_quoted(struct FgetConv *fc, FILE *fout, bool istext)
+static void encode_quoted(struct FgetConv *fc, FILE *fp_out, bool istext)
{
int c, linelen = 0;
char line[77], savechar;
if (line[linelen - 3] == '=')
{
line[linelen - 3] = 0;
- fputs(line, fout);
- fputs("=\n", fout);
+ fputs(line, fp_out);
+ fputs("=\n", fp_out);
line[linelen] = 0;
line[0] = '=';
line[1] = line[linelen - 2];
savechar = line[linelen - 1];
line[linelen - 1] = '=';
line[linelen] = 0;
- fputs(line, fout);
- fputc('\n', fout);
+ fputs(line, fp_out);
+ fputc('\n', fp_out);
line[0] = savechar;
linelen = 1;
}
if (linelen < 74)
{
sprintf(line + linelen - 1, "=%2.2X", (unsigned char) line[linelen - 1]);
- fputs(line, fout);
+ fputs(line, fp_out);
}
else
{
line[linelen - 1] = '=';
line[linelen] = 0;
- fputs(line, fout);
- fprintf(fout, "\n=%2.2X", (unsigned char) savechar2);
+ fputs(line, fp_out);
+ fprintf(fp_out, "\n=%2.2X", (unsigned char) savechar2);
}
}
else
{
line[linelen] = 0;
- fputs(line, fout);
+ fputs(line, fp_out);
}
- fputc('\n', fout);
+ fputc('\n', fp_out);
linelen = 0;
}
else if (c != 9 && (c < 32 || c > 126 || c == '='))
{
line[linelen++] = '=';
line[linelen] = 0;
- fputs(line, fout);
- fputc('\n', fout);
+ fputs(line, fp_out);
+ fputc('\n', fp_out);
linelen = 0;
}
sprintf(line + linelen, "=%2.2X", (unsigned char) c);
savechar = line[linelen - 1];
line[linelen - 1] = '=';
line[linelen] = 0;
- fputs(line, fout);
- fputc('\n', fout);
+ fputs(line, fp_out);
+ fputc('\n', fp_out);
sprintf(line, "=%2.2X", (unsigned char) savechar);
}
}
else
line[linelen] = 0;
- fputs(line, fout);
+ fputs(line, fp_out);
}
}
/**
* b64_flush - Save the bytes to the file
- * @param bctx Cursor for the base64 conversion
- * @param fout File to save the output
+ * @param bctx Cursor for the base64 conversion
+ * @param fp_out File to save the output
*/
-static void b64_flush(struct B64Context *bctx, FILE *fout)
+static void b64_flush(struct B64Context *bctx, FILE *fp_out)
{
/* for some reasons, mutt_b64_encode expects the
* output buffer to be larger than 10B */
if (bctx->linelen >= 72)
{
- fputc('\n', fout);
+ fputc('\n', fp_out);
bctx->linelen = 0;
}
ret = mutt_b64_encode(bctx->buffer, bctx->size, encoded, sizeof(encoded));
for (size_t i = 0; i < ret; i++)
{
- fputc(encoded[i], fout);
+ fputc(encoded[i], fp_out);
bctx->linelen++;
}
/**
* b64_putc - Base64-encode one character
- * @param bctx Cursor for the base64 conversion
- * @param c Character to encode
- * @param fout File to save the output
+ * @param bctx Cursor for the base64 conversion
+ * @param c Character to encode
+ * @param fp_out File to save the output
*/
-static void b64_putc(struct B64Context *bctx, char c, FILE *fout)
+static void b64_putc(struct B64Context *bctx, char c, FILE *fp_out)
{
if (bctx->size == 3)
- b64_flush(bctx, fout);
+ b64_flush(bctx, fp_out);
bctx->buffer[bctx->size++] = c;
}
/**
* encode_base64 - Base64-encode some data
* @param fc Cursor for converting a file's encoding
- * @param fout File to store the result
+ * @param fp_out File to store the result
* @param istext Is the input text?
*/
-static void encode_base64(struct FgetConv *fc, FILE *fout, int istext)
+static void encode_base64(struct FgetConv *fc, FILE *fp_out, int istext)
{
struct B64Context bctx;
int ch, ch1 = EOF;
return;
}
if (istext && ch == '\n' && ch1 != '\r')
- b64_putc(&bctx, '\r', fout);
- b64_putc(&bctx, ch, fout);
+ b64_putc(&bctx, '\r', fp_out);
+ b64_putc(&bctx, ch, fp_out);
ch1 = ch;
}
- b64_flush(&bctx, fout);
- fputc('\n', fout);
+ b64_flush(&bctx, fp_out);
+ fputc('\n', fp_out);
}
/**
* encode_8bit - Write the data as raw 8-bit data
* @param fc Cursor for converting a file's encoding
- * @param fout File to store the result
+ * @param fp_out File to store the result
*/
-static void encode_8bit(struct FgetConv *fc, FILE *fout)
+static void encode_8bit(struct FgetConv *fc, FILE *fp_out)
{
int ch;
SigInt = 0;
return;
}
- fputc(ch, fout);
+ fputc(ch, fp_out);
}
}
/**
* mutt_write_mime_header - Create a MIME header
- * @param a Body part
- * @param f File to write to
+ * @param a Body part
+ * @param fp File to write to
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_write_mime_header(struct Body *a, FILE *f)
+int mutt_write_mime_header(struct Body *a, FILE *fp)
{
- fprintf(f, "Content-Type: %s/%s", TYPE(a), a->subtype);
+ fprintf(fp, "Content-Type: %s/%s", TYPE(a), a->subtype);
if (!TAILQ_EMPTY(&a->parameter))
{
if (!np->value)
continue;
- fputc(';', f);
+ fputc(';', fp);
char buf[256];
buf[0] = 0;
if (len + tmplen + 2 > 76)
{
- fputs("\n\t", f);
+ fputs("\n\t", fp);
len = tmplen + 8;
}
else
{
- fputc(' ', f);
+ fputc(' ', fp);
len += tmplen + 1;
}
- fprintf(f, "%s%s=%s", np->attribute, encode ? "*" : "", buf);
+ fprintf(fp, "%s%s=%s", np->attribute, encode ? "*" : "", buf);
}
}
- fputc('\n', f);
+ fputc('\n', fp);
if (a->language)
- fprintf(f, "Content-Language: %s\n", a->language);
+ fprintf(fp, "Content-Language: %s\n", a->language);
if (a->description)
- fprintf(f, "Content-Description: %s\n", a->description);
+ fprintf(fp, "Content-Description: %s\n", a->description);
if (a->disposition != DISP_NONE)
{
if (a->disposition < sizeof(dispstr) / sizeof(char *))
{
- fprintf(f, "Content-Disposition: %s", dispstr[a->disposition]);
+ fprintf(fp, "Content-Disposition: %s", dispstr[a->disposition]);
if (a->use_disp && (a->disposition != DISP_INLINE))
{
const int encode = rfc2231_encode_string(&tmp);
mutt_addr_cat(buf, sizeof(buf), tmp, MimeSpecials);
FREE(&tmp);
- fprintf(f, "; filename%s=%s", encode ? "*" : "", buf);
+ fprintf(fp, "; filename%s=%s", encode ? "*" : "", buf);
}
}
- fputc('\n', f);
+ fputc('\n', fp);
}
else
{
}
if (a->encoding != ENC_7BIT)
- fprintf(f, "Content-Transfer-Encoding: %s\n", ENCODING(a->encoding));
+ fprintf(fp, "Content-Transfer-Encoding: %s\n", ENCODING(a->encoding));
if (C_CryptProtectedHeadersWrite && a->mime_headers)
- mutt_rfc822_write_header(f, a->mime_headers, NULL, MUTT_WRITE_HEADER_MIME, false, false);
+ mutt_rfc822_write_header(fp, a->mime_headers, NULL, MUTT_WRITE_HEADER_MIME, false, false);
/* Do NOT add the terminator here!!! */
- return ferror(f) ? -1 : 0;
+ return ferror(fp) ? -1 : 0;
}
/**
/**
* mutt_write_mime_body - Write a MIME part
- * @param a Body to use
- * @param f File to write to
+ * @param a Body to use
+ * @param fp File to write to
* @retval 0 Success
* @retval -1 Failure
*/
-int mutt_write_mime_body(struct Body *a, FILE *f)
+int mutt_write_mime_body(struct Body *a, FILE *fp)
{
- FILE *fpin = NULL;
+ FILE *fp_in = NULL;
struct FgetConv *fc = NULL;
if (a->type == TYPE_MULTIPART)
for (struct Body *t = a->parts; t; t = t->next)
{
- fprintf(f, "\n--%s\n", boundary);
- if (mutt_write_mime_header(t, f) == -1)
+ fprintf(fp, "\n--%s\n", boundary);
+ if (mutt_write_mime_header(t, fp) == -1)
return -1;
- fputc('\n', f);
- if (mutt_write_mime_body(t, f) == -1)
+ fputc('\n', fp);
+ if (mutt_write_mime_body(t, fp) == -1)
return -1;
}
- fprintf(f, "\n--%s--\n", boundary);
- return ferror(f) ? -1 : 0;
+ fprintf(fp, "\n--%s--\n", boundary);
+ return ferror(fp) ? -1 : 0;
}
/* This is pretty gross, but it's the best solution for now... */
if (((WithCrypto & APPLICATION_PGP) != 0) && a->type == TYPE_APPLICATION &&
(mutt_str_strcmp(a->subtype, "pgp-encrypted") == 0))
{
- fputs("Version: 1\n", f);
+ fputs("Version: 1\n", fp);
return 0;
}
- fpin = fopen(a->filename, "r");
- if (!fpin)
+ fp_in = fopen(a->filename, "r");
+ if (!fp_in)
{
mutt_debug(LL_DEBUG1, "%s no longer exists\n", a->filename);
mutt_error(_("%s no longer exists"), a->filename);
{
char send_charset[128];
fc = mutt_ch_fgetconv_open(
- fpin, a->charset, mutt_body_get_charset(a, send_charset, sizeof(send_charset)), 0);
+ fp_in, a->charset,
+ mutt_body_get_charset(a, send_charset, sizeof(send_charset)), 0);
}
else
- fc = mutt_ch_fgetconv_open(fpin, 0, 0, 0);
+ fc = mutt_ch_fgetconv_open(fp_in, 0, 0, 0);
mutt_sig_allow_interrupt(1);
if (a->encoding == ENC_QUOTED_PRINTABLE)
- encode_quoted(fc, f, write_as_text_part(a));
+ encode_quoted(fc, fp, write_as_text_part(a));
else if (a->encoding == ENC_BASE64)
- encode_base64(fc, f, write_as_text_part(a));
+ encode_base64(fc, fp, write_as_text_part(a));
else if (a->type == TYPE_TEXT && (!a->noconv))
- encode_8bit(fc, f);
+ encode_8bit(fc, fp);
else
- mutt_file_copy_stream(fpin, f);
+ mutt_file_copy_stream(fp_in, fp);
mutt_sig_allow_interrupt(0);
mutt_ch_fgetconv_close(&fc);
- mutt_file_fclose(&fpin);
+ mutt_file_fclose(&fp_in);
if (SigInt == 1)
{
SigInt = 0;
return -1;
}
- return ferror(f) ? -1 : 0;
+ return ferror(fp) ? -1 : 0;
}
/**
/**
* convert_file_to - Change the encoding of a file
- * @param[in] file File to convert
+ * @param[in] fp File to convert
* @param[in] fromcode Original encoding
* @param[in] ncodes Number of target encodings
* @param[in] tocodes List of target encodings
* long as the input for any pair of charsets we might be interested
* in.
*/
-static size_t convert_file_to(FILE *file, const char *fromcode, int ncodes,
+static size_t convert_file_to(FILE *fp, const char *fromcode, int ncodes,
const char **tocodes, int *tocode, struct Content *info)
{
char bufi[256], bufu[512], bufo[4 * sizeof(bufi)];
}
}
- rewind(file);
+ rewind(fp);
size_t ibl = 0;
while (true)
{
/* Try to fill input buffer */
- size_t n = fread(bufi + ibl, 1, sizeof(bufi) - ibl, file);
+ size_t n = fread(bufi + ibl, 1, sizeof(bufi) - ibl, fp);
ibl += n;
/* Convert to UTF-8 */
/**
* convert_file_from_to - Convert a file between encodings
- * @param[in] file File to read from
+ * @param[in] fp File to read from
* @param[in] fromcodes Charsets to try converting FROM
* @param[in] tocodes Charsets to try converting TO
* @param[out] fromcode From charset selected
* However, if fromcode is zero then fromcodes is assumed to be the name of a
* single charset even if it contains a colon.
*/
-static size_t convert_file_from_to(FILE *file, const char *fromcodes, const char *tocodes,
+static size_t convert_file_from_to(FILE *fp, const char *fromcodes, const char *tocodes,
char **fromcode, char **tocode, struct Content *info)
{
char *fcode = NULL;
continue;
fcode = mutt_str_substr_dup(c, c1);
- ret = convert_file_to(file, fcode, ncodes, (const char **) tcode, &cn, info);
+ ret = convert_file_to(fp, fcode, ncodes, (const char **) tcode, &cn, info);
if (ret != (size_t)(-1))
{
*fromcode = fcode;
else
{
/* There is only one fromcode */
- ret = convert_file_to(file, fromcodes, ncodes, (const char **) tcode, &cn, info);
+ ret = convert_file_to(fp, fromcodes, ncodes, (const char **) tcode, &cn, info);
if (ret != (size_t)(-1))
{
*tocode = tcode[cn];
*/
int mutt_lookup_mime_type(struct Body *att, const char *path)
{
- FILE *f = NULL;
+ FILE *fp = NULL;
char *p = NULL, *q = NULL, *ct = NULL;
char buf[PATH_MAX];
char subtype[256], xtype[256];
goto bye; /* shouldn't happen */
}
- f = fopen(buf, "r");
- if (f)
+ fp = fopen(buf, "r");
+ if (fp)
{
found_mimetypes = true;
- while (fgets(buf, sizeof(buf) - 1, f))
+ while (fgets(buf, sizeof(buf) - 1, fp))
{
/* weed out any comments */
p = strchr(buf, '#');
p = NULL;
}
}
- mutt_file_fclose(&f);
+ mutt_file_fclose(&fp);
}
}
/**
* transform_to_7bit - Convert MIME parts to 7-bit
* @param a Body of the email
- * @param fpin File to read
+ * @param fp_in File to read
*/
-static void transform_to_7bit(struct Body *a, FILE *fpin)
+static void transform_to_7bit(struct Body *a, FILE *fp_in)
{
char buf[PATH_MAX];
struct State s = { 0 };
if (a->encoding != ENC_7BIT)
a->encoding = ENC_7BIT;
- transform_to_7bit(a->parts, fpin);
+ transform_to_7bit(a->parts, fp_in);
}
else if (mutt_is_message_type(a->type, a->subtype))
{
- mutt_message_to_7bit(a, fpin);
+ mutt_message_to_7bit(a, fp_in);
}
else
{
mutt_perror("fopen");
return;
}
- s.fp_in = fpin;
+ s.fp_in = fp_in;
mutt_decode_attachment(a, &s);
mutt_file_fclose(&s.fp_out);
FREE(&a->d_filename);
{
char temp[PATH_MAX];
char *line = NULL;
- FILE *fpin = NULL;
- FILE *fpout = NULL;
+ FILE *fp_in = NULL;
+ FILE *fp_out = NULL;
struct stat sb;
if (!a->filename && fp)
- fpin = fp;
- else if (!a->filename || !(fpin = fopen(a->filename, "r")))
+ fp_in = fp;
+ else if (!a->filename || !(fp_in = fopen(a->filename, "r")))
{
mutt_error(_("Could not open %s"), a->filename ? a->filename : "(null)");
return;
if (stat(a->filename, &sb) == -1)
{
mutt_perror("stat");
- mutt_file_fclose(&fpin);
+ mutt_file_fclose(&fp_in);
}
a->length = sb.st_size;
}
mutt_mktemp(temp, sizeof(temp));
- fpout = mutt_file_fopen(temp, "w+");
- if (!fpout)
+ fp_out = mutt_file_fopen(temp, "w+");
+ if (!fp_out)
{
mutt_perror("fopen");
goto cleanup;
}
- if (!fpin)
+ if (!fp_in)
goto cleanup;
- fseeko(fpin, a->offset, SEEK_SET);
- a->parts = mutt_rfc822_parse_message(fpin, a);
+ fseeko(fp_in, a->offset, SEEK_SET);
+ a->parts = mutt_rfc822_parse_message(fp_in, a);
- transform_to_7bit(a->parts, fpin);
+ transform_to_7bit(a->parts, fp_in);
- mutt_copy_hdr(fpin, fpout, a->offset, a->offset + a->length,
+ mutt_copy_hdr(fp_in, fp_out, a->offset, a->offset + a->length,
CH_MIME | CH_NONEWLINE | CH_XMIT, NULL);
- fputs("MIME-Version: 1.0\n", fpout);
- mutt_write_mime_header(a->parts, fpout);
- fputc('\n', fpout);
- mutt_write_mime_body(a->parts, fpout);
+ fputs("MIME-Version: 1.0\n", fp_out);
+ mutt_write_mime_header(a->parts, fp_out);
+ fputc('\n', fp_out);
+ mutt_write_mime_body(a->parts, fp_out);
cleanup:
FREE(&line);
- if (fpin && fpin != fp)
- mutt_file_fclose(&fpin);
- if (fpout)
- mutt_file_fclose(&fpout);
+ if (fp_in && fp_in != fp)
+ mutt_file_fclose(&fp_in);
+ if (fp_out)
+ mutt_file_fclose(&fp_out);
else
return;
*/
static void run_mime_type_query(struct Body *att)
{
- FILE *fp, *fperr;
+ FILE *fp, *fp_err;
char cmd[STR_COMMAND];
char *buf = NULL;
size_t buflen;
mutt_file_expand_fmt_quote(cmd, sizeof(cmd), C_MimeTypeQueryCommand, att->filename);
- pid = mutt_create_filter(cmd, NULL, &fp, &fperr);
+ pid = mutt_create_filter(cmd, NULL, &fp, &fp_err);
if (pid < 0)
{
mutt_error(_("Error running \"%s\""), cmd);
}
mutt_file_fclose(&fp);
- mutt_file_fclose(&fperr);
+ mutt_file_fclose(&fp_err);
mutt_wait_filter(pid);
}
/**
* mutt_write_references - Add the message references to a list
* @param r String List of references
- * @param f File to write to
+ * @param fp File to write to
* @param trim Trim the list to at most this many items
*
* Write the list in reverse because they are stored in reverse order when
* parsed to speed up threading.
*/
-void mutt_write_references(const struct ListHead *r, FILE *f, size_t trim)
+void mutt_write_references(const struct ListHead *r, FILE *fp, size_t trim)
{
struct ListNode *np = NULL;
size_t length = 0;
for (size_t i = 0; i < length; ++i)
{
- fputc(' ', f);
- fputs(ref[i]->data, f);
+ fputc(' ', fp);
+ fputs(ref[i]->data, fp);
if (i != length - 1)
- fputc('\n', f);
+ fputc('\n', fp);
}
FREE(&ref);
char tempfile[PATH_MAX];
mutt_mktemp(tempfile, sizeof(tempfile));
- FILE *f = mutt_file_fopen(tempfile, "w");
- if (f)
+ FILE *fp_tmp = mutt_file_fopen(tempfile, "w");
+ if (fp_tmp)
{
char date[128];
CopyHeaderFlags chflags = CH_XMIT | CH_NONEWLINE | CH_NOQFROM;
chflags |= CH_WEED_DELIVERED;
fseeko(fp, e->offset, SEEK_SET);
- fprintf(f, "Resent-From: %s", resent_from);
- fprintf(f, "\nResent-%s", mutt_date_make_date(date, sizeof(date)));
+ fprintf(fp_tmp, "Resent-From: %s", resent_from);
+ fprintf(fp_tmp, "\nResent-%s", mutt_date_make_date(date, sizeof(date)));
char *msgid_str = gen_msgid();
- fprintf(f, "Resent-Message-ID: %s\n", msgid_str);
+ fprintf(fp_tmp, "Resent-Message-ID: %s\n", msgid_str);
FREE(&msgid_str);
- fputs("Resent-To: ", f);
- mutt_write_address_list(to, f, 11, 0);
- mutt_copy_header(fp, e, f, chflags, NULL);
- fputc('\n', f);
- mutt_file_copy_bytes(fp, f, e->content->length);
- if (mutt_file_fclose(&f) != 0)
+ fputs("Resent-To: ", fp_tmp);
+ mutt_write_address_list(to, fp_tmp, 11, 0);
+ mutt_copy_header(fp, e, fp_tmp, chflags, NULL);
+ fputc('\n', fp_tmp);
+ mutt_file_copy_bytes(fp, fp_tmp, e->content->length);
+ if (mutt_file_fclose(&fp_tmp) != 0)
{
mutt_perror(tempfile);
unlink(tempfile);
{
struct Message *msg = NULL;
char tempfile[PATH_MAX];
- FILE *tempfp = NULL;
+ FILE *fp_tmp = NULL;
int rc = -1;
bool need_mailbox_cleanup = false;
struct stat st;
if ((ctx_fcc->mailbox->magic == MUTT_MMDF) || (ctx_fcc->mailbox->magic == MUTT_MBOX))
{
mutt_mktemp(tempfile, sizeof(tempfile));
- tempfp = mutt_file_fopen(tempfile, "w+");
- if (!tempfp)
+ fp_tmp = mutt_file_fopen(tempfile, "w+");
+ if (!fp_tmp)
{
mutt_perror(tempfile);
mx_mbox_close(&ctx_fcc);
msg = mx_msg_open_new(ctx_fcc->mailbox, e, onm_flags);
if (!msg)
{
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
mx_mbox_close(&ctx_fcc);
goto done;
}
}
#endif
- if (tempfp)
+ if (fp_tmp)
{
char sasha[1024];
int lines = 0;
- mutt_write_mime_body(e->content, tempfp);
+ mutt_write_mime_body(e->content, fp_tmp);
/* make sure the last line ends with a newline. Emacs doesn't ensure
* this will happen, and it can cause problems parsing the mailbox
* later.
*/
- fseek(tempfp, -1, SEEK_END);
- if (fgetc(tempfp) != '\n')
+ fseek(fp_tmp, -1, SEEK_END);
+ if (fgetc(fp_tmp) != '\n')
{
- fseek(tempfp, 0, SEEK_END);
- fputc('\n', tempfp);
+ fseek(fp_tmp, 0, SEEK_END);
+ fputc('\n', fp_tmp);
}
- fflush(tempfp);
- if (ferror(tempfp))
+ fflush(fp_tmp);
+ if (ferror(fp_tmp))
{
mutt_debug(LL_DEBUG1, "%s: write failed.\n", tempfile);
- mutt_file_fclose(&tempfp);
+ mutt_file_fclose(&fp_tmp);
unlink(tempfile);
mx_msg_commit(ctx_fcc->mailbox, msg); /* XXX really? */
mx_msg_close(ctx_fcc->mailbox, &msg);
}
/* count the number of lines */
- rewind(tempfp);
- while (fgets(sasha, sizeof(sasha), tempfp))
+ rewind(fp_tmp);
+ while (fgets(sasha, sizeof(sasha), fp_tmp))
lines++;
- fprintf(msg->fp, "Content-Length: " OFF_T_FMT "\n", (LOFF_T) ftello(tempfp));
+ fprintf(msg->fp, "Content-Length: " OFF_T_FMT "\n", (LOFF_T) ftello(fp_tmp));
fprintf(msg->fp, "Lines: %d\n\n", lines);
/* copy the body and clean up */
- rewind(tempfp);
- rc = mutt_file_copy_stream(tempfp, msg->fp);
- if (fclose(tempfp) != 0)
+ rewind(fp_tmp);
+ rc = mutt_file_copy_stream(fp_tmp, msg->fp);
+ if (fclose(fp_tmp) != 0)
rc = -1;
/* if there was an error, leave the temp version */
if (!rc)
void mutt_update_encoding(struct Body *a);
void mutt_write_address_list(struct Address *addr, FILE *fp, int linelen, bool display);
int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath);
-int mutt_write_mime_body(struct Body *a, FILE *f);
-int mutt_write_mime_header(struct Body *a, FILE *f);
+int mutt_write_mime_body(struct Body *a, FILE *fp);
+int mutt_write_mime_header(struct Body *a, FILE *fp);
int mutt_write_multiple_fcc(const char *path, struct Email *e, const char *msgid, bool post, char *fcc, char **finalpath);
int mutt_write_one_header(FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, CopyHeaderFlags chflags);
-void mutt_write_references(const struct ListHead *r, FILE *f, size_t trim);
+void mutt_write_references(const struct ListHead *r, FILE *fp, size_t trim);
#endif /* MUTT_SENDLIB_H */