use mkstemp on systems that have it
[mmh] / sbr / m_tmpfil.c
1
2 /*
3  * m_tmpfil.c -- construct a temporary file
4  *
5  * $Id$
6  */
7
8 #include <h/mh.h>
9
10
11 char *
12 m_tmpfil (char *template)
13 {
14     static char tmpfil[BUFSIZ];
15
16     snprintf (tmpfil, sizeof(tmpfil), "/tmp/%sXXXXXX", template);
17 #ifdef HAVE_MKSTEMP
18     unlink(mkstemp(tmpfil));
19 #else
20     unlink(mktemp(tmpfil));
21 #endif
22
23     return tmpfil;
24 }