summaryrefslogtreecommitdiff
path: root/mail/escape.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-11-25 17:12:32 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-11-25 19:39:53 +0200
commit8acde412feee7235b342196182c69d0ed25fe1fc (patch)
treed03411665f570504b028be70d1c48c01a61e6237 /mail/escape.c
parent80bb8b2fc30ba04dda9eb652519c65897542437e (diff)
downloadmailutils-8acde412feee7235b342196182c69d0ed25fe1fc.tar.gz
mailutils-8acde412feee7235b342196182c69d0ed25fe1fc.tar.bz2
Rewrite temporary file handling.
* include/mailutils/util.h (mu_make_file_name_suf): New proto. (mu_make_file_name): Replace with a macro. (MU_TEMPFILE_TMPDIR,MU_TEMPFILE_SUFFIX) (MU_TEMPFILE_MKDIR): New flags. (mu_tempfile_hints): New struct. (mu_tempfile): Change signature. * libmailutils/base/tempfile.c (mu_create_temp_file): New function. (mu_tempfile): Rewrite from scratch. Change signature. All callers changed. * libmailutils/string/mkfilename.c (mu_make_file_name): Remove. (mu_make_file_name_suf): New function. * libmailutils/stream/streamcpy.c (mu_stream_copy): Don't return EIO on EOF. * libmailutils/stream/file_stream.c (mu_fd_stream_create): If MU_STREAM_SEEK is set, position fd to 0. * guimb/collect.c: Update calls to mu_tempfile. * lib/mailcap.c: Likewise. * libmailutils/base/amd.c (_amd_tempfile): Rewrite using mu_tempfile. * libmailutils/tests/tempfile.c: New file. * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Add tempfile.
Diffstat (limited to 'mail/escape.c')
-rw-r--r--mail/escape.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/mail/escape.c b/mail/escape.c
index efa2d7977..27d8c2f12 100644
--- a/mail/escape.c
+++ b/mail/escape.c
@@ -324,11 +324,19 @@ escape_run_editor (char *ed, int argc, char **argv, compose_env_t *env)
if (!mailvar_get (NULL, "editheaders", mailvar_type_boolean, 0))
{
char *filename;
- int fd = mu_tempfile (NULL, &filename);
- FILE *fp = fdopen (fd, "w+");
+ int fd;
+ FILE *fp;
char buffer[512];
int rc;
+ rc = mu_tempfile (NULL, 0, &fd, &filename);
+ if (rc)
+ {
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_tempfile", NULL, rc);
+ return rc;
+ }
+
+ fp = fdopen (fd, "w+");
dump_headers (fp, env);
rewind (env->file);
@@ -639,8 +647,7 @@ escape_pipe (int argc, char **argv, compose_env_t *env)
return 1;
}
- fd = mu_tempfile (NULL, NULL);
- if (fd == -1)
+ if (mu_tempfile (NULL, 0, &fd, NULL))
return 1;
if ((pid = fork ()) < 0)

Return to:

Send suggestions and report system problems to the System administrator.