]> diplodocus.org Git - nmh/blob - sbr/m_scratch.c
Added notes about the configure change.
[nmh] / sbr / m_scratch.c
1
2 /*
3 * m_scratch.c -- construct a scratch file
4 *
5 * $Id$
6 */
7
8 #include <h/mh.h>
9
10
11 char *
12 m_scratch (char *file, char *template)
13 {
14 char *cp;
15 static char buffer[BUFSIZ], tmpfil[BUFSIZ];
16
17 snprintf (tmpfil, sizeof(tmpfil), "%sXXXXXX", template);
18 mktemp (tmpfil);
19 if ((cp = r1bindex (file, '/')) == file)
20 strncpy (buffer, tmpfil, sizeof(buffer));
21 else
22 snprintf (buffer, sizeof(buffer), "%.*s%s", cp - file, file, tmpfil);
23 unlink (buffer);
24
25 return buffer;
26 }