X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fm_mktemp.c;h=ff5d00c71b6948818a30283efcea8cfeb9737aab;hp=9b9652bbab4209fd68f324dc6f71484d12a5e4c4;hb=e917512db8efcbf3b5b5baeb64b6d345fd3686db;hpb=ced6090a330d3d83d0bce709f756aa3d7d65fea4 diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index 9b9652b..ff5d00c 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -6,8 +6,10 @@ ** complete copyright information. */ -#include #include +#include +#include +#include static char *get_temp_dir(); @@ -41,7 +43,7 @@ static char *get_temp_dir(); ** char *tmp_pathname = m_mktemp2(NULL, "mypre", ...); */ char * -m_mktemp ( +m_mktemp( const char *pfx_in, /* Pathname prefix for temporary file. */ int *fd_ret, /* (return,opt.) File descriptor to temp file. */ FILE **fp_ret /* (return,opt.) FILE pointer to temp file. */ @@ -100,7 +102,7 @@ m_mktemp ( ** above) is used to create the temp file. */ char * -m_mktemp2 ( +m_mktemp2( const char *dir_in, /* Directory to place temp file. */ const char *pfx_in, /* Basename prefix for temp file. */ int *fd_ret, /* (return,opt.) File descriptor to temp file. */ @@ -119,12 +121,12 @@ m_mktemp2 ( return m_mktemp(buffer, fd_ret, fp_ret); } - if ((cp = r1bindex ((char *)dir_in, '/')) == dir_in) { + if ((cp = mhbasename((char *)dir_in)) == dir_in) { /* No directory component */ return m_mktemp(pfx_in, fd_ret, fp_ret); } n = (int)(cp-dir_in-1); /* Length of dir component */ - snprintf(buffer, sizeof(buffer), "%.*s%s", n, dir_in, pfx_in); + snprintf(buffer, sizeof(buffer), "%.*s/%s", n, dir_in, pfx_in); return m_mktemp(buffer, fd_ret, fp_ret); } @@ -144,5 +146,5 @@ get_temp_dir() tmpdir = getenv("TMP"); if (tmpdir != NULL && *tmpdir != '\0') return tmpdir; } - return m_maildir(""); + return toabsdir("+"); }