buf[0] = '\0';
rfc822_write_address(buf, sizeof(buf), new->addr, 0);
write_safe_address(rc, buf);
- fclose(rc);
+ m_fclose(&rc);
mutt_message _("Alias added.");
} else {
mutt_perror(buf);
else
mutt_perror(fpin ? tempfile : a->filename);
- if (fpin)
- fclose (fpin);
- if (fpout)
- fclose (fpout);
+ m_fclose(&fpin);
+ m_fclose(&fpout);
return a->unlink ? 0 : -1;
}
goto bailout;
}
mutt_copy_stream (fp, tfp);
- fclose (fp);
- fclose (tfp);
+ m_fclose(&fp);
+ m_fclose(&tfp);
mutt_unlink (a->filename);
if (mutt_rename_file (tempfile, a->filename) != 0) {
mutt_perror (_("Failure to rename file."));
fseeko ((s.fpin = fp), m->offset, 0);
mutt_decode_attachment (m, &s);
- if (fclose (s.fpout) != 0) {
+ if (m_fclose(&s.fpout) != 0) {
mutt_perror ("fclose");
return (-1);
}
}
- }
- else {
+ } else {
/* In send mode, just copy file */
FILE *ofp, *nfp;
if (stat (m->filename, &st) == -1) {
mutt_perror ("stat");
- fclose (s.fpout);
+ m_fclose(&s.fpout);
return (-1);
}
mutt_body_handler (m, &s);
- fclose (s.fpout);
+ m_fclose(&s.fpout);
if (fp == NULL) {
m->length = 0;
m->encoding = saved_encoding;
m->parts = saved_parts;
m->hdr = saved_hdr;
}
- fclose (s.fpin);
+ m_fclose(&s.fpin);
}
return (0);
p++;
}
}
- fclose (fp);
+ m_fclose(&fp);
return (found);
}
}
pipe_msg (h, fpout, decode, print);
- fclose (fpout);
+ m_fclose(&fpout);
rc = mutt_wait_filter (thepid);
}
else { /* handle tagged messages */
p_delete(&idx[idxlen]);
continue;
}
- fclose (fp);
+ m_fclose(&fp);
if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL) {
mutt_error
fseeko (fp, cur->offset, 0);
if (mutt_copy_bytes (fp, fpout, cur->length) == -1) {
- fclose (fp);
+ m_fclose(&fp);
body_list_wipe(&cur);
return (-1);
}
body_list_wipe(&cur);
- fclose (fp);
+ m_fclose(&fp);
}
else {
fseeko (fpin, body->offset, 0);
mx_close_mailbox (&tmpctx, NULL);
bail:
- if (fp)
- fclose (fp);
+ m_fclose(&fp);
if (rc >= 0)
unlink (tmp);
if (decode) {
b->length = ftello (s->fpout);
b->offset = 0;
- fclose (s->fpout);
+ m_fclose(&s->fpout);
/* restore final destination and substitute the tempfile for input */
s->fpout = fp;
b->offset = tmpoffset;
/* restore the original source stream */
- fclose (s->fpin);
+ m_fclose(&s->fpin);
s->fpin = fp;
}
}
mutt_copy_stream (ifp, ofp);
- fclose (ifp);
- fclose (ofp);
+ m_fclose(&ifp);
+ m_fclose(&ofp);
if (stat (path, &st) == -1) {
mutt_perror (path);
if ((ofp = safe_fopen (body, "w")) == NULL) {
/* intentionally leak a possible temporary file here */
- fclose (ifp);
+ m_fclose(&ifp);
mutt_perror (body);
return;
}
n = mutt_read_rfc822_header (ifp, NULL, 1, 0);
while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0)
fwrite (buffer, 1, i, ofp);
- fclose (ofp);
- fclose (ifp);
+ m_fclose(&ofp);
+ m_fclose(&ifp);
mutt_unlink (path);
/* restore old info. */
if (menu != MENU_PAGER)
dump_unbound (f, OpGeneric, Keymaps[MENU_GENERIC], Keymaps[menu]);
- fclose(f);
+ m_fclose(&f);
snprintf(buf, sizeof (buf), _("Help for %s"), desc);
} while (mutt_do_pager(buf, tmp,
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
imap_free_header_data((void *)&h.data);
- fclose (fp);
+ m_fclose(&fp);
mutt_hcache_close (hc);
return -1;
}
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK))) {
imap_free_header_data ((void *)&h.data);
- fclose (fp);
+ m_fclose(&fp);
#ifdef USE_HCACHE
mutt_hcache_close (hc);
#endif /* USE_HCACHE */
mutt_hcache_close (hc);
#endif /* USE_HCACHE */
- fclose (fp);
+ m_fclose(&fp);
if (ctx->msgcount > oldmsgcount)
mx_update_context (ctx, ctx->msgcount - oldmsgcount);
pc = imap_next_word (pc);
mutt_error ("%s", pc);
mutt_sleep (1);
- fclose (fp);
+ m_fclose(&fp);
goto fail;
}
flush_buffer (buf, &len, idata->conn);
mutt_socket_write (idata->conn, "\r\n");
- fclose (fp);
+ m_fclose(&fp);
do
rc = imap_cmd_step (idata);
}
p_delete(&token.data);
p_delete(&linebuf);
- fclose (f);
+ m_fclose(&f);
if (pid != -1)
mutt_wait_filter (pid);
if (rc) {
q++;
*q = '\0';
NewsServer = m_strdup(p);
- fclose (f);
+ m_fclose(&f);
}
}
if ((p = getenv ("NNTPSERVER")))
buf[0] = c;
gpgme_data_write (data, buf, 1);
}
- fclose (fptmp);
gpgme_data_seek (data, 0, SEEK_SET);
- }
- else {
- fclose (fptmp);
+ } else {
err = gpgme_data_new_from_file (&data, tempfile, 1);
}
+ m_fclose(&fptmp);
unlink (tempfile);
if (err) {
mutt_error (_("error allocating data object: %s\n"), gpgme_strerror (err));
while ((nread = gpgme_data_read (data, buf, sizeof (buf)))) {
if (fwrite (buf, nread, 1, fp) != 1) {
mutt_perror (tempfile);
- fclose (fp);
+ m_fclose(&fp);
unlink (tempfile);
return NULL;
}
if (ret_fp)
rewind (fp);
else
- fclose (fp);
+ m_fclose(&fp);
if (nread == -1) {
mutt_error (_("error reading data object: %s\n"), gpgme_strerror (err));
unlink (tempfile);
- fclose (fp);
+ m_fclose(&fp);
return NULL;
}
if (ret_fp)
b->type = saved_b_type;
b->length = saved_b_length;
b->offset = saved_b_offset;
- fclose (tmpfp);
+ m_fclose(&tmpfp);
rewind (*fpout);
if (*cur && !is_signed && !(*cur)->parts
&& mutt_is_application_smime (*cur)) {
bb->length = ftello (s.fpout);
bb->offset = 0;
rewind (tmpfp);
- fclose (*fpout);
+ m_fclose(&*fpout);
p_clear(&s, 1);
s.fpin = tmpfp;
bb->type = saved_b_type;
bb->length = saved_b_length;
bb->offset = saved_b_offset;
- fclose (tmpfp);
+ m_fclose(&tmpfp);
rewind (*fpout);
body_list_wipe(cur);
*cur = tmp_b;
}
fgetconv_close (&fc);
- fclose (fp);
+ m_fclose(&fp);
}
body_list_wipe(&tattach);
}
- fclose (fpout);
+ m_fclose(&fpout);
mutt_unlink (tempfile);
return (rc);
}
body_list_wipe(&tattach);
}
- fclose (fpout);
+ m_fclose(&fpout);
mutt_unlink (tempfile);
return (rc);
}
leave:
gpgme_key_release (k);
gpgme_release (listctx);
- fclose (fp);
+ m_fclose(&fp);
mutt_clear_error ();
snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"), crypt_keyid (key));
mutt_do_pager (cmd, tempfile, 0, NULL);
if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
!crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
security)) {
- fclose (fpout);
+ m_fclose(&fpout);
break;
}
}
}
- fclose (fpout);
+ m_fclose(&fpout);
if (isendwin ())
mutt_any_key_to_continue (NULL);
if (ferror (fp))
mutt_perror ("fgets");
- fclose (fp);
+ m_fclose(&fp);
mutt_wait_filter (thepid);
close (devnull);
fseeko (s->fpin, sigbdy->offset, 0);
mutt_copy_bytes (s->fpin, fp, sigbdy->length);
- fclose (fp);
+ m_fclose(&fp);
pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL);
if (pgperr == NULL) {
mutt_body_handler (top, &s);
- fclose (tempfp);
+ m_fclose(&tempfp);
pgp_invoke_import (tempfname);
mutt_any_key_to_continue (NULL);
unlink (pgperrfile);
pgptmp = m_tempfile(pgptmpfile, sizeof(pgptmpfile), NONULL(Tempdir), NULL);
- if (pgptmp == NULL) {
+ if (!pgptmp == NULL) {
mutt_perror (pgptmpfile);
- fclose (pgperr);
+ m_fclose(&pgperr);
return NULL;
}
fseeko (s->fpin, a->offset, 0);
mutt_copy_bytes (s->fpin, pgptmp, a->length);
- fclose (pgptmp);
+ m_fclose(&pgptmp);
if ((thepid = pgp_invoke_decrypt (&pgpin, &pgpout, NULL, -1, -1,
fileno (pgperr), pgptmpfile)) == -1) {
- fclose (pgperr);
+ m_fclose(&pgperr);
unlink (pgptmpfile);
if (s->flags & M_DISPLAY)
state_attach_puts (_
if (!pgp_use_gpg_agent ())
fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
- fclose (pgpin);
+ m_fclose(&pgpin);
/* Read the output from PGP, and make sure to change CRLF to LF, otherwise
* read_mime_header has a hard time parsing the message.
fputs (buf, fpout);
}
- fclose (pgpout);
+ m_fclose(&pgpout);
rv = mutt_wait_filter (thepid);
mutt_unlink (pgptmpfile);
p->goodsig = 0;
state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
}
- fclose (pgperr);
+ m_fclose(&pgperr);
fflush (fpout);
rewind (fpout);
rc = -1;
}
- fclose (fpout);
+ m_fclose(&fpout);
mutt_unlink (tempfile);
return (rc);
sfp = m_tempfile(signedfile, sizeof(signedfile), NONULL(Tempdir), NULL);
if (sfp == NULL) {
mutt_perror (signedfile);
- fclose (fp);
+ m_fclose(&fp);
unlink (sigfile);
return NULL;
}
mutt_write_mime_header (a, sfp);
fputc ('\n', sfp);
mutt_write_mime_body (a, sfp);
- fclose (sfp);
+ m_fclose(&sfp);
if ((thepid = pgp_invoke_sign (&pgpin, &pgpout, &pgperr,
-1, -1, -1, signedfile)) == -1) {
mutt_perror (_("Can't open PGP subprocess!"));
- fclose (fp);
+ m_fclose(&fp);
unlink (sigfile);
unlink (signedfile);
return NULL;
if (!pgp_use_gpg_agent ())
fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
- fclose (pgpin);
+ m_fclose(&pgpin);
/*
* Read back the PGP signature. Also, change MESSAGE=>SIGNATURE as
if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
empty = 1;
- fclose (pgperr);
- fclose (pgpout);
+ m_fclose(&pgperr);
+ m_fclose(&pgpout);
unlink (signedfile);
- if (fclose (fp) != 0) {
+ if (m_fclose(&fp) != 0) {
mutt_perror ("fclose");
unlink (sigfile);
return (NULL);
pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL);
if (pgperr == NULL) {
mutt_perror (pgperrfile);
- fclose (fpout);
+ m_fclose(&fpout);
unlink (tempfile);
return NULL;
}
fptmp = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL);
if (fptmp == NULL) {
mutt_perror (pgpinfile);
- fclose (fpout);
+ m_fclose(&fpout);
unlink (tempfile);
- fclose (pgperr);
+ m_fclose(&pgperr);
unlink (pgperrfile);
return NULL;
}
mutt_write_mime_header (a, fptmp);
fputc ('\n', fptmp);
mutt_write_mime_body (a, fptmp);
- fclose (fptmp);
+ m_fclose(&fptmp);
if ((thepid = pgp_invoke_encrypt (&pgpin, NULL, NULL, -1,
fileno (fpout), fileno (pgperr),
pgpinfile, keylist, sign)) == -1) {
- fclose (pgperr);
+ m_fclose(&pgperr);
unlink (pgpinfile);
return (NULL);
}
fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
}
- fclose (pgpin);
+ m_fclose(&pgpin);
if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
empty = 1;
rewind (fpout);
if (!empty)
empty = (fgetc (fpout) == EOF);
- fclose (fpout);
+ m_fclose(&fpout);
fflush (pgperr);
rewind (pgperr);
err = 1;
fputs (buf, stdout);
}
- fclose (pgperr);
+ m_fclose(&pgperr);
/* pause if there is any error output from PGP */
if (err)
pgpin = m_tempfile(pgpinfile, sizeof(pgpinfile), NONULL(Tempdir), NULL);
if (pgpin == NULL) {
mutt_perror (pgpinfile);
- fclose (fp);
+ m_fclose(&fp);
return NULL;
}
mutt_copy_stream (fp, pgpin);
}
m_fclose(&fp);
- fclose (pgpin);
+ m_fclose(&pgpin);
pgpout = m_tempfile(pgpoutfile, sizeof(pgpoutfile), NONULL(Tempdir), NULL);
pgperr = m_tempfile(pgperrfile, sizeof(pgperrfile), NONULL(Tempdir), NULL);
if (pgpout == NULL || pgperr == NULL) {
mutt_perror (pgpout ? pgperrfile : pgpoutfile);
- fclose (pgpin);
+ m_fclose(&pgpin);
unlink (pgpinfile);
- if (pgpout) {
- fclose (pgpout);
- unlink (pgpoutfile);
- }
- if (pgperr) {
- fclose(pgperr);
- unlink(pgperrfile);
- }
+ m_fclose(&pgpout);
+ unlink (pgpoutfile);
+ m_fclose(&pgperr);
+ unlink(pgperrfile);
return NULL;
}
pgpinfile, keylist, flags)) == -1) {
mutt_perror (_("Can't invoke PGP"));
- fclose (pgpout);
- fclose (pgperr);
+ m_fclose(&pgpout);
+ m_fclose(&pgperr);
mutt_unlink (pgpinfile);
unlink (pgpoutfile);
return NULL;
*PgpPass = 0;
if (flags & SIGN)
fprintf (pgpin, "%s\n", PgpPass);
- fclose (pgpin);
+ m_fclose(&pgpin);
if (mutt_wait_filter (thepid) && option (OPTPGPCHECKEXIT))
empty = 1;
if (!empty)
empty = (fgetc (pgpout) == EOF);
- fclose (pgpout);
+ m_fclose(&pgpout);
err = 0;
fputs (buff, stdout);
}
- fclose (pgperr);
+ m_fclose(&pgperr);
if (err)
mutt_any_key_to_continue (NULL);
break;
}
if ((fp = safe_fopen (tempfile, "w")) == NULL) {
- fclose (devnull);
+ m_fclose(&devnull);
mutt_perror (_("Can't create temporary file"));
break;
mutt_perror (_("Can't create filter"));
unlink (tempfile);
- fclose (fp);
- fclose (devnull);
+ m_fclose(&fp);
+ m_fclose(&devnull);
}
mutt_wait_filter (thepid);
- fclose (fp);
- fclose (devnull);
+ m_fclose(&fp);
+ m_fclose(&devnull);
mutt_clear_error ();
snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"),
pgp_keyid (pgp_principal_key
if ((devnull = fopen ("/dev/null", "w")) == NULL) { /* __FOPEN_CHECKED__ */
mutt_perror (_("Can't open /dev/null"));
- fclose (tempfp);
+ m_fclose(&tempfp);
if (tempf == tempfb)
unlink (tempf);
return NULL;
mutt_perror (_("Can't create filter"));
unlink (tempf);
- fclose (tempfp);
- fclose (devnull);
+ m_fclose(&tempfp);
+ m_fclose(&devnull);
return NULL;
}
mutt_wait_filter (thepid);
- fclose (tempfp);
- fclose (devnull);
+ m_fclose(&tempfp);
+ m_fclose(&devnull);
att = body_new();
att->filename = m_strdup(tempf);
if (fgets (buf, sizeof (buf), idx))
cert_num++;
}
- fclose (idx);
+ m_fclose(&idx);
for (;;) {
*qry = 0;
cur++;
}
- fclose (idx);
+ m_fclose(&idx);
/* Make Helpstring */
helpstr[0] = 0;
fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
if (!fpout) {
- fclose (fperr);
+ m_fclose(&fperr);
mutt_perror (tmpfname);
return 1;
}
certificate, NULL, NULL, NULL, NULL, NULL,
SmimeGetCertEmailCommand)) == -1) {
mutt_message (_("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ m_fclose(&fperr);
+ m_fclose(&fpout);
return 1;
}
else if (copy)
ret = 2;
- fclose (fpout);
- fclose (fperr);
+ m_fclose(&fpout);
+ m_fclose(&fperr);
return ret;
}
fpout = m_tempfile (pk7out, sizeof(tmpfname), NONULL(Tempdir), NULL);
if (!fpout) {
- fclose (fperr);
+ m_fclose(&fperr);
mutt_perror (pk7out);
return NULL;
}
SmimePk7outCommand)) == -1) {
mutt_any_key_to_continue (_
("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ m_fclose(&fperr);
+ m_fclose(&fpout);
mutt_unlink (pk7out);
return NULL;
}
empty = (fgetc (fpout) == EOF);
- fclose (fpout);
+ m_fclose(&fpout);
if (empty) {
mutt_perror (pk7out);
mutt_copy_stream (fperr, stdout);
- fclose (fperr);
+ m_fclose(&fperr);
mutt_unlink (pk7out);
return NULL;
}
fpout = m_tempfile (certfile, sizeof(certfile), NONULL(Tempdir), NULL);
if (!fpout) {
- fclose (fperr);
+ m_fclose(&fperr);
mutt_unlink (pk7out);
mutt_perror (certfile);
return NULL;
SmimeGetCertCommand)) == -1) {
mutt_any_key_to_continue (_
("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ m_fclose(&fperr);
+ m_fclose(&fpout);
mutt_unlink (pk7out);
mutt_unlink (certfile);
return NULL;
empty = (fgetc (fpout) == EOF);
if (empty) {
mutt_copy_stream (fperr, stdout);
- fclose (fpout);
- fclose (fperr);
+ m_fclose(&fpout);
+ m_fclose(&fperr);
mutt_unlink (certfile);
return NULL;
}
- fclose (fpout);
- fclose (fperr);
+ m_fclose(&fpout);
+ m_fclose(&fperr);
return m_strdup(certfile);
}
m_tempfile (certfile, sizeof(certfile), NONULL(Tempdir), NULL);
if (!fpout) {
- fclose (fperr);
+ m_fclose(&fperr);
mutt_perror (certfile);
return NULL;
}
SmimeGetSignerCertCommand)) == -1) {
mutt_any_key_to_continue (_
("Error: unable to create OpenSSL subprocess!"));
- fclose (fperr);
- fclose (fpout);
+ m_fclose(&fperr);
+ m_fclose(&fpout);
mutt_unlink (pk7out);
mutt_unlink (certfile);
return NULL;
rewind (fperr);
fflush (fperr);
empty = (fgetc (fpout) == EOF);
+ m_fclose(&fpout);
+
if (empty) {
mutt_endwin (NULL);
mutt_copy_stream (fperr, stdout);
mutt_any_key_to_continue (NULL);
- fclose (fpout);
- fclose (fperr);
+ m_fclose(&fperr);
mutt_unlink (certfile);
return NULL;
}
- fclose (fpout);
- fclose (fperr);
+ m_fclose(&fperr);
return m_strdup(certfile);
}
fpout = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
if (!fpout) {
- fclose (fperr);
+ m_fclose(&fperr);
mutt_perror (tmpfname);
return;
}
}
fputs (buf, smimein);
fputc ('\n', smimein);
- fclose (smimein);
+ m_fclose(&smimein);
mutt_wait_filter (thepid);
mutt_copy_stream (fpout, stdout);
mutt_copy_stream (fperr, stdout);
- fclose (fpout);
- fclose (fperr);
-
+ m_fclose(&fpout);
+ m_fclose(&fperr);
}
-
-
int smime_verify_sender (HEADER * h)
{
char *mbox = NULL, *certfile, tempfname[_POSIX_PATH_MAX];
mutt_copy_message (fpout, Context, h, 0, 0);
fflush (fpout);
- fclose (fpout);
+ m_fclose(&fpout);
if (h->env->from) {
h->env->from = mutt_expand_aliases (h->env->from);
smimeerr = m_tempfile (smimeerrfile, sizeof(smimeerrfile), NONULL(Tempdir), NULL);
if (!smimeerr) {
mutt_perror (smimeerrfile);
- fclose (fpout);
+ m_fclose(&fpout);
mutt_unlink (tempfile);
return NULL;
}
if (!fptmp) {
mutt_perror (smimeinfile);
mutt_unlink (tempfile);
- fclose (fpout);
- fclose (smimeerr);
+ m_fclose(&fpout);
+ m_fclose(&smimeerr);
return NULL;
}
mutt_write_mime_header (a, fptmp);
fputc ('\n', fptmp);
mutt_write_mime_body (a, fptmp);
- fclose (fptmp);
+ m_fclose(&fptmp);
if ((thepid =
smime_invoke_encrypt (&smimein, NULL, NULL, -1,
fileno (fpout), fileno (smimeerr),
smimeinfile, certfile)) == -1) {
- fclose (smimeerr);
+ m_fclose(&smimeerr);
mutt_unlink (smimeinfile);
mutt_unlink (certfile);
return (NULL);
}
- fclose (smimein);
+ m_fclose(&smimein);
mutt_wait_filter (thepid);
mutt_unlink (smimeinfile);
fflush (fpout);
rewind (fpout);
empty = (fgetc (fpout) == EOF);
- fclose (fpout);
+ m_fclose(&fpout);
fflush (smimeerr);
rewind (smimeerr);
err = 1;
fputs (buf, stdout);
}
- fclose (smimeerr);
+ m_fclose(&smimeerr);
/* pause if there is any error output from SMIME */
if (err)
smimeout = m_tempfile (signedfile, sizeof(signedfile), NONULL(Tempdir), NULL);
if (!smimeout) {
mutt_perror (signedfile);
- fclose (sfp);
+ m_fclose(&sfp);
mutt_unlink (filetosign);
return NULL;
}
mutt_write_mime_header (a, sfp);
fputc ('\n', sfp);
mutt_write_mime_body (a, sfp);
- fclose (sfp);
+ m_fclose(&sfp);
filetosign)) == -1) {
mutt_perror (_("Can't open OpenSSL subprocess!"));
- fclose (smimeout);
+ m_fclose(&smimeout);
mutt_unlink (signedfile);
mutt_unlink (filetosign);
return NULL;
}
fputs (SmimePass, smimein);
fputc ('\n', smimein);
- fclose (smimein);
+ m_fclose(&smimein);
mutt_wait_filter (thepid);
err = 1;
fputs (buffer, stdout);
}
- fclose (smimeerr);
+ m_fclose(&smimeerr);
fflush (smimeout);
rewind (smimeout);
empty = (fgetc (smimeout) == EOF);
- fclose (smimeout);
+ m_fclose(&smimeout);
mutt_unlink (filetosign);
sigbdy->length = ftello (s->fpout);
sigbdy->offset = 0;
- fclose (s->fpout);
+ m_fclose(&s->fpout);
/* restore final destination and substitute the tempfile for input */
s->fpout = fp;
if ((thepid = smime_invoke_verify (NULL, &smimeout, NULL,
-1, -1, fileno (smimeerr),
tempfile, signedfile, 0)) != -1) {
- fflush (smimeout);
- fclose (smimeout);
+ m_fclose(&smimeout);
if (mutt_wait_filter (thepid))
badsig = -1;
fflush (smimeerr);
rewind (smimeerr);
mutt_copy_stream (smimeerr, s->fpout);
- fclose (smimeerr);
+ m_fclose(&smimeerr);
state_attach_puts (_("[-- End of OpenSSL output --]\n\n"), s);
sigbdy->offset = tmpoffset;
/* restore the original source stream */
- fclose (s->fpin);
+ m_fclose(&s->fpin);
s->fpin = fp;
smimeerr = m_tempfile(errfile, sizeof(errfile), NONULL(Tempdir), NULL);
if (!smimeerr) {
mutt_perror (errfile);
- fclose (smimeout);
+ m_fclose(&smimeout);
return NULL;
}
mutt_unlink (errfile);
tmpfp = m_tempfile (tmpfname, sizeof(tmpfname), NONULL(Tempdir), NULL);
if (!tmpfp) {
mutt_perror (tmpfname);
- fclose (smimeout);
- fclose (smimeerr);
+ m_fclose(&smimeout);
+ m_fclose(&smimeerr);
return NULL;
}
last_pos = m->offset;
mutt_copy_bytes (s->fpin, tmpfp, m->length);
-
- fflush (tmpfp);
- fclose (tmpfp);
+ m_fclose(&tmpfp);
if ((type & ENCRYPT) &&
(thepid = smime_invoke_decrypt (&smimein, NULL, NULL, -1,
fileno (smimeout), fileno (smimeerr),
tmpfname)) == -1) {
- fclose (smimeout);
- smimeout = NULL;
+ m_fclose(&smimeout);
mutt_unlink (tmpfname);
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
fileno (smimeout),
fileno (smimeerr), NULL, tmpfname,
SIGNOPAQUE)) == -1) {
- fclose (smimeout);
- smimeout = NULL;
+ m_fclose(&smimeout);
mutt_unlink (tmpfname);
if (s->flags & M_DISPLAY)
state_attach_puts (_("[-- Error: unable to create OpenSSL subprocess! --]\n"), s);
fputc ('\n', smimein);
}
- fclose (smimein);
+ m_fclose(&smimein);
mutt_wait_filter (thepid);
mutt_unlink (tmpfname);
fpout = m_tempfile (tmptmpfname, sizeof(tmptmpfname), NONULL(Tempdir), NULL);
if (!fpout) {
mutt_perror (tmptmpfname);
- fclose (smimeout);
+ m_fclose(&smimeout);
return NULL;
}
}
}
}
- fclose (smimeout);
- smimeout = NULL;
+ m_fclose(&smimeout);
mutt_unlink (outfile);
if (!outFile) {
- fclose (fpout);
+ m_fclose(&fpout);
mutt_unlink (tmptmpfname);
}
fpout = NULL;
m->goodsig = p->goodsig;
m->badsig = p->badsig;
}
- fclose (smimeerr);
+ m_fclose(&smimeerr);
return (p);
}
fwrite(buf, 1, MIN(ssizeof(buf), sb.st_size), f);
sb.st_size -= MIN(ssizeof(buf), sb.st_size);
}
- fclose (f);
+ m_fclose(&f);
}
}
}
nfp = safe_fopen(newfile, "w");
if (!nfp) {
- fclose (ofp);
+ m_fclose(&ofp);
return 3;
}
mutt_copy_stream(ofp, nfp);
- fclose(nfp);
- fclose(ofp);
+ m_fclose(&nfp);
+ m_fclose(&ofp);
mutt_unlink(oldfile);
return 0;
}
rfc1524_entry_init(entry);
}
} /* while (!found && (buf = mutt_read_line ())) */
- fclose (fp);
+ m_fclose(&fp);
error:
p_delete(&buf);
out = m_tempfile(tmpf, sizeof(tmpf), NONULL(Tempdir), NULL);
if (!out) {
- fclose(in);
+ m_fclose(&in);
return;
}
}
fputs (buf, out);
}
- fclose (in);
- fclose (out);
+ m_fclose(&in);
+ m_fclose(&out);
mutt_set_mtime (hdr->content->filename, tmpf);
unlink (hdr->content->filename);
m_strreplace(&hdr->content->filename, tmpf);
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 0, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
rc = mutt_system (cmd);
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
if (rc) {
mutt_any_key_to_continue (NULL);
if (!is_new (ctx->realpath))
if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
if ((fh = safe_fopen (ctx->path, "w")))
- fclose (fh);
+ m_fclose(&fh);
/* No error checking - the parent function will catch it */
return (0);
void mutt_fast_close_compressed (CONTEXT * ctx)
{
if (ctx->cinfo) {
- if (ctx->fp)
- fclose (ctx->fp);
- ctx->fp = NULL;
+ m_fclose(&ctx->fp);
+
/* if the folder was removed, remove the gzipped folder too */
if (access (ctx->path, F_OK) != 0 && !option (OPTSAVEEMPTY))
remove (ctx->realpath);
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
p_delete(&cmd);
return (0);
}
- if (ctx->fp)
- fclose (ctx->fp);
- ctx->fp = NULL;
+ m_fclose(&ctx->fp);
if (!ctx->quiet) {
if (append == ci->close)
}
mutt_block_signals ();
if (mbox_lock_compressed (ctx, fp, 1, 1) == -1) {
- fclose (fp);
+ m_fclose(&fp);
mutt_unblock_signals ();
mutt_error _("Unable to lock mailbox!");
p_delete(&cmd);
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
return (-1);
}
mbox_unlock_compressed (ctx, fp);
mutt_unblock_signals ();
- fclose (fp);
+ m_fclose(&fp);
remove_file (ctx);
restore_path (ctx);
p_delete(&cmd);
}
}
- if (fclose (fp) != 0) {
- fp = NULL;
+ if (m_fclose(&fp) != 0) {
unlink (tempfile);
mutt_perror (tempfile);
mutt_sleep (5);
goto bail;
}
- fp = NULL;
/* Save the state of this folder. */
if (stat (ctx->path, &statbuf) == -1) {
}
}
- fclose (fp);
- fp = NULL;
+ m_fclose(&fp);
mbox_unlock_mailbox (ctx);
- if (fclose (ctx->fp) != 0 || i == -1) {
+ if (m_fclose(&ctx->fp) != 0 || i == -1) {
/* error occured while writing the mailbox back, so keep the temp copy
* around
*/
h->env = mutt_read_rfc822_header (f, h, 0, 0);
fstat (fileno (f), &st);
- fclose (f);
+ m_fclose(&f);
if (!h->received)
h->received = h->date_sent;
return 0;
if (!X509_digest (peercert, EVP_sha1 (), peermd, &peermdlen)) {
- fclose (fp);
+ m_fclose(&fp);
return 0;
}
break;
}
X509_free (cert);
- fclose (fp);
+ m_fclose(&fp);
return pass;
}
if ((fp = fopen (SslCertFile, "a"))) {
if (PEM_write_X509 (fp, data->cert))
done = 1;
- fclose (fp);
+ m_fclose(&fp);
}
if (!done) {
mutt_error (_("Warning: Couldn't save certificate"));
}
b64_data.size = fread (b64_data.data, 1, b64_data.size, fd1);
- fclose (fd1);
+ m_fclose(&fd1);
do {
ret = gnutls_pem_base64_decode_alloc (NULL, &b64_data, &cert);
m_strcmp(linestr + pmatch[2].rm_so, buf) == 0) {
regfree (&preg);
p_delete(&linestr);
- fclose (fp);
+ m_fclose(&fp);
return 1;
}
}
}
regfree (&preg);
- fclose (fp);
+ m_fclose(&fp);
}
/* not found a matching name */
gnutls_free (pemdata.data);
}
}
- fclose (fp);
+ m_fclose(&fp);
}
if (!done) {
mutt_error (_("Warning: Couldn't save certificate"));
}
}
p_delete(&buf);
- fclose (fp);
+ m_fclose(&fp);
if (mutt_wait_filter (thepid)) {
if (!quiet)
mutt_error ("%s", msg);
if (!option (OPTNOCURSES))
mutt_endwin (NULL);
perror (tempfile);
- fclose (fin);
+ m_fclose(&fin);
p_delete(&tempfile);
exit (1);
}
mutt_copy_stream (fin, fout);
else if (bodytext)
fputs (bodytext, fout);
- fclose (fout);
+ m_fclose(&fout);
if (fin && fin != stdin)
- fclose (fin);
+ m_fclose(&fin);
}
}
}
if (f != stdin)
- fclose (f);
+ m_fclose(&f);
exit (1);
}
}
Done:
- if (fp != NULL)
- fclose (fp);
+ m_fclose(&fp);
if (hostportstr != NULL)
p_delete(&hostportstr);
if (session != NULL)
/* read line */
p_clear(&expn, 1);
expn.data = mutt_read_line(NULL, &expn.dsize, fp, &line);
- fclose(fp);
+ m_fclose(&fp);
mutt_wait_filter(pid);
/* if we got output, make a new string consiting of the shell ouptput
return -1;
/* hmm, should we use dotlock? */
if (mx_lock_file (news->newsrc, fileno (fp), 0, 0, 1)) {
- fclose (fp);
+ m_fclose(&fp);
return -1;
}
p_delete(&buf);
mx_unlock_file (news->newsrc, fileno (fp), 0);
- fclose (fp);
+ m_fclose(&fp);
return 0;
}
mutt_newsgroup_stat (data);
}
}
- fclose (idx);
+ m_fclose(&idx);
return 0;
}
/* if file not exist, create it */
if ((ifp = safe_fopen (filename, "a")))
- fclose (ifp);
+ m_fclose(&ifp);
if (!(ifp = safe_fopen (filename, "r"))) {
mutt_error (_("Unable to open %s for reading"), filename);
return -1;
}
if (mx_lock_file (filename, fileno (ifp), 0, 0, 1)) {
- fclose (ifp);
+ m_fclose(&ifp);
mutt_error (_("Unable to lock %s"), filename);
return -1;
}
m_strcpy(tmpfile, sizeof(tmpfile), basename(filename));
mutt_adv_mktemp ((const char*) dirname (buf), tmpfile, sizeof (tmpfile));
if (!(ofp = fopen (tmpfile, "w"))) {
- fclose (ifp);
+ m_fclose(&ifp);
mutt_error (_("Unable to open %s for writing"), tmpfile);
return -1;
}
r = fputc ('\n', ofp);
}
mx_unlock_file (filename, fileno (ifp), 0);
- fclose (ofp);
- fclose (ifp);
+ m_fclose(&ofp);
+ m_fclose(&ifp);
if (r == EOF) {
unlink (tmpfile);
mutt_error (_("Can't write %s"), tmpfile);
snprintf (buf, sizeof (buf), "%s %d %d %c\n", d->group,
d->lastMessage, d->firstMessage, d->allowed ? 'y' : 'n');
if (fputs (buf, f) == EOF) {
- fclose (f);
+ m_fclose(&f);
unlink (file);
return -1;
}
}
}
- fclose (f);
+ m_fclose(&f);
if (nntp_update_cacheindex (news, NULL)) {
unlink (file);
snprintf (buf, sizeof (buf), "\t%zd\t%d\tXref: %s\n",
h->content->length, h->lines, NONULL (h->env->xref));
if (fputs (buf, f) == EOF) {
- fclose (f);
+ m_fclose(&f);
unlink (file);
return -1;
}
Sort = save;
mutt_sort_headers (ctx, 0);
}
- fclose (f);
+ m_fclose(&f);
if (nntp_update_cacheindex (((NNTP_DATA *) ctx->data)->nserv,
(NNTP_DATA *) ctx->data)) {
ret = mutt_nntp_fetch (nntp_data, buf, NULL, NULL, nntp_read_tempfile, f, 0);
if (ret) {
- fclose (f);
+ m_fclose(&f);
unlink (tempfile);
return (ret == -1 ? -1 : 1);
}
h->article_num = article_num;
h->env = mutt_read_rfc822_header (f, h, 0, 0);
- fclose (f);
+ m_fclose(&f);
unlink (tempfile);
if (h->env->xref != NULL)
mutt_message ("%s %d/%d", msg2, c, r);
add_xover_line (buf, &fc);
}
- fclose (f);
+ m_fclose(&f);
nntp_data->lastLoaded = fc.last;
first = fc.last + 1;
if (ctx->msgcount > oldmsgcount)
}
if (ret) {
- fclose (msg->fp);
+ m_fclose(&msg->fp);
unlink (path);
p_delete(&cache->path);
return -1;
else
mutt_socket_write(nntp_data->nserv->conn, buf + 1);
}
- fclose (f);
+ m_fclose(&f);
if (buf[m_strlen(buf) - 1] != '\n')
mutt_socket_write(nntp_data->nserv->conn, "\r\n");
i++;
}
add_group (NULL, NULL);
- fclose (f);
+ m_fclose(&f);
mutt_clear_error ();
return 0;
}
if (stat (fname, &sb) != 0) {
mutt_perror (fname);
- fclose (fp);
+ m_fclose(&fp);
return (-1);
}
unlink (fname);
}
}
- fclose (fp);
+ m_fclose(&fp);
if (IsHeader (extra)) {
Context->msgnotreadyet = -1;
if (rc == -1)
{
mx_close_message (&msg);
if (fp) {
- fclose (fp);
+ m_fclose(&fp);
unlink (tempfile);
}
return (0);
mx_close_message (&msg);
if (option (OPTTHOROUGHSRC)) {
- fclose (fp);
+ m_fclose(&fp);
unlink (tempfile);
}
}
FGETPOS (rfp, pos);
}
-
- fclose (rfp);
-
+ m_fclose(&rfp);
}
static void print_userid (const char *id)
}
}
- fclose (f);
+ m_fclose(&f);
unlink (tempfile);
return ret;
}
/* that's it. */
if (bfp != fp)
- fclose (bfp);
+ m_fclose(&bfp);
if (msg)
mx_close_message (&msg);
rc = mutt_save_attachment (fp, top, tfile, append, hdr);
if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
fprintf (fpout, "%s", AttachSep);
- fclose (fpout);
+ m_fclose(&fpout);
}
}
else {
rc = mutt_save_attachment (fp, top, tfile, M_SAVE_APPEND, hdr);
if (rc == 0 && AttachSep && (fpout = fopen (tfile, "a")) != NULL) {
fprintf (fpout, "%s", AttachSep);
- fclose (fpout);
+ m_fclose(&fpout);
}
}
}
return;
}
mutt_copy_stream (ifp, state->fpout);
- fclose (ifp);
+ m_fclose(&ifp);
if (AttachSep)
state_puts (AttachSep, state);
}
mutt_endwin (NULL);
thepid = mutt_create_filter (buf, &state.fpout, NULL, NULL);
pipe_attachment_list (buf, fp, tag, top, afilter, &state);
- fclose (state.fpout);
+ m_fclose(&state.fpout);
if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
mutt_any_key_to_continue (NULL);
}
0) {
if ((ifp = fopen (newfile, "r")) != NULL) {
mutt_copy_stream (ifp, state->fpout);
- fclose (ifp);
+ m_fclose(&ifp);
if (AttachSep)
state_puts (AttachSep, state);
}
p_clear(&state, 1);
thepid = mutt_create_filter (NONULL (PrintCmd), &state.fpout, NULL, NULL);
print_attachment_list (fp, tag, top, &state);
- fclose (state.fpout);
+ m_fclose(&state.fpout);
if (mutt_wait_filter (thepid) != 0 || option (OPTWAITKEY))
mutt_any_key_to_continue (NULL);
}
idxmax = 0;
if (need_secured && secured) {
- fclose (fp);
+ m_fclose(&fp);
body_list_wipe(&cur);
}
}
mutt_forward_trailer (tmpfp);
-
- fclose (tmpfp);
- tmpfp = NULL;
+ m_fclose(&tmpfp);
/* now that we have the template, send it. */
ci_send_message (flags, tmphdr, tmpbody, NULL, parent);
return;
bail:
-
- if (tmpfp) {
- fclose (tmpfp);
- mutt_unlink (tmpbody);
- }
-
+ m_fclose(&tmpfp);
+ mutt_unlink(tmpbody);
header_delete(&tmphdr);
}
}
}
}
- fclose (tmpfp);
+ m_fclose(&tmpfp);
}
else if (rc == M_YES) { /* do MIME encapsulation - we don't need to do much here */
last = &tmphdr->content;
copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen,
0) == NULL) {
header_delete(&tmphdr);
- fclose (tmpfp);
+ m_fclose(&tmpfp);
return;
}
}
- fclose (tmpfp);
+ m_fclose(&tmpfp);
if (ci_send_message (flags, tmphdr, tmpbody, NULL, parent) == 0)
mutt_set_flag (Context, hdr, M_REPLIED, 1);
else if (SignOffString)
fputs ("\n", f);
mutt_copy_stream (tmpfp, f);
- fclose (tmpfp);
+ m_fclose(&tmpfp);
if (thepid != -1)
mutt_wait_filter (thepid);
}
fputc ('\n', tempfp); /* tie off the header. */
if ((mutt_write_mime_body (msg->content, tempfp) == -1)) {
- fclose (tempfp);
+ m_fclose(&tempfp);
unlink (tempfile);
return (-1);
}
- if (fclose (tempfp) != 0) {
+ if (m_fclose(&tempfp) != 0) {
mutt_perror (tempfile);
unlink (tempfile);
return (-1);
#undef write_as_text_part
fgetconv_close (&fc);
- fclose (fpin);
+ m_fclose(&fpin);
return (ferror (f) ? -1 : 0);
}
p = NULL;
}
}
- fclose (f);
+ m_fclose(&f);
}
}
a->offset = 0;
if (stat (a->filename, &sb) == -1) {
mutt_perror ("stat");
- fclose (fpin);
+ m_fclose(&fpin);
}
a->length = sb.st_size;
}
p_delete(&line);
if (fpin && !fp)
- fclose (fpin);
+ m_fclose(&fpin);
if (fpout)
- fclose (fpout);
+ m_fclose(&fpout);
else
return;
}
s.fpin = fpin;
mutt_decode_attachment (a, &s);
- fclose (s.fpout);
+ m_fclose(&s.fpout);
a->d_filename = a->filename;
a->filename = m_strdup(buff);
a->unlink = 1;
mutt_update_encoding (body);
body->parts = body->hdr->content;
- fclose (fp);
+ m_fclose(&fp);
return (body);
}
mutt_copy_header (fp, h, f, ch_flags, NULL);
fputc ('\n', f);
mutt_copy_bytes (fp, f, h->content->length);
- fclose (f);
+ m_fclose(&f);
ret = mutt_invoke_mta(env_from, to, NULL, NULL, tempfile,
h->content->encoding == ENC8BIT);
fflush (tempfp);
if (ferror (tempfp)) {
- fclose (tempfp);
+ m_fclose(&tempfp);
unlink (tempfile);
mx_commit_message (msg, &f); /* XXX - really? */
mx_close_message (&msg);
/* copy the body and clean up */
rewind (tempfp);
r = mutt_copy_stream (tempfp, msg->fp);
- if (fclose (tempfp) != 0)
+ if (m_fclose(&tempfp) != 0)
r = -1;
/* if there was an error, leave the temp version */
if (!r)