1: /* m_scratch.c - construct a scratch file */ 2: 3: #include "../h/mh.h" 4: #include <stdio.h> 5: 6: 7: char *m_scratch (file, template) 8: register char *file, 9: *template; 10: { 11: register char *cp; 12: static char buffer[BUFSIZ], 13: tmpfil[BUFSIZ]; 14: 15: (void) sprintf (tmpfil, "%sXXXXXX", template); 16: (void) mktemp (tmpfil); 17: if ((cp = r1bindex (file, '/')) == file) 18: (void) strcpy (buffer, tmpfil); 19: else 20: (void) sprintf (buffer, "%.*s%s", cp - file, file, tmpfil); 21: (void) unlink (buffer); 22: 23: return buffer; 24: }