diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-25 17:12:32 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-11-25 19:39:53 +0200 |
commit | 8acde412feee7235b342196182c69d0ed25fe1fc (patch) | |
tree | d03411665f570504b028be70d1c48c01a61e6237 /libmailutils/string | |
parent | 80bb8b2fc30ba04dda9eb652519c65897542437e (diff) | |
download | mailutils-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 'libmailutils/string')
-rw-r--r-- | libmailutils/string/mkfilename.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libmailutils/string/mkfilename.c b/libmailutils/string/mkfilename.c index 7bf0665bf..d815e0bf2 100644 --- a/libmailutils/string/mkfilename.c +++ b/libmailutils/string/mkfilename.c @@ -25,22 +25,27 @@ #include <mailutils/util.h> char * -mu_make_file_name (const char *dir, const char *file) +mu_make_file_name_suf (const char *dir, const char *file, const char *suf) { char *tmp; size_t dirlen = strlen (dir); + size_t suflen = suf ? strlen (suf) : 0; + size_t fillen = strlen (file); size_t len; while (dirlen > 0 && dir[dirlen-1] == '/') dirlen--; - len = dirlen + 1 + strlen (file); + len = dirlen + 1 + fillen + suflen; tmp = mu_alloc (len + 1); if (tmp) { memcpy (tmp, dir, dirlen); tmp[dirlen++] = '/'; - strcpy (tmp + dirlen, file); + memcpy (tmp + dirlen, file, fillen); + if (suf) + memcpy (tmp + dirlen + fillen, suf, suflen); + tmp[len] = 0; } return tmp; } |